@Override public void paint(Editor editor, Graphics g, Rectangle r) { Color gutterColor = getGutterColor(myRange, editor); Color borderColor = getGutterBorderColor(editor); Rectangle area = getMarkerArea(editor, r, myRange.getLine1(), myRange.getLine2()); final int x = area.x; final int endX = area.x + area.width; final int y = area.y; final int endY = area.y + area.height; if (myRange.getInnerRanges() == null) { // Mode.DEFAULT if (y != endY) { paintRect(g, gutterColor, borderColor, x, y, endX, endY); } else { paintTriangle(g, gutterColor, borderColor, x, endX, y); } } else { // Mode.SMART if (y == endY) { paintTriangle(g, gutterColor, borderColor, x, endX, y); } else { List<Range.InnerRange> innerRanges = myRange.getInnerRanges(); for (Range.InnerRange innerRange : innerRanges) { if (innerRange.getType() == Range.DELETED) continue; int start = lineToY(editor, innerRange.getLine1()); int end = lineToY(editor, innerRange.getLine2()); paintRect(g, getGutterColor(innerRange, editor), null, x, start, endX, end); } for (int i = 0; i < innerRanges.size(); i++) { Range.InnerRange innerRange = innerRanges.get(i); if (innerRange.getType() != Range.DELETED) continue; int start; int end; if (i == 0) { start = lineToY(editor, innerRange.getLine1()); end = lineToY(editor, innerRange.getLine2()) + 5; } else if (i == innerRanges.size() - 1) { start = lineToY(editor, innerRange.getLine1()) - 5; end = lineToY(editor, innerRange.getLine2()); } else { start = lineToY(editor, innerRange.getLine1()) - 3; end = lineToY(editor, innerRange.getLine2()) + 3; } paintRect(g, getGutterColor(innerRange, editor), null, x, start, endX, end); } paintRect(g, null, borderColor, x, y, endX, endY); } } }
@NotNull private static String getTooltipText(@NotNull Range range) { if (range.getLine1() == range.getLine2()) { if (range.getVcsLine1() + 1 == range.getVcsLine2()) { return VcsBundle.message("tooltip.text.line.before.deleted", range.getLine1() + 1); } else { return VcsBundle.message( "tooltip.text.lines.before.deleted", range.getLine1() + 1, range.getVcsLine2() - range.getVcsLine1()); } } else if (range.getLine1() + 1 == range.getLine2()) { return VcsBundle.message("tooltip.text.line.changed", range.getLine1() + 1); } else { return VcsBundle.message( "tooltip.text.lines.changed", range.getLine1() + 1, range.getLine2()); } }