PSI link two different xml tags & file name together.

Is there any correct way to do such kind of thing.
1) I have xml file, describing resources. (path to image file and unique resource name.)
2) There are another xml files, where resource is used (by name)
3) There is a resource file inside the project, we can get it from first xml by path.

I'd like allow refactoring like renaming for file name and automatically update resource path in first xml and
rename of resource id, updating all resource id occurense.

Is there any way to make it in a proper way? Automatically, without a tonn of bug-tended code?
As I understood PSI references allow this. Where can I read more about it?

Thank you.

3 comments

Hi there,

All of this is possible with the DOM Api, the documentation is available here http://confluence.jetbrains.com/display/IDEADEV/Accessing+XML+through+IntelliJ+IDEA+DOM

Cheers,
Alan

0

I have read carefully given link, but still can't imagine, how to work with it. First of all it looks complicated for me.
All I wanted, is a way to connect two PSI elements together, and change them synchroniously. So, as I can imagine, I should intercept PSI parsing stage(or reparse them manually at startup) for all my xml files, and (If there is no ready for use solution), have a list of usages(PSI elements) for each resource name tag. Then, If original tag is changed, change content for every linked tag.

Is my way-of-think improper?
Where is IDEA DOM here?

0

The API is extremely easy to learn, don't worry :)
You should look into converters for reference resolving from the Dom Api documentation. This will allow you to provide your references to your files/configuration, which allows ctrl+clicking, renaming etc out of the box.
So nothing complex is required from your plugin like you're suggesting

Try to give it a go and be sure to check out the existing open source plugin examples, and if you get stuck, just ask.

Cheers,
Alan

0

Please sign in to leave a comment.