Search in sources :

Example 1 with DartMethodHierarchyTreeStructure

use of com.jetbrains.lang.dart.ide.hierarchy.method.DartMethodHierarchyTreeStructure 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);
}
Also used : Project(com.intellij.openapi.project.Project) DartComponentName(com.jetbrains.lang.dart.psi.DartComponentName) DartClass(com.jetbrains.lang.dart.psi.DartClass) DartMethodHierarchyTreeStructure(com.jetbrains.lang.dart.ide.hierarchy.method.DartMethodHierarchyTreeStructure) HierarchyBrowserManager(com.intellij.ide.hierarchy.HierarchyBrowserManager) PsiElement(com.intellij.psi.PsiElement)

Aggregations

HierarchyBrowserManager (com.intellij.ide.hierarchy.HierarchyBrowserManager)1 Project (com.intellij.openapi.project.Project)1 PsiElement (com.intellij.psi.PsiElement)1 DartMethodHierarchyTreeStructure (com.jetbrains.lang.dart.ide.hierarchy.method.DartMethodHierarchyTreeStructure)1 DartClass (com.jetbrains.lang.dart.psi.DartClass)1 DartComponentName (com.jetbrains.lang.dart.psi.DartComponentName)1