java-language-server icon indicating copy to clipboard operation
java-language-server copied to clipboard

I've added support for the CLASSPATH environment variable in InferCon…

Open georgewfraser opened this issue 8 months ago • 1 comments

…fig.

This change modifies the InferConfig class to allow the Java language server to determine the project's classpath using the CLASSPATH environment variable.

Key changes:

  • The classPath() method in InferConfig.java now checks for the CLASSPATH environment variable first. If set, its value is parsed and used as the classpath. This allows you to override the default classpath discovery mechanisms (Maven, Bazel).
  • InferConfig.java was refactored to allow injection of environment variables for testing purposes. This involved adding a new constructor that accepts a map of environment variables and updating methods that access environment variables to use this injected map.
  • A new unit test, classpathFromEnvironmentVariable, was added to InferConfigTest.java to specifically verify the new functionality. This test uses the new constructor to inject a mock CLASSPATH variable.

All tests in InferConfigTest.java, including the new test, pass.

Note: During testing, I observed three pre-existing test failures in other classes (CompletionsTest.overloadedOnClassPath, FindSrcZipTest.testFindSrcZip, HoverTest.docString). These failures are believed to be unrelated to the changes in this commit and should be investigated separately.

georgewfraser avatar May 23 '25 20:05 georgewfraser

Tests seem not independent. I mentioned it at https://github.com/georgewfraser/java-language-server/pull/313 In this branch all tests passed for me

[INFO] Results: [INFO] [WARNING] Tests run: 227, Failures: 0, Errors: 0, Skipped: 10

alepekhin avatar May 24 '25 06:05 alepekhin