Skip to content

Read the syntax around a reference from selection ranges - #55

Merged
PiotrRogulski merged 1 commit into
claude/quirky-hawking-jdfvsx-2-semantic-tokensfrom
claude/quirky-hawking-jdfvsx-3-selection-ranges
Sep 17, 2026
Merged

PiotrRogulski merged 1 commit into
claude/quirky-hawking-jdfvsx-2-semantic-tokensfrom
claude/quirky-hawking-jdfvsx-3-selection-ranges

Conversation

@PiotrRogulski

@PiotrRogulski PiotrRogulski commented Sep 17, 2026

Copy link
Copy Markdown
Member

textDocument/selectionRange returns the syntax nodes enclosing a position, innermost first, many positions per request. Nodes have ranges but no kinds, so "this is a case clause" is checked by the node's first semantic token.

  • LspClient.selectionRanges and a per-position cache; the finder fetches the positions the checks need before classification, one request per file.
  • isPatternRef: the type heads a pattern whose parent opens with case, or starts a switch-expression arm whose parent opens with switch.
  • isDotValuesRef / enumIteratesOwnValues: the reference and values form one node; a bare values starts its own expression.
  • isRedirectingFactory: the last token's chain reaches the declaration without crossing a body node.
  • Removed the bracket matching behind all of these. lexing.dart still backs two constructor checks (next PR).

Same verdicts on the fixture package. A position without a chain reads as "not the special shape", which keeps code.

🤖 Generated with Claude Code

https://claude.ai/code/session_0146xh6qZsHDegsCAoRBEqwz

@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-3-selection-ranges branch from 34eb050 to 317308f Compare September 17, 2026 09:29
@PiotrRogulski
PiotrRogulski added this pull request to stack #57 September 17, 2026 09:35
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-3-selection-ranges branch from 317308f to 40cb9c6 Compare September 17, 2026 10:16
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-3-selection-ranges branch from 40cb9c6 to 56cadbe Compare September 17, 2026 10:37
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-3-selection-ranges branch from 56cadbe to b48d104 Compare September 17, 2026 10:38
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-3-selection-ranges branch from b48d104 to 6a7fe10 Compare September 17, 2026 10:39
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-3-selection-ranges branch from 6a7fe10 to 7423770 Compare September 17, 2026 11:42
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-3-selection-ranges branch from 7423770 to 9ab37da Compare September 17, 2026 11:44
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-3-selection-ranges branch from 9ab37da to 9fa3749 Compare September 17, 2026 11:49
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-3-selection-ranges branch 2 times, most recently from 8fc12c4 to 0f2b828 Compare September 17, 2026 11:55
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-3-selection-ranges branch from 0f2b828 to 1afdca5 Compare September 17, 2026 12:08
Comment thread test/syntax_rules_test.dart Outdated
Comment thread test/syntax_rules_test.dart Outdated
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-3-selection-ranges branch from 1afdca5 to ed9af72 Compare September 17, 2026 12:30
Comment thread lib/src/syntax_rules.dart Outdated
Comment thread lib/src/syntax_rules.dart Outdated
Comment thread lib/src/syntax_rules.dart Outdated
Comment thread lib/src/syntax_rules.dart Outdated
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-3-selection-ranges branch 3 times, most recently from 90cd786 to d87e93b Compare September 17, 2026 12:39
@PiotrRogulski
PiotrRogulski marked this pull request as ready for review September 17, 2026 12:45
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-3-selection-ranges branch from d87e93b to b4843a5 Compare September 17, 2026 12:56
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-3-selection-ranges branch from b4843a5 to 56fca2b Compare September 17, 2026 13:15
@PiotrRogulski
PiotrRogulski force-pushed the claude/quirky-hawking-jdfvsx-3-selection-ranges branch from 56fca2b to 5bc5c68 Compare September 17, 2026 19:32
Comment thread lib/src/lsp/semantic_tokens.dart Outdated
textDocument/selectionRange returns the syntax nodes enclosing a position,
innermost first. Use them for type patterns, Enum.values iteration, a bare
`values` in an enum body, and redirecting factories, instead of matching
brackets in ciach's own token stream. The finder fetches the ranges it
needs before classification, one request per file.

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-3-selection-ranges branch from 5bc5c68 to 952dd15 Compare September 17, 2026 19:48
@PiotrRogulski
PiotrRogulski merged commit 7f58d46 into main Sep 17, 2026
3 checks passed
@PiotrRogulski
PiotrRogulski deleted the claude/quirky-hawking-jdfvsx-3-selection-ranges 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