use of com.jetbrains.lang.dart.psi.DartClass in project intellij-plugins by JetBrains.
the class DartMethodHierarchyTest method doMethodHierarchyTest.
private void doMethodHierarchyTest(final String className, final String methodName, final boolean shouldHide, final String... fileNames) throws Exception {
doHierarchyTest(() -> {
final Project project = getProject();
final List<DartComponentName> dartComponentNames = DartClassIndex.getItemsByName(className, project, GlobalSearchScope.projectScope(project));
for (DartComponentName name : dartComponentNames) {
DartClass dartClass = PsiTreeUtil.getParentOfType(name, DartClass.class);
if (dartClass != null && className.equals(dartClass.getName())) {
PsiElement member = dartClass.findMemberByName(methodName);
if (member == null) {
member = findReference(dartClass, methodName);
}
if (member == null) {
fail("Method not found");
}
if (shouldHide) {
HierarchyBrowserManager.State state = HierarchyBrowserManager.getInstance(myProject).getState();
assert state != null;
state.HIDE_CLASSES_WHERE_METHOD_NOT_IMPLEMENTED = true;
}
return new DartMethodHierarchyTreeStructure(project, (DartComponent) member);
}
}
return null;
}, fileNames);
}
use of com.jetbrains.lang.dart.psi.DartClass in project intellij-plugins by JetBrains.
the class DartGenericSpecialization method getGenericKey.
public static String getGenericKey(@Nullable PsiElement element, @NotNull String genericName) {
final StringBuilder result = new StringBuilder();
final DartComponent dartComponent = PsiTreeUtil.getParentOfType(element, DartComponent.class, false);
if (dartComponent instanceof DartClass) {
result.append(dartComponent.getName());
} else if (dartComponent != null) {
DartClass dartClass = PsiTreeUtil.getParentOfType(dartComponent, DartClass.class);
if (dartClass != null) {
result.append(dartClass.getName());
}
if (PsiTreeUtil.getChildOfType(dartComponent, DartTypeArguments.class) != null) {
// generic method
result.append(":");
result.append(dartComponent.getName());
}
}
if (result.length() > 0) {
result.append("-");
}
result.append(genericName);
return result.toString();
}
use of com.jetbrains.lang.dart.psi.DartClass 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;
}
use of com.jetbrains.lang.dart.psi.DartClass in project intellij-plugins by JetBrains.
the class DartImplementMethodHandler method collectCandidates.
@Override
protected void collectCandidates(@NotNull final DartClass dartClass, @NotNull final List<DartComponent> candidates) {
Map<Pair<String, Boolean>, DartComponent> result = new THashMap<>(computeSuperInterfacesMembersMap(dartClass));
Map<Pair<String, Boolean>, DartComponent> superClassesMemberMap = new THashMap<>(computeSuperClassesMemberMap(dartClass));
result.keySet().removeAll(superClassesMemberMap.keySet());
for (Map.Entry<Pair<String, Boolean>, DartComponent> entry : superClassesMemberMap.entrySet()) {
final DartComponent component = entry.getValue();
if (component.isAbstract() && !result.containsKey(entry.getKey())) {
result.put(entry.getKey(), entry.getValue());
}
}
result.keySet().removeAll(computeClassMembersMap(dartClass, false).keySet());
candidates.addAll(ContainerUtil.findAll(result.values(), component -> component.isPublic() || DartResolveUtil.sameLibrary(dartClass, component)));
}
use of com.jetbrains.lang.dart.psi.DartClass in project intellij-plugins by JetBrains.
the class BaseDartGenerateHandler method computeSuperClassesMemberMap.
@NotNull
protected final Map<Pair<String, Boolean>, DartComponent> computeSuperClassesMemberMap(@NotNull final DartClass dartClass) {
final List<DartClass> superClasses = new ArrayList<>();
final List<DartClass> superInterfaces = new ArrayList<>();
DartResolveUtil.collectSupers(superClasses, superInterfaces, dartClass);
List<DartComponent> superClassesMembers = new ArrayList<>();
for (DartClass superClass : superClasses) {
superClassesMembers.addAll(DartResolveUtil.getNamedSubComponents(superClass));
}
superClassesMembers = ContainerUtil.filter(superClassesMembers, NOT_CONSTRUCTOR_CONDITION);
superClassesMembers = ContainerUtil.filter(superClassesMembers, NOT_STATIC_CONDITION);
return DartResolveUtil.namedComponentToMap(superClassesMembers);
}
Aggregations