Search in sources :

Example 11 with StructureViewComponent

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

the class DomStructureViewBuilder method createStructureView.

@Override
@NotNull
public StructureView createStructureView(final FileEditor fileEditor, @NotNull final Project project) {
    return new StructureViewComponent(fileEditor, createStructureViewModel(fileEditor instanceof TextEditor ? ((TextEditor) fileEditor).getEditor() : null), project, true) {

        @Override
        public AsyncResult<AbstractTreeNode> expandPathToElement(final Object element) {
            if (element instanceof XmlElement && ((XmlElement) element).isValid()) {
                final XmlElement xmlElement = (XmlElement) element;
                XmlTag tag = PsiTreeUtil.getParentOfType(xmlElement, XmlTag.class, false);
                while (tag != null) {
                    final DomElement domElement = DomManager.getDomManager(xmlElement.getProject()).getDomElement(tag);
                    if (domElement != null) {
                        for (DomElement curElement = domElement; curElement != null; curElement = curElement.getParent()) {
                            if (myDescriptor.fun(curElement) == DomService.StructureViewMode.SHOW) {
                                return super.expandPathToElement(curElement.getXmlElement());
                            }
                        }
                    }
                    tag = PsiTreeUtil.getParentOfType(tag, XmlTag.class, true);
                }
            }
            return super.expandPathToElement(element);
        }
    };
}
Also used : TextEditor(com.intellij.openapi.fileEditor.TextEditor) DomElement(com.intellij.util.xml.DomElement) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) XmlElement(com.intellij.psi.xml.XmlElement) StructureViewComponent(com.intellij.ide.structureView.newStructureView.StructureViewComponent) XmlTag(com.intellij.psi.xml.XmlTag) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

StructureViewComponent (com.intellij.ide.structureView.newStructureView.StructureViewComponent)11 FileEditor (com.intellij.openapi.fileEditor.FileEditor)6 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 PsiClass (com.intellij.psi.PsiClass)4 StructureViewBuilder (com.intellij.ide.structureView.StructureViewBuilder)2 TreeElement (com.intellij.ide.util.treeView.smartTree.TreeElement)2 LanguageStructureViewBuilder (com.intellij.lang.LanguageStructureViewBuilder)2 PsiField (com.intellij.psi.PsiField)2 StructureViewWrapperImpl (com.intellij.ide.impl.StructureViewWrapperImpl)1 AbstractProjectViewPSIPane (com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane)1 StructureViewModel (com.intellij.ide.structureView.StructureViewModel)1 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 Language (com.intellij.lang.Language)1 Document (com.intellij.openapi.editor.Document)1 TextEditor (com.intellij.openapi.fileEditor.TextEditor)1 XmlElement (com.intellij.psi.xml.XmlElement)1 XmlTag (com.intellij.psi.xml.XmlTag)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1 DomElement (com.intellij.util.xml.DomElement)1