Package com.intellij.openapi.editor.markup

Examples of com.intellij.openapi.editor.markup.RangeHighlighter


    {
      editorHighlighters = new IdentityHashMap<Issue, RangeHighlighter>();
      highlighters.put(editor, editorHighlighters);
    }

    RangeHighlighter highlighter =
      editor.getMarkupModel().addRangeHighlighter(
        marker.getStartOffset(),
        marker.getEndOffset(),
        HighlighterLayer.FIRST - 1,
        null,
        HighlighterTargetArea.LINES_IN_RANGE);
    editorHighlighters.put(issue, highlighter);

    // Issue on while file are displayed on first line
    int lineStart = issue.getLineStart();
    if (lineStart == -1)
    {
      lineStart = 0;
    }

    // Gutter renderer, only one renderer for same line start
    CustomGutterIconRenderer renderer = editorRenderers.get(lineStart);
    if (renderer == null)
    {
      renderer = new CustomGutterIconRenderer(this, lineStart);
      editorRenderers.put(lineStart, renderer);

      // Only set gutter icon for first highligther with same line start
      highlighter.setGutterIconRenderer(renderer);
    }

    renderer.addIssue(issue, highlighter);
  }
View Full Code Here


    for (Editor editor : documentChangeTracker.getEditors())
    {
      Map<Issue, RangeHighlighter> editorHighlighters = highlighters.get(editor);
      if (editorHighlighters != null)
      {
        RangeHighlighter highlighter = editorHighlighters.remove(issue);

        if (highlighter != null)
        {
          editor.getMarkupModel().removeHighlighter(highlighter);

          Map<Integer, CustomGutterIconRenderer> editorRenderers = renderers.get(editor);
          int lineStart = (issue.getLineStart() == -1) ? 0 : issue.getLineStart();
          CustomGutterIconRenderer renderer = editorRenderers.get(lineStart);
          if (renderer != null)
          {
            renderer.removeIssue(issue);
            if (renderer.isEmpty())
            {
              editorRenderers.remove(renderer.getLineStart());
            }
            else if (highlighter.getGutterIconRenderer() != null)
            {
              // Reaffecct share gutter icon to first remaining highlighter
              RangeHighlighter marker = (RangeHighlighter) renderer.getIssues().values().iterator().next();
              marker.setGutterIconRenderer(renderer);
            }
          }
        }
      }
    }
View Full Code Here

    final int line = bugInstanceNode.getSourceLines()[0] - 1;
    if(line >= 0) {
      final LogicalPosition problemPos = new LogicalPosition(line, 0);
      editor.getCaretModel().moveToLogicalPosition(problemPos);
    } else { // anonymous classes
      final RangeHighlighter rangeHighlighter = editor.getMarkupModel().getAllHighlighters()[0];
      editor.getCaretModel().moveToOffset(rangeHighlighter.getStartOffset());
    }
    editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
  }
View Full Code Here

            }
          } else {
            TextAttributes attrs = new TextAttributes();
//            uncomment to make visible
//            attrs.setForegroundColor(JBColor.BLUE);
            final RangeHighlighter rangeHighlighter = markupModel.addRangeHighlighter(
                textRange.getStartOffset(),
                textRange.getEndOffset(),
                0,
                attrs,
                HighlighterTargetArea.EXACT_RANGE);
            Set<SonarIssue> issuesOfHighlighter = Sets.newLinkedHashSet();
            issuesOfHighlighter.add(issue);
            rangeHighlighter.putUserData(KEY, issuesOfHighlighter);
          }
        }
      });
    }
  }
View Full Code Here

    }

    private int getItemIndex(int offset) {
        synchronized (items) {
            for (int i = 0; i < items.size(); i++) {
                RangeHighlighter item = items.get(i);
                if (offset >= item.getStartOffset() && offset <= item.getEndOffset()) {
                    return i;
                }
            }
        }
        return -1;
View Full Code Here

                int index = -1;
                do {
                    index = text.indexOf(highlightText, index + 1);
                    // wenn gefunden und ganzes wort -> aufnehmen
                    if (index >= 0 && BWACUtils.isStartEnd(text, index, index + highlightText.length(), true)) {
                        RangeHighlighter rangeHighlighter = markupModel.addRangeHighlighter(index, index + highlightText.length(), HIGHLIGHTLAYER, textAttributes, HighlighterTargetArea.EXACT_RANGE);
                        rangeHighlighter.setErrorStripeTooltip(highlightText);
                        items.add(rangeHighlighter);
                    }
                } while (index >= 0);
            }
        }
