private int getPosAfterCommentEnd(Tree t, int minPos) { CommentSet cs = getCommentsForTree(t, false); List<Comment> cmm = cs.getComments(CommentSet.RelativePosition.TRAILING); if (cmm.isEmpty()) { cmm = cs.getComments(CommentSet.RelativePosition.INLINE); } if (cmm.isEmpty()) { return minPos; } Comment c = cmm.get(cmm.size() - 1); int pos = c.endPos(); assert pos >= 0; if (c.style() == Comment.Style.LINE || c.style() == Comment.Style.WHITESPACE) { // compensate trailing newline to preserve line ends for line comment and whitespace if (pos > 0 && diffContext.origText.charAt(pos - 1) == '\n') { pos--; } } return Math.max(minPos, pos); }
private void printPrecedingComments(JCTree tree, boolean printWhitespace) { if (!precedingCommentsHandled.add(tree)) { return; } CommentSet commentSet = commentHandler.getComments(tree); java.util.List<Comment> pc = commentSet.getComments(CommentSet.RelativePosition.PRECEDING); DocCommentTree doc = tree2Doc.get(tree); if (!pc.isEmpty()) { Comment javadoc = null; for (Comment comment : pc) { if(comment.style() == Style.JAVADOC) { javadoc = comment; } } for (Comment c : pc) { if(doc != null && c == javadoc) { print((DCTree)doc); doc = null; } else { printComment(c, true, printWhitespace); } } } if(doc!=null) { print((DCTree)doc); } }
boolean nonWs = false; for (Comment c : l) { if (c.style() != Comment.Style.WHITESPACE) { last = index; if (!nonWs) {
if (oldComment.style() == Style.LINE) containedEmbeddedNewLine = true; if (nueComment.style() == Style.LINE) containsEmbeddedNewLine = true; newInlineComments.get(newInlineComments.size() - 1) : newTrailingComments.get(newTrailingComments.size() - 1); if (c.style() != Comment.Style.LINE) { while (printer.out.isWhitespaceLine()) { printer.eatChars(1);
public void printComment(Comment comment, boolean preceding, boolean printWhitespace, boolean preventClosingWhitespace) { boolean onlyWhitespaces = out.isWhitespaceLine(); if (Comment.Style.WHITESPACE == comment.style()) { if (false && printWhitespace) { char[] data = comment.getText().toCharArray(); out.toLineStart(); } else if (comment.indent() == 0) { if (!preceding && out.lastBlankLines == 0 && comment.style() != Style.LINE) newline(); out.toLineStart(); } else if (comment.indent() > 0 && !preceding) { if (out.lastBlankLines == 0 && comment.style() != Style.LINE) newline(); toLeftMargin(); switch (comment.style()) { case LINE: print("// "); switch (comment.style()) { case BLOCK: print(" */"); if ((onlyWhitespaces && !preventClosingWhitespace) || comment.style() == Style.LINE) { newline(); if (!preventClosingWhitespace) {