Пример #1
0
 @Nullable
 public RangeHighlighter addMarker(ChangeSide changeSide, ChangeHighlighterHolder markup) {
   String text = changeSide.getText();
   if (text != null && text.length() > 0) {
     return addBlock(text, changeSide, markup, myDiffType);
   } else {
     return addLine(markup, changeSide.getStartLine(), myDiffType, SeparatorPlacement.TOP);
   }
 }
Пример #2
0
  @Nullable
  private RangeHighlighter addBlock(
      String text,
      ChangeSide changeSide,
      final ChangeHighlighterHolder markup,
      TextDiffType diffType) {
    EditorColorsScheme colorScheme = markup.getEditor().getColorsScheme();
    Color separatorColor = getSeparatorColor(diffType.getLegendColor(colorScheme));

    int length = text.length();
    int start = changeSide.getStart();
    int end = start + length;
    RangeHighlighter highlighter =
        markup.addRangeHighlighter(
            start, end, LAYER, diffType, HighlighterTargetArea.EXACT_RANGE, myApplied);

    LineSeparatorRenderer lineSeparatorRenderer =
        new LineSeparatorRenderer() {
          @Override
          public void drawLine(Graphics g, int x1, int x2, int y) {
            Graphics2D g2 = (Graphics2D) g;
            Color color = myDiffType.getPolygonColor(markup.getEditor());
            if (color != null) {
              if (myApplied) {
                UIUtil.drawBoldDottedLine(g2, x1, x2, y, null, color, false);
              } else {
                UIUtil.drawLine(g2, x1, y, x2, y, null, DiffUtil.getFramingColor(color));
              }
            }
          }
        };

    if (highlighter != null) {
      highlighter.setLineSeparatorPlacement(SeparatorPlacement.TOP);
      highlighter.setLineSeparatorColor(separatorColor);
      highlighter.setLineSeparatorRenderer(lineSeparatorRenderer);
    }

    if (text.charAt(length - 1) == '\n') {
      end--;
    }

    highlighter =
        markup.addRangeHighlighter(
            start, end, LAYER, TextDiffType.NONE, HighlighterTargetArea.EXACT_RANGE, myApplied);
    if (highlighter != null) {
      highlighter.setLineSeparatorPlacement(SeparatorPlacement.BOTTOM);
      highlighter.setLineSeparatorColor(separatorColor);
      highlighter.setLineSeparatorRenderer(lineSeparatorRenderer);
    }
    return highlighter;
  }