Skip to content

[Compiler] Resolve cross-file related-location URIs in LSP relatedInformation #303

@cssbruno

Description

@cssbruno

Follow-up from #297 and PR #300.

Problem

#297 maps diagnostic related locations to LSP relatedInformation, but the
mapping uses the current document's URI for every related location
(relatedInformationFromLang in internal/lsp/diagnostics.go). That is correct
for the single-document check the server runs today, where conflicts are
in-file, but a related location whose File differs from the open document
points at the wrong URI.

Relevant code:

  • internal/lsp/diagnostics.go: relatedInformationFromLang (uses one uri)
  • internal/lsp/notifications.go: publishDiagnostics (single-document check)
  • internal/lang/diagnostic.go: RelatedLocation.File

Scope

Resolve cross-file related locations to their own file:// URI and compute the
range against the related file's content (loading it when the related File
differs from the open document), so a conflict that spans two files links each
location to the right file.

Acceptance Criteria

  • A related location with a different File is emitted with that file's URI and
    a range computed against that file.
  • Same-file related locations keep current behavior.
  • A test covers a cross-file related location URI.

Verification

go test ./internal/lsp

Metadata

Metadata

Assignees

No one assigned

    Labels

    LSPLanguage server and editor toolingdiagnosticsDiagnostic codes, spans, and messages

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions