Search in sources :

Example 11 with TypeHierarchyItem

use of org.dartlang.analysis.server.protocol.TypeHierarchyItem in project intellij-plugins by JetBrains.

the class DartServerSubtypesHierarchyTreeStructure method buildChildren.

@NotNull
protected final Object[] buildChildren(@NotNull final HierarchyNodeDescriptor descriptor) {
    final DartClass dartClass = ((DartTypeHierarchyNodeDescriptor) descriptor).getDartClass();
    if (dartClass == null)
        return ArrayUtil.EMPTY_OBJECT_ARRAY;
    if (DartResolveUtil.OBJECT.equals(dartClass.getName())) {
        return new Object[] { DartBundle.message("dart.hierarchy.object") };
    }
    final List<TypeHierarchyItem> items = getTypeHierarchyItems(dartClass);
    if (items.isEmpty())
        return ArrayUtil.EMPTY_OBJECT_ARRAY;
    addSubClassHierarchy(Sets.newHashSet(), myProject, items, items.get(0), descriptor);
    return descriptor.getCachedChildren();
}
Also used : DartClass(com.jetbrains.lang.dart.psi.DartClass) DartHierarchyUtil.findDartClass(com.jetbrains.lang.dart.ide.hierarchy.DartHierarchyUtil.findDartClass) TypeHierarchyItem(org.dartlang.analysis.server.protocol.TypeHierarchyItem) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with TypeHierarchyItem

use of org.dartlang.analysis.server.protocol.TypeHierarchyItem in project intellij-plugins by JetBrains.

the class DartServerSupertypesHierarchyTreeStructure method buildChildren.

@NotNull
protected final Object[] buildChildren(@NotNull final HierarchyNodeDescriptor descriptor) {
    final DartClass dartClass = ((DartTypeHierarchyNodeDescriptor) descriptor).getDartClass();
    if (dartClass == null || DartResolveUtil.OBJECT.equals(dartClass.getName())) {
        return ArrayUtil.EMPTY_OBJECT_ARRAY;
    }
    final List<TypeHierarchyItem> items = getTypeHierarchyItems(dartClass);
    if (items.isEmpty())
        return ArrayUtil.EMPTY_OBJECT_ARRAY;
    addSuperClassHierarchy(Sets.newHashSet(), myProject, items, items.get(0), descriptor);
    return descriptor.getCachedChildren();
}
Also used : DartClass(com.jetbrains.lang.dart.psi.DartClass) DartHierarchyUtil.findDartClass(com.jetbrains.lang.dart.ide.hierarchy.DartHierarchyUtil.findDartClass) TypeHierarchyItem(org.dartlang.analysis.server.protocol.TypeHierarchyItem) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with TypeHierarchyItem

use of org.dartlang.analysis.server.protocol.TypeHierarchyItem in project intellij-plugins by JetBrains.

the class DartServerSupertypesHierarchyTreeStructure method addSuperClassNode.

private static void addSuperClassNode(@NotNull final Set<TypeHierarchyItem> stackItems, @NotNull final Project project, @NotNull final List<TypeHierarchyItem> items, @NotNull final HierarchyNodeDescriptor parentNode, @NotNull final List<HierarchyNodeDescriptor> descriptors, final int index) {
    final TypeHierarchyItem superItem = items.get(index);
    if (DartResolveUtil.OBJECT.equals(superItem.getClassElement().getName())) {
        return;
    }
    final DartClass superClass = findDartClass(project, superItem);
    final HierarchyNodeDescriptor superDescriptor = new DartTypeHierarchyNodeDescriptor(project, parentNode, superClass, false);
    descriptors.add(superDescriptor);
    addSuperClassHierarchy(stackItems, project, items, superItem, superDescriptor);
}
Also used : DartClass(com.jetbrains.lang.dart.psi.DartClass) DartHierarchyUtil.findDartClass(com.jetbrains.lang.dart.ide.hierarchy.DartHierarchyUtil.findDartClass) TypeHierarchyItem(org.dartlang.analysis.server.protocol.TypeHierarchyItem) HierarchyNodeDescriptor(com.intellij.ide.hierarchy.HierarchyNodeDescriptor)

Example 14 with TypeHierarchyItem

use of org.dartlang.analysis.server.protocol.TypeHierarchyItem in project intellij-plugins by JetBrains.

