Skip to content

feat: add Phase 5 document highlights provider - #244

Merged
j4rviscmd merged 1 commit into
mainfrom
feat/language-host-highlight
Jul 26, 2026
Merged

feat: add Phase 5 document highlights provider#244
j4rviscmd merged 1 commit into
mainfrom
feat/language-host-highlight

Conversation

@j4rviscmd

Copy link
Copy Markdown
Owner

Summary

Phase 5 of the native (Rust) Language Host: tree-sitter-backed DocumentHighlightProvider, continuing Phase 0→1→2→3→4 (documentSymbol/foldingRange/hover/definition/references already merged).

Phase 5 — Document Highlights

  • Message::DocumentHighlights { uri, line, column }DocumentHighlightsResponse { highlights: [{ range, kind }] } or null
  • Resolve the identifier at the cursor, then recursively walk the document AST collecting ALL identifier-like nodes whose text matches; each becomes a DocumentHighlight { range, kind } where kind is Write(2) for declaration names (is_declaration_name) and Read(1) otherwise. Text(0) is unused in v1.
  • File-local only; all matches returned (no scope-aware filtering — shadowed locals highlight too)

Refactor

  • Extracted point_for_position helper (shared Point resolution between hover and find_identifier_at_position)
  • Unified response interfaces to use IRange

Fix

Corrected DocumentHighlightKind comment (Text=0, not Text=3 — VS Code enum, not LSP). No runtime impact (only Read=1/Write=2 are emitted).

Known limitation

File-local, name-based — no cross-file type resolution like tsserver, no scope-aware filtering. Coexists with the built-in TS provider (non-exclusive, Phase 1 pattern).

How to verify

  1. `cd rust && cargo build`
  2. `npm run watch` + `./scripts/code.sh`
  3. Enable `coderm.languageHost.enabled` and set `coderm.languageHost.languages` (e.g. `["typescript", "tsx"]`)
  4. Open a `.ts` file, place the cursor on an identifier and wait — all same-name identifiers in the file get highlighted (declaration = Write, references = Read).

Phase 5 — tree-sitter-backed DocumentHighlightProvider: highlight all occurrences of the symbol at the cursor. Message::DocumentHighlights { uri, line, column } -> DocumentHighlightsResponse { highlights: [{ range, kind }] } or null. Resolve the identifier at the position, then recursively walk the document AST collecting ALL identifier-like nodes whose text matches; kind heuristic: declaration name (is_declaration_name) -> Write(2), otherwise Read(1). File-local only.

Refactor: extracted point_for_position helper (shared Point resolution between hover and find_identifier_at_position); unified response interfaces to use IRange.

Fix: corrected DocumentHighlightKind comment (Text=0, not Text=3 — VS Code enum, not LSP). No runtime impact (only Read=1/Write=2 are emitted).

Known limitation (documented): file-local, name-based — no cross-file type resolution, no scope-aware filtering. Coexists with the built-in TS provider (non-exclusive, Phase 1 pattern).

Co-Authored-By: Claude <noreply@anthropic.com>
@j4rviscmd j4rviscmd added the enhancement New feature or request label Jul 26, 2026
@j4rviscmd
j4rviscmd merged commit 181657b into main Jul 26, 2026
3 checks passed
@j4rviscmd
j4rviscmd deleted the feat/language-host-highlight branch July 26, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant