private void addParameterCommentTo(CtElement ele, ParamOnElement... paramsOnElement) { for (ParamOnElement paramOnElement : paramsOnElement) { if (isNodeContained(paramOnElement.node) == false) { params.add(paramOnElement); } } if (isPrintParametersAsComments() && isCommentVisible(ele) && !params.isEmpty()) { ele.addComment(ele.getFactory().Code().createComment(getSubstitutionRequestsDescription(ele, params), CommentType.BLOCK)); params.clear(); } }
private CtComment getJavaDoc(CtElement ele) { for (CtComment comment : ele.getComments()) { if (comment.getCommentType() == CtComment.CommentType.JAVADOC) { return comment; } } CtComment c = ele.getFactory().Code().createComment("", CtComment.CommentType.JAVADOC); ele.addComment(c); return c; }
@Override public void scan(CtElement e) { if (e == null) { return; } // Do not visit the AST, only the first element if (!isScanned) { isScanned = true; SourcePosition sp = e.getPosition(); if (sp.getSourceStart() == comment.getPosition().getSourceStart()) { e.addComment(comment); return; } if (sp instanceof DeclarationSourcePosition) { DeclarationSourcePosition dsp = (DeclarationSourcePosition) sp; if (comment.getPosition().getSourceEnd() < dsp.getModifierSourceEnd()) { e.addComment(comment); return; } } super.scan(e); } }
best.addComment(comment);
public static void addComment(CtElement element, String content, CtComment.CommentType type) { CtComment comment = element.getFactory().createComment(content, type); if (!element.getComments().contains(comment)) { element.addComment(comment); } }