I'm having a issue getting the refactor-rename mechanism to pop-up for the following scenario:
The plugin is extending the YAML language and I'm creating a declaration using a sequence, then at another location I'm using that variable. So let's say the document looks like:
- $variable = 'something'
I can create a reference from the usage at someProperty which will resolve to the YamlPlainText ($variable = 'something'). But there was no FindUsage available. I fixed that by using the PsiSymbolDeclarationProvider which creates the PsiSymbolDeclaration. Now the FindUsage works :)
But now I also want to support refactor-rename which is not available as an option when I have the caret at the declaration. When I have the caret at the usage than it works. Unfortunately I cannot 'catch' the refactor-rename operation this way and since the PlainText is not a PsiNamedElement with a NameIdentifier it doesn't rename the declaration.
I could work around this too by placing a reference on the declaration which points to itself. Now I can use the handleElementRename of the reference to rightfully rename the PlainText but this leaves me with the last issue: I can no longer trigger the FindUsages by clicking on the declaration, since that would simply resolve the self-reference.
I wonder if I'm missing some kind of provider that I can register for these kinds of situations. Ideally I would like to be able to override a method in the PsiSymbolDeclaration where it would also be called with a newName so I can determine exactly how the PlainText should look like afterwards.