Repository navigation
fix Reference Counting #2194 - #2907
asukaminato0721 wants to merge 4 commits into
Conversation
011421e to
c711129
Compare
There was a problem hiding this comment.
Pull request overview
Adds CodeLens-based reference counts for Python symbols in the Pyrefly LSP when indexing is enabled, backed by the existing global references engine, and introduces an LSP interaction test to validate the behavior.
Changes:
- Advertise
textDocument/codeLenscapability when indexing is enabled and handleCodeLensRequeston the server. - Generate CodeLens entries for class/function/method definitions with
editor.action.showReferenceswired up. - Add LSP interaction tests and test fixtures validating CodeLens reference counts.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pyrefly/lib/lsp/non_wasm/server.rs | Advertises CodeLens capability and implements textDocument/codeLens request handling to return reference-count lenses. |
| pyrefly/lib/lsp/non_wasm/workspace.rs | Adds code_lens flag to disabled-language-services gating for textDocument/codeLens. |
| pyrefly/lib/test/lsp/lsp_interaction/object_model.rs | Adds a test client helper to send CodeLensRequest. |
| pyrefly/lib/test/lsp/lsp_interaction/mod.rs | Registers new code_lens LSP interaction test module. |
| pyrefly/lib/test/lsp/lsp_interaction/code_lens.rs | Adds tests verifying capability advertisement and reference-count CodeLens results. |
| pyrefly/lib/test/lsp/lsp_interaction/test_files/code_lens_references/{symbols.py,usage.py} | Adds small fixtures used by the new CodeLens tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
c1dbfe4 to
a3b4c67
Compare
a3b4c67 to
8db5e91
Compare
8db5e91 to
dc17cb7
Compare
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
|
I'm closing this PR, I think it's too old to review (for example, already attached to a stale diff). If you decide to open a fresh PR, which I think we will be better at turning around, some suggestions from AI review:
Nits (we should still address these, code quality is important!)
Just noting: some things are good in the existing work:
|
Summary
Fixes #2194
The server now advertises
textDocument/codeLenswhen indexing is enabled and returns CodeLens entries for class/function/method definitions using the existing global references engine.Each lens shows N reference(s) and wires to VS Code’s built-in
editor.action.showReferences, so clicking the count opens the references UI.Test Plan
add LSP interaction test