use of com.jetbrains.lang.dart.psi.DartComponentName in project intellij-plugins by JetBrains.
the class DartTypeHierarchyTest method doDartTypeHierarchyTest.
private void doDartTypeHierarchyTest(final String className, final boolean subtype, 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 && dartClass.getName().equals(className)) {
if (subtype) {
return new DartServerTypeHierarchyTreeStructure(project, dartClass, HierarchyBrowserBaseEx.SCOPE_PROJECT);
} else {
return new DartServerSupertypesHierarchyTreeStructure(project, dartClass);
}
}
}
return null;
}, fileNames);
}
use of com.jetbrains.lang.dart.psi.DartComponentName 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.DartComponentName in project intellij-plugins by JetBrains.
the class DartPsiScopeProcessor method execute.
@Override
public final boolean execute(@NotNull final PsiElement element, @NotNull final ResolveState state) {
if (!(element instanceof DartComponentName))
return true;
final String name = ((DartComponentName) element).getName();
if (!myShowHideFilters.isEmpty() && StringUtil.startsWithChar(name, '_')) {
return true;
}
if (isFilteredOut(name)) {
final VirtualFile importedFile = myShowHideFilters.peek().first;
Collection<PsiElement> elements = myFilteredOutElements.get(importedFile);
if (elements == null) {
elements = new ArrayList<>();
myFilteredOutElements.put(importedFile, elements);
}
elements.add(element);
return true;
}
return doExecute((DartComponentName) element);
}
use of com.jetbrains.lang.dart.psi.DartComponentName 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