Search in sources :

Example 11 with DartComponentName

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);
}
Also used : Project(com.intellij.openapi.project.Project) DartComponentName(com.jetbrains.lang.dart.psi.DartComponentName) DartClass(com.jetbrains.lang.dart.psi.DartClass) DartServerSupertypesHierarchyTreeStructure(com.jetbrains.lang.dart.ide.hierarchy.type.DartServerSupertypesHierarchyTreeStructure) DartServerTypeHierarchyTreeStructure(com.jetbrains.lang.dart.ide.hierarchy.type.DartServerTypeHierarchyTreeStructure)

Example 12 with DartComponentName

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);
}
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)

Example 13 with DartComponentName

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DartComponentName(com.jetbrains.lang.dart.psi.DartComponentName) PsiElement(com.intellij.psi.PsiElement)

Example 14 with DartComponentName

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;
}
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

DartComponentName (com.jetbrains.lang.dart.psi.DartComponentName)14 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 PsiElement (com.intellij.psi.PsiElement)8 DartClass (com.jetbrains.lang.dart.psi.DartClass)6 DartComponent (com.jetbrains.lang.dart.psi.DartComponent)6 NotNull (org.jetbrains.annotations.NotNull)6 Project (com.intellij.openapi.project.Project)4 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)4 Pass (com.intellij.codeHighlighting.Pass)3 DaemonBundle (com.intellij.codeInsight.daemon.DaemonBundle)3 GutterIconNavigationHandler (com.intellij.codeInsight.daemon.GutterIconNavigationHandler)3 LineMarkerInfo (com.intellij.codeInsight.daemon.LineMarkerInfo)3 LineMarkerProvider (com.intellij.codeInsight.daemon.LineMarkerProvider)3 PsiElementListNavigator (com.intellij.codeInsight.daemon.impl.PsiElementListNavigator)3 AllIcons (com.intellij.icons.AllIcons)3 DefaultPsiElementCellRenderer (com.intellij.ide.util.DefaultPsiElementCellRenderer)3 GutterIconRenderer (com.intellij.openapi.editor.markup.GutterIconRenderer)3 DartAnalysisServerService (com.jetbrains.lang.dart.analyzer.DartAnalysisServerService)3 DartServerData (com.jetbrains.lang.dart.analyzer.DartServerData)3 DartResolveUtil (com.jetbrains.lang.dart.util.DartResolveUtil)3