impl Rename Refactors #2207#2661
Conversation
There was a problem hiding this comment.
Pull request overview
Adds rename refactoring options (rename in comments/strings and in non-Python text files) and introduces LSP linkedEditingRange support for inline rename ranges, wiring both through workspace configuration and adding interaction tests/fixtures.
Changes:
- Add
pyrefly.renameworkspace config (commentsAndStrings,textOccurrences) and propagate into LSP server behavior. - Implement comment/string scanning + workspace-wide non-Python text scanning to produce additional rename edits.
- Add
linkedEditingRangecapability/handler and LSP interaction tests + fixtures.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
pyrefly/lib/lsp/non_wasm/server.rs |
Implements rename options, workspace text scanning, and linkedEditingRange request handling/capability. |
pyrefly/lib/lsp/non_wasm/workspace.rs |
Adds RenameConfig to workspace settings and configuration application/getter. |
pyrefly/lib/state/lsp.rs |
Adds helpers to find identifier occurrences in comment/string content ranges. |
pyrefly/lib/test/lsp/lsp_interaction/rename.rs |
Adds LSP interaction tests for rename options + linked editing ranges. |
pyrefly/lib/test/lsp/lsp_interaction/test_files/rename_inline_options/main.py |
New fixture covering code, comment, and string occurrences. |
pyrefly/lib/test/lsp/lsp_interaction/test_files/rename_inline_options/notes.txt |
New fixture for text occurrence renames in non-Python files. |
lsp/package.json |
Exposes python.pyrefly.rename settings in the extension schema. |
pyrefly/Cargo.toml / Cargo.lock |
Adds the ignore crate dependency used for workspace walking. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
This comment has been minimized.
This comment has been minimized.
| new_text: params.new_name.clone(), | ||
| }), | ||
| ); | ||
| FindPreference { |
There was a problem hiding this comment.
We added a lot of new logic in line here. I think we should either break this up into some smaller functions or try to make it more clear what is happening here. Seeing a large code block like this is hard to follow.
8f9890d to
eb13a90
Compare
This comment has been minimized.
This comment has been minimized.
kinto0
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
This comment has been minimized.
This comment has been minimized.
eb13a90 to
35325fa
Compare
This comment has been minimized.
This comment has been minimized.
35325fa to
cf33221
Compare
This comment has been minimized.
This comment has been minimized.
cf33221 to
35b66c3
Compare
This comment has been minimized.
This comment has been minimized.
35b66c3 to
b683000
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1c93b34 to
a251da5
Compare
|
looks like some tests are red |
a251da5 to
d941f9d
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
d941f9d to
00edf1f
Compare
00edf1f to
d3ace7b
Compare
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Summary
Fixes part of #2207
Implemented rename refactoring options for comments/strings and text occurrences, aligned with PyCharm’s inline rename behavior and availability cues.
Added LSP linkedEditingRange support for inline rename ranges in-file, and wired the new rename options through workspace config.
Test Plan
Added LSP interaction tests and fixtures covering comment/string and text-file occurrences, plus linked editing ranges.