use of com.google.gerrit.reviewdb.client.Comment in project gerrit by GerritCodeReview.
the class CommentsUtil method byPatchSet.
public List<Comment> byPatchSet(ReviewDb db, ChangeNotes notes, PatchSet.Id psId) throws OrmException {
if (!migration.readChanges()) {
return sort(toComments(serverId, db.patchComments().byPatchSet(psId).toList()));
}
List<Comment> comments = new ArrayList<>();
comments.addAll(publishedByPatchSet(db, notes, psId));
for (Ref ref : getDraftRefs(notes.getChangeId())) {
Account.Id account = Account.Id.fromRefSuffix(ref.getName());
if (account != null) {
comments.addAll(draftByPatchSetAuthor(db, psId, account, notes));
}
}
return sort(comments);
}
use of com.google.gerrit.reviewdb.client.Comment in project gerrit by GerritCodeReview.
the class PatchScriptBuilder method ensureCommentsVisible.
private void ensureCommentsVisible(final CommentDetail comments) {
if (comments.getCommentsA().isEmpty() && comments.getCommentsB().isEmpty()) {
//
return;
}
// Construct empty Edit blocks around each location where a comment is.
// This will force the later packContent method to include the regions
// containing comments, potentially combining those regions together if
// they have overlapping contexts. UI renders will also be able to make
// correct hunks from this, but because the Edit is empty they will not
// style it specially.
//
final List<Edit> empty = new ArrayList<>();
int lastLine;
lastLine = -1;
for (Comment c : comments.getCommentsA()) {
final int a = c.lineNbr;
if (lastLine != a) {
final int b = mapA2B(a - 1);
if (0 <= b) {
safeAdd(empty, new Edit(a - 1, b));
}
lastLine = a;
}
}
lastLine = -1;
for (Comment c : comments.getCommentsB()) {
int b = c.lineNbr;
if (lastLine != b) {
final int a = mapB2A(b - 1);
if (0 <= a) {
safeAdd(empty, new Edit(a, b - 1));
}
lastLine = b;
}
}
// Sort the final list by the index in A, so packContent can combine
// them correctly later.
//
edits.addAll(empty);
Collections.sort(edits, EDIT_SORT);
}
use of com.google.gerrit.reviewdb.client.Comment in project gerrit by GerritCodeReview.
the class PatchScriptFactory method loadPublished.
private void loadPublished(Map<Patch.Key, Patch> byKey, String file) throws OrmException {
ChangeNotes notes = control.getNotes();
for (Comment c : commentsUtil.publishedByChangeFile(db, notes, changeId, file)) {
comments.include(change.getId(), c);
PatchSet.Id psId = new PatchSet.Id(change.getId(), c.key.patchSetId);
Patch.Key pKey = new Patch.Key(psId, c.key.filename);
Patch p = byKey.get(pKey);
if (p != null) {
p.setCommentCount(p.getCommentCount() + 1);
}
}
}
Aggregations