use of com.github.javaparser.ast.comments.JavadocComment in project controller by opendaylight.
the class SieASTVisitor method visit.
@Override
public void visit(final ClassOrInterfaceDeclaration n, final Void arg) {
extnds = n.getExtends().toString();
final Comment c = n.getComment();
if (c instanceof JavadocComment) {
javadoc = c.toString();
}
super.visit(n, arg);
}
use of com.github.javaparser.ast.comments.JavadocComment in project javaparser by javaparser.
the class GeneratedJavaParserTokenManagerBase method createCommentFromToken.
/**
* Since comments are completely captured in a single token, including their delimiters, deconstruct them here so we
* can turn them into nodes later on.
*/
static Comment createCommentFromToken(Token token) {
String commentText = token.image;
if (token.kind == JAVADOC_COMMENT) {
return new JavadocComment(tokenRange(token), commentText.substring(3, commentText.length() - 2));
} else if (token.kind == MULTI_LINE_COMMENT) {
return new BlockComment(tokenRange(token), commentText.substring(2, commentText.length() - 2));
} else if (token.kind == SINGLE_LINE_COMMENT) {
// line comments have their end of line character(s) included, and we don't want that.
Range range = new Range(pos(token.beginLine, token.beginColumn), pos(token.endLine, token.endColumn));
while (commentText.endsWith("\r") || commentText.endsWith("\n")) {
commentText = commentText.substring(0, commentText.length() - 1);
}
range = range.withEnd(pos(range.begin.line, range.begin.column + commentText.length()));
LineComment comment = new LineComment(tokenRange(token), commentText.substring(2));
comment.setRange(range);
return comment;
}
throw new AssertionError("Unexpectedly got passed a non-comment token.");
}
use of com.github.javaparser.ast.comments.JavadocComment in project javaparser by javaparser.
the class CloneVisitor method visit.
@Override
public Node visit(InitializerDeclaration _n, Object _arg) {
JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
BlockStmt block = cloneNodes(_n.getBlock(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
InitializerDeclaration r = new InitializerDeclaration(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), _n.isStatic(), block);
r.setComment(comment);
return r;
}
use of com.github.javaparser.ast.comments.JavadocComment in project javaparser by javaparser.
the class CloneVisitor method visit.
@Override
public Node visit(AnnotationDeclaration _n, Object _arg) {
JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
List<BodyDeclaration> members = visit(_n.getMembers(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
AnnotationDeclaration r = new AnnotationDeclaration(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), _n.getModifiers(), annotations, _n.getName(), members);
r.setComment(comment);
return r;
}
use of com.github.javaparser.ast.comments.JavadocComment in project javaparser by javaparser.
the class CloneVisitor method visit.
@Override
public Node visit(EmptyMemberDeclaration _n, Object _arg) {
JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
EmptyMemberDeclaration r = new EmptyMemberDeclaration(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn());
r.setComment(comment);
return r;
}
Aggregations