eclipse / lsp4mp

Technology lsp4mp
Eclipse Public License 2.0
22 stars 27 forks source link

Add diagnostic for multiple classes of type `Application` #181

Open AlexXuChen opened 3 years ago

AlexXuChen commented 3 years ago

Given two java files in a quarkus project:

import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application;

@ApplicationPath("/api") public class MyApplication extends Application {

}

- `SecondApplication.java`
```java
package org.acme;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("/ipa")
public class SecondApplication extends Application{

}

The following error will occur when building the quarkus project: Screenshot from 2021-09-15 10-01-14

We should have a diagnostic thrown to indicate that more than one Application class isn't supported.

rgrunber commented 3 years ago

One idea for doing this : The Java SearchEngine API should be able to search the entire project and find all type declarations. From there, it should just be a matter of figuring out if the total number of type declarations containing an ApplicationPath annotation is greater than 1.

rgrunber commented 2 years ago

Also @ApplicationPath is only supported on a class that extends javax.ws.rs.Application. We should validate that the type declaration satisfies this. Maybe even providing a code action to make the necessary fix.