Repository navigation
fix: apply the relatedDocuments of pull diagnostic reports - #1723
Merged
angelozerr merged 1 commit intoOct 19, 2026
Merged
Conversation
Fixes redhat-developer#1722. Two bugs together kept the diagnostics of related documents from ever being applied: - LSP4J 1.0.0 cannot parse a textDocument/diagnostic reply with relatedDocuments: "Ambiguous Either type: token BEGIN_OBJECT matches both alternatives" (eclipse-lsp4j/lsp4j#990, fixed in eclipse-lsp4j/lsp4j#991, not yet released). In LSP4IJ's test harness such a pull never completed. - DocumentContentSynchronizer.refreshPullDiagnostic applied relatedDocuments only for an unchanged report, and dropped them from a full one. refreshPullDiagnostic now applies the related documents of both report kinds, through updateRelatedPullDiagnostics. RelatedDocumentsTypeAdapterFactory, registered in JSONUtils.configureCompatibilityAdapters beside the other LSP4J compatibility adapters, reads each relatedDocuments value by its kind, as LSP4J does for the report itself. It only matches the exact field type, so LSP4J's own field adapter takes precedence once LSP4IJ uses a release with redhat-developer#991, and the factory can then be removed. Validation: - New PullRelatedDocumentsTest: the mock answers the opened file's pull with a full report, and in a second test an unchanged one. Each carries diagnostics for a second, closed file, which must be stored. - New RelatedDocumentsSerializationTest round-trips such a textDocument/diagnostic response through MessageJsonHandler with configureCompatibilityAdapters. - With neither part, or with only the handling fix, all three tests fail. With only the adapter, the unchanged-report and serialization tests pass and the full-report test fails. With both, all pass. - ./gradlew check: 579 tests, 0 failures, 3 existing skips. Signed-off-by: Marcus Lagergren <[email protected]>
Collaborator
Author
|
@coderabbitai full review |
✅ Action performedFull review finished. |
Contributor
|
Nice fix @lagergren ! |
This was referenced Oct 28, 2026
angelozerr
pushed a commit
that referenced
this pull request
Nov 4, 2026
* docs: describe the 0.30.0 LSP and DAP changes that the docs miss Several changes merged for 0.30.0 changed behavior that the docs describe, or added behavior that they don't. LSPSupport.md still said that pull diagnostics don't support related documents, which #1723 changed. LSP: - LSPSupport.md, Pull Diagnostics: previousResultId, and the relatedDocuments of either kind of report (#1723, #1735), in place of "It doesn't support the related documents." - LSPSupport.md, Inline Completion: the trigger kind and the selected completion item (#1715). - LSPSupport.md, Signature Help: the retrigger, the active parameter of each signature, and signatures without parameters (#1712, #1734). - LSPSupport.md, Formatting: a file without an open editor (#1707). - LSPSupport.md, new Did Change Watched Files section: the directories outside the project that watchers name, and the watchers of a stopped server (#1742). The support list links to it. - UserGuide.md, Formatting: the Do not format patterns (#1817). - UserDefinedLanguageServer.md, Configuration tab: null properties (#1710, #1847) and invalid JSON (#1828). - DeveloperGuide.md, Workspace Configuration: null members of createSettings() (#1710, #1847). DAP, dap/UserGuide.md: - Exception breakpoint: the hint built from exceptionInfo (#1761). The screenshot of the stop at the exception moves back after the example it shows; the Smart Step Into section had come between them. - Large variables: a page with fewer children than asked for is the last one (#1851). Validation: each statement was checked against the code at d1a281d: DocumentContentSynchronizer.refreshPullDiagnostic, LSPInlineCompletionProvider.createParams, LSPParameterInfoHandler, ClientCapabilitiesFactory, AbstractLSPFormattingService.canFormat, LSPFormattingSupport, FileSystemWatchRoots, LanguageServerPanel .validateJsonFields, JsonSettingsTypeAdapterFactory, DAPClient.getExceptionHint and DAPVariableChildren. The other changes merged for 0.30.0 are already documented, by their own PRs, #1784 and #1810, or change nothing that the docs describe. Limits: docs only, no new screenshots, no build run. * docs: say that the JSON fields of a language server are read leniently CodeRabbit noted that "must be valid JSON" is stricter than what LSP4IJ accepts. The dialog's check (LanguageServerPanel.jsonError, JsonParser.parseString) and the readers at run time (SettingsHelper.parseJson, JsonParser.parseReader for the initialization options, experimental and installer, Gson.fromJson for the client configuration and workspace folders) all read leniently. The paragraph now says which JSON is accepted and which isn't. Validation: probed Gson 2.15.0's JsonParser.parseString and Gson.fromJson. Both accept // and /* */ and # comments, unquoted names and single-quoted strings, and both reject a trailing comma, a missing brace and an unescaped backslash, such as in C:\Users.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1722. Pull diagnostics now apply the
relatedDocumentsof a report of either kind. Until LSP4J can parse such reports, LSP4IJ parses them itself.Problem
There are two bugs, and with both present no related document's diagnostics are ever applied.
textDocument/diagnosticreply withrelatedDocumentsfails with "Ambiguous Either type: token BEGIN_OBJECT matches both alternatives" (Parsing a textDocument/diagnostic report with relatedDocuments fails: Ambiguous Either type eclipse-lsp4j/lsp4j#990, fixed in Add type adapter for the relatedDocuments of document diagnostic reports eclipse-lsp4j/lsp4j#991, not yet released). In LSP4IJ's test harness such a pull never completes.DocumentContentSynchronizer.refreshPullDiagnosticappliesrelatedDocumentsonly for an unchanged report. For a full report, the usual case, it applies the document's own items and drops the related documents.LSP defines
relatedDocumentson both report kinds:Change
refreshPullDiagnosticapplies the related documents of both report kinds, through one new method,updateRelatedPullDiagnostics.RelatedDocumentsTypeAdapterFactoryis registered inJSONUtils.configureCompatibilityAdapters, next to LSP4IJ's other LSP4J compatibility adapters.relatedDocumentsvalue by itskind, as LSP4J does for the report itself.Validation
New
PullRelatedDocumentsTestopens a file, and the mock server answers the pull with a full report and, in a second test, with an unchanged report. Each carries diagnostics for a second file that stays closed, and the test requires those diagnostics to be stored.New
RelatedDocumentsSerializationTestround-trips atextDocument/diagnosticresponse with related documents throughMessageJsonHandlerwithconfigureCompatibilityAdapters.Each part was run on its own:
main)./gradlew check: 579 tests, 0 failures, the 3 existing skips.Related
RelatedDocumentsTypeAdapterFactoryand its registration can be removed.