feat(lsp): alias definition, references and rename - #27
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slice 3 core: the navigation/refactor trio over block aliases. The handler had hover/completion/semanticTokens/diagnostics; this adds go-to-definition, find-all-references and rename — reusing the existing alias/scope analysis (no new inference).
Pure core (analyze.ml):
symbol_at blocks ~offsetresolves the alias symbol under the cursor — the cursor may sit on the alias value in a fence info string (a declaration) or on the name token of a{{alias...}}reference. Returns the declaration range + the name-token range of every reference that resolves to that same declaration (nearest-aliased-above, honoring shadowing;$prevresolves viaprev_decl). Path segments and prose yield None — so rename never touches text that merely looks like an alias.Handlers (httui_lsp.ml) mirror on_hover:
on_definition(Location),on_references(honorsincludeDeclaration),on_rename(WorkspaceEdit over the single document;$previs a no-op — positional, no name token). Capabilities advertise definition/references/rename providers. Intra-document only (refs never cross files — DAG within one doc).Tests (test_lsp.ml, +7): definition→declaration, references incl/excl declaration (3/2), rename produces decl + 2 ref-name edits, the
{{req1.req1}}path segment is NOT renamed (the RFC exit criterion), every edit writes the new name, and$prev(definition resolves to the previous block, rename is null). 119 total green; bench--checkgate still green (nav is on-demand, no per-keystroke cost).Follow-up (separate PR): desktop wiring (go-to-def/find-refs/rename via @codemirror/lsp-client + keybindings) and removing cm-references.ts/cm-autocomplete.ts.