Search in sources :

Example 11 with NavigatablePsiElement

use of com.intellij.psi.NavigatablePsiElement in project intellij-plugins by JetBrains.

the class DartStructureViewElement method getChildrenBase.

@NotNull
@Override
public Collection<StructureViewTreeElement> getChildrenBase() {
    final NavigatablePsiElement element = getElement();
    final List<StructureViewTreeElement> result = new ArrayList<>();
    if (element instanceof DartFile || element instanceof DartEmbeddedContent) {
        THashSet<DartComponentName> componentNames = new THashSet<>();
        DartPsiCompositeElementImpl.processDeclarationsImpl(element, new ComponentNameScopeProcessor(componentNames), ResolveState.initial(), null);
        for (DartComponentName componentName : componentNames) {
            PsiElement parent = componentName.getParent();
            if (parent instanceof DartComponent) {
                result.add(new DartStructureViewElement((DartComponent) parent));
            }
        }
    } else if (element instanceof DartClass) {
        for (DartComponent subNamedComponent : DartResolveUtil.getNamedSubComponents((DartClass) element)) {
            result.add(new DartStructureViewElement(subNamedComponent));
        }
    }
    Collections.sort(result, (o1, o2) -> {
        PsiElement element1, element2;
        if (o1 instanceof DartStructureViewElement && o2 instanceof DartStructureViewElement && (element1 = ((DartStructureViewElement) o1).getElement()) != null && (element2 = ((DartStructureViewElement) o2).getElement()) != null) {
            return element1.getTextRange().getStartOffset() - element2.getTextRange().getStartOffset();
        }
        return 0;
    });
    return result;
}
Also used : THashSet(gnu.trove.THashSet) ComponentNameScopeProcessor(com.jetbrains.lang.dart.resolve.ComponentNameScopeProcessor) StructureViewTreeElement(com.intellij.ide.structureView.StructureViewTreeElement) NavigatablePsiElement(com.intellij.psi.NavigatablePsiElement) PsiElement(com.intellij.psi.PsiElement) NavigatablePsiElement(com.intellij.psi.NavigatablePsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NavigatablePsiElement (com.intellij.psi.NavigatablePsiElement)11 PsiElement (com.intellij.psi.PsiElement)7 Nullable (org.jetbrains.annotations.Nullable)4 ItemPresentation (com.intellij.navigation.ItemPresentation)3 DefaultPsiElementCellRenderer (com.intellij.ide.util.DefaultPsiElementCellRenderer)2 CompositeAppearance (com.intellij.openapi.roots.ui.util.CompositeAppearance)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 PsiFile (com.intellij.psi.PsiFile)2 DartClass (com.jetbrains.lang.dart.psi.DartClass)2 PyClass (com.jetbrains.python.psi.PyClass)2 MouseEvent (java.awt.event.MouseEvent)2 GutterIconNavigationHandler (com.intellij.codeInsight.daemon.GutterIconNavigationHandler)1 LineMarkerInfo (com.intellij.codeInsight.daemon.LineMarkerInfo)1 ListBackgroundUpdaterTask (com.intellij.codeInsight.navigation.ListBackgroundUpdaterTask)1 RefElement (com.intellij.codeInspection.reference.RefElement)1 RefEntity (com.intellij.codeInspection.reference.RefEntity)1 FindUtil (com.intellij.find.FindUtil)1 PsiCopyPasteManager (com.intellij.ide.PsiCopyPasteManager)1 StructureViewTreeElement (com.intellij.ide.structureView.StructureViewTreeElement)1 PsiElementListCellRenderer (com.intellij.ide.util.PsiElementListCellRenderer)1