Do I have to use an External Annotator? Trying to highlight all subtags within a specific XmlTag.

已回答

I've successfully highlighted a specific XmlTag within my Xml file by just using the Annotator extension point, however I want to also highlight every tag within that tag. The Annotator class is called bottom-up when parsing, so I can't figure out a way to just highlight everything in my tag once I've found it. 

I tried to extend the External Annotator and use a Visitor in the collectInformation() method to collect all the tags I would like to highlight, but it doesn't seem to be running when I test the plugin. 

What is the best approach to this? To reiterate, I would like to find a tag and then highlight all the elements within that tag. 

0

Hi,

You should just focus on highlighting the lowest possible level elements, for example, an element passed to the annotate function. If the information about whether an element should be highlighted is in/depends on the parent element, just walk the tree up to find it out.

This approach is the most efficient, even if you walk the parents many times the same way. As annotators are called bottom-up, lower-level elements will be annotated first. Also, editor highlighting is optimized to annotate the code in the visible area first. If you annotate the top tag and it doesn't fit within the visible area, it will be highlighted late but users expect to get as much information as fast as possible.

ExternalAnnotator should be used in cases where the information about annotations comes from a different source, like an external tool, not from the PSI analysis.

0

Hi, thank you for your response! Was able to figure out

0

请先登录再写评论。