use of com.intellij.ide.projectView.impl.nodes.PsiFileNode in project intellij-plugins by JetBrains.
the class SwfProjectViewStructureProvider method modify.
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
if (!(parent instanceof PsiFileNode)) {
return children;
}
final PsiFile psiFile = ((PsiFileNode) parent).getValue();
if (!(psiFile instanceof PsiCompiledFile) || !(psiFile instanceof JSFile)) {
return children;
}
final VirtualFile vFile = psiFile.getVirtualFile();
if (vFile == null || vFile.getFileType() != FlexApplicationComponent.SWF_FILE_TYPE) {
return children;
}
if (isTooManySWFs(vFile.getParent())) {
return children;
}
List<JSQualifiedNamedElement> elements = new ArrayList<>();
for (JSSourceElement e : ((JSFile) psiFile).getStatements()) {
if (e instanceof JSQualifiedNamedElement) {
String qName = ((JSQualifiedNamedElement) e).getQualifiedName();
if (qName == null) {
final Attachment attachment = e.getParent() != null ? new Attachment("Parent element.txt", e.getParent().getText()) : new Attachment("Element text.txt", e.getText());
LOG.error(LogMessageEx.createEvent("Null qname: '" + e.getClass().getName() + "'", DebugUtil.currentStackTrace(), attachment));
continue;
}
elements.add((JSQualifiedNamedElement) e);
} else if (e instanceof JSVarStatement) {
Collections.addAll(elements, ((JSVarStatement) e).getVariables());
}
}
Collections.sort(elements, QNAME_COMPARATOR);
return getChildrenForPackage("", elements, 0, elements.size(), psiFile.getProject(), ((PsiFileNode) parent).getSettings());
}
Aggregations