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

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 unused throws warning by explicitly declaring it.
This suppresses an info message about missing default case
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.

This commit converts the links to just code snippets to balance off
readability with removing javadoc warnings.
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.
@jonahgraham jonahgraham requested a review from pisv November 23, 2025 02:16
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

1 participant