Skip to content

Conversation

@jonahgraham
Copy link
Contributor

See individual commits + commit messages for details of why and how different warnings are handled.

Fixes #923

@jonahgraham jonahgraham requested a review from pisv November 23, 2025 02:16
Copy link
Contributor

@pisv pisv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for taking care of cleaning all the warnings! 👍

I have just a few minor notes...

@sebthom
Copy link
Contributor

sebthom commented Nov 23, 2025

Awesome!

Because test code and production code have the same warning settings
this commit works around some of the warnings in tests.

The warnings were in one of these categories:

- Javadoc warnings
- Declared exception not thrown
- Unused imports
- Unused objects (these were the result of testing that constructors
  throw exceptions)
- Possible null usage
- Missing try-with-resources
This suppresses an info message about missing default case
@jonahgraham jonahgraham force-pushed the remove-all-warnings-in-lsp4j branch from 87492aa to 2c873b5 Compare November 24, 2025 00:13
@github-actions
Copy link

github-actions bot commented Nov 24, 2025

Test Results

  500 files  ±0    500 suites  ±0   42s ⏱️ -1s
  359 tests ±0    359 ✅ ±0  0 💤 ±0  0 ❌ ±0 
4 052 runs  ±0  4 052 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 25b3003. ± Comparison against base commit fd40a78.

♻️ This comment has been updated with latest results.

This is a place where we meet the problem of Java vs Typescript.

In Typescript, the fields are directly accessible, and matches
what the LSP spec says. But in Java we wrap the fields in a
get/set pair, meaning the field is not visible and generates
a javadoc warning.
There are lots of these warnings and they can be ignored with this
setting, or `@param params` can be added to Javadoc block for each of them.

As this warning was recently introduced, and is not a common default,
I have elected to turn the warning off. To turn this warning on again,
ensure that all existing cases are resolved.
The Gson library that LSP4J is heavily dependent on uses the errorprone
annotations. If Eclipse supported warning suppression based on the
errorprone annotations, the dozens of potential resource leak warnings
in the LSP4J code would be automatically suppressed.

This happens because Gson classes such as JsonWriter returns `this`
in many of its methods, and since JsonWriter is a Closeable, the
JDT warns about it. See for example JsonWrite.nullValue. Gson annotates
this method as CanIgnoreReturnValue, meaning no potential resource leak.

If JDT gets support for error prone annotations, this warning can be
re-enabled.
Copy link
Contributor

@pisv pisv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thank you very much for this effort! 👍

@jonahgraham jonahgraham merged commit b5a8adf into eclipse-lsp4j:main Nov 24, 2025
7 checks passed
@jonahgraham jonahgraham deleted the remove-all-warnings-in-lsp4j branch November 24, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warning free LSP4J code

4 participants