the class DartServerTypeHierarchyTreeStructure method filterSuperClasses.

@NotNull
public static DartClass[] filterSuperClasses(@NotNull final Project project, @NotNull final List<TypeHierarchyItem> items) {
    if (items.isEmpty())
        return new DartClass[] {};
    final Set<TypeHierarchyItem> seenItems = Sets.newHashSet();
    final List<DartClass> superClasses = Lists.newArrayList();
    Integer superIndex = items.get(0).getSuperclass();
    while (superIndex != null) {
        TypeHierarchyItem superItem = items.get(superIndex);
        if (!seenItems.add(superItem)) {
            break;
        }
        final DartClass superClass = findDartClass(project, superItem);
        if (superClass != null) {
            superClasses.add(superClass);
        }
        superIndex = superItem.getSuperclass();
    }
    return superClasses.toArray(new DartClass[superClasses.size()]);
}
Also used : DartClass(com.jetbrains.lang.dart.psi.DartClass) DartHierarchyUtil.findDartClass(com.jetbrains.lang.dart.ide.hierarchy.DartHierarchyUtil.findDartClass) TypeHierarchyItem(org.dartlang.analysis.server.protocol.TypeHierarchyItem) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with TypeHierarchyItem

use of org.dartlang.analysis.server.protocol.TypeHierarchyItem in project intellij-plugins by JetBrains.

the class CreateEqualsAndHashcodeFix method doesSuperclassOverrideEqualEqualAndHashCode.

private static boolean doesSuperclassOverrideEqualEqualAndHashCode(@NotNull final DartClass dartClass) {
    final Project project = dartClass.getProject();
    final VirtualFile file = dartClass.getContainingFile().getVirtualFile();
    final DartComponentName name = dartClass.getComponentName();
    if (name == null) {
        return false;
    }
    final List<TypeHierarchyItem> items = DartAnalysisServerService.getInstance(dartClass.getProject()).search_getTypeHierarchy(file, name.getTextRange().getStartOffset(), true);
    for (DartClass superClass : DartServerTypeHierarchyTreeStructure.filterSuperClasses(project, items)) {
        if (superClass != null && superClass.getName() != null && !superClass.getName().equals("Object")) {
            if (DartGenerateEqualsAndHashcodeAction.doesClassContainEqualsAndHashCode(superClass)) {
                return true;
            }
        }
    }
    return false;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) DartComponentName(com.jetbrains.lang.dart.psi.DartComponentName) DartClass(com.jetbrains.lang.dart.psi.DartClass) TypeHierarchyItem(org.dartlang.analysis.server.protocol.TypeHierarchyItem)

Aggregations

TypeHierarchyItem (org.dartlang.analysis.server.protocol.TypeHierarchyItem)15 DartClass (com.jetbrains.lang.dart.psi.DartClass)9 DartHierarchyUtil.findDartClass (com.jetbrains.lang.dart.ide.hierarchy.DartHierarchyUtil.findDartClass)7 DartComponent (com.jetbrains.lang.dart.psi.DartComponent)7 NotNull (org.jetbrains.annotations.NotNull)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 PsiElement (com.intellij.psi.PsiElement)5 HierarchyNodeDescriptor (com.intellij.ide.hierarchy.HierarchyNodeDescriptor)4 DefaultPsiElementCellRenderer (com.intellij.ide.util.DefaultPsiElementCellRenderer)3 DartAnalysisServerService (com.jetbrains.lang.dart.analyzer.DartAnalysisServerService)3 DartComponentName (com.jetbrains.lang.dart.psi.DartComponentName)3 Pass (com.intellij.codeHighlighting.Pass)2 DaemonBundle (com.intellij.codeInsight.daemon.DaemonBundle)2 GutterIconNavigationHandler (com.intellij.codeInsight.daemon.GutterIconNavigationHandler)2 LineMarkerInfo (com.intellij.codeInsight.daemon.LineMarkerInfo)2 LineMarkerProvider (com.intellij.codeInsight.daemon.LineMarkerProvider)2 PsiElementListNavigator (com.intellij.codeInsight.daemon.impl.PsiElementListNavigator)2 AllIcons (com.intellij.icons.AllIcons)2 GutterIconRenderer (com.intellij.openapi.editor.markup.GutterIconRenderer)2 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)2