Search in sources :

Example 1 with AddAllMembersProcessor

use of com.intellij.ide.structureView.impl.AddAllMembersProcessor 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)

Aggregations

AddAllMembersProcessor (com.intellij.ide.structureView.impl.AddAllMembersProcessor)1 TreeElement (com.intellij.ide.util.treeView.smartTree.TreeElement)1 NotNull (org.jetbrains.annotations.NotNull)1