Skip to content

Conversation

@asukaminato0721
Copy link
Contributor

@asukaminato0721 asukaminato0721 commented Jan 8, 2026

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.

@meta-cla meta-cla bot added the cla signed label Jan 8, 2026
@asukaminato0721 asukaminato0721 marked this pull request as ready for review January 8, 2026 03:33
Copilot AI review requested due to automatic review settings January 8, 2026 03:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@github-actions

This comment has been minimized.

@asukaminato0721 asukaminato0721 marked this pull request as draft January 8, 2026 04:10
@asukaminato0721 asukaminato0721 marked this pull request as ready for review January 8, 2026 05:29
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

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.

2 participants