fix Language server does not expose read/write metadata for symbols #3246#3249
fix Language server does not expose read/write metadata for symbols #3246#3249asukaminato0721 wants to merge 2 commits intofacebook:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes document highlight responses to include read/write metadata (DocumentHighlight.kind) so editors can apply distinct highlighting for reads vs writes (addresses #3246).
Changes:
- Populate
DocumentHighlight.kindasREADvsWRITEbased on whether the reference is a write context. - Track attribute expression context (
Load/Store/Del) so attribute writes can be classified correctly. - Add/adjust LSP interaction tests to assert the returned highlight kind for both regular files and notebook cells.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
pyrefly/lib/lsp/non_wasm/server.rs |
Sets DocumentHighlight.kind to READ/WRITE for each highlighted reference. |
pyrefly/lib/state/lsp.rs |
Stores attribute expr context and adds a helper to classify a reference as write vs read. |
pyrefly/lib/test/lsp/lsp_interaction/document_highlight.rs |
New test asserting read/write kind values are present in highlight responses. |
pyrefly/lib/test/lsp/lsp_interaction/notebook_document_highlight.rs |
Updates existing notebook highlight test expectations to include kind. |
pyrefly/lib/test/lsp/lsp_interaction/mod.rs |
Registers the new document_highlight test module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment has been minimized.
This comment has been minimized.
kinto0
left a comment
There was a problem hiding this comment.
approach looks great, thanks for picking this up!
just a few code style suggestions
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
|
@kinto0 has imported this pull request. If you are a Meta employee, you can view this in D103052266. |
connernilsen
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Summary
Fixes #3246
Document highlights now set LSP DocumentHighlightKind::WRITE for assignment/declaration-style references and READ for normal uses.
Test Plan
add test