Skip to content

feat: add Phase 4 references provider - #243

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

feat: add Phase 4 references provider#243
j4rviscmd merged 1 commit into
mainfrom
feat/language-host-references

Conversation

@j4rviscmd

Copy link
Copy Markdown
Owner

Summary

Phase 4 of the native (Rust) Language Host: tree-sitter-backed ReferenceProvider (Find All References, Shift+F12), continuing Phase 0→1→2→3 (documentSymbol/foldingRange/hover/definition already merged).

Phase 4 — References

  • Message::References { uri, line, column, include_declaration }DefinitionResponse { locations: Location[] } or null
  • Resolve the identifier at the position, then recursively walk the document AST collecting ALL identifier-like nodes whose text matches; declaration name nodes gated by include_declaration (VS Code ReferenceContext)
  • File-local only; all matches returned (no scope-aware filtering)

Fix

Message::References was missing per-variant rename_all = "camelCase", so include_declaration expected snake_case while the renderer sent camelCase includeDeclaration — every references request failed to deserialize and timed out. Added the attribute (same serde trap as Phase 2).

Refactor

  • Extracted find_identifier_at_position (shared prelude between definition and references)
  • Unified parseDefinition/parseReferences into parseLocations
  • Flattened the declaration-gating condition in collect_reference_locations

Known limitation

File-local, name-based — no cross-file type resolution like tsserver, no scope-aware filtering (shadowed locals match too). 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 a symbol, press `Shift+F12` → peek shows all references (and the declaration).

Verified end-to-end by the user (Shift+F12).

Phase 4 — tree-sitter-backed ReferenceProvider (Find All References, Shift+F12): Message::References { uri, line, column, include_declaration } -> DefinitionResponse { locations: Location[] } or null. Resolve the identifier at the position, then recursively walk the document AST collecting ALL identifier-like nodes whose text matches; declaration name nodes (parent is_definition_declaration_kind, node is its name field) are gated by include_declaration (VS Code ReferenceContext). File-local only; all matches returned.

Fix: Message::References was missing per-variant rename_all = "camelCase", so include_declaration expected snake_case while the renderer sent camelCase includeDeclaration — every references request failed to deserialize and timed out. Added the attribute (same serde trap as Phase 2).

Refactor: extracted find_identifier_at_position (shared prelude between definition and references), unified parseDefinition/parseReferences into parseLocations, flattened the declaration-gating condition.

Known limitation (documented): 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).

Co-Authored-By: Claude <noreply@anthropic.com>
@j4rviscmd j4rviscmd added the enhancement New feature or request label Jul 26, 2026
@j4rviscmd
j4rviscmd merged commit 95cdd31 into main Jul 26, 2026
3 checks passed
@j4rviscmd
j4rviscmd deleted the feat/language-host-references branch July 26, 2026 02:15
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