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();
}
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();
}
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);
}
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()]);
}
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;
}
Aggregations