Search in sources :

Example 1 with RestElement

use of com.jetbrains.rest.psi.RestElement in project intellij-community by JetBrains.

the class RestStructureViewElement method getChildren.

@NotNull
public StructureViewTreeElement[] getChildren() {
    final Set<RestElement> childrenElements = new LinkedHashSet<>();
    myElement.acceptChildren(new PsiElementVisitor() {

        @Override
        public void visitElement(PsiElement element) {
            if (element instanceof RestTitle && ((RestTitle) element).getName() != null)
                childrenElements.add((RestElement) element);
            else
                element.acceptChildren(this);
        }
    });
    StructureViewTreeElement[] children = new StructureViewTreeElement[childrenElements.size()];
    int i = 0;
    for (RestElement element : childrenElements) {
        children[i] = new RestStructureViewElement(element);
        i += 1;
    }
    return children;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) RestElement(com.jetbrains.rest.psi.RestElement) RestTitle(com.jetbrains.rest.psi.RestTitle) StructureViewTreeElement(com.intellij.ide.structureView.StructureViewTreeElement) PsiElementVisitor(com.intellij.psi.PsiElementVisitor) PsiElement(com.intellij.psi.PsiElement) NavigatablePsiElement(com.intellij.psi.NavigatablePsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

StructureViewTreeElement (com.intellij.ide.structureView.StructureViewTreeElement)1 NavigatablePsiElement (com.intellij.psi.NavigatablePsiElement)1 PsiElement (com.intellij.psi.PsiElement)1 PsiElementVisitor (com.intellij.psi.PsiElementVisitor)1 RestElement (com.jetbrains.rest.psi.RestElement)1 RestTitle (com.jetbrains.rest.psi.RestTitle)1 LinkedHashSet (java.util.LinkedHashSet)1 NotNull (org.jetbrains.annotations.NotNull)1