/** * Returns the preceding immediate comment */ static String getPrecedingImmediateCommentText(CompilationInfo cinfo, Tree tree) { List<Comment> comments = cinfo.getTreeUtilities().getComments(tree, true); return comments.size() > 0 ? comments.get(comments.size()-1).getText() : null; }
private static void moveCommentsBeforeOffset(WorkingCopy wc, Tree from, Tree to, int offset, Document doc) { List<Comment> toMove = new LinkedList<>(); int idx = 0; for (Comment comment : wc.getTreeUtilities().getComments(from, true)) { if (comment.pos() >= offset || comment.endPos() > offset) { break; } DocumentGuards guards = LineDocumentUtils.as(doc, DocumentGuards.class); if (guards != null) { int epAfterBlock = guards.adjustPosition(comment.pos(), true); // comment that ends exactly at the GB boundary cannot be really // reassigned from the previous member. if (epAfterBlock >= comment.endPos()) { // set new offset, after the guarded block break; } } toMove.add(comment); idx++; } if (toMove.size() > 0) { doMoveComments(wc, from, to, offset, toMove, 0, idx); } }
int idx = 0; int firstToRemove = -1; for (Comment comment : wc.getTreeUtilities().getComments(from, false)) { if (comment.endPos() <= offset) {
for (Comment comm : treeUtilities.getComments(tree, true)) { if (comm.pos() < 0) { continue; for (Comment comm : treeUtilities.getComments(tree, false)) { if (comm.pos() < 0) { continue;
for (Comment comm : treeUtilities.getComments(tree, true)) { if (comm.pos() < 0) { continue; for (Comment comm : treeUtilities.getComments(tree, false)) { if (comm.pos() < 0) { continue;