Skip to content

Feature request: Add "move" symbol refactoring action #426

@maciejzj

Description

@maciejzj

Hi!
It would be great to be able to move existing symbol (variable, function, class) to an existing file. Right now we can only "extract function" to a new file. A feature like this is present in IntelliJ products and VSCode refactoring tools.

I image that this would open a file picker (telescope/enhanced selection popup from nvim dressing would be great, I am not so sure about native nvim selection UI) and let the user choose the file where the symbol should be moved to.

This would be especially helpful if the refactoring tool was able to move code with necessary dependencies (e.g. Python import statements with modules used inside the function that is to be moved). This behaviour has been mentioned in slightly different context in #331. This would also require other modules to change how they import the symbol that is being moved (so they import it from the new location).

This could be expanded even more to enhance existing "extract function to file", which could then be split into "extract function to new file" (would work as it does now), and "extract function to existing file" which would combine extracting function with moving it to one of existing files via file picker. Moving modules would also be great (effectively this would be renaming files with updating other modules that depend on it to update they imports to the new name/location).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions