Search in sources :

Example 36 with LineMarkerInfo

use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.

the class JavaGotoSuperTest method findMarkerWithElement.

private static LineMarkerInfo findMarkerWithElement(List<LineMarkerInfo> markers, PsiElement psiMethod) {
    LineMarkerInfo marker = ContainerUtil.find(markers, info -> info.getElement().equals(psiMethod));
    assertNotNull(markers.toString(), marker);
    return marker;
}
Also used : LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo)

Example 37 with LineMarkerInfo

use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.

the class GroovyLineMarkerProvider method collectOverridingMethods.

private static void collectOverridingMethods(@NotNull final Set<PsiMethod> methods, @NotNull Collection<LineMarkerInfo> result) {
    final Set<PsiElement> overridden = new HashSet<>();
    Set<PsiClass> classes = new THashSet<>();
    for (PsiMethod method : methods) {
        ProgressManager.checkCanceled();
        final PsiClass parentClass = method.getContainingClass();
        if (parentClass != null && !CommonClassNames.JAVA_LANG_OBJECT.equals(parentClass.getQualifiedName())) {
            classes.add(parentClass);
        }
    }
    for (final PsiClass aClass : classes) {
        AllOverridingMethodsSearch.search(aClass).forEach(pair -> {
            ProgressManager.checkCanceled();
            final PsiMethod superMethod = pair.getFirst();
            if (isCorrectTarget(superMethod) && isCorrectTarget(pair.getSecond())) {
                if (methods.remove(superMethod)) {
                    overridden.add(PsiImplUtil.handleMirror(superMethod));
                }
            }
            return !methods.isEmpty();
        });
    }
    for (PsiElement element : overridden) {
        final Icon icon = AllIcons.Gutter.OverridenMethod;
        element = PsiImplUtil.handleMirror(element);
        PsiElement range = element instanceof GrNamedElement ? ((GrNamedElement) element).getNameIdentifierGroovy() : element;
        final MarkerType type = element instanceof GrField ? GroovyMarkerTypes.OVERRIDEN_PROPERTY_TYPE : GroovyMarkerTypes.GR_OVERRIDEN_METHOD;
        LineMarkerInfo info = new LineMarkerInfo<>(range, range.getTextRange(), icon, Pass.LINE_MARKERS, type.getTooltip(), type.getNavigationHandler(), GutterIconRenderer.Alignment.RIGHT);
        result.add(info);
    }
}
Also used : GrField(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField) LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) GrNamedElement(org.jetbrains.plugins.groovy.lang.psi.GrNamedElement) MethodSignatureBackedByPsiMethod(com.intellij.psi.util.MethodSignatureBackedByPsiMethod) MarkerType(com.intellij.codeInsight.daemon.impl.MarkerType) THashSet(gnu.trove.THashSet) HashSet(com.intellij.util.containers.HashSet) THashSet(gnu.trove.THashSet)

Example 38 with LineMarkerInfo

use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.

the class GroovyLineMarkerTest method doTest.

private void doTest(int count) {
    final Editor editor = myFixture.getEditor();
    final Project project = myFixture.getProject();
    myFixture.doHighlighting();
    final List<LineMarkerInfo> infoList = DaemonCodeAnalyzerImpl.getLineMarkers(editor.getDocument(), project);
    assertEquals(count, infoList.size());
}
Also used : Project(com.intellij.openapi.project.Project) LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) Editor(com.intellij.openapi.editor.Editor)

Example 39 with LineMarkerInfo

use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.

the class LineMarkersUtil method setLineMarkersToEditor.

