Search in sources :

Example 6 with DElementPattern

use of org.kohsuke.rngom.digested.DElementPattern in project intellij-community by JetBrains.

the class CompositeDescriptor method getElementsDescriptors.

@Override
public XmlElementDescriptor[] getElementsDescriptors(XmlTag context) {
    final List<XmlElementDescriptor> descriptors = new ArrayList<>(Arrays.asList(super.getElementsDescriptors(context)));
    for (DElementPattern pattern : myPatterns) {
        final List<DElementPattern> list = ChildElementFinder.find(2, pattern);
        descriptors.addAll(Arrays.asList(myNsDescriptor.convertElementDescriptors(list)));
    }
    return descriptors.toArray(new XmlElementDescriptor[descriptors.size()]);
}
Also used : ArrayList(java.util.ArrayList) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) DElementPattern(org.kohsuke.rngom.digested.DElementPattern)

Example 7 with DElementPattern

use of org.kohsuke.rngom.digested.DElementPattern in project intellij-community by JetBrains.

the class RngNsDescriptor method convertElementDescriptors.

XmlElementDescriptor[] convertElementDescriptors(List<DElementPattern> patterns) {
    patterns = ContainerUtil.findAll(patterns, NamedPatternFilter.INSTANCE);
    final Map<QName, List<DElementPattern>> name2patterns = new HashMap<>();
    for (DElementPattern pattern : patterns) {
        for (QName qName : pattern.getName().listNames()) {
            List<DElementPattern> dPatterns = name2patterns.get(qName);
            if (dPatterns == null) {
                dPatterns = new ArrayList<>();
                name2patterns.put(qName, dPatterns);
            }
            if (!dPatterns.contains(pattern))
                dPatterns.add(pattern);
        }
    }
    final List<XmlElementDescriptor> result = new ArrayList<>();
    for (QName qName : name2patterns.keySet()) {
        final List<DElementPattern> patternList = name2patterns.get(qName);
        final XmlElementDescriptor descriptor = findDescriptor(qName, patternList);
        if (descriptor != null) {
            result.add(descriptor);
        }
    }
    return result.toArray(new XmlElementDescriptor[result.size()]);
}
Also used : HashMap(com.intellij.util.containers.HashMap) QName(javax.xml.namespace.QName) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) AnyXmlElementDescriptor(com.intellij.xml.impl.schema.AnyXmlElementDescriptor) DElementPattern(org.kohsuke.rngom.digested.DElementPattern)

Aggregations

DElementPattern (org.kohsuke.rngom.digested.DElementPattern)7 XmlElementDescriptor (com.intellij.xml.XmlElementDescriptor)5 AnyXmlElementDescriptor (com.intellij.xml.impl.schema.AnyXmlElementDescriptor)2 ArrayList (java.util.ArrayList)2 QName (javax.xml.namespace.QName)2 PsiElement (com.intellij.psi.PsiElement)1 XmlAttribute (com.intellij.psi.xml.XmlAttribute)1 XmlElement (com.intellij.psi.xml.XmlElement)1 XmlTag (com.intellij.psi.xml.XmlTag)1 HashMap (com.intellij.util.containers.HashMap)1 XmlAttributeDescriptor (com.intellij.xml.XmlAttributeDescriptor)1 Collection (java.util.Collection)1 CompositeDescriptor (org.intellij.plugins.relaxNG.model.descriptors.CompositeDescriptor)1 RngElementDescriptor (org.intellij.plugins.relaxNG.model.descriptors.RngElementDescriptor)1 RngXmlAttributeDescriptor (org.intellij.plugins.relaxNG.model.descriptors.RngXmlAttributeDescriptor)1 Nullable (org.jetbrains.annotations.Nullable)1 DPattern (org.kohsuke.rngom.digested.DPattern)1 NameClass (org.kohsuke.rngom.nc.NameClass)1