Search in sources :

Example 1 with NameClass

use of org.kohsuke.rngom.nc.NameClass in project intellij-community by JetBrains.

the class RngNsDescriptor method findDescriptor.

private XmlElementDescriptor findDescriptor(final QName qName, List<DElementPattern> list) {
    int max = -1;
    DElementPattern maxPattern = null;
    for (DElementPattern pattern : list) {
        final NameClass nameClass = pattern.getName();
        if (nameClass.contains(qName)) {
            final int spec = nameClass.containsSpecificity(qName);
            if (spec > max) {
                maxPattern = pattern;
                max = spec;
            }
        }
    }
    final List<DElementPattern> patterns = ContainerUtil.findAll(list, pattern -> {
        final NameClass nameClass = pattern.getName();
        return nameClass.contains(qName);
    });
    if (maxPattern != null) {
        if (patterns.size() > 1) {
            return initDescriptor(new CompositeDescriptor(this, maxPattern, patterns));
        } else {
            return initDescriptor(new RngElementDescriptor(this, maxPattern));
        }
    } else {
        return null;
    }
}
Also used : NameClass(org.kohsuke.rngom.nc.NameClass) DElementPattern(org.kohsuke.rngom.digested.DElementPattern)

Aggregations

DElementPattern (org.kohsuke.rngom.digested.DElementPattern)1 NameClass (org.kohsuke.rngom.nc.NameClass)1