Skip to content

feat: the Semantic Tokens Inspector formats without a write action, and shows the language server, its legend and the data of the answer - #2402

Open
lagergren wants to merge 2 commits into
redhat-developer:mainfrom
lagergren:feat/semantic-tokens-inspector
Open

lagergren wants to merge 2 commits into
redhat-developer:mainfrom
lagergren:feat/semantic-tokens-inspector

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Fixes #2349.

Gap 10 of #2334. Two commits, for rebase-merge.

1. perf: the inspector formats without a write action

Before: while the Semantic Tokens Inspector was open, each highlighting pass formatted its tokens in a throwaway DocumentImpl, inside WriteCommandAction.runWriteCommandAction. That is a write action on the UI thread, which cancels the highlighting passes that run.

Now: the tags go into a StringBuilder, at the same offsets and in the same order as the document edits, which gives the same text. format keeps its signature.

2. feat: the inspector shows the answer the tokens come from

Before: the inspector showed the decoded tokens only, without the language server they came from, its legend, or the data of its answer.

Now:

  • The left panel, under the check boxes, shows for the selected file's tab:
    • the name of the language server;
    • its legend's token types and modifiers;
    • the data of the answer, a line per token of its five integers (relative line, character, length, type, modifiers), up to 1000 tokens.
  • Updates: it follows the tab that a new answer selects, and a change of tab.
  • SemanticTokensInspectorData has three new components: languageServer, legend and data. Its earlier constructors remain, with null for them. SemanticTokensData.highlight fills them, with the server's name from the semantic tokens feature's client features.
  • Docs: the Semantic Tokens Inspector section of UserGuide.md.

Behaviour changes

Before After
The open inspector took a write action at each highlighting pass It takes none
The inspector showed the decoded tokens only It also shows the language server, its legend and the data of the answer

Tests

  • SemanticTokensInspectorTest:
    • formatting takes no write action, counted with an ApplicationListener. With the old formatting it fails: 1 write action;
    • the data of an answer shows a line per token, up to the limit.
  • SemanticTokensInspectorAnswerTest: a real highlighting with the mock server gives the inspector the server's name, its legend and the answer's data.
  • Whole suite: 2,866 tests, 0 failures, 7 skipped.
  • 2026.3: the semantic tokens tests pass, 116 tests.

…ing pass without a write action

Each highlighting pass formatted its tokens for the open inspector in a
throwaway document, inside WriteCommandAction.runWriteCommandAction: a
write action on the UI thread, which cancels the highlighting passes
that run. The tags are now inserted in a StringBuilder, at the same
offsets and in the same order, which gives the same text.
…gend and the data of the answer

The left panel of the inspector shows, for the selected file, the name
of the language server that its tokens come from, the token types and
modifiers of its legend, and the data of the answer, a line per token,
for the first 1000 tokens. SemanticTokensInspectorData carries them.

Fixes redhat-developer#2349
@lagergren lagergren added this to the 0.30.3 milestone Dec 1, 2026
@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 08374bd1-b245-4bad-b28b-aa3b4766f405
Commits

Reviewing files that changed from the base of the PR and between 7883ae1 and a2a35df.

Files selected for processing: 9

  • docs/UserGuide.md
  • src/main/java/com/redhat/devtools/lsp4ij/features/semanticTokens/SemanticTokensData.java
  • src/main/java/com/redhat/devtools/lsp4ij/features/semanticTokens/inspector/SemanticTokensInspectorData.java
  • src/main/java/com/redhat/devtools/lsp4ij/features/semanticTokens/inspector/SemanticTokensInspectorDetail.java
  • src/main/java/com/redhat/devtools/lsp4ij/features/semanticTokens/inspector/SemanticTokensInspectorManager.java
  • src/main/java/com/redhat/devtools/lsp4ij/features/semanticTokens/inspector/SemanticTokensInspectorToolWindowPanel.java
  • src/main/resources/messages/LanguageServerBundle.properties
  • src/test/java/com/redhat/devtools/lsp4ij/features/semanticTokens/inspector/SemanticTokensInspectorAnswerTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/features/semanticTokens/inspector/SemanticTokensInspectorTest.java

@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 36.36364% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.17%. Comparing base (7883ae1) to head (a2a35df).

Files with missing lines Patch % Lines
...okens/inspector/SemanticTokensInspectorDetail.java 29.72% 26 Missing ⚠️
...pector/SemanticTokensInspectorToolWindowPanel.java 0.00% 6 Missing ⚠️
...ij/features/semanticTokens/SemanticTokensData.java 60.00% 2 Missing ⚠️
...cTokens/inspector/SemanticTokensInspectorData.java 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2402      +/-   ##
==========================================
- Coverage   60.26%   60.17%   -0.09%     
==========================================
  Files         864      864              
  Lines       37908    37948      +40     
  Branches     7847     7857      +10     
==========================================
- Hits        22845    22835      -10     
- Misses      11947    11996      +49     
- Partials     3116     3117       +1     

☔ 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.

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.

Semantic Tokens Inspector: no write action per highlighting pass, and show the language server, its legend and the raw data

1 participant