Search in sources :

Example 1 with JavadocComment

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);
}
Also used : JavadocComment(com.github.javaparser.ast.comments.JavadocComment) Comment(com.github.javaparser.ast.comments.Comment) JavadocComment(com.github.javaparser.ast.comments.JavadocComment)

Example 2 with JavadocComment

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.");
}
Also used : BlockComment(com.github.javaparser.ast.comments.BlockComment) JavadocComment(com.github.javaparser.ast.comments.JavadocComment) LineComment(com.github.javaparser.ast.comments.LineComment)

Example 3 with JavadocComment

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;
}
Also used : JavadocComment(com.github.javaparser.ast.comments.JavadocComment) BlockComment(com.github.javaparser.ast.comments.BlockComment) LineComment(com.github.javaparser.ast.comments.LineComment) Comment(com.github.javaparser.ast.comments.Comment) JavadocComment(com.github.javaparser.ast.comments.JavadocComment) InitializerDeclaration(com.github.javaparser.ast.body.InitializerDeclaration)

Example 4 with JavadocComment

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;
}
Also used : JavadocComment(com.github.javaparser.ast.comments.JavadocComment) BlockComment(com.github.javaparser.ast.comments.BlockComment) LineComment(com.github.javaparser.ast.comments.LineComment) Comment(com.github.javaparser.ast.comments.Comment) JavadocComment(com.github.javaparser.ast.comments.JavadocComment) AnnotationDeclaration(com.github.javaparser.ast.body.AnnotationDeclaration) BodyDeclaration(com.github.javaparser.ast.body.BodyDeclaration)

Example 5 with JavadocComment

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;
}
Also used : JavadocComment(com.github.javaparser.ast.comments.JavadocComment) BlockComment(com.github.javaparser.ast.comments.BlockComment) LineComment(com.github.javaparser.ast.comments.LineComment) Comment(com.github.javaparser.ast.comments.Comment) JavadocComment(com.github.javaparser.ast.comments.JavadocComment) EmptyMemberDeclaration(com.github.javaparser.ast.body.EmptyMemberDeclaration)

Aggregations

JavadocComment (com.github.javaparser.ast.comments.JavadocComment)25 Comment (com.github.javaparser.ast.comments.Comment)16 BlockComment (com.github.javaparser.ast.comments.BlockComment)14 LineComment (com.github.javaparser.ast.comments.LineComment)14 Test (org.junit.Test)7 BodyDeclaration (com.github.javaparser.ast.body.BodyDeclaration)4 ClassOrInterfaceDeclaration (com.github.javaparser.ast.body.ClassOrInterfaceDeclaration)4 TypeParameter (com.github.javaparser.ast.TypeParameter)3 MultiTypeParameter (com.github.javaparser.ast.body.MultiTypeParameter)3 AnnotationDeclaration (com.github.javaparser.ast.body.AnnotationDeclaration)2 EnumConstantDeclaration (com.github.javaparser.ast.body.EnumConstantDeclaration)2 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)2 Parameter (com.github.javaparser.ast.body.Parameter)2 CsmElement (com.github.javaparser.printer.concretesyntaxmodel.CsmElement)2 CsmToken (com.github.javaparser.printer.concretesyntaxmodel.CsmToken)2 Javadoc (act.apidoc.javadoc.Javadoc)1 ParseProblemException (com.github.javaparser.ParseProblemException)1 com.github.javaparser.ast (com.github.javaparser.ast)1 CompilationUnit (com.github.javaparser.ast.CompilationUnit)1 Modifier (com.github.javaparser.ast.Modifier)1