Search in sources :

Example 11 with TreeElement

use of com.intellij.ide.util.treeView.smartTree.TreeElement in project intellij-community by JetBrains.

the class TemplateLanguageStructureViewBuilder method isPsiValid.

private static boolean isPsiValid(@NotNull StructureViewComposite.StructureViewDescriptor baseStructureViewDescriptor) {
    final StructureViewComponent view = (StructureViewComponent) baseStructureViewDescriptor.structureView;
    if (view.isDisposed())
        return false;
    final Object root = view.getTreeStructure().getRootElement();
    if (root instanceof StructureViewComponent.StructureViewTreeElementWrapper) {
        final TreeElement value = ((StructureViewComponent.StructureViewTreeElementWrapper) root).getValue();
        if (value instanceof StructureViewTreeElement) {
            final Object psi = ((StructureViewTreeElement) value).getValue();
            if (psi instanceof PsiElement) {
                return ((PsiElement) psi).isValid();
            }
        }
    }
    return true;
}
Also used : StructureViewComponent(com.intellij.ide.structureView.newStructureView.StructureViewComponent) TreeElement(com.intellij.ide.util.treeView.smartTree.TreeElement)

Example 12 with TreeElement

use of com.intellij.ide.util.treeView.smartTree.TreeElement in project intellij-community by JetBrains.

the class MethodUpDownUtil method addStructureViewElements.

private static void addStructureViewElements(final TreeElement parent, final Collection<PsiElement> array, @NotNull PsiFile file) {
    for (TreeElement treeElement : parent.getChildren()) {
        Object value = ((StructureViewTreeElement) treeElement).getValue();
        if (value instanceof PsiElement) {
            PsiElement element = (PsiElement) value;
            if (array.contains(element) || !file.equals(element.getContainingFile()))
                continue;
            array.add(element);
        }
        addStructureViewElements(treeElement, array, file);
    }
}
Also used : StructureViewTreeElement(com.intellij.ide.structureView.StructureViewTreeElement) PsiElement(com.intellij.psi.PsiElement) TreeElement(com.intellij.ide.util.treeView.smartTree.TreeElement) StructureViewTreeElement(com.intellij.ide.structureView.StructureViewTreeElement)

Example 13 with TreeElement

use of com.intellij.ide.util.treeView.smartTree.TreeElement in project intellij-community by JetBrains.

the class JavaInheritedMembersNodeProvider method provideNodes.

@NotNull
@Override
public Collection<TreeElement> provideNodes(@NotNull TreeElement node) {
    if (node instanceof JavaClassTreeElement) {
        final PsiClass aClass = ((JavaClassTreeElement) node).getElement();
        if (aClass == null)
            return Collections.emptyList();
        Collection<PsiElement> inherited = new LinkedHashSet<>();
        Collection<PsiElement> ownChildren = JavaClassTreeElement.getOwnChildren(aClass);
        aClass.processDeclarations(new AddAllMembersProcessor(inherited, aClass), ResolveState.initial(), null, aClass);
        inherited.removeAll(ownChildren);
        if (aClass instanceof PsiAnonymousClass) {
            final PsiElement element = ((PsiAnonymousClass) aClass).getBaseClassReference().resolve();
            if (element instanceof PsiClass) {
                ContainerUtil.addAll(inherited, ((PsiClass) element).getInnerClasses());
            }
        }
        List<TreeElement> array = new ArrayList<>();
        for (PsiElement child : inherited) {
            if (!child.isValid())
                continue;
            final Set<PsiClass> parents = ((JavaClassTreeElement) node).getParents();
            if (child instanceof PsiClass && !parents.contains(child)) {
                array.add(new JavaClassTreeElement((PsiClass) child, true, parents));
            } else if (child instanceof PsiField) {
                array.add(new PsiFieldTreeElement((PsiField) child, true));
            } else if (child instanceof PsiMethod) {
                array.add(new PsiMethodTreeElement((PsiMethod) child, true));
            } else if (child instanceof PsiClassInitializer) {
                array.add(new ClassInitializerTreeElement((PsiClassInitializer) child));
            }
        }
        return array;
    }
    return Collections.emptyList();
}
Also used : TreeElement(com.intellij.ide.util.treeView.smartTree.TreeElement) AddAllMembersProcessor(com.intellij.ide.structureView.impl.AddAllMembersProcessor) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with TreeElement

use of com.intellij.ide.util.treeView.smartTree.TreeElement in project intellij-community by JetBrains.

the class StructureViewElementWrapper method getChildren.

@NotNull
@Override
public StructureViewTreeElement[] getChildren() {
    TreeElement[] baseChildren = myTreeElement.getChildren();
    List<StructureViewTreeElement> result = new ArrayList<>();
    for (TreeElement element : baseChildren) {
        StructureViewTreeElement wrapper = new StructureViewElementWrapper((StructureViewTreeElement) element, myMainFile);
        result.add(wrapper);
    }
    return result.toArray(new StructureViewTreeElement[result.size()]);
}
Also used : ArrayList(java.util.ArrayList) StructureViewTreeElement(com.intellij.ide.structureView.StructureViewTreeElement) TreeElement(com.intellij.ide.util.treeView.smartTree.TreeElement) StructureViewTreeElement(com.intellij.ide.structureView.StructureViewTreeElement) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with TreeElement

use of com.intellij.ide.util.treeView.smartTree.TreeElement 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)

Aggregations

TreeElement (com.intellij.ide.util.treeView.smartTree.TreeElement)24 NotNull (org.jetbrains.annotations.NotNull)10 ArrayList (java.util.ArrayList)7 StructureViewTreeElement (com.intellij.ide.structureView.StructureViewTreeElement)5 Pair (com.intellij.openapi.util.Pair)4 PsiElement (com.intellij.psi.PsiElement)4 Call (org.elixir_lang.psi.call.Call)4 Module (org.elixir_lang.structure_view.element.modular.Module)3 Module.addClausesToCallDefinition (org.elixir_lang.structure_view.element.modular.Module.addClausesToCallDefinition)3 Nullable (org.jetbrains.annotations.Nullable)3 StructureViewBuilder (com.intellij.ide.structureView.StructureViewBuilder)2 StructureViewModel (com.intellij.ide.structureView.StructureViewModel)2 StructureViewComponent (com.intellij.ide.structureView.newStructureView.StructureViewComponent)2 LanguageStructureViewBuilder (com.intellij.lang.LanguageStructureViewBuilder)2 IProperty (com.intellij.lang.properties.IProperty)2 FileEditor (com.intellij.openapi.fileEditor.FileEditor)2 ElixirPsiImplUtil.enclosingMacroCall (org.elixir_lang.psi.impl.ElixirPsiImplUtil.enclosingMacroCall)2 Contract (org.jetbrains.annotations.Contract)2 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)1 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)1