jwir3
jwir3

Reputation: 6219

IntelliJ plugin invoke rename refactoring

I'm writing a plugin for IntelliJ that does a couple of things. One of the things that it performs is a rename of all references if they don't meet a specific style guideline (think of it like a style police officer that checks code styles before saving). What I'd like to do is the following (from within an existing AnAction):

  1. Find all usages of a given identifier.
  2. For each usage, rename the identifier to a different identifier.

Clearly, this is the exact workflow that the rename refactoring uses. So, my question is: How do I invoke the rename refactoring, given a PsiElement (or even just a String representation of the identifier), from within an existing AnAction (i.e. I want to do multiple things in succession, this is just one of them, so I don't want the user to have to go back through the refactoring menu for each thing they want to perform).

Upvotes: 0

Views: 231

Answers (1)

yole
yole

Reputation: 97338

Try this:

RefactoringFactory.getInstance(project).createRename()

Upvotes: 1

Related Questions