use of com.google.gerrit.client.patches.SkippedLine in project gerrit by GerritCodeReview.
the class SkipManager method renderSkips.
private void renderSkips(List<SkippedLine> skips, int lineA, int lineB) {
if (!skips.isEmpty()) {
boolean isSideBySide = host.isSideBySide();
CodeMirror cmA = null;
if (isSideBySide) {
cmA = host.getCmFromSide(DisplaySide.A);
}
CodeMirror cmB = host.getCmFromSide(DisplaySide.B);
for (SkippedLine skip : skips) {
SkipBar barA = null;
SkipBar barB = newSkipBar(cmB, DisplaySide.B, skip);
skipBars.add(barB);
if (isSideBySide) {
barA = newSkipBar(cmA, DisplaySide.A, skip);
SkipBar.link(barA, barB);
skipBars.add(barA);
}
if (skip.getStartA() == 0 || skip.getStartB() == 0) {
if (isSideBySide) {
barA.upArrow.setVisible(false);
}
barB.upArrow.setVisible(false);
setLine0(barB);
} else if (skip.getStartA() + skip.getSize() == lineA || skip.getStartB() + skip.getSize() == lineB) {
if (isSideBySide) {
barA.downArrow.setVisible(false);
}
barB.downArrow.setVisible(false);
}
}
}
}
use of com.google.gerrit.client.patches.SkippedLine in project gerrit by GerritCodeReview.
the class CommentManager method splitSkips.
List<SkippedLine> splitSkips(int context, List<SkippedLine> skips) {
if (sideA.containsKey(0) || sideB.containsKey(0)) {
// Special case of file comment; cannot skip first line.
for (SkippedLine skip : skips) {
if (skip.getStartA() == 0) {
skip.incrementStart(1);
break;
}
}
}
for (int boxLine : getLinesWithCommentGroups()) {
List<SkippedLine> temp = new ArrayList<>(skips.size() + 2);
for (SkippedLine skip : skips) {
int startLine = host.getCmLine(skip.getStartB(), DisplaySide.B);
int deltaBefore = boxLine - startLine;
int deltaAfter = startLine + skip.getSize() - boxLine;
if (deltaBefore < -context || deltaAfter < -context) {
// Size guaranteed to be greater than 1
temp.add(skip);
} else if (deltaBefore > context && deltaAfter > context) {
SkippedLine before = new SkippedLine(skip.getStartA(), skip.getStartB(), skip.getSize() - deltaAfter - context);
skip.incrementStart(deltaBefore + context);
checkAndAddSkip(temp, before);
checkAndAddSkip(temp, skip);
} else if (deltaAfter > context) {
skip.incrementStart(deltaBefore + context);
checkAndAddSkip(temp, skip);
} else if (deltaBefore > context) {
skip.reduceSize(deltaAfter + context);
checkAndAddSkip(temp, skip);
}
}
if (temp.isEmpty()) {
return temp;
}
skips = temp;
}
return skips;
}
use of com.google.gerrit.client.patches.SkippedLine in project gerrit by GerritCodeReview.
the class SkipManager method render.
void render(int context, DiffInfo diff) {
if (context == DiffPreferencesInfo.WHOLE_FILE_CONTEXT) {
return;
}
List<SkippedLine> skips = new ArrayList<>();
int lineA = 0;
int lineB = 0;
JsArray<Region> regions = diff.content();
for (int i = 0; i < regions.length(); i++) {
Region current = regions.get(i);
if (current.ab() != null || current.common() || current.skip() > 0) {
int len = current.skip() > 0 ? current.skip() : (current.ab() != null ? current.ab() : current.b()).length();
if (i == 0 && len > context + 1) {
skips.add(new SkippedLine(0, 0, len - context));
} else if (i == regions.length() - 1 && len > context + 1) {
skips.add(new SkippedLine(lineA + context, lineB + context, len - context));
} else if (len > 2 * context + 1) {
skips.add(new SkippedLine(lineA + context, lineB + context, len - 2 * context));
}
lineA += len;
lineB += len;
} else {
lineA += current.a() != null ? current.a().length() : 0;
lineB += current.b() != null ? current.b().length() : 0;
}
}
skips = host.getCommentManager().splitSkips(context, skips);
renderSkips(skips, lineA, lineB);
}
Aggregations