eclipse-jdtls / eclipse.jdt.ls

Java language server
1.81k stars 404 forks source link

Null Analysis keeps prompting, despite java.compile.nullAnalysis.mode = automatic #3050

Open vorburger opened 9 months ago

vorburger commented 9 months ago

It seems like the java.compile.nullAnalysis.mode settings doesn't quite work as documented:

java.compile.nullAnalysis.mode: Specify how to enable the annotation-based null analysis. Supported values are disabled (disable the null analysis), interactive (asks when null annotation types are detected), automatic (automatically enable null analysis when null annotation types are detected). Defaults to interactive.

I have it set to "java.compile.nullAnalysis.mode": "automatic" here, but it still keeps re-prompting me: (Every time I do Java: Clean Java Language Server Workspace.)

Null annotation types have been detected in the project. Do you wish to enable null analysis for this project?

Note that my project (https://github.com/enola-dev/enola) uses https://github.com/salesforce/bazel-vscode-java - I'm not sure if this settings somehow needs to be "piped through" by that extension to the internal JDT project configuration, so unclear (to me) if the gap is here in the eclipse.jdt.ls project or missing there?

@CsCherrYY @rgrunber @testforstephen @mickaelistria @guw

PS: https://www.lastnpe.org greetings!

rgrunber commented 9 months ago

This is where the message is sent https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/a55e3241e7533bc2f45a46ee9287b6a16f37c973/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java#L2349-L2358 . With bazel-vscode-java, I can still see automatic being sent to the language server and we don't ever set it to anything else. Unfortunately I can't really confirm the behaviour because I haven't go the bazel binary to properly test.

Bazel contributes some bundles to the JDT-LS runtime from https://github.com/salesforce/bazel-eclipse :

"bundles": [
            "/home/rgrunber/vscode-test/extensions/sfdc.bazel-vscode-java-1.2.0/server/com.github.ben-manes.caffeine.jar",
            "/home/rgrunber/vscode-test/extensions/sfdc.bazel-vscode-java-1.2.0/server/com.github.ben-manes.caffeine.guava.jar",
            "/home/rgrunber/vscode-test/extensions/sfdc.bazel-vscode-java-1.2.0/server/org.jsr-305.jar",
            "/home/rgrunber/vscode-test/extensions/sfdc.bazel-vscode-java-1.2.0/server/org.fusesource.jansi.jar",
            "/home/rgrunber/vscode-test/extensions/sfdc.bazel-vscode-java-1.2.0/server/wrapped.com.google.protobuf.protobuf-java.jar",
            "/home/rgrunber/vscode-test/extensions/sfdc.bazel-vscode-java-1.2.0/server/com.salesforce.bazel.logback.jar",
            "/home/rgrunber/vscode-test/extensions/sfdc.bazel-vscode-java-1.2.0/server/com.salesforce.bazel.importedsource.jar",
            "/home/rgrunber/vscode-test/extensions/sfdc.bazel-vscode-java-1.2.0/server/com.salesforce.bazel.sdk.jar",
            "/home/rgrunber/vscode-test/extensions/sfdc.bazel-vscode-java-1.2.0/server/com.salesforce.bazel.eclipse.core.jar",
            "/home/rgrunber/vscode-test/extensions/sfdc.bazel-vscode-java-1.2.0/server/com.salesforce.bazel.eclipse.jdtls.jar"
        ],

but I don't see anything in there to override the null analysis setting. Those bundles are probably helping to resolve the classpath, which is used by the null analysis to detect if its present, but if the automatic is set, it should never prompt.

What happens if you set "java.compile.nullAnalysis.mode": "automatic" at the user-level (instead of workspace) ? Does it still occur ?