Search and Scroll (to) some XML attribute

Hi,

I'd be thankfull is anyone could provide some guidelines on how to search and scroll to some PsiElement?

Say I have an XML file and I want to scroll to the first attribute which looks like this:


This is the best I could come up with:


Is there anything better ?
I dont think the indexOf solution is too elegant; Perhaps search the PsiElements of the XmlFile and have a way to scroll to their offset...

Any Ideas?

Thank you for your time

Eyal

2 comments

Eyal Katz wrote:

I'd be thankfull is anyone could provide some guidelines on how to search and scroll to some PsiElement?


Most implementations of PsiElements like XmlTag, XmlAtribute, etc. implement the
Navigatable interface. Once you've found your attribute, cast it to Navigatable
and call navigate(true).

For finding the attribute, PsiRecursiveElementVisitor is what you can use to
walk through the PSI structure of the file.

Sascha

0

Hi Sascha,

Thanks very much for the quick reply
Here's the code for the sake of whoever will search the forums later on:

0

Please sign in to leave a comment.