eclipse-jdtls / eclipse-jdt-core-incubator

Eclipse Public License 2.0
8 stars 1 forks source link

[javac] Report "unused ..." diagnostics #300

Closed fbricon closed 1 day ago

fbricon commented 3 months ago

The javac compiler doesn't report "unused ..." diagnostics, but there's still a way to access that information, see how it's done in https://github.com/georgewfraser/java-language-server: com.sun.source.tree.CompilationUnitTree is scanned for unused local variables or fields in https://github.com/georgewfraser/java-language-server/blob/master/src/main/java/org/javacs/markup/WarnUnused.java

mickaelistria commented 3 months ago

We can probably just copy the code from the java-language-server, it's MIT and it can work almost without change.

fbricon commented 1 week ago

@testforstephen is this something you could look at?

testforstephen commented 1 week ago

Sure, I have made some local experiments to support unused local variables, private fields, methods, and classes, and it works. Basically, we need to add this support into two places: the JavacCompiler and the DOM parser, as both will report diagnostics.

fbricon commented 1 week ago

Sounds awesome, waiting for your PR ;-)