use of org.eclipse.jdt.core.dom.BlockComment in project AutoRefactor by JnRouvignac.
the class CommentsCleanUp method betterCommentExist.
private boolean betterCommentExist(final Comment comment, final ASTNode nodeWhereToAddJavadoc) {
if (hasJavadoc(nodeWhereToAddJavadoc)) {
return true;
}
SourceLocation nodeLoc = new SourceLocation(nodeWhereToAddJavadoc);
SourceLocation bestLoc = new SourceLocation(comment);
Comment bestComment = comment;
for (Iterator<Pair<SourceLocation, Comment>> iter = this.comments.iterator(); iter.hasNext(); ) {
Pair<SourceLocation, Comment> pair = iter.next();
SourceLocation newLoc = pair.getFirst();
Comment newComment = pair.getSecond();
if (newLoc.compareTo(bestLoc) < 0) {
// Since comments are visited in ascending order,
// we can forget this comment.
iter.remove();
continue;
}
if (nodeLoc.compareTo(newLoc) < 0) {
break;
}
if (bestLoc.compareTo(newLoc) < 0 && (!(newComment instanceof LineComment) || !(bestComment instanceof LineComment))) {
// New comment is a BlockComment or a Javadoc
bestLoc = newLoc;
bestComment = newComment;
continue;
}
}
return bestComment != null && bestComment != comment;
}
Aggregations