Search in sources :

Example 11 with PsiFileNode

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());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFileNode(com.intellij.ide.projectView.impl.nodes.PsiFileNode) PsiCompiledFile(com.intellij.psi.PsiCompiledFile) JSQualifiedNamedElement(com.intellij.lang.javascript.psi.ecmal4.JSQualifiedNamedElement) PsiFile(com.intellij.psi.PsiFile) Attachment(com.intellij.openapi.diagnostic.Attachment) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiFileNode (com.intellij.ide.projectView.impl.nodes.PsiFileNode)11 PsiFile (com.intellij.psi.PsiFile)7 NotNull (org.jetbrains.annotations.NotNull)7 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)6 PsiDirectoryNode (com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode)3 Project (com.intellij.openapi.project.Project)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 PropertiesFile (com.intellij.lang.properties.psi.PropertiesFile)2 PsiElement (com.intellij.psi.PsiElement)2 ArrayList (java.util.ArrayList)2 IdeBundle (com.intellij.ide.IdeBundle)1 BaseProjectTreeBuilder (com.intellij.ide.projectView.BaseProjectTreeBuilder)1 ProjectViewNode (com.intellij.ide.projectView.ProjectViewNode)1 TreeStructureProvider (com.intellij.ide.projectView.TreeStructureProvider)1 ViewSettings (com.intellij.ide.projectView.ViewSettings)1 AbstractProjectTreeStructure (com.intellij.ide.projectView.impl.AbstractProjectTreeStructure)1 ProjectAbstractTreeStructureBase (com.intellij.ide.projectView.impl.ProjectAbstractTreeStructureBase)1 ProjectTreeBuilder (com.intellij.ide.projectView.impl.ProjectTreeBuilder)1 BasePsiNode (com.intellij.ide.projectView.impl.nodes.BasePsiNode)1 ClassTreeNode (com.intellij.ide.projectView.impl.nodes.ClassTreeNode)1