[platform diff] PY-20132 changed access level of diff-related attributes and methods from private

Needed for extensibility in Jupyter diff implementation. This modification allows for the inheritance and creation of specialized functionalities tailored to the needs of Jupyter notebook diff processing.

GitOrigin-RevId: 34ce30ef32de8079d483c78b335622091b0942c7
This commit is contained in:
Bogdan Kirilenko
2023-12-19 13:28:45 +00:00
committed by intellij-monorepo-bot
parent 41f7ee9ccd
commit f731230839
6 changed files with 51 additions and 47 deletions
@@ -72,7 +72,7 @@ public class SimpleDiffChangeUi {
myOperations.add(createAcceptOperation(Side.RIGHT));
}
private void createHighlighter(@NotNull Side side) {
protected void createHighlighter(@NotNull Side side) {
Editor editor = myViewer.getEditor(side);
TextDiffType type = myChange.getDiffType();
@@ -17,13 +17,13 @@ import java.util.List;
import java.util.*;
public class SimpleDiffModel {
@NotNull private final SimpleDiffViewer myViewer;
@NotNull protected final SimpleDiffViewer myViewer;
@NotNull private final List<SimpleDiffChange> myValidChanges = new ArrayList<>();
@NotNull private final List<SimpleDiffChange> myAllChanges = new ArrayList<>();
@NotNull private ThreeState myIsContentsEqual = ThreeState.UNSURE;
@NotNull private final List<@Nullable SimpleDiffChangeUi> myPresentations = new ArrayList<>();
@NotNull protected final List<@Nullable SimpleDiffChangeUi> myPresentations = new ArrayList<>();
public SimpleDiffModel(@NotNull SimpleDiffViewer viewer) {
myViewer = viewer;
@@ -104,15 +104,15 @@ public class SimpleDiffModel {
myValidChanges.removeAll(invalidated);
}
public void paintPolygons(@NotNull Graphics2D g, @NotNull JComponent divider) {
protected void paintPolygons(@NotNull Graphics2D g, @NotNull JComponent divider) {
MyPaintable paintable = new MyPaintable(myPresentations);
DiffDividerDrawUtil.paintPolygons(g, divider.getWidth(), myViewer.getEditor1(), myViewer.getEditor2(), paintable);
}
private static class MyPaintable implements DiffDividerDrawUtil.DividerPaintable {
protected static class MyPaintable implements DiffDividerDrawUtil.DividerPaintable {
private final @NotNull List<@Nullable SimpleDiffChangeUi> myPresentations;
private MyPaintable(@NotNull List<@Nullable SimpleDiffChangeUi> presentations) {
protected MyPaintable(@NotNull List<@Nullable SimpleDiffChangeUi> presentations) {
myPresentations = presentations;
}
@@ -54,10 +54,10 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer implements Differenc
@NotNull private final PrevNextDifferenceIterable myPrevNextDifferenceIterable;
@NotNull protected final StatusPanel myStatusPanel;
@NotNull protected final SimpleDiffModel myModel = new SimpleDiffModel(this);
@NotNull protected SimpleDiffModel myModel = new SimpleDiffModel(this);
@NotNull private final AlignedDiffModel myAlignedDiffModel;
@NotNull private final MyFoldingModel myFoldingModel;
@NotNull protected final MyFoldingModel myFoldingModel;
@NotNull private final MyInitialScrollHelper myInitialScrollHelper = new MyInitialScrollHelper();
@NotNull private final ModifierProvider myModifierProvider;
@@ -96,6 +96,10 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer implements Differenc
super.onDispose();
}
protected void setModel(@NotNull SimpleDiffModel model) {
this.myModel = model;
}
@NotNull
@Override
protected List<AnAction> createToolbarActions() {
@@ -746,7 +750,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer implements Differenc
}
}
private class MyDividerPainter implements DiffSplitter.Painter {
protected class MyDividerPainter implements DiffSplitter.Painter {
@DirtyUI
@Override
public void paint(@NotNull Graphics g, @NotNull JComponent divider) {
@@ -792,14 +796,14 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer implements Differenc
}
}
private static class MyFoldingModel extends FoldingModelSupport {
private final MyPaintable myPaintable = new MyPaintable(0, 1);
protected static class MyFoldingModel extends FoldingModelSupport {
protected final MyPaintable myPaintable = new MyPaintable(0, 1);
private final TwosideContentPanel myContentPanel;
MyFoldingModel(@Nullable Project project,
@NotNull List<? extends EditorEx> editors,
@NotNull TwosideContentPanel contentPanel,
@NotNull Disposable disposable) {
protected MyFoldingModel(@Nullable Project project,
@NotNull List<? extends EditorEx> editors,
@NotNull TwosideContentPanel contentPanel,
@NotNull Disposable disposable) {
super(project, editors.toArray(new EditorEx[0]), disposable);
myContentPanel = contentPanel;
}
@@ -93,7 +93,7 @@ public final class DiffDividerDrawUtil {
return handler.getPolygons();
}
private static boolean isIntervalFolded(@NotNull Editor editor, int startLine, int endLine) {
public static boolean isIntervalFolded(@NotNull Editor editor, int startLine, int endLine) {
TextRange range = DiffUtil.getLinesRange(editor.getDocument(), startLine, endLine);
return FoldingUtil.isTextRangeFolded(editor, range);
}
@@ -125,7 +125,7 @@ public final class DiffDividerDrawUtil {
return separators;
}
private static int getEditorTopOffset(@NotNull final Editor editor) {
public static int getEditorTopOffset(@NotNull final Editor editor) {
final JComponent header = editor.getHeaderComponent();
int headerOffset = header == null ? 0 : header.getHeight();
return -editor.getScrollingModel().getVerticalScrollOffset() + headerOffset;
@@ -157,7 +157,7 @@ public final class DiffDividerDrawUtil {
}
@NotNull
private static LineRange getVisibleInterval(Editor editor) {
public static LineRange getVisibleInterval(Editor editor) {
return ReadAction.compute(() -> {
Rectangle area = editor.getScrollingModel().getVisibleArea();
if (area.height < 0) return new LineRange(0, 0);
@@ -185,7 +185,7 @@ public final class DiffDividerDrawUtil {
}
}
private static class DividerPaintableHandlerImpl implements DividerPaintable.Handler {
public static class DividerPaintableHandlerImpl implements DividerPaintable.Handler {
private final Editor myEditor1;
private final Editor myEditor2;
@@ -193,7 +193,7 @@ public final class DiffDividerDrawUtil {
private final LineRange myRightInterval;
private final List<DividerPolygon> myPolygons = new ArrayList<>();
private DividerPaintableHandlerImpl(@NotNull Editor editor1,
public DividerPaintableHandlerImpl(@NotNull Editor editor1,
@NotNull Editor editor2) {
myEditor1 = editor1;
myEditor2 = editor2;
@@ -235,12 +235,12 @@ public final class DiffDividerDrawUtil {
}
}
private boolean process(int startLine1, int endLine1, int startLine2, int endLine2,
public boolean process(int startLine1, int endLine1, int startLine2, int endLine2,
@NotNull Painter painter) {
return process(startLine1, endLine1, startLine2, endLine2, painter, false);
}
private boolean process(int startLine1, int endLine1, int startLine2, int endLine2,
public boolean process(int startLine1, int endLine1, int startLine2, int endLine2,
@NotNull Painter painter, boolean withAlignedHeight) {
if (myLeftInterval.start > endLine1 && myRightInterval.start > endLine2) return true;
if (myLeftInterval.end < startLine1 && myRightInterval.end < startLine2) return false;
@@ -255,7 +255,7 @@ public final class DiffDividerDrawUtil {
return true;
}
private static int getInlayOffset(@NotNull Editor editor1, @NotNull Editor editor2,
public static int getInlayOffset(@NotNull Editor editor1, @NotNull Editor editor2,
int startLine1, int startLine2,
@NotNull TextDiffType type) {
int visualStartLine1 = EditorUtil.logicalToVisualLine(editor1, startLine1);
@@ -294,6 +294,7 @@ public final class DiffDividerDrawUtil {
: DiffDrawUtil.getGutterMarkerPaintRange(editor1, startLine1, endLine1);
MarkerRange range2 = isFolded2 ? getDividerMarkerPaintRange(editor2, startLine2, endLine2)
: DiffDrawUtil.getGutterMarkerPaintRange(editor2, startLine2, endLine2);
return new DividerPolygon(range1.y1 + topOffset1, range2.y1 + topOffset2,
range1.y2 + topOffset1, range2.y2 + topOffset2,
painter.getFillColor(editor2, isFolded),
@@ -307,10 +308,10 @@ public final class DiffDividerDrawUtil {
return type;
}
private static class DefaultPainter implements Painter {
public static class DefaultPainter implements Painter {
private final TextDiffType myType;
private DefaultPainter(@NotNull TextDiffType type) {
public DefaultPainter(@NotNull TextDiffType type) {
myType = type;
}
@@ -340,11 +341,11 @@ public final class DiffDividerDrawUtil {
}
}
private static class ResolvablePainter implements Painter {
public static class ResolvablePainter implements Painter {
private final TextDiffType myType;
private final boolean myResolved;
private ResolvablePainter(@NotNull TextDiffType type, boolean resolved) {
public ResolvablePainter(@NotNull TextDiffType type, boolean resolved) {
myType = type;
myResolved = resolved;
}
@@ -375,12 +376,12 @@ public final class DiffDividerDrawUtil {
}
}
private static class ExcludablePainter implements Painter {
public static class ExcludablePainter implements Painter {
private final TextDiffType myType;
private final boolean myExcluded;
private final boolean mySkipped;
private ExcludablePainter(@NotNull TextDiffType type, boolean excluded, boolean skipped) {
public ExcludablePainter(@NotNull TextDiffType type, boolean excluded, boolean skipped) {
myType = type;
myExcluded = excluded;
mySkipped = skipped;
@@ -413,7 +414,7 @@ public final class DiffDividerDrawUtil {
}
}
private interface Painter {
public interface Painter {
@Nullable Color getFillColor(@NotNull Editor editor, boolean isFolded);
@Nullable Color getBorderColor(@NotNull Editor editor, boolean isFolded);
@@ -542,7 +543,7 @@ public final class DiffDividerDrawUtil {
}
public static class DividerSeparator {
// pixels from the top of editor
// pixels from the top of the editor
private final int myStart1;
private final int myStart2;
private final int myEnd1;
@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.diff.util;
import com.intellij.codeInsight.folding.impl.FoldingUtil;
@@ -250,11 +250,11 @@ public final class DiffDrawUtil {
public static MarkerRange getGutterMarkerPaintRange(@NotNull Editor editor, int startLine, int endLine) {
int y1;
int y2;
if (startLine == endLine) {
if (startLine == 0) {
y1 = lineToY(editor, 0, true, true) + 1;
}
else {
} else {
y1 = lineToY(editor, startLine - 1, false, true);
}
y2 = y1;
@@ -689,7 +689,7 @@ public final class DiffDrawUtil {
this(editor, line, placement, 0);
}
private LineMarkerBuilder(@NotNull Editor editor, int line, @NotNull SeparatorPlacement placement, int layerPriority) {
public LineMarkerBuilder(@NotNull Editor editor, int line, @NotNull SeparatorPlacement placement, int layerPriority) {
this.editor = editor;
this.placement = placement;
@@ -720,7 +720,6 @@ public final class DiffDrawUtil {
return this;
}
@NotNull
public LineMarkerBuilder withDefaultRenderer(@NotNull TextDiffType type, boolean doubleLine, boolean dottedLine,
@Nullable RangeHighlighter parentHighlighter) {
@@ -854,7 +853,7 @@ public final class DiffDrawUtil {
private final @NotNull TextDiffType myType;
private final @Nullable Editor myEditor;
DiffTextAttributes(@NotNull BackgroundType background, @NotNull TextDiffType type, @Nullable Editor editor) {
public DiffTextAttributes(@NotNull BackgroundType background, @NotNull TextDiffType type, @Nullable Editor editor) {
myBackground = background;
myType = type;
myEditor = editor;
@@ -870,11 +869,11 @@ public final class DiffDrawUtil {
}
}
private static class DiffStripeMarkerTextAttributes extends TextAttributes {
public static class DiffStripeMarkerTextAttributes extends TextAttributes {
private final @NotNull TextDiffType myType;
private final @NotNull Editor myEditor;
DiffStripeMarkerTextAttributes(@NotNull TextDiffType type, @NotNull Editor editor) {
public DiffStripeMarkerTextAttributes(@NotNull TextDiffType type, @NotNull Editor editor) {
myType = type;
myEditor = editor;
}
@@ -925,7 +924,7 @@ public final class DiffDrawUtil {
}
}
private static class DiffDefaultBorderRenderer implements LineSeparatorRenderer {
public static class DiffDefaultBorderRenderer implements LineSeparatorRenderer {
private final @Nullable RangeHighlighter myParentHighlighter;
private final @NotNull Editor myEditor;
private final @NotNull SeparatorPlacement myPlacement;
@@ -12,16 +12,16 @@ import java.awt.Graphics2D
import java.awt.Rectangle
@ApiStatus.Internal
class DiffLineMarkerRenderer internal constructor(
private val highlighter: RangeHighlighter,
open class DiffLineMarkerRenderer(
val highlighter: RangeHighlighter,
val diffType: TextDiffType,
val editorMode: PaintMode,
val gutterMode: PaintMode,
private val hideWithoutLineNumbers: Boolean,
val hideWithoutLineNumbers: Boolean,
val isEmptyRange: Boolean,
val isFirstLine: Boolean,
val isLastLine: Boolean,
private val alignedSides: Boolean
val alignedSides: Boolean
) : LineMarkerRendererEx {
override fun paint(editor: Editor, g: Graphics, range: Rectangle) {
@@ -72,9 +72,9 @@ class DiffLineMarkerRenderer internal constructor(
}
}
private fun drawMarker(editor: Editor, g: Graphics2D,
x1: Int, x2: Int, y1: Int, y2: Int,
alignedSides: Boolean, mode: PaintMode) {
fun drawMarker(editor: Editor, g: Graphics2D,
x1: Int, x2: Int, y1: Int, y2: Int,
alignedSides: Boolean, mode: PaintMode) {
if (x1 >= x2) return
val dottedLine = mode.border == BorderType.DOTTED