Skip to content

Pull diagnostics ignore the relatedDocuments of a full report #1722

Closed

Description

@lagergren

Problem

DocumentContentSynchronizer.refreshPullDiagnostic applies the relatedDocuments of a textDocument/diagnostic report only when the report itself is unchanged. When the report is full, the usual case, it applies the document's own items and ignores relatedDocuments. See DocumentContentSynchronizer.java#L519-L540 on main (20df566):

  • isLeft(), the RelatedFullDocumentDiagnosticReport, calls updatePullDiagnostics(file, fileReport) only.
  • isRight(), the RelatedUnchangedDocumentDiagnosticReport (named allFilesReport there), walks relatedDocuments.

LSP defines relatedDocuments on both report kinds:

Diagnostics of related documents. This information is useful in programming languages where code in a file A can generate diagnostics in a file B which A depends on. An example of such a language is C/C++ where marco definitions in a file a.cpp and result in errors in a header file b.hpp.

So with a full report, diagnostics that the server reports for other files are lost.

LSP4J cannot parse these reports either

LSP4J 1.0.0 cannot parse a report that has relatedDocuments at all; it fails with "Ambiguous Either type: token BEGIN_OBJECT matches both alternatives".

Fix

The LSP4IJ change is small. Apply relatedDocuments for both report kinds, from one method:

  • for a full report, after the document's own items;
  • for an unchanged report, as now.

An unchanged related entry needs no update, since it means the last report for that file is still valid.

The fix is in #1723 and can be merged now. Until LSP4J releases eclipse-lsp4j/lsp4j#991, it registers a temporary compatibility adapter, so that LSP4J 1.0.0 can parse these reports.

Its test opens one file and has the mock answer the pull with a full report, and in a second test with an unchanged one. Each carries diagnostics for a second file that stays closed, and the test requires those diagnostics to be stored.

Activity

  1. added a commit that references this issue on Oct 19, 2026
    d9d45d8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions