impl inline refactor code actions#2033
Closed
asukaminato0721 wants to merge 3 commits intofacebook:mainfrom
Closed
impl inline refactor code actions#2033asukaminato0721 wants to merge 3 commits intofacebook:mainfrom
asukaminato0721 wants to merge 3 commits intofacebook:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request implements three inline refactoring code actions for Python: inline variable, inline method (call-site only), and inline parameter. The implementation includes comprehensive safety checks to ensure conservative refactoring operations.
Key Changes
- Added inline variable refactoring that replaces all references with the assigned value and removes the assignment
- Added inline method refactoring that replaces a single call site with the method body (preserving the method definition)
- Added inline parameter refactoring that requires exactly one call site, removes the parameter, and inlines the argument value
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pyrefly/lib/test/lsp/code_actions.rs | Added test helpers and unit tests for the three new inline refactoring actions |
| pyrefly/lib/state/lsp/quick_fixes/mod.rs | Added module declarations for the three new inline refactoring implementations |
| pyrefly/lib/state/lsp/quick_fixes/inline_variable.rs | Implemented inline variable with safety checks for recursion, nested scopes, and disallowed expressions |
| pyrefly/lib/state/lsp/quick_fixes/inline_parameter.rs | Implemented inline parameter with single call site requirement and parameter usage validation |
| pyrefly/lib/state/lsp/quick_fixes/inline_method.rs | Implemented inline method for single call sites with parameter mapping and substitution |
| pyrefly/lib/state/lsp.rs | Added public API methods to expose the three inline code actions to the LSP layer |
| pyrefly/lib/lsp/non_wasm/server.rs | Registered REFACTOR_INLINE capability and wired the three actions into the code action pipeline |
💡 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.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
yangdanny97
approved these changes
Jan 21, 2026
Contributor
yangdanny97
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
meta-codesync bot
pushed a commit
that referenced
this pull request
Feb 5, 2026
Summary: enhancement for #2033 find that class method is missing support Implemented class instance method inline support by adding an AST-based fallback when find_definition can’t resolve self.foo(); it now resolves to the method in the same enclosing class only when the receiver matches the enclosing method’s first parameter and the enclosing method isn’t `staticmethod`/`classmethod`. Pull Request resolved: #2301 Test Plan: add test Reviewed By: stroxler Differential Revision: D92313955 Pulled By: kinto0 fbshipit-source-id: 50fecc3e30f39f9699494985cf61b934421ef287
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes part of #364
Added conservative inline refactor code actions (variable, call‑site method, and parameter) with safety checks, wired them into LSP capabilities and the code‑action pipeline.
Inline method replaces the selected call only (doesn’t delete the definition). Inline parameter requires a single local call site and removes the parameter + argument.
https://www.jetbrains.com/help/pycharm/inline.html#inline-variable-python
Test Plan
added focused unit tests in the LSP code‑actions suite.