mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[diff] Draw highlighters above gutters. Step 2: draw lines for deletion/insertion
DrawBorders should always be true to accomplish that. So removing this parameter, since it is always true.
This commit is contained in:
@@ -123,7 +123,7 @@ public class ChangesDiffCalculator implements Disposable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void highlightText(Fragment fragment, boolean drawBorder, GutterIconRenderer gutterIconRenderer) {
|
||||
public void highlightText(Fragment fragment, GutterIconRenderer gutterIconRenderer) {
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ public class ChangesDiffCalculator implements Disposable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void highlightText(Fragment fragment, boolean drawBorder, GutterIconRenderer gutterIconRenderer) {
|
||||
public void highlightText(Fragment fragment, GutterIconRenderer gutterIconRenderer) {
|
||||
TextRange currentRange = fragment.getRange(FragmentSide.SIDE2);
|
||||
if (INTERESTED_DIFF_TYPES.contains(fragment.getType())) {
|
||||
ranges.add(currentRange);
|
||||
|
||||
+5
-5
@@ -40,19 +40,19 @@ public class FragmentHighlighterImpl implements FragmentHighlighter {
|
||||
}
|
||||
|
||||
public void highlightInline(final InlineFragment fragment) {
|
||||
highlightFragmentImpl(fragment, true);
|
||||
highlightFragmentImpl(fragment);
|
||||
}
|
||||
|
||||
protected void highlightFragmentImpl(final Fragment fragment, final boolean drawBorder) {
|
||||
myAppender1.highlightText(fragment, drawBorder, null);
|
||||
myAppender2.highlightText(fragment, drawBorder, null);
|
||||
protected void highlightFragmentImpl(final Fragment fragment) {
|
||||
myAppender1.highlightText(fragment, null);
|
||||
myAppender2.highlightText(fragment, null);
|
||||
}
|
||||
|
||||
public void highlightLine(final LineFragment fragment) {
|
||||
addModifyActions(fragment, myAppender1, myAppender2);
|
||||
final Iterator<Fragment> iterator = fragment.getChildrenIterator();
|
||||
if (iterator == null) {
|
||||
highlightFragmentImpl(fragment, false);
|
||||
highlightFragmentImpl(fragment);
|
||||
}
|
||||
else {
|
||||
for (; iterator.hasNext();) {
|
||||
|
||||
+2
-3
@@ -64,16 +64,15 @@ public abstract class DiffMarkup implements EditorSource, Disposable {
|
||||
return editor == null ? null : editor.getMarkupModel();
|
||||
}
|
||||
|
||||
public void highlightText(Fragment fragment, boolean drawBorder, GutterIconRenderer gutterIconRenderer) {
|
||||
public void highlightText(Fragment fragment, GutterIconRenderer gutterIconRenderer) {
|
||||
final TextDiffTypeEnum diffTypeEnum = fragment.getType();
|
||||
if (diffTypeEnum == null) return;
|
||||
TextDiffType type = TextDiffType.create(diffTypeEnum);
|
||||
if (type == null) return;
|
||||
TextRange range = fragment.getRange(getSide());
|
||||
TextAttributes attributes = type.getTextAttributes(getEditor());
|
||||
if (!drawBorder && range.getLength() == 0) return;
|
||||
RangeHighlighter rangeMarker;
|
||||
if (drawBorder && range.getLength() == 0) {
|
||||
if (range.getLength() == 0) {
|
||||
TextAttributes textAttributes = new TextAttributes(null, null, attributes.getBackgroundColor(), EffectType.BOXED, Font.PLAIN);
|
||||
rangeMarker = getMarkupModel().addRangeHighlighter(range.getStartOffset(), range.getStartOffset(), LAYER, textAttributes, HighlighterTargetArea.EXACT_RANGE);
|
||||
}
|
||||
|
||||
+7
-7
@@ -75,29 +75,29 @@ public class NumberedFragmentHighlighter extends FragmentHighlighterImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void highlightFragmentImpl(Fragment fragment, boolean drawBorder) {
|
||||
protected void highlightFragmentImpl(Fragment fragment) {
|
||||
if (! myDrawNumber || fragment.getType() == null || TextDiffTypeEnum.NONE.equals(fragment.getType())) {
|
||||
myAppender1.highlightText(fragment, drawBorder, null);
|
||||
myAppender2.highlightText(fragment, drawBorder, null);
|
||||
myAppender1.highlightText(fragment, null);
|
||||
myAppender2.highlightText(fragment, null);
|
||||
return;
|
||||
}
|
||||
int lineLeft = myAppender1.getDocument().getLineNumber(fragment.getRange(FragmentSide.SIDE1).getStartOffset());
|
||||
int lineRight = myAppender2.getDocument().getLineNumber(fragment.getRange(FragmentSide.SIDE2).getStartOffset());
|
||||
Pair<String, TextDiffTypeEnum> left = myLeftPrecalculated.get(lineLeft);
|
||||
if (myPreviousLineLeft == lineLeft || left == null) {
|
||||
myAppender1.highlightText(fragment, drawBorder, null);
|
||||
myAppender1.highlightText(fragment, null);
|
||||
} else {
|
||||
// draw border == true for range marker with highlighting and number be set anyway, even if range is empty
|
||||
myAppender1.highlightText(fragment, true, new FragmentNumberGutterIconRenderer(left.getFirst(), getColorAttributesKey(left.getSecond()), myAppender1.getEditor().getScrollPane(), myAppender1.getEditor()));
|
||||
myAppender1.highlightText(fragment, new FragmentNumberGutterIconRenderer(left.getFirst(), getColorAttributesKey(left.getSecond()), myAppender1.getEditor().getScrollPane(), myAppender1.getEditor()));
|
||||
myPreviousLineLeft = lineLeft;
|
||||
}
|
||||
|
||||
Pair<String, TextDiffTypeEnum> right = myRightPrecalculated.get(lineRight);
|
||||
if (myPreviousLineRight == lineRight || right == null) {
|
||||
myAppender2.highlightText(fragment, drawBorder, null);
|
||||
myAppender2.highlightText(fragment, null);
|
||||
} else {
|
||||
// draw border == true for range marker with highlighting and number be set anyway, even if range is empty
|
||||
myAppender2.highlightText(fragment, true, new FragmentNumberGutterIconRenderer(right.getFirst(), getColorAttributesKey(right.getSecond()), myAppender1.getEditor().getScrollPane(),
|
||||
myAppender2.highlightText(fragment, new FragmentNumberGutterIconRenderer(right.getFirst(), getColorAttributesKey(right.getSecond()), myAppender1.getEditor().getScrollPane(),
|
||||
myAppender1.getEditor()));
|
||||
myPreviousLineRight = lineRight;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user