Skip to content

fix: give a document opened from workspace/textDocumentContent the features of its server - #2028

Merged
lagergren merged 2 commits into
redhat-developer:mainfrom
lagergren:fix/document-content-language-features
Nov 20, 2026
Merged

lagergren merged 2 commits into
redhat-developer:mainfrom
lagergren:fix/document-content-language-features

Conversation

@lagergren

@lagergren lagergren commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2026

A document that a language server provides with workspace/textDocumentContent (#1749) is open on that server under its own URI, but LanguageServersRegistry.isFileSupported left it out with every other LightVirtualFile outside the local file system (#782). So Go to Definition, hover, highlighting, folding, semantic tokens and the other features sent no request in it.

  • isFileSupported, in both of its forms, now takes a DocumentContentFile. Other light files are still left out.
  • EditorBehaviorFeature no longer caches its flags for a file without a VFS id: the provider of the cached value captured the file, and a light file holds its PSI, which IntelliJ 2026.3's leak check reports once such a document gets features.
  • MarkdownConverter no longer assumes that the file has a parent folder to resolve relative links against. A DocumentContentFile has none, and its hover threw a NullPointerException once the check passed.

Tests

DocumentContentNavigationTest:

  • testGoToDefinitionWorksInTheContentOfTheServer asks Go to Declaration in an open server document, as IntelliJ does, and gets the target in another document of the server. It fails without the fix: no target.
  • testDocumentationRendersInTheContentOfTheServer renders markdown with a relative link for a server document. It fails without the fix with the NullPointerException.

./gradlew test: 1732 tests, 0 failures, 7 skipped (the Windows-only and inline completion tests that are skipped on main). The DocumentContent tests also pass on IU 2026.3 (-PplatformVersion=2026.3 -PplatformType=IU); without the EditorBehaviorFeature change, testGoToDefinitionWorksInTheContentOfTheServer fails there with the leak check.

Checked in xtclang/xvm's IntelliJ playbook with this build: in a library source that Go to Definition opened from the server, Go to Definition on a call now goes to the method in another source of the library, with no IDE errors, in 2 of 2 runs. With 0.30.1 it does nothing.

…atures of its server

Fixes redhat-developer#2026

LanguageServersRegistry.isFileSupported left out every LightVirtualFile outside the local file system, so a
DocumentContentFile, which the server has open under its own URI, got no Go to Definition, hover, highlighting or
other feature. It is now supported. MarkdownConverter no longer needs a parent folder of the file for relative
links, which such a document doesn't have.
@lagergren lagergren added this to the 0.31.0 milestone Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved support for server-provided document content, including content from non-local files, so it can be matched with the appropriate language server.
    • Fixed Markdown rendering for documents without a parent directory.
  • Tests
    • Added coverage for navigating from server-provided content to definitions in other documents and for links in rendered Markdown.

The registry now recognizes matching DocumentContentFile instances. Feature-state computation handles virtual files without IDs. Markdown rendering handles files without parents. Tests cover navigation between server-provided documents and Markdown rendering.

Changes: Document-content language features

Layer / File(s) Summary
Document-content file support and feature state
src/main/java/com/redhat/devtools/lsp4ij/LanguageServersRegistry.java, src/main/java/com/redhat/devtools/lsp4ij/client/features/EditorBehaviorFeature.java
The registry accepts matching DocumentContentFile instances, including non-local light virtual files. EditorBehaviorFeature computes feature state directly for virtual files without IDs and retains cached computation for files with IDs.
Navigation and Markdown rendering
src/main/java/com/redhat/devtools/lsp4ij/features/documentation/MarkdownConverter.java, src/test/java/com/redhat/devtools/lsp4ij/features/documentContent/DocumentContentNavigationTest.java
The renderer uses a null base directory when the virtual file has no parent. Tests check Go to Declaration to another server-provided document and Markdown conversion of server-provided content.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: scwells72, angelozerr

Merge Risk: Minimal · up to 2ac45

This change lets Go to Definition and other language features work in documents served by workspace/textDocumentContent. It also avoids a cache-related PSI retention problem and a null-parent error when rendering relative links in Markdown. Nothing in the review shows a concrete regression, and the change looks safe to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: documents opened from workspace/textDocumentContent now get the features of their language server. The changeset makes both isFileSupported forms accept DocumentConten…
Description check Passed The description is specific and relevant. It links issue #2026, explains why isFileSupported excluded DocumentContentFile, and describes the EditorBehaviorFeature and MarkdownConverter changes. It als…
Linked Issues check Passed Issue #2026 requires language features in a DocumentContentFile opened from workspace/textDocumentContent, and a hover that does not fail when the file has no parent.

Feature enablement: the previous…
Out of Scope Changes check Passed The production changes are limited to LanguageServersRegistry, MarkdownConverter, and EditorBehaviorFeature. All three serve #2026. LanguageServersRegistry adds the DocumentContentFile exception. Mark…
Full details: Title check

Explanation

The title names the main change: documents opened from workspace/textDocumentContent now get the features of their language server. The changeset makes both isFileSupported forms accept DocumentContentFile, which matches the title. The title does not mention the EditorBehaviorFeature or MarkdownConverter changes, but it does not need to cover every detail.

Full details: Description check

Explanation

The description is specific and relevant. It links issue #2026, explains why isFileSupported excluded DocumentContentFile, and describes the EditorBehaviorFeature and MarkdownConverter changes. It also lists the tests added and the validation performed.

Full details: Linked Issues check

Explanation

Issue #2026 requires language features in a DocumentContentFile opened from workspace/textDocumentContent, and a hover that does not fail when the file has no parent.

Feature enablement: the previous review found that LanguageServersRegistry now accepts DocumentContentFile in both the PSI-based check and the virtual-file-only check. Other non-local LightVirtualFile instances still return false. The listed features check this method before they send a request. The registry code was not re-read in this review.

Hover: the previous review found that MarkdownConverter.getHtmlRenderer at head sets FILE_BASE_DIR to null when the virtual file has no parent. This removes the NullPointerException in #2026.

Incremental change since the previous review: EditorBehaviorFeature.isEnabled at head bypasses the cached value for a file that is not a VirtualFileWithId. It calls a shared compute method instead. Files with an ID keep the cached path. This change prevents a cached-value provider from holding the PSI of a light file. It supports the enablement of features for #2026 documents and does not reduce the requirement coverage.

Tests: DocumentContentNavigationTest contains testGoToDefinitionWorksInTheContentOfTheServer and testDocumentationRendersInTheContentOfTheServer. Both match the reproduction in #2026. The PR reports ./gradlew test with 0 failures. I did not run the tests. The xtclang/xvm playbook result is an external report and is not verified here.

No unmet coding requirement is found in the evidence.

Full details: Out of Scope Changes check

Explanation

The production changes are limited to LanguageServersRegistry, MarkdownConverter, and EditorBehaviorFeature. All three serve #2026. LanguageServersRegistry adds the DocumentContentFile exception. MarkdownConverter adds a null-parent guard. EditorBehaviorFeature skips the cached value for files without a VFS ID. The PR description states that this change prevents the IntelliJ 2026.3 leak check from reporting retained PSI once a server document receives features. The test file adds tests for the two reported behaviors.

Limit: the text diff for the changed blobs could not be read in this review. The EditorBehaviorFeature content was read from the head file. The previous review relied on the head file content for the other two production files. Neither limit changes the result.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6ee34e2b-1606-42f6-9031-f9854c2a03da
Commits

Reviewing files that changed from the base of the PR and between 9bd9cb3 and 2ac45b7.

Files selected for processing: 1

  • src/main/java/com/redhat/devtools/lsp4ij/client/features/EditorBehaviorFeature.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.23%. Comparing base (8655e28) to head (2ac45b7).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../lsp4ij/client/features/EditorBehaviorFeature.java 60.00% 2 Missing and 2 partials ⚠️
...edhat/devtools/lsp4ij/LanguageServersRegistry.java 33.33% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2028      +/-   ##
==========================================
+ Coverage   49.17%   49.23%   +0.05%     
==========================================
  Files         813      813              
  Lines       33095    33101       +6     
  Branches     6771     6774       +3     
==========================================
+ Hits        16276    16297      +21     
+ Misses      14275    14249      -26     
- Partials     2544     2555      +11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…cached value

A document opened from workspace/textDocumentContent is a LightVirtualFile, which holds its PSI. The provider of
EditorBehaviorFeature's cached value captured the file, which IntelliJ 2026.3's leak check reports as retaining PSI
once such a document gets the features of its server. A file without a VFS id is now checked each time.
@lagergren lagergren modified the milestones: 0.31.0, 0.30.2 Nov 20, 2026
@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren
lagergren merged commit 9cf7de5 into redhat-developer:main Nov 20, 2026
9 of 10 checks passed
@lagergren lagergren added the bug Something isn't working label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No language features in a document opened from workspace/textDocumentContent

1 participant