I'm working on a custom in place renamer for my XML tag. When I rename an attribute of a particular tag, I want also to rename attributes of other specific tags in the same file. My template builder method looks like this:

To the first exception: you start the template over attribute which would be a container in your case and should contain everything else you add to the template. But then you add refs which are tags and I assume that they are not children of the attribute - so the exception.

When you pass the whole file, then the previous issue should be fixed. It looks like that the caret position is left as it was and it should be shifted as you replace your real values with variables.

That's all is very overcomplicated and it would be really better if the common scenario would be used instead. Why do you want to implement the template yourself and not reuse existing inplace renamer?

I guess the answer for your question is "I don't know how to reuse existing in place renamer" :) Perhaps you can point me to an example?

Here's the situation. I have a tag named "flow" which is a declaration. Then I might have multiple "flow-ref" tags which are references to the declared flow. E.g. <flow name="Hello"/> and multiple <flow-ref name="Hello"/> in multiple XML files in my project. I've implemented FlowRefPsiReference class which extends PsiReferenceBase<XmlAttributeValue>. When I rename the attribute in one <flow-ref> , the rest of the attributes in other refs and in <flow> tag are renamed correctly. However, if I rename attribute in the <flow> tag, nothing happens. So for some reason it only works one way, from reference to the declaration, but not the other way around. That's why I implemented my own RenameHandler, extending the XmlTagRenameHandler. Just like in its parent, there is a rename dialog, which works perfectly, and the in place renamer, which I'm struggling with :)