Skip to content

impl Rename Refactors #2207 - #2661

Open
asukaminato0721 wants to merge 9 commits into
facebook:mainfrom
asukaminato0721:2207-rename
Open

asukaminato0721 wants to merge 9 commits into
facebook:mainfrom
asukaminato0721:2207-rename

Conversation

@asukaminato0721

@asukaminato0721 asukaminato0721 commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator

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.

@meta-cla meta-cla Bot added the cla signed label Mar 5, 2026
@asukaminato0721
asukaminato0721 marked this pull request as ready for review March 5, 2026 04:06
Copilot AI review requested due to automatic review settings March 5, 2026 04:06
@asukaminato0721
asukaminato0721 marked this pull request as draft March 5, 2026 04:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.rename workspace 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 linkedEditingRange capability/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.

Comment thread pyrefly/lib/state/lsp.rs Outdated
Comment thread pyrefly/lib/lsp/non_wasm/server.rs Outdated
@github-actions

This comment has been minimized.

@asukaminato0721
asukaminato0721 marked this pull request as ready for review March 5, 2026 05:21
@jvansch1 jvansch1 self-assigned this Mar 5, 2026
@meta-codesync

meta-codesync Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

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

Comment thread pyrefly/lib/lsp/non_wasm/server.rs Outdated
Comment thread pyrefly/lib/lsp/non_wasm/server.rs
Comment thread pyrefly/lib/lsp/non_wasm/server.rs Outdated
Comment thread pyrefly/lib/lsp/non_wasm/server.rs Outdated
Comment thread pyrefly/lib/state/lsp.rs Outdated
Comment thread pyrefly/lib/state/lsp.rs Outdated
@asukaminato0721
asukaminato0721 force-pushed the 2207-rename branch 2 times, most recently from 8f9890d to eb13a90 Compare March 5, 2026 20:36
@github-actions

This comment has been minimized.

@asukaminato0721
asukaminato0721 requested a review from jvansch1 March 6, 2026 10:01

@kinto0 kinto0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review automatically exported from Phabricator review in Meta.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot added size/xl and removed size/xl labels Jul 31, 2026
@codspeed

codspeed Bot commented Jul 31, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 28 untouched benchmarks
⏩ 9 skipped benchmarks1


Comparing asukaminato0721:2207-rename (d15a41d) with main (cc48666)

Open in CodSpeed

Footnotes

  1. 9 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions

This comment has been minimized.

Comment thread pyrefly/lib/lsp/rename.rs Outdated
Comment thread pyrefly/lib/lsp/non_wasm/rename.rs
Comment thread pyrefly/lib/lsp/non_wasm/rename.rs Outdated
Comment thread pyrefly/lib/lsp/non_wasm/rename.rs Outdated

@kinto0 kinto0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI comments:

  • Was scoping considered for commentsAndStrings? PyCharm restricts comment/string search to the usage search scope; here any comment in any loaded module containing the bare word gets rewritten, including
    modules with their own unrelated foo. That's a lot of unexpected edits behind a single boolean.
  • linkedEditingRange is now advertised whenever indexing_mode != None, which changes behavior for all users who have editor.linkedEditing on — independent of the two new settings. Intentional?

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

5 similar comments
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

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

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

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

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

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

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

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

@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. ✅

@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. ✅

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.

4 participants