Search in sources :

Example 11 with StructureViewTreeElement

use of com.intellij.ide.structureView.StructureViewTreeElement in project intellij-community by JetBrains.

the class AbstractListBuilder method selectElement.

public final void selectElement(final Object element, VirtualFile virtualFile) {
    if (element == null) {
        return;
    }
    try {
        AbstractTreeNode node = goDownToElement(element, virtualFile);
        if (node == null)
            return;
        AbstractTreeNode parentElement = node.getParent();
        if (parentElement == null)
            return;
        buildList(parentElement);
        for (int i = 0; i < myModel.getSize(); i++) {
            if (myModel.getElementAt(i) instanceof AbstractTreeNode) {
                final AbstractTreeNode desc = (AbstractTreeNode) myModel.getElementAt(i);
                if (desc.getValue() instanceof StructureViewTreeElement) {
                    StructureViewTreeElement treeelement = (StructureViewTreeElement) desc.getValue();
                    if (element.equals(treeelement.getValue())) {
                        selectItem(i);
                        break;
                    }
                } else {
                    if (element.equals(desc.getValue())) {
                        selectItem(i);
                        break;
                    }
                }
            }
        }
    } finally {
        updateParentTitle();
    }
}
Also used : AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) StructureViewTreeElement(com.intellij.ide.structureView.StructureViewTreeElement)

Example 12 with StructureViewTreeElement

use of com.intellij.ide.structureView.StructureViewTreeElement in project intellij-plugins by JetBrains.

the class MarkdownStructureElement method getChildrenBase.

@NotNull
@Override
public Collection<StructureViewTreeElement> getChildrenBase() {
    final List<StructureViewTreeElement> childrenElements = new ArrayList<>();
    final PsiElement myElement = getElement();
    if (myElement == null)
        return childrenElements;
    final PsiElement structureContainer = myElement instanceof MarkdownFile ? myElement.getFirstChild() : getParentOfType(myElement, TRANSPARENT_CONTAINERS);
    if (structureContainer == null) {
        return Collections.emptyList();
    }
    final MarkdownPsiElement currentHeader = myElement instanceof MarkdownHeaderImpl ? ((MarkdownHeaderImpl) myElement) : null;
    processContainer(structureContainer, currentHeader, currentHeader, element -> childrenElements.add(new MarkdownStructureElement(element)));
    return childrenElements;
}
Also used : MarkdownHeaderImpl(org.intellij.plugins.markdown.lang.psi.impl.MarkdownHeaderImpl) MarkdownFile(org.intellij.plugins.markdown.lang.psi.impl.MarkdownFile) StructureViewTreeElement(com.intellij.ide.structureView.StructureViewTreeElement) MarkdownPsiElement(org.intellij.plugins.markdown.lang.psi.MarkdownPsiElement) PsiElement(com.intellij.psi.PsiElement) MarkdownPsiElement(org.intellij.plugins.markdown.lang.psi.MarkdownPsiElement) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with StructureViewTreeElement

use of com.intellij.ide.structureView.StructureViewTreeElement in project intellij-plugins by JetBrains.

the class StructureViewTreeModel method getRoot.

@NotNull
@Override
public StructureViewTreeElement getRoot() {
    final XmlFile xmlFile = getPsiFile();
    final DomFileElement<DomElement> fileElement = DomManager.getDomManager(xmlFile.getProject()).getFileElement(xmlFile, DomElement.class);
    if (fileElement == null) {
        return new XmlFileTreeElement(xmlFile);
    }
    return new com.intellij.struts2.structure.StructureViewTreeElement(fileElement.getRootElement().createStableCopy());
}
Also used : DomElement(com.intellij.util.xml.DomElement) XmlFile(com.intellij.psi.xml.XmlFile) StructureViewTreeElement(com.intellij.ide.structureView.StructureViewTreeElement) XmlFileTreeElement(com.intellij.ide.structureView.impl.xml.XmlFileTreeElement) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with StructureViewTreeElement

use of com.intellij.ide.structureView.StructureViewTreeElement in project android by JetBrains.

the class StructureViewTest method testManifestStructure.

public void testManifestStructure() throws Exception {
    copyFileToProject("manifest/MyActivity.java", "src/p1/p2/MyActivity.java");
    deleteManifest();
    final VirtualFile file = copyFileToProject("manifest/structure_view_test.xml", "AndroidManifest.xml");
    final PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file);
    assertInstanceOf(psiFile, XmlFile.class);
    final DomStructureViewBuilder builder = new DomStructureViewBuilder(((XmlFile) psiFile), DomStructureViewBuilderProvider.DESCRIPTOR);
    final StructureViewTreeElement root = builder.createStructureViewModel(null).getRoot();
    assertNotNull(root);
    final String expected = "Manifest\n" + "  Application\n" + "    Activity\n" + "      Intent Filter\n" + "        Action (android.intent.action.MAIN)\n" + "        Category (android.intent.category.LAUNCHER)\n" + "    Activity Alias\n" + "      Intent Filter\n" + "        Action (android.intent.action.CREATE_SHORTCUT)\n" + "        Category (android.intent.category.DEFAULT)\n";
    assertEquals(expected, dumpTree(root));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XmlFile(com.intellij.psi.xml.XmlFile) PsiFile(com.intellij.psi.PsiFile) StructureViewTreeElement(com.intellij.ide.structureView.StructureViewTreeElement) DomStructureViewBuilder(com.intellij.util.xml.structure.DomStructureViewBuilder)

