XmlAttributeValue rename

Hi!

I have an xml format, that describes some objects. For example:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<views>
<view class="Foo" name="foo-view" extends="foo-another-view">
<property name="bar"/>
<property name="person" view="_minimal"/>
</view>
<view class="Foo" name="foo-another-view" extends="_local">
<property name="createTs"/>
<property name="createdBy"/>
<property name="updateTs"/>
<property name="updatedBy"/>
</view>
</views>

The objects can have references to each other, so 'foo-view' references 'foo-another-view' in 'extends' attribute.

The attribute 'name' represents name of view. When I move caret to 'extends' attribute value, and start rename refactoring, it renames corresponding view 'name' correctly. But when I place caret to 'name' attribute value, the rename refactoring doesn't work, as the attribute value is neither PsiReference nor PsiNamedElement. So hot to mark that 'name' attribute value represents some name, that could be renamed?

1
4 comments

You need to have a PsiReference for the "name" attribute value, resolving to the containing "view" tag.

0

Hi Dmitry!

I've done as you say, but Rename refactoring tries to rename the tag, not the 'name' attribute value.

Than, I created reference from xml attribute value to itself, and it looks like that refactoring works good now. Is this correct? By the way, ctrl-click on a class name shows usages list of the class, but ctrl-click on 'name' attribute value navigates to itself (or to the containing "view" tag).

0

Such references (both from "name" and "extends" attributes) point ususally to the tag, but you can reference "name" attribute if it fits your needs.

0

But if reference points to tag, rename refactoring tries to rename tag name, that looks weird.

0

Please sign in to leave a comment.