I'm trying to implement the Rename refactoring for the plugin I'm currently building (FitNesse, https://github.com/gshakhn/idea-fitnesse).
In FitNesse tables contain the information that has to be executed on a System under test (SUT).
So the first thing I did was figure out the text that identifies the "fixture" class that has to be executed. FitNesse uses a human readable version of the camel case syntax -- so "my fixture" will translate to a class named "MyFixture".
So far so good. I set up referencing stuff between the fixture class name in the FitNesse file and the Java class.
I added a RenameHandler and a NamesValidator (since FitNesse names can contain spaces).
Only when I try to rename, I always end up renaming the Java class. The friendly text in my FitNesse page is substituted by the real class name and that is what is edited. I would expect I can edit the FitNesse fixture name instead.
I traced it as much as I could and it looks like AnActionEvent.getData("psi.Element") tries to figure out the element underneath the cursor, but via PsiAwareTextEditorImpl and TargetElementUtilBase.findTargetElement() it ends up with the first reference found.
I'm clearly missing something. What does it take to rename my FixtureClass and not end up renaming the referenced Java class (its reference)?
Should I use a ReferenceContributor instead of using FixtureClass.getReference?
It might be worth noting that the FixtureClass (PSI) element is a composite element and contains words and whitespace that make up the fixture class name. Does this have something to do with it?