use of com.google.gerrit.client.diff.CommentRange in project gerrit by GerritCodeReview.
the class LocalComments method getInlineComment.
private static InlineComment getInlineComment(String key) {
String path;
Side side = Side.PARENT;
int line = 0;
CommentRange range;
StorageBackend storage = new StorageBackend();
String[] elements = key.split("-");
int offset = 1;
if (key.startsWith("patchReply-") || key.startsWith("patchCommentEdit-")) {
offset = 2;
}
Change.Id changeId = new Change.Id(Integer.parseInt(elements[offset + 0]));
PatchSet.Id psId = new PatchSet.Id(changeId, Integer.parseInt(elements[offset + 1]));
path = atob(elements[offset + 2]);
side = (Side.PARENT.toString().equals(elements[offset + 3])) ? Side.PARENT : Side.REVISION;
range = null;
if (elements[offset + 4].startsWith("R")) {
String rangeStart = elements[offset + 4].substring(1);
String rangeEnd = elements[offset + 5];
String[] split = rangeStart.split(",");
int sl = Integer.parseInt(split[0]);
int sc = Integer.parseInt(split[1]);
split = rangeEnd.split(",");
int el = Integer.parseInt(split[0]);
int ec = Integer.parseInt(split[1]);
range = CommentRange.create(sl, sc, el, ec);
line = sl;
} else {
line = Integer.parseInt(elements[offset + 4]);
}
CommentInfo info = CommentInfo.create(path, side, line, range, false);
info.message(storage.getItem(key));
if (key.startsWith("patchReply-")) {
info.inReplyTo(elements[1]);
} else if (key.startsWith("patchCommentEdit-")) {
info.id(elements[1]);
}
InlineComment inlineComment = new InlineComment(psId, info);
return inlineComment;
}
Aggregations