use of com.intellij.openapi.diff.impl.util.TextDiffTypeEnum in project intellij-community by JetBrains.
the class FragmentHighlighterImpl method addSeparatingLine.
private static void addSeparatingLine(@NotNull LineFragment fragment, @NotNull DiffMarkup appender, int startLine, int endLine) {
if (endLine <= 0)
return;
TextDiffTypeEnum type = fragment.getType();
appender.addLineMarker(endLine - 1, type == null ? null : DiffUtil.makeTextDiffType(fragment), SeparatorPlacement.BOTTOM);
if (fragment.getRange(appender.getSide()).getLength() > 0 && startLine > 0) {
appender.addLineMarker(startLine, type == null ? null : DiffUtil.makeTextDiffType(fragment), SeparatorPlacement.TOP);
}
}
use of com.intellij.openapi.diff.impl.util.TextDiffTypeEnum in project intellij-community by JetBrains.
the class DummyDiffFragmentsProcessor method process.
public ArrayList<LineFragment> process(String text1, String text2) {
ArrayList<LineFragment> lineFragments = new ArrayList<LineFragment>();
if (text1.isEmpty() && text2.isEmpty()) {
return lineFragments;
}
TextDiffTypeEnum type;
if (text1.isEmpty()) {
type = TextDiffTypeEnum.INSERT;
} else if (text2.isEmpty()) {
type = TextDiffTypeEnum.DELETED;
} else {
type = TextDiffTypeEnum.CHANGED;
}
lineFragments.add(new LineFragment(0, countLines(text1), 0, countLines(text2), type, new TextRange(0, text1.length()), new TextRange(0, text2.length())));
return lineFragments;
}
use of com.intellij.openapi.diff.impl.util.TextDiffTypeEnum in project intellij-community by JetBrains.
the class DiffMarkup method highlightText.
public void highlightText(@NotNull Fragment fragment, @Nullable GutterIconRenderer gutterIconRenderer) {
MarkupModel markupModel = getMarkupModel();
EditorEx editor = getEditor();
TextDiffTypeEnum diffTypeEnum = fragment.getType();
if (diffTypeEnum == null || markupModel == null || editor == null) {
return;
}
TextDiffType type = fragment instanceof LineFragment ? DiffUtil.makeTextDiffType((LineFragment) fragment) : TextDiffType.create(diffTypeEnum);
final TextRange range = fragment.getRange(getSide());
final TextAttributes attributes = type.getTextAttributes(editor);
if (attributes == null) {
return;
}
RangeHighlighter rangeMarker;
if (range.getLength() == 0) {
final int offset = range.getStartOffset();
rangeMarker = markupModel.addRangeHighlighter(offset, offset, LAYER, attributes, HighlighterTargetArea.EXACT_RANGE);
rangeMarker.setCustomRenderer(new CustomHighlighterRenderer() {
@Override
public void paint(@NotNull Editor ed, @NotNull RangeHighlighter highlighter, @NotNull Graphics g) {
g.setColor(attributes.getBackgroundColor());
Point point = ed.logicalPositionToXY(ed.offsetToLogicalPosition(highlighter.getStartOffset()));
int endy = point.y + ed.getLineHeight() - 1;
g.drawLine(point.x, point.y, point.x, endy);
g.drawLine(point.x - 1, point.y, point.x - 1, endy);
}
});
} else {
rangeMarker = markupModel.addRangeHighlighter(range.getStartOffset(), range.getEndOffset(), LAYER, attributes, HighlighterTargetArea.EXACT_RANGE);
}
if (gutterIconRenderer != null) {
rangeMarker.setGutterIconRenderer(gutterIconRenderer);
}
setLineMarkerRenderer(rangeMarker, fragment, type);
rangeMarker.setThinErrorStripeMark(true);
if (DiffUtil.isInlineWrapper(fragment)) {
rangeMarker.setErrorStripeMarkColor(null);
}
saveHighlighter(rangeMarker);
}
Aggregations