Renaming PsiElement that resolves to a file

Answered

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

0
2 comments

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.

1

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.

0

Please sign in to leave a comment.