Renaming PsiElement that resolves to a file
Hey all
I managed to get a PsiReferenceProvider implemented that resolves to a file when a specific XML-Tag is clicked. Let me give you an example:
<Name>Policy_Step1</Name>
When one clicks Policy_Step1 the file that defines Policy_Step1 is opened. This does not specifically need to be the name of the file containing said policy. Now I would also like to implement the handleRename function. Imagine the actual file Policy_Step1_File.xml would be like that:
<Policy name="Policy_Step1">...</Policy>
The handleRename should now adjust the value of that attribute. The problem is that when I hit refactor->rename it opens a file rename dialog and renames the file Policy_Step1_File.xml to what I set.
Do I have to return a different PsiElement and not the one created from the file to have this working?
Cheers,
Yanick
Please sign in to leave a comment.
Is your reference's handleElementRename method called? If not, you can put a breakpoint into DocumentImpl.changedUpdate and see which code changes the XML text. Knowing that, one could figure out a way to fix the issue.
Hello Peter
Thank you for your hints, it turned out i haven't properly understood the Reference/Element relationship. Now that my references are properly returning the right elements in resolve and isReferenceTo everything is working fine an my handleRename methods get called.