Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemtation of VSCode RenameProvider for variable/function renaming #2152

Open
wants to merge 116 commits into
base: main
Choose a base branch
from

Conversation

Razmo99
Copy link

@Razmo99 Razmo99 commented Mar 25, 2024

PR Summary

This is a sister pull request to pr #4950 and issue Smart Variable Rename. It implements the server side component to allow refactoring of Powershell functions and variables.

It does this by implementing two new handlers RenameSymbolHandler and PrepareRenameSymbolHandler which is just plumbing to receive the incoming requests from the client. PrepareRenameSymbolHandler is used to determine if the rename is possible and RenameSymbolHandler is what actually returns the edits to the client.

All the action to decide what is renamed is done within two classes IterativeFunctionRename and IterativeVariableRename to boil it down the Abstract Syntax Tree(AST) of the script file is analyzed, then the symbol at the target line and column is retrieved. It then loops through the AST following rules to determine scope and what to rename. This is then passed back to the client to action.

Below are the current features

  • Rename Variables
  • Rename Functions
  • Is Scope Aware
  • Supports renaming splats
  • Supports renaming function parameters
  • If a function parameter is renamed it will add an alias

Below are the current limitations

  • Only refactors within the open file
  • Restricted to not work if dot sourcing is detected

Tests to cover as many scenarios as I could think of and to ensure the features described above function have been written

PR Context

This pull request should be helpful as its implementing a feature that I think has been desired for some time among Powershell developers. It should improve coding efficiency and allow code to be refactored with ease.

@Razmo99 Razmo99 changed the title WIP: Implemtation of VSCode RenameProvider for variable/function renaming Implemtation of VSCode RenameProvider for variable/function renaming Mar 25, 2024
@Razmo99 Razmo99 marked this pull request as ready for review March 25, 2024 04:06
@Razmo99 Razmo99 requested a review from a team as a code owner March 25, 2024 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant