Skip to content

Read comments, annotations and modifiers from semantic tokens - #54

Merged
PiotrRogulski merged 1 commit into
claude/quirky-hawking-jdfvsxfrom
claude/quirky-hawking-jdfvsx-2-semantic-tokens
Sep 17, 2026
Merged

PiotrRogulski merged 1 commit into
claude/quirky-hawking-jdfvsxfrom
claude/quirky-hawking-jdfvsx-2-semantic-tokens

Conversation

@PiotrRogulski

@PiotrRogulski PiotrRogulski commented Sep 17, 2026

Copy link
Copy Markdown
Member

semanticTokens/full classifies every span: comment (with documentation), keyword, string, annotation names with the annotation modifier, declarations with static/instance. A doc comment's [Foo] link is its own class token, so a doc reference is one whose line opens with a documentation-comment token. The server serves tokens for files that were never opened.

  • lib/src/lsp/semantic_tokens.dart: legend, decoder, position lookups. Tokens are fetched with the symbols and outline for every scanned file, and before classification for referenced files outside the scan.
  • isDocReference: line's first token is a doc comment (was startsWith('///'), which missed /** */).
  • @override, vm:entry-point, @freezed: annotation tokens in the declaration's metadata, replacing comment stripping and a regex.
  • classHasFinalInstanceField: keyword tokens before the field statement's first declarator, replacing a backward scan over the lexer's tokens.
  • Cross-library recovery reuses the cached tokens.

Behavior: a reference in a /** */ doc block is now doc-only. One more request per scanned file.

🤖 Generated with Claude Code

https://claude.ai/code/session_0146xh6qZsHDegsCAoRBEqwz

@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-2-semantic-tokens branch from d229e31 to 7bb444c Compare September 17, 2026 09:28
@PiotrRogulski
PiotrRogulski added this pull request to stack #57 September 17, 2026 09:35
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-2-semantic-tokens branch 4 times, most recently from 7fd4ea2 to 78f75a9 Compare September 17, 2026 10:39
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-2-semantic-tokens branch from 78f75a9 to 801e5ff Compare September 17, 2026 11:42
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-2-semantic-tokens branch from 801e5ff to 10c6277 Compare September 17, 2026 11:44
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-2-semantic-tokens branch from 10c6277 to c98518c Compare September 17, 2026 11:49
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-2-semantic-tokens branch 2 times, most recently from d436a92 to 6816e93 Compare September 17, 2026 11:53
Comment thread lib/src/cross_library_refs.dart Outdated
Comment thread test/semantic_tokens_test.dart Outdated
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-2-semantic-tokens branch from 6816e93 to db6652f Compare September 17, 2026 12:08
@PiotrRogulski
PiotrRogulski marked this pull request as ready for review September 17, 2026 12:13
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-2-semantic-tokens branch from db6652f to 3a30bb3 Compare September 17, 2026 12:35
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-2-semantic-tokens branch from 3a30bb3 to dd93cc5 Compare September 17, 2026 12:56
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-2-semantic-tokens branch from dd93cc5 to 9db843d Compare September 17, 2026 13:15
Comment thread lib/src/lsp/semantic_tokens.dart Outdated
The server's semantic tokens classify every span as a comment, keyword,
annotation, string or declaration. Use them for the doc-reference check
(which now covers /** */ blocks), the @OverRide, @freezed and
vm:entry-point checks, and the final-field check, instead of stripping
comments and scanning a hand-rolled token stream. Tokens are fetched for
every scanned file, and for referenced files before classification; the
cross-library check reuses them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0146xh6qZsHDegsCAoRBEqwz
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-2-semantic-tokens branch from 9db843d to 6b59dbc Compare September 17, 2026 19:32
@PiotrRogulski
PiotrRogulski merged commit 7f58d46 into main Sep 17, 2026
3 checks passed
@PiotrRogulski
PiotrRogulski deleted the claude/quirky-hawking-jdfvsx-2-semantic-tokens branch September 17, 2026 20:57
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.

3 participants