fix Language server does not expose read/write metadata for symbols #3246#3249
Open
asukaminato0721 wants to merge 2 commits intofacebook:mainfrom
Open
fix Language server does not expose read/write metadata for symbols #3246#3249asukaminato0721 wants to merge 2 commits intofacebook:mainfrom
asukaminato0721 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
requested changes
Apr 27, 2026
Contributor
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. ✅ |
Contributor
|
@kinto0 has imported this pull request. If you are a Meta employee, you can view this in D103052266. |
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.
Summary
Fixes #3246
Document highlights now set LSP DocumentHighlightKind::WRITE for assignment/declaration-style references and READ for normal uses.
Test Plan
add test