Side (@NotNull Range range1, @NotNull Range range2) { int start1 = range1.start1; int end1 = range1.end1; int start2 = range2.start1; int end2 = range2.end1; if (end1 <= start2) return Side.LEFT; if (end2 <= start1) return Side.RIGHT; int startBase = Math.max(start1, start2); int endBase = Math.min(end1, end2); int count = endBase - startBase; int startShift1 = startBase - start1; int startShift2 = startBase - start2; int startLeft = range1.start2 + startShift1; int endLeft = startLeft + count; int startRight = range2.start2 + startShift2; int endRight = startRight + count; myChangesBuilder.markEqual(startLeft, startBase, startRight, endLeft, endBase, endRight); return Side.fromLeft(end1 <= end2); }