Search in sources :

Example 61 with RangeHighlighter

use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.

the class UnifiedDiffChange method destroyHighlighter.

public void destroyHighlighter() {
    for (RangeHighlighter highlighter : myHighlighters) {
        highlighter.dispose();
    }
    myHighlighters.clear();
    for (MyGutterOperation operation : myOperations) {
        operation.dispose();
    }
    myOperations.clear();
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter)

Example 62 with RangeHighlighter

use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.

the class TextMergeChange method createOperation.

@Nullable
private MyGutterOperation createOperation(@NotNull ThreeSide side, @NotNull OperationType type) {
    if (isResolved(side))
        return null;
    EditorEx editor = myViewer.getEditor(side);
    Document document = editor.getDocument();
    int line = getStartLine(side);
    int offset = line == DiffUtil.getLineCount(document) ? document.getTextLength() : document.getLineStartOffset(line);
    RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(offset, offset, HighlighterLayer.ADDITIONAL_SYNTAX, null, HighlighterTargetArea.LINES_IN_RANGE);
    return new MyGutterOperation(side, highlighter, type);
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) EditorEx(com.intellij.openapi.editor.ex.EditorEx) Document(com.intellij.openapi.editor.Document) Nullable(org.jetbrains.annotations.Nullable)

Example 63 with RangeHighlighter

use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.

the class SimpleOnesideDiffViewer method clearDiffPresentation.

private void clearDiffPresentation() {
    myPanel.resetNotifications();
    for (RangeHighlighter highlighter : myHighlighters) {
        highlighter.dispose();
    }
    myHighlighters.clear();
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter)

Example 64 with RangeHighlighter

use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.

the class DaemonTooltipRendererProvider method calcTooltipRenderer.

@Override
public TooltipRenderer calcTooltipRenderer(@NotNull final Collection<RangeHighlighter> highlighters) {
    LineTooltipRenderer bigRenderer = null;
    List<HighlightInfo> infos = new SmartList<>();
    //do not show same tooltip twice
    Collection<String> tooltips = new THashSet<>();
    for (RangeHighlighter marker : highlighters) {
        final Object tooltipObject = marker.getErrorStripeTooltip();
        if (tooltipObject == null)
            continue;
        if (tooltipObject instanceof HighlightInfo) {
            HighlightInfo info = (HighlightInfo) tooltipObject;
            if (info.getToolTip() != null && tooltips.add(info.getToolTip())) {
                infos.add(info);
            }
        } else {
            final String text = tooltipObject.toString();
            if (tooltips.add(text)) {
                if (bigRenderer == null) {
                    bigRenderer = new MyRenderer(text, new Object[] { highlighters });
                } else {
                    bigRenderer.addBelow(text);
                }
            }
        }
    }
    if (!infos.isEmpty()) {
        // show errors first
        ContainerUtil.quickSort(infos, (o1, o2) -> {
            int i = SeverityRegistrar.getSeverityRegistrar(myProject).compare(o2.getSeverity(), o1.getSeverity());
            if (i != 0)
                return i;
            return o1.getToolTip().compareTo(o2.getToolTip());
        });
        final HighlightInfoComposite composite = new HighlightInfoComposite(infos);
        String toolTip = composite.getToolTip();
        MyRenderer myRenderer = new MyRenderer(toolTip == null ? null : UIUtil.convertSpace2Nbsp(toolTip), new Object[] { highlighters });
        if (bigRenderer == null) {
            bigRenderer = myRenderer;
        } else {
            myRenderer.addBelow(bigRenderer.getText());
            bigRenderer = myRenderer;
        }
    }
    return bigRenderer;
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) SmartList(com.intellij.util.SmartList) LineTooltipRenderer(com.intellij.codeInsight.hint.LineTooltipRenderer) THashSet(gnu.trove.THashSet)

Example 65 with RangeHighlighter

use of com.intellij.openapi.editor.markup.RangeHighlighter in project intellij-community by JetBrains.

the class HighlightersRecycler method pickupHighlighterFromGarbageBin.

// null means no highlighter found in the cache
@Nullable
RangeHighlighter pickupHighlighterFromGarbageBin(int startOffset, int endOffset, int layer) {
    TextRange range = new TextRange(startOffset, endOffset);
    Collection<RangeHighlighter> collection = incinerator.get(range);
    for (RangeHighlighter highlighter : collection) {
        if (highlighter.isValid() && highlighter.getLayer() == layer) {
            incinerator.remove(range, highlighter);
            return highlighter;
        }
    }
    return null;
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) ProperTextRange(com.intellij.openapi.util.ProperTextRange) TextRange(com.intellij.openapi.util.TextRange) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)97 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)26 TextRange (com.intellij.openapi.util.TextRange)22 HighlightManager (com.intellij.codeInsight.highlighting.HighlightManager)18 Editor (com.intellij.openapi.editor.Editor)15 ArrayList (java.util.ArrayList)15 NotNull (org.jetbrains.annotations.NotNull)15 EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)10 Project (com.intellij.openapi.project.Project)10 RelativePoint (com.intellij.ui.awt.RelativePoint)8 Nullable (org.jetbrains.annotations.Nullable)8 Document (com.intellij.openapi.editor.Document)7 EditorEx (com.intellij.openapi.editor.ex.EditorEx)7 MarkupModelEx (com.intellij.openapi.editor.ex.MarkupModelEx)7 MarkupModel (com.intellij.openapi.editor.markup.MarkupModel)7 PsiElement (com.intellij.psi.PsiElement)6 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)5 EditorWindow (com.intellij.injected.editor.EditorWindow)4 Result (com.intellij.openapi.application.Result)4 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)4