use of com.intellij.ide.projectView.ProjectViewNode in project intellij-community by JetBrains.
the class TodoTreeBuilder method validateNode.
@Override
protected boolean validateNode(final Object child) {
if (child instanceof ProjectViewNode) {
final ProjectViewNode projectViewNode = (ProjectViewNode) child;
projectViewNode.update();
if (projectViewNode.getValue() == null) {
return false;
}
}
return true;
}
use of com.intellij.ide.projectView.ProjectViewNode in project intellij-community by JetBrains.
the class ClassesTreeStructureProvider method modify.
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
ArrayList<AbstractTreeNode> result = new ArrayList<>();
for (final AbstractTreeNode child : children) {
Object o = child.getValue();
if (o instanceof PsiClassOwner && !(o instanceof ServerPageFile)) {
final ViewSettings settings1 = ((ProjectViewNode) parent).getSettings();
final PsiClassOwner classOwner = (PsiClassOwner) o;
final VirtualFile file = classOwner.getVirtualFile();
if (!(classOwner instanceof PsiCompiledElement)) {
//do not show duplicated items if jar file contains classes and sources
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
if (file != null && fileIndex.isInLibrarySource(file)) {
final PsiElement originalElement = classOwner.getOriginalElement();
if (originalElement instanceof PsiFile) {
PsiFile classFile = (PsiFile) originalElement;
final VirtualFile virtualClassFile = classFile.getVirtualFile();
if (virtualClassFile != null && fileIndex.isInLibraryClasses(virtualClassFile) && !classOwner.getManager().areElementsEquivalent(classOwner, classFile) && classOwner.getManager().areElementsEquivalent(classOwner.getContainingDirectory(), classFile.getContainingDirectory())) {
continue;
}
}
}
}
if (fileInRoots(file)) {
PsiClass[] classes = ApplicationManager.getApplication().runReadAction(new Computable<PsiClass[]>() {
@Override
public PsiClass[] compute() {
try {
return classOwner.getClasses();
} catch (IndexNotReadyException e) {
return PsiClass.EMPTY_ARRAY;
}
}
});
if (classes.length == 1 && !(classes[0] instanceof SyntheticElement) && (file == null || file.getNameWithoutExtension().equals(classes[0].getName()))) {
result.add(new ClassTreeNode(myProject, classes[0], settings1));
} else {
result.add(new PsiClassOwnerTreeNode(classOwner, settings1));
}
continue;
}
}
result.add(child);
}
return result;
}
Aggregations