Example 15 with StructureViewTreeElement

use of com.intellij.ide.structureView.StructureViewTreeElement in project intellij-plugins by JetBrains.

the class FlexTreeStructureProvider method modify.

@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
    List<AbstractTreeNode> result = new ArrayList<>();
    if (parent instanceof SwfQualifiedNamedElementNode || parent instanceof FlexFileNode) {
        if (((ProjectViewNode) parent).getSettings().isShowMembers()) {
            JSQualifiedNamedElement parentElement = getElement(parent);
            if (parentElement != null) {
                JSStructureViewElement structureViewElement = parentElement instanceof XmlBackedJSClassImpl ? new FlexStructureViewElement(((XmlBackedJSClassImpl) parentElement), (XmlFile) parentElement.getContainingFile(), false) : new JSStructureViewElement(parentElement, false, true);
                StructureViewTreeElement[] structureViewChildren = structureViewElement.getChildren();
                for (final StructureViewTreeElement structureViewChild : structureViewChildren) {
                    if (structureViewChild instanceof JSStructureViewElement) {
                        PsiElement childElement = ((JSStructureViewElement) structureViewChild).getValue();
                        result.add(new FlexClassMemberNode((JSElement) childElement, ((ProjectViewNode) parent).getSettings()));
                    } else {
                        result.add(new UnknownNode(parentElement.getProject(), structureViewChild, ((ProjectViewNode) parent).getSettings()));
                    }
                }
            }
        }
    } else {
        for (final AbstractTreeNode child : children) {
            Object o = child.getValue();
            if (o instanceof JSFileImpl && !(o instanceof PsiCompiledFile) && DialectDetector.isActionScript((PsiFile) o) || o instanceof XmlFile && JavaScriptSupportLoader.isFlexMxmFile((PsiFile) o)) {
                result.add(new FlexFileNode((PsiFile) o, ((ProjectViewNode) parent).getSettings()));
                continue;
            }
            result.add(child);
        }
    }
    return result;
}
Also used : XmlBackedJSClassImpl(com.intellij.lang.javascript.flex.XmlBackedJSClassImpl) XmlFile(com.intellij.psi.xml.XmlFile) ArrayList(java.util.ArrayList) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) JSQualifiedNamedElement(com.intellij.lang.javascript.psi.ecmal4.JSQualifiedNamedElement) JSStructureViewElement(com.intellij.lang.javascript.structureView.JSStructureViewElement) FlexStructureViewElement(com.intellij.lang.javascript.flex.presentation.FlexStructureViewProvider.FlexStructureViewElement) JSFileImpl(com.intellij.lang.javascript.psi.impl.JSFileImpl) ProjectViewNode(com.intellij.ide.projectView.ProjectViewNode) PsiCompiledFile(com.intellij.psi.PsiCompiledFile) JSElement(com.intellij.lang.javascript.psi.JSElement) StructureViewTreeElement(com.intellij.ide.structureView.StructureViewTreeElement) PsiFile(com.intellij.psi.PsiFile) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

StructureViewTreeElement (com.intellij.ide.structureView.StructureViewTreeElement)25 NotNull (org.jetbrains.annotations.NotNull)16 PsiElement (com.intellij.psi.PsiElement)9 ArrayList (java.util.ArrayList)8 TreeElement (com.intellij.ide.util.treeView.smartTree.TreeElement)5 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)4 IProperty (com.intellij.lang.properties.IProperty)3 PsiFile (com.intellij.psi.PsiFile)3 XmlFile (com.intellij.psi.xml.XmlFile)3 ProjectListBuilder (com.intellij.ide.commander.ProjectListBuilder)2 TextRange (com.intellij.openapi.util.TextRange)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 NavigatablePsiElement (com.intellij.psi.NavigatablePsiElement)2 CfmlFile (com.intellij.coldFusion.model.files.CfmlFile)1 CfmlFunction (com.intellij.coldFusion.model.psi.CfmlFunction)1 ProjectViewNode (com.intellij.ide.projectView.ProjectViewNode)1 StructureView (com.intellij.ide.structureView.StructureView)1 StructureViewBuilder (com.intellij.ide.structureView.StructureViewBuilder)1 StructureViewExtension (com.intellij.ide.structureView.StructureViewExtension)1 StructureViewFactoryEx (com.intellij.ide.structureView.StructureViewFactoryEx)1