private void addCommentsGutter( Editor editor, String filePath, String revisionId, Iterable<CommentInfo> fileComments) { for (CommentInfo fileComment : fileComments) { fileComment.path = PathUtils.ensureSlashSeparators(filePath); addComment(editor, changeInfo, revisionId, project, fileComment); } }
private void handleComments(final DiffPanelImpl diffPanel, final String filePathString) { final FilePath filePath = new FilePathImpl(new File(filePathString), false); final String relativeFilePath = PathUtils.ensureSlashSeparators(getRelativeOrAbsolutePath(project, filePath.getPath())); addCommentAction(diffPanel, relativeFilePath, changeInfo); gerritUtil.getChangeDetails( changeInfo._number, project, new Consumer<ChangeInfo>() { @Override public void consume(ChangeInfo changeDetails) { gerritUtil.getComments( changeDetails.id, selectedRevisionId, project, true, true, new Consumer<Map<String, List<CommentInfo>>>() { @Override public void consume(Map<String, List<CommentInfo>> comments) { List<CommentInfo> fileComments = comments.get(relativeFilePath); if (fileComments != null) { addCommentsGutter( diffPanel.getEditor2(), relativeFilePath, selectedRevisionId, Iterables.filter(fileComments, REVISION_COMMENT)); if (!baseRevision.isPresent()) { addCommentsGutter( diffPanel.getEditor1(), relativeFilePath, selectedRevisionId, Iterables.filter(fileComments, Predicates.not(REVISION_COMMENT))); } } } }); if (baseRevision.isPresent()) { gerritUtil.getComments( changeDetails.id, baseRevision.get().getFirst(), project, true, true, new Consumer<Map<String, List<CommentInfo>>>() { @Override public void consume(Map<String, List<CommentInfo>> comments) { List<CommentInfo> fileComments = comments.get(relativeFilePath); if (fileComments != null) { Collections.sort(fileComments, COMMENT_ORDERING); addCommentsGutter( diffPanel.getEditor1(), relativeFilePath, baseRevision.get().getFirst(), Iterables.filter(fileComments, REVISION_COMMENT)); } } }); } gerritUtil.setReviewed(changeDetails.id, selectedRevisionId, relativeFilePath, project); } }); }