mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
diff: more desctiptive method name
selectN -> selectNotNull
This commit is contained in:
@@ -70,7 +70,7 @@ public enum Side {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <T> T selectN(@NotNull T left, @NotNull T right) {
|
||||
public <T> T selectNotNull(@NotNull T left, @NotNull T right) {
|
||||
return isLeft() ? left : right;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public enum Side {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <T> T selectN(@NotNull T[] array) {
|
||||
public <T> T selectNotNull(@NotNull T[] array) {
|
||||
assert array.length == 2;
|
||||
return array[myIndex];
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public enum Side {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <T> T selectN(@NotNull List<T> list) {
|
||||
public <T> T selectNotNull(@NotNull List<T> list) {
|
||||
assert list.size() == 2;
|
||||
return list.get(myIndex);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public enum Side {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <T> T selectN(@NotNull Couple<T> region) {
|
||||
public <T> T selectNotNull(@NotNull Couple<T> region) {
|
||||
return isLeft() ? region.first : region.second;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public enum ThreeSide {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <T> T selectN(@NotNull T left, @NotNull T base, @NotNull T right) {
|
||||
public <T> T selectNotNull(@NotNull T left, @NotNull T base, @NotNull T right) {
|
||||
if (myIndex == 0) return left;
|
||||
if (myIndex == 1) return base;
|
||||
if (myIndex == 2) return right;
|
||||
@@ -67,7 +67,7 @@ public enum ThreeSide {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <T> T selectN(@NotNull T[] array) {
|
||||
public <T> T selectNotNull(@NotNull T[] array) {
|
||||
assert array.length == 3;
|
||||
return array[myIndex];
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public enum ThreeSide {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <T> T selectN(@NotNull List<T> list) {
|
||||
public <T> T selectNotNull(@NotNull List<T> list) {
|
||||
assert list.size() == 3;
|
||||
return list.get(myIndex);
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ public class MergeUtil {
|
||||
|
||||
@NotNull
|
||||
private Interval getRange(@NotNull ThreeSide side) {
|
||||
return side.selectN(myLeft, myBase, myRight);
|
||||
return side.selectNotNull(myLeft, myBase, myRight);
|
||||
}
|
||||
|
||||
public int getStartLine(@NotNull ThreeSide side) {
|
||||
|
||||
@@ -388,7 +388,7 @@ public class BinaryDiffViewer extends ListenerDiffViewerBase {
|
||||
FileEditor editor = getCurrentEditor();
|
||||
if (editor == null) return null;
|
||||
|
||||
DiffContent content = getCurrentSide().selectN(request.getContents());
|
||||
DiffContent content = getCurrentSide().selectNotNull(request.getContents());
|
||||
|
||||
return content.getOpenFileDescriptor();
|
||||
}
|
||||
|
||||
@@ -1009,7 +1009,7 @@ public class OnesideDiffViewer extends TextDiffViewerBase {
|
||||
myShouldScroll = !doScrollToContext(myNavigationContext);
|
||||
}
|
||||
if (myShouldScroll && myCaretPosition != null && myCaretPosition.length == 2) {
|
||||
LogicalPosition twosidePosition = myMasterSide.selectN(myCaretPosition);
|
||||
LogicalPosition twosidePosition = myMasterSide.selectNotNull(myCaretPosition);
|
||||
int onesideLine = transferLineToOneside(myMasterSide, twosidePosition.line);
|
||||
LogicalPosition position = new LogicalPosition(onesideLine, twosidePosition.column);
|
||||
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ public class OnesideEditorHighlighter implements EditorHighlighter {
|
||||
offset = base.getStartOffset();
|
||||
}
|
||||
|
||||
HighlighterIterator it = range.getSide().selectN(it1, it2);
|
||||
HighlighterIterator it = range.getSide().selectNotNull(it1, it2);
|
||||
while (!it.atEnd() && changed.getStartOffset() >= it.getEnd()) {
|
||||
it.advance();
|
||||
}
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ public class OnesideFragmentBuilder {
|
||||
}
|
||||
|
||||
private void appendText(@NotNull Side side, int offset1, int offset2, int lines, int startLine1, int startLine2) {
|
||||
Document document = side.selectN(myDocument1, myDocument2);
|
||||
Document document = side.selectNotNull(myDocument1, myDocument2);
|
||||
|
||||
int newline = document.getTextLength() > offset2 + 1 ? 1 : 0;
|
||||
TextRange base = new TextRange(myBuilder.length(), myBuilder.length() + offset2 - offset1 + newline);
|
||||
|
||||
@@ -228,9 +228,9 @@ public class SimpleDiffChange {
|
||||
final Document document1 = myEditor1.getDocument();
|
||||
final Document document2 = myEditor2.getDocument();
|
||||
|
||||
DiffUtil.applyModification(sourceSide.other().selectN(document1, document2),
|
||||
DiffUtil.applyModification(sourceSide.other().selectNotNull(document1, document2),
|
||||
getStartLine(sourceSide.other()), getEndLine(sourceSide.other()),
|
||||
sourceSide.selectN(document1, document2),
|
||||
sourceSide.selectNotNull(document1, document2),
|
||||
getStartLine(sourceSide), getEndLine(sourceSide));
|
||||
|
||||
destroyHighlighter();
|
||||
@@ -246,9 +246,9 @@ public class SimpleDiffChange {
|
||||
final Document document1 = myEditor1.getDocument();
|
||||
final Document document2 = myEditor2.getDocument();
|
||||
|
||||
DiffUtil.applyModification(sourceSide.other().selectN(document1, document2),
|
||||
DiffUtil.applyModification(sourceSide.other().selectNotNull(document1, document2),
|
||||
getEndLine(sourceSide.other()), getEndLine(sourceSide.other()),
|
||||
sourceSide.selectN(document1, document2),
|
||||
sourceSide.selectNotNull(document1, document2),
|
||||
getStartLine(sourceSide), getEndLine(sourceSide));
|
||||
|
||||
destroyHighlighter();
|
||||
@@ -262,7 +262,7 @@ public class SimpleDiffChange {
|
||||
private MyGutterOperation createOperation(@NotNull Side side) {
|
||||
assert myEditor1 != null && myEditor2 != null;
|
||||
int offset = side.getStartOffset(myFragment);
|
||||
EditorEx editor = side.selectN(myEditor1, myEditor2);
|
||||
EditorEx editor = side.selectNotNull(myEditor1, myEditor2);
|
||||
RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(offset, offset,
|
||||
HighlighterLayer.ADDITIONAL_SYNTAX,
|
||||
null,
|
||||
@@ -303,8 +303,8 @@ public class SimpleDiffChange {
|
||||
myCtrlPressed = myViewer.getModifierProvider().isCtrlPressed();
|
||||
myShiftPressed = myViewer.getModifierProvider().isShiftPressed();
|
||||
|
||||
boolean isEditable = DiffUtil.isEditable(mySide.selectN(myEditor1, myEditor2));
|
||||
boolean isOtherEditable = DiffUtil.isEditable(mySide.other().selectN(myEditor1, myEditor2));
|
||||
boolean isEditable = DiffUtil.isEditable(mySide.selectNotNull(myEditor1, myEditor2));
|
||||
boolean isOtherEditable = DiffUtil.isEditable(mySide.other().selectNotNull(myEditor1, myEditor2));
|
||||
|
||||
if (myCtrlPressed && myShiftPressed) return null;
|
||||
if ((myShiftPressed || !isOtherEditable) && isEditable) {
|
||||
@@ -350,7 +350,7 @@ public class SimpleDiffChange {
|
||||
@Nullable
|
||||
private GutterIconRenderer createIconRenderer(@NotNull final Side sourceSide, @NotNull final Icon icon, @NotNull final Runnable perform) {
|
||||
assert myEditor1 != null && myEditor2 != null;
|
||||
if (!DiffUtil.isEditable(sourceSide.other().selectN(myEditor1, myEditor2))) return null;
|
||||
if (!DiffUtil.isEditable(sourceSide.other().selectNotNull(myEditor1, myEditor2))) return null;
|
||||
return new GutterIconRenderer() {
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -372,7 +372,7 @@ public class SimpleDiffChange {
|
||||
|
||||
if (!myIsValid) return;
|
||||
|
||||
DiffUtil.executeWriteCommand(sourceSide.other().selectN(document1, document2), project, "Replace change", new Runnable() {
|
||||
DiffUtil.executeWriteCommand(sourceSide.other().selectNotNull(document1, document2), project, "Replace change", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
perform.run();
|
||||
|
||||
@@ -608,7 +608,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
return;
|
||||
}
|
||||
|
||||
Editor modifiedEditor = side.other(myModifyOpposite).selectN(myEditor1, myEditor2);
|
||||
Editor modifiedEditor = side.other(myModifyOpposite).selectNotNull(myEditor1, myEditor2);
|
||||
if (!DiffUtil.isEditable(modifiedEditor)) {
|
||||
e.getPresentation().setEnabledAndVisible(false);
|
||||
return;
|
||||
@@ -626,7 +626,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
final Side side = Side.fromLeft(editor == myEditor1);
|
||||
final List<SimpleDiffChange> selectedChanges = getSelectedChanges(side);
|
||||
|
||||
Editor modifiedEditor = side.other(myModifyOpposite).selectN(myEditor1, myEditor2);
|
||||
Editor modifiedEditor = side.other(myModifyOpposite).selectNotNull(myEditor1, myEditor2);
|
||||
String title = e.getPresentation().getText() + " selected changes";
|
||||
DiffUtil.executeWriteCommand(modifiedEditor.getDocument(), e.getProject(), title, new Runnable() {
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -81,7 +81,7 @@ public class SimpleThreesideDiffChange {
|
||||
//
|
||||
|
||||
private void createHighlighter(@NotNull ThreeSide side) {
|
||||
Editor editor = side.selectN(myEditors);
|
||||
Editor editor = side.selectNotNull(myEditors);
|
||||
Document document = editor.getDocument();
|
||||
|
||||
TextDiffType type = getDiffType();
|
||||
@@ -208,7 +208,7 @@ public class SimpleThreesideDiffChange {
|
||||
private static CharSequence getRangeContent(@NotNull MergeLineFragment fragment,
|
||||
@NotNull List<EditorEx> editors,
|
||||
@NotNull ThreeSide side) {
|
||||
DocumentEx document = side.selectN(editors).getDocument();
|
||||
DocumentEx document = side.selectNotNull(editors).getDocument();
|
||||
int line1 = fragment.getStartLine(side);
|
||||
int line2 = fragment.getEndLine(side);
|
||||
return DiffUtil.getLinesContent(document, line1, line2);
|
||||
|
||||
+8
-8
@@ -391,7 +391,7 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer {
|
||||
@NotNull
|
||||
@Override
|
||||
protected SyncScrollSupport.SyncScrollable getSyncScrollable(@NotNull Side side) {
|
||||
return side.selectN(mySyncScrollable1, mySyncScrollable2);
|
||||
return side.selectNotNull(mySyncScrollable1, mySyncScrollable2);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -548,15 +548,15 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer {
|
||||
|
||||
@Override
|
||||
protected void processHelper(@NotNull ScrollHelper helper) {
|
||||
ThreeSide left = mySide.selectN(ThreeSide.LEFT, ThreeSide.BASE);
|
||||
ThreeSide right = mySide.selectN(ThreeSide.BASE, ThreeSide.RIGHT);
|
||||
ThreeSide left = mySide.selectNotNull(ThreeSide.LEFT, ThreeSide.BASE);
|
||||
ThreeSide right = mySide.selectNotNull(ThreeSide.BASE, ThreeSide.RIGHT);
|
||||
|
||||
if (!helper.process(0, 0)) return;
|
||||
for (SimpleThreesideDiffChange diffChange : myDiffChanges) {
|
||||
if (!helper.process(diffChange.getStartLine(left), diffChange.getStartLine(right))) return;
|
||||
if (!helper.process(diffChange.getEndLine(left), diffChange.getEndLine(right))) return;
|
||||
}
|
||||
helper.process(left.selectN(myEditors).getDocument().getLineCount(), right.selectN(myEditors).getDocument().getLineCount());
|
||||
helper.process(left.selectNotNull(myEditors).getDocument().getLineCount(), right.selectNotNull(myEditors).getDocument().getLineCount());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,8 +569,8 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer {
|
||||
|
||||
@Override
|
||||
public void process(@NotNull Handler handler) {
|
||||
ThreeSide left = mySide.selectN(ThreeSide.LEFT, ThreeSide.BASE);
|
||||
ThreeSide right = mySide.selectN(ThreeSide.BASE, ThreeSide.RIGHT);
|
||||
ThreeSide left = mySide.selectNotNull(ThreeSide.LEFT, ThreeSide.BASE);
|
||||
ThreeSide right = mySide.selectNotNull(ThreeSide.BASE, ThreeSide.RIGHT);
|
||||
|
||||
for (SimpleThreesideDiffChange diffChange : myDiffChanges) {
|
||||
if (!diffChange.getType().isChange(mySide)) continue;
|
||||
@@ -596,8 +596,8 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer {
|
||||
public void paint(@NotNull Graphics g, @NotNull Component divider) {
|
||||
Graphics2D gg = getDividerGraphics(g, divider);
|
||||
|
||||
Editor editor1 = mySide.selectN(myEditors.get(0), myEditors.get(1));
|
||||
Editor editor2 = mySide.selectN(myEditors.get(1), myEditors.get(2));
|
||||
Editor editor1 = mySide.selectNotNull(myEditors.get(0), myEditors.get(1));
|
||||
Editor editor2 = mySide.selectNotNull(myEditors.get(1), myEditors.get(2));
|
||||
|
||||
//DividerPolygonUtil.paintSimplePolygons(gg, divider.getWidth(), editor1, editor2, myPaintable);
|
||||
DiffDividerDrawUtil.paintPolygons(gg, divider.getWidth(), editor1, editor2, myPaintable);
|
||||
|
||||
@@ -264,7 +264,7 @@ public class FoldingModelSupport {
|
||||
}
|
||||
|
||||
public void paintOnDivider(@NotNull Graphics2D gg, @NotNull Component divider, @NotNull Side side) {
|
||||
MyPaintable paintable = side.selectN(myPaintable1, myPaintable2);
|
||||
MyPaintable paintable = side.selectNotNull(myPaintable1, myPaintable2);
|
||||
paintable.paintOnDivider(gg, divider);
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -254,7 +254,7 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase {
|
||||
|
||||
@NotNull
|
||||
public EditorEx getCurrentEditor() {
|
||||
return myCurrentSide.selectN(myEditors);
|
||||
return myCurrentSide.selectNotNull(myEditors);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -274,7 +274,7 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase {
|
||||
|
||||
@CalledInAwt
|
||||
protected void scrollToLine(@NotNull ThreeSide side, int line) {
|
||||
Editor editor = side.selectN(myEditors);
|
||||
Editor editor = side.selectNotNull(myEditors);
|
||||
DiffUtil.scrollEditor(editor, line);
|
||||
myCurrentSide = side;
|
||||
}
|
||||
@@ -301,7 +301,7 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase {
|
||||
protected OpenFileDescriptor getOpenFileDescriptor() {
|
||||
EditorEx editor = getCurrentEditor();
|
||||
|
||||
DocumentContent content = getCurrentSide().selectN(myActualContents);
|
||||
DocumentContent content = getCurrentSide().selectNotNull(myActualContents);
|
||||
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
return content.getOpenFileDescriptor(offset);
|
||||
@@ -363,8 +363,8 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase {
|
||||
DiffContent[] contents = myRequest.getContents();
|
||||
String[] titles = myRequest.getContentTitles();
|
||||
|
||||
DiffRequest request = new SimpleDiffRequest(myRequest.getTitle(), mySide1.selectN(contents), mySide2.selectN(contents),
|
||||
mySide1.selectN(titles), mySide1.selectN(titles));
|
||||
DiffRequest request = new SimpleDiffRequest(myRequest.getTitle(), mySide1.selectNotNull(contents), mySide2.selectNotNull(contents),
|
||||
mySide1.selectNotNull(titles), mySide1.selectNotNull(titles));
|
||||
DiffManager.getInstance().showDiff(myProject, request, new DiffDialogHints(null, myPanel));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user