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;
}
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);
}
}
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();
}
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()]);
}
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);
}
Aggregations