Rename base method?

In the IDEA GUI, when I refactor-rename an overriden method, I am prompted to either: 1. rename base method or 2. rename only current method.

How would I set that preference in my own plugins code?  It seems to default to rename only current method.

 RefactoringFactory rf = RefactoringFactory.getInstance(psiFile.getProject());


...


 PsiMethod[] jInnerPsiMethods = psiClass.getMethods();
 for (int k=0; k < jInnerPsiMethods.length; k++)
 { PsiMethod kMeth = jInnerPsiMethods[k];
 if (!kMeth.isConstructor())
 { RenameRefactoring renameMethods = rf.createRename( kMeth, methodNama.getNextName(), true, true );
 renameMethods.doRefactoring(renameMethods.findUsages());
 }
 }



Attachment(s):
override.png
5 comments
Comment actions Permalink

It seems, after studying the API, I need to use findSuperMethods to make the changes up the chain of super methods myself.  That is straightforward.

But this requires I start with my deepest SubClasses.  Before I go through and build a utility to do this, I thought I would ask if there is an existing Utility to do this?  Any methods you'd suggest using?

0
Comment actions Permalink

hm..what are you trying to do?
If you choose "rename base method" intelij will rename base method and all methods that are overriding it (in all classes that are within your project).

0
Comment actions Permalink

I am writing a plugin to change the name of every method and class and field in my project.

When I call createRename on a method which is also implemented in subClasses, it is not being renamed in the subclasses.  Do I need to make those changes myself?


0
Comment actions Permalink

And a related problem:

Given a PsiMethod, how do I get a list of PsiMethods where it is overridden in subClasses?

0
Comment actions Permalink

I got this working.

Let me clean up my code and then I will put a project up on github.  

I strongly suspect there is a better way to build this plugin.  I hope the intellij community can critique it and help make it better.

0

Please sign in to leave a comment.