feat(lsp): textDocument/documentHighlight#4081
Conversation
Highlight all same-file occurrences of the symbol under the cursor: declaration + usages for locals, parameters, top-level items, and class fields. New document_highlights_at in baml_lsp2_actions reuses the usages machinery restricted to the request file (highlights fire on every cursor move, so the package-wide scan usages_at does would be wasted work), then adds the declaration occurrence back, narrowed to its name token (the recorded local range covers 'let name' and a param's covers 'name: type'). Shares the enclosing-function scope walk that usages_at and definition_at each had their own copy of via a new utils::enclosing_function_loc. No highlight kinds: BAML has no reassignment, so the read/write split carries no signal.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
⏭️ Performance benchmarks were skippedPerf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to To run them on this PR, do any of the following, then push a commit (or re-run CI):
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughAdds LSP ChangesDocument highlight support
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant LSPClient
participant BexMulitProject
participant document_highlights_at
LSPClient->>BexMulitProject: textDocument/documentHighlight request
BexMulitProject->>document_highlights_at: file and cursor offset
document_highlights_at-->>BexMulitProject: sorted same-file ranges
BexMulitProject-->>LSPClient: DocumentHighlight values
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Binary size checks failed❌ 4 violations · ✅ 3 passed
Details & how to fixViolations:
Add/update baselines:
[artifacts.baml-cli]
file_bytes = 19528576
stripped_bytes = 19528624
gzip_bytes = 9327682
[artifacts.bridge_wasm]
file_bytes = 16170257
gzip_bytes = 4405840
[artifacts.baml-cli]
file_bytes = 21053952
stripped_bytes = 21053952
gzip_bytes = 9535850
[artifacts.baml-cli]
file_bytes = 25252304
stripped_bytes = 25252296
gzip_bytes = 10724634Generated by |
Highlights all same-file occurrences of the symbol under the cursor — declaration + usages for locals, parameters, top-level items, and class fields.
document_highlights_atinbaml_lsp2_actionsreuses theusages_atmachinery restricted to the request file: the LSP scopes highlights to one document and editors re-request them on every cursor move, so the package-wide CST scanusages_atdoes would be wasted work.usages_atbehavior is unchanged (it delegates to the same impl with package-wide scope).usages_atexcludes it by contract), narrowed to its name token — the semantic index's recorded local range coverslet nameand a parameter's signature span coversname: type, both too wide to highlight.usages_atanddefinition_ateach had a private copy of is now shared asutils::enclosing_function_loc.DocumentHighlightKind: BAML has no reassignment, so the read/write split carries no signal.document_highlight_providercapability wired inbex_project.Tests: 5 new cursor-marker tests (
highlights_tests.rs) covering local declaration+usages from both cursor positions, parameters, cross-file isolation, and non-identifier positions.Summary by CodeRabbit
New Features
Bug Fixes
Tests