View Full Code Here

    {
      editorHighlighters = new IdentityHashMap<Issue, RangeHighlighter>();
      highlighters.put(editor, editorHighlighters);
    }

    RangeHighlighter highlighter =
      editor.getMarkupModel().addRangeHighlighter(
        marker.getStartOffset(),
        marker.getEndOffset(),
        HighlighterLayer.FIRST - 1,
        null,
        HighlighterTargetArea.LINES_IN_RANGE);
    editorHighlighters.put(issue, highlighter);

    // Issue on while file are displayed on first line
    int lineStart = issue.getLineStart();
    if (lineStart == -1)
    {
      lineStart = 0;
    }

    // Gutter renderer, only one renderer for same line start
    CustomGutterIconRenderer renderer = editorRenderers.get(lineStart);
    if (renderer == null)
    {
      renderer = new CustomGutterIconRenderer(this, lineStart);
      editorRenderers.put(lineStart, renderer);

      // Only set gutter icon for first highligther with same line start
      highlighter.setGutterIconRenderer(renderer);
    }

    renderer.addIssue(issue, highlighter);
  }
View Full Code Here

    for (Editor editor : documentChangeTracker.getEditors())
    {
      Map<Issue, RangeHighlighter> editorHighlighters = highlighters.get(editor);
      if (editorHighlighters != null)
      {
        RangeHighlighter highlighter = editorHighlighters.remove(issue);

        if (highlighter != null)
        {
          editor.getMarkupModel().removeHighlighter(highlighter);

          Map<Integer, CustomGutterIconRenderer> editorRenderers = renderers.get(editor);
          int lineStart = (issue.getLineStart() == -1) ? 0 : issue.getLineStart();
          CustomGutterIconRenderer renderer = editorRenderers.get(lineStart);
          if (renderer != null)
          {
            renderer.removeIssue(issue);
            if (renderer.isEmpty())
            {
              editorRenderers.remove(renderer.getLineStart());
            }
            else if (highlighter.getGutterIconRenderer() != null)
            {
              // Reaffecct share gutter icon to first remaining highlighter
              RangeHighlighter marker = (RangeHighlighter) renderer.getIssues().values().iterator().next();
              marker.setGutterIconRenderer(renderer);
            }
          }
        }
      }
    }
View Full Code Here

    public void addComment(Editor editor, ChangeInfo changeInfo, String revisionId, Project project, Comment comment) {
        if (editor == null) return;
        MarkupModel markup = editor.getMarkupModel();

        RangeHighlighter rangeHighlighter = null;
        if (comment.range != null) {
            rangeHighlighter = highlightRangeComment(comment.range, editor, project);
        }

        int lineCount = markup.getDocument().getLineCount();

        int line = comment.line - 1;
        if (line < 0) {
            line = 0;
        }
        if (line > lineCount - 1) {
            line = lineCount - 1;
        }
        if (line >= 0) {
            final RangeHighlighter highlighter = markup.addLineHighlighter(line, HighlighterLayer.ERROR + 1, null);
            CommentGutterIconRenderer iconRenderer = new CommentGutterIconRenderer(
                    this, editor, gerritUtil, selectedRevisions, addCommentActionBuilder,
                    comment, changeInfo, revisionId, highlighter, rangeHighlighter);
            highlighter.setGutterIconRenderer(iconRenderer);
        }
    }
View Full Code Here

        attributes.setBackgroundColor(color);

        int markerLineNumber = getLineNumber(marker);

        RangeHighlighter newHighlighter = documentMarkupModel.addLineHighlighter(markerLineNumber, 500, attributes);

        boolean newLine = true;

        for (RangeHighlighter highlighter : documentMarkupModel.getAllHighlighters()) {
            if (highlighter.getGutterIconRenderer() instanceof ThreadFixMarkerRenderer) {
                ThreadFixMarkerRenderer renderer = ((ThreadFixMarkerRenderer) highlighter.getGutterIconRenderer());
                if (renderer != null && markerLineNumber == renderer.getLineNumber()) {
                    newLine = false;
                    renderer.addMarkerInfo(marker);
                    break;
                }
            }
        }

        if (newLine) {
            newHighlighter.setGutterIconRenderer(new ThreadFixMarkerRenderer(marker));
        }
    }
View Full Code Here

TOP

Related Classes of com.intellij.openapi.editor.markup.RangeHighlighter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.