Closed fbricon closed 6 days ago
Also private constructors should not be flagged as unused
Initially you see the unused diagnostics in the problems view, they're reported by the build job. When you open the Java file, it disappears because the DOM parser does not enable the unused checker and cleanup the diagnostics of current file.
I hooked the unused checker into the DOM parser by listening at the ANALYZE task. It looks like the ANALYZE task is never invoked by DOM parser. This should work before, no idea why it's not called in latest code.
@mickaelistria any thoughts?
At the moment, the analyze
is called while resolving bindings. So when bindings are disabled, analyze() is never run. We should probably also consider FORCE_PROBLEM_DETECTION flag to run that analyze
code.
https://github.com/eclipse-jdtls/eclipse-jdt-core-incubator/pull/771 might help. @testforstephen Can you please check?
After debugging the code, it's because the analyze in DOM parser stops on error and return earlier. In the build job, we have overwritten the compiler to force it to proceed on error. But for the DOM parser, we don't do that and it will return earlier if the errorCount() of JavaCompiler > 0.
Also private static final long serialVersionUID
fields on Serializable classes should be ignored
There are a couple issues with the 'unused' code detection:
https://github.com/user-attachments/assets/373ff4ba-c3e7-41a8-ae31-3b86b5cd23d2
Tested against https://github.com/eclipse/lemminx