static void setLineMarkersToEditor(@NotNull Project project, @NotNull Document document, @NotNull Segment bounds, @NotNull Collection<LineMarkerInfo> markers, int group) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    MarkupModelEx markupModel = (MarkupModelEx) DocumentMarkupModel.forDocument(document, project, true);
    HighlightersRecycler toReuse = new HighlightersRecycler();
    processLineMarkers(project, document, bounds, group, info -> {
        toReuse.recycleHighlighter(info.highlighter);
        return true;
    });
    if (LOG.isDebugEnabled()) {
        List<LineMarkerInfo> oldMarkers = DaemonCodeAnalyzerImpl.getLineMarkers(document, project);
        LOG.debug("LineMarkersUtil.setLineMarkersToEditor(markers: " + markers + ", group: " + group + "); oldMarkers: " + oldMarkers + "; reused: " + toReuse.forAllInGarbageBin().size());
    }
    for (final LineMarkerInfo info : markers) {
        PsiElement element = info.getElement();
        if (element == null) {
            continue;
        }
        TextRange textRange = element.getTextRange();
        if (textRange == null)
            continue;
        TextRange elementRange = InjectedLanguageManager.getInstance(project).injectedToHost(element, textRange);
        if (!TextRange.containsRange(bounds, elementRange)) {
            continue;
        }
        createOrReuseLineMarker(info, markupModel, toReuse);
    }
    for (RangeHighlighter highlighter : toReuse.forAllInGarbageBin()) {
        highlighter.dispose();
    }
}
Also used : LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) MarkupModelEx(com.intellij.openapi.editor.ex.MarkupModelEx) TextRange(com.intellij.openapi.util.TextRange) PsiElement(com.intellij.psi.PsiElement)

Example 40 with LineMarkerInfo

use of com.intellij.codeInsight.daemon.LineMarkerInfo in project intellij-community by JetBrains.

the class LineMarkersUtil method addLineMarkerToEditorIncrementally.

static void addLineMarkerToEditorIncrementally(@NotNull Project project, @NotNull Document document, @NotNull LineMarkerInfo marker) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    MarkupModelEx markupModel = (MarkupModelEx) DocumentMarkupModel.forDocument(document, project, true);
    LineMarkerInfo[] markerInTheWay = { null };
    boolean allIsClear = markupModel.processRangeHighlightersOverlappingWith(marker.startOffset, marker.endOffset, highlighter -> (markerInTheWay[0] = getLineMarkerInfo(highlighter)) == null);
    if (allIsClear) {
        createOrReuseLineMarker(marker, markupModel, null);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("LineMarkersUtil.addLineMarkerToEditorIncrementally: " + marker + " " + (allIsClear ? "created" : " (was not added because " + markerInTheWay[0] + " was in the way)"));
    }
}
Also used : LineMarkerInfo(com.intellij.codeInsight.daemon.LineMarkerInfo) MarkupModelEx(com.intellij.openapi.editor.ex.MarkupModelEx)

Aggregations

LineMarkerInfo (com.intellij.codeInsight.daemon.LineMarkerInfo)42 PsiElement (com.intellij.psi.PsiElement)16 Nullable (org.jetbrains.annotations.Nullable)12 NotNull (org.jetbrains.annotations.NotNull)7 Pass (com.intellij.codeHighlighting.Pass)5 GutterIconNavigationHandler (com.intellij.codeInsight.daemon.GutterIconNavigationHandler)5 AllIcons (com.intellij.icons.AllIcons)5 Document (com.intellij.openapi.editor.Document)5 GutterIconRenderer (com.intellij.openapi.editor.markup.GutterIconRenderer)5 Collection (java.util.Collection)5 LineMarkerProvider (com.intellij.codeInsight.daemon.LineMarkerProvider)4 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)4 Project (com.intellij.openapi.project.Project)4 List (java.util.List)4 javax.swing (javax.swing)4 DaemonBundle (com.intellij.codeInsight.daemon.DaemonBundle)3 PsiElementListNavigator (com.intellij.codeInsight.daemon.impl.PsiElementListNavigator)3 DefaultPsiElementCellRenderer (com.intellij.ide.util.DefaultPsiElementCellRenderer)3 MarkupModelEx (com.intellij.openapi.editor.ex.MarkupModelEx)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3