@NotNull
 public static TextDiffType makeTextDiffType(@NotNull LineFragment fragment) {
   TextDiffType type = TextDiffType.create(fragment.getType());
   if (isInlineWrapper(fragment)) {
     return TextDiffType.deriveInstanceForInlineWrapperFragment(type);
   }
   return type;
 }
Beispiel #2
0
 private ChangeType(TextDiffType diffType, boolean applied) {
   myApplied = applied;
   if (applied) {
     myDiffType = TextDiffType.deriveApplied(diffType);
   } else {
     myDiffType = diffType;
   }
 }
Beispiel #3
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;
  }
Beispiel #4
0
 public TextAttributesKey convert(TextDiffType textDiffType) {
   return textDiffType.getAttributesKey();
 }
Beispiel #5
0
 public String toString() {
   return myDiffType.getDisplayName();
 }