Search in sources :

Example 1 with NodeStartPositionComparator

use of org.autorefactor.refactoring.ASTHelper.NodeStartPositionComparator in project AutoRefactor by JnRouvignac.

the class RemoveSemiColonRefactoring method filterCommentsInRange.

private List<Comment> filterCommentsInRange(int start, int end, List<Comment> commentList) {
    if (commentList.isEmpty()) {
        return Collections.emptyList();
    }
    final List<Comment> comments = new ArrayList<Comment>(commentList);
    Collections.sort(comments, new NodeStartPositionComparator());
    final Iterator<Comment> it = comments.iterator();
    while (it.hasNext()) {
        final Comment comment = it.next();
        if (comment.getStartPosition() < start || getEndPosition(comment) > end) {
            it.remove();
        }
    }
    return comments;
}
Also used : Comment(org.eclipse.jdt.core.dom.Comment) ArrayList(java.util.ArrayList) NodeStartPositionComparator(org.autorefactor.refactoring.ASTHelper.NodeStartPositionComparator)

Aggregations

ArrayList (java.util.ArrayList)1 NodeStartPositionComparator (org.autorefactor.refactoring.ASTHelper.NodeStartPositionComparator)1 Comment (org.eclipse.jdt.core.dom.Comment)1