Fixed-number(single) SubTag elements

Hello, I'm defining dom structure for my plugin, one of my interface looks like this:

public interface PrimaryElement extends DomElement {
    @SubTag("bundle")     Bundle getBundle();
}



I want restrict PrimaryElement to contains only one subtag <bundle>.
When I run this code I expected  that IDEA will highlite error when two <bundle> or more tags presented - but there is no highlighting.
Do I missed something or this is normal?

I use IDEA 123.139
8 comments
Comment actions Permalink

Do you have a working DomElementsInspection for your DOM installed?


0
Comment actions Permalink

No, I expected that IDEA will highlight this automatically.
So, from you question I see that I need to do it manually.

But maybe you know why IDEA does not highlight it automatically(what's the reason)?
I think it's clean that if I declare singular type of subtag - it should be only one child with this name.

0
Comment actions Permalink

These "standard" highlightings will be provide by IntelliJ IDEA as soon as you register a "blank" com.intellij.util.xml.highlighting.BasicDomElementsInspection with your DOM root type. So yes, it's a bit of manual work (register inspection) but then you get a lot for free ;-)

0
Comment actions Permalink

There's no such specific highlighting available currently. There's a more general option. You can annotate your root DomElement with @DefinesXml annotation and then everything in your XML that's not covered by DOM methods will be red.

0
Comment actions Permalink

I'm already use this annotation, and this behaviour is avesome, but thats why I asked this question - IDEA highlight all unknow attributes/tags that not defined in my interface "schema"(also completion - perfect!), except the defined child uniqueness(unexpectedly for me).

0
Comment actions Permalink

I see. Nobody ever needed that and consequently this is not implemented yet. :) Could you please file a feature request?

0
Comment actions Permalink

Hmm, after I created and registered empty BDEI implementation(really empty - only constructor) nothing changes,
highlightings(errors) for tags and attributes(unknown, mandatory) are the same as without inspection.
So, at this moment for my situation, I think, I should write proper inspection manually.

0

Please sign in to leave a comment.