Skip to content

impl Rename Refactors #2207#2661

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

impl Rename Refactors #2207#2661
asukaminato0721 wants to merge 5 commits into
facebook:mainfrom
asukaminato0721:2207-rename

Conversation

@asukaminato0721

@asukaminato0721 asukaminato0721 commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

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
new_text: params.new_name.clone(),
}),
);
FindPreference {

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.

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.

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 github-actions Bot added size/xl and removed size/xl labels Apr 25, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@kinto0

kinto0 commented May 15, 2026

Copy link
Copy Markdown
Contributor

looks like some tests are red

@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the stale label May 20, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the stale label Jun 3, 2026
@github-actions

github-actions Bot commented Jun 3, 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 removed the stale label Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

4 participants