Search in sources :

Example 1 with DomElementVisitor

use of com.intellij.util.xml.DomElementVisitor in project intellij-community by JetBrains.

the class DomElementsProblemsHolderImpl method getProblemsMap.

@NotNull
private Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> getProblemsMap(final DomElement domElement) {
    final Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> map = myCachedChildrenErrors.get(domElement);
    if (map != null) {
        return map;
    }
    final Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> problems = new THashMap<>();
    if (domElement == myElement) {
        for (Map<Class<? extends DomElementsInspection>, List<DomElementProblemDescriptor>> listMap : myCachedErrors.values()) {
            mergeMaps(problems, listMap);
        }
    } else {
        mergeMaps(problems, myCachedErrors.get(domElement));
        if (DomUtil.hasXml(domElement)) {
            domElement.acceptChildren(new DomElementVisitor() {

                @Override
                public void visitDomElement(DomElement element) {
                    mergeMaps(problems, getProblemsMap(element));
                }
            });
        }
    }
    myCachedChildrenErrors.put(domElement, problems);
    return problems;
}
Also used : DomElement(com.intellij.util.xml.DomElement) THashMap(gnu.trove.THashMap) DomElementVisitor(com.intellij.util.xml.DomElementVisitor) SmartList(com.intellij.util.SmartList) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with DomElementVisitor

use of com.intellij.util.xml.DomElementVisitor in project intellij-plugins by JetBrains.

the class StructureViewTreeElement method getChildren.

@NotNull
public TreeElement[] getChildren() {
    final DomElement element = getElement();
    if (!element.isValid()) {
        return EMPTY_ARRAY;
    }
    final List<TreeElement> result = new SmartList<>();
    DomUtil.acceptAvailableChildren(element, new DomElementVisitor() {

        @Override
        public void visitDomElement(final DomElement domElement) {
            result.add(new StructureViewTreeElement(domElement));
        }
    });
    return ArrayUtil.toObjectArray(result, TreeElement.class);
}
Also used : DomElement(com.intellij.util.xml.DomElement) DomElementVisitor(com.intellij.util.xml.DomElementVisitor) SmartList(com.intellij.util.SmartList) DomStructureTreeElement(com.intellij.util.xml.structure.DomStructureTreeElement) TreeElement(com.intellij.ide.util.treeView.smartTree.TreeElement) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with DomElementVisitor

use of com.intellij.util.xml.DomElementVisitor in project intellij-community by JetBrains.

the class DomElementPattern method getChildren.

@Override
protected DomElement[] getChildren(@NotNull final DomElement domElement) {
    final List<DomElement> children = new ArrayList<>();
    domElement.acceptChildren(new DomElementVisitor() {

        @Override
        public void visitDomElement(final DomElement element) {
            children.add(element);
        }
    });
    return children.toArray(new DomElement[children.size()]);
}
Also used : DomElement(com.intellij.util.xml.DomElement) DomElementVisitor(com.intellij.util.xml.DomElementVisitor) ArrayList(java.util.ArrayList)

Aggregations

DomElement (com.intellij.util.xml.DomElement)3 DomElementVisitor (com.intellij.util.xml.DomElementVisitor)3 SmartList (com.intellij.util.SmartList)2 NotNull (org.jetbrains.annotations.NotNull)2 TreeElement (com.intellij.ide.util.treeView.smartTree.TreeElement)1 DomStructureTreeElement (com.intellij.util.xml.structure.DomStructureTreeElement)1 THashMap (gnu.trove.THashMap)1 ArrayList (java.util.ArrayList)1