Skip to content

fix Language server does not expose read/write metadata for symbols #3246#3249

Open
asukaminato0721 wants to merge 2 commits intofacebook:mainfrom
asukaminato0721:3246
Open

fix Language server does not expose read/write metadata for symbols #3246#3249
asukaminato0721 wants to merge 2 commits intofacebook:mainfrom
asukaminato0721:3246

Conversation

@asukaminato0721
Copy link
Copy Markdown
Contributor

@asukaminato0721 asukaminato0721 commented Apr 27, 2026

Summary

Fixes #3246

Document highlights now set LSP DocumentHighlightKind::WRITE for assignment/declaration-style references and READ for normal uses.

Test Plan

add test

@meta-cla meta-cla Bot added the cla signed label Apr 27, 2026
@asukaminato0721 asukaminato0721 marked this pull request as ready for review April 27, 2026 14:30
Copilot AI review requested due to automatic review settings April 27, 2026 14:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.kind as READ vs WRITE based 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.

Comment thread pyrefly/lib/test/lsp/lsp_interaction/document_highlight.rs Outdated
Comment thread pyrefly/lib/test/lsp/lsp_interaction/notebook_document_highlight.rs
@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

@kinto0 kinto0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approach looks great, thanks for picking this up!

just a few code style suggestions

Comment thread pyrefly/lib/test/lsp/lsp_interaction/document_highlight.rs Outdated
Comment thread pyrefly/lib/test/lsp/lsp_interaction/document_highlight.rs Outdated
Comment thread pyrefly/lib/test/lsp/lsp_interaction/document_highlight.rs Outdated
Comment thread pyrefly/lib/state/lsp.rs Outdated
@kinto0 kinto0 self-assigned this Apr 27, 2026
@github-actions
Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Copy Markdown
Contributor

@kinto0 kinto0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!! very clean

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Apr 29, 2026

@kinto0 has imported this pull request. If you are a Meta employee, you can view this in D103052266.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Language server does not expose read/write metadata for symbols

3 participants