Search in sources :

Example 6 with JavadocComment

use of com.github.javaparser.ast.comments.JavadocComment in project javaparser by javaparser.

the class CloneVisitor method visit.

@Override
public Node visit(EmptyTypeDeclaration _n, Object _arg) {
    JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
    Comment comment = cloneNodes(_n.getComment(), _arg);
    EmptyTypeDeclaration r = new EmptyTypeDeclaration(_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) EmptyTypeDeclaration(com.github.javaparser.ast.body.EmptyTypeDeclaration)

Example 7 with JavadocComment

use of com.github.javaparser.ast.comments.JavadocComment in project javaparser by javaparser.

the class CloneVisitor method visit.

@Override
public Node visit(EnumConstantDeclaration _n, Object _arg) {
    JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
    List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
    List<Expression> args = visit(_n.getArgs(), _arg);
    List<BodyDeclaration> classBody = visit(_n.getClassBody(), _arg);
    Comment comment = cloneNodes(_n.getComment(), _arg);
    EnumConstantDeclaration r = new EnumConstantDeclaration(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), annotations, _n.getName(), args, classBody);
    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) EnumConstantDeclaration(com.github.javaparser.ast.body.EnumConstantDeclaration) JavadocComment(com.github.javaparser.ast.comments.JavadocComment) BodyDeclaration(com.github.javaparser.ast.body.BodyDeclaration)

Example 8 with JavadocComment

use of com.github.javaparser.ast.comments.JavadocComment in project javaparser by javaparser.

the class CloneVisitor method visit.

@Override
public Node visit(MethodDeclaration _n, Object _arg) {
    JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
    List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
    List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg);
    Type type_ = cloneNodes(_n.getType(), _arg);
    List<Parameter> parameters = visit(_n.getParameters(), _arg);
    List<NameExpr> throws_ = visit(_n.getThrows(), _arg);
    BlockStmt block = cloneNodes(_n.getBody(), _arg);
    Comment comment = cloneNodes(_n.getComment(), _arg);
    MethodDeclaration r = new MethodDeclaration(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), _n.getModifiers(), annotations, typeParameters, type_, _n.getName(), parameters, _n.getArrayCount(), throws_, 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) TypeParameter(com.github.javaparser.ast.TypeParameter) MultiTypeParameter(com.github.javaparser.ast.body.MultiTypeParameter) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) JavadocComment(com.github.javaparser.ast.comments.JavadocComment) Parameter(com.github.javaparser.ast.body.Parameter) TypeParameter(com.github.javaparser.ast.TypeParameter) MultiTypeParameter(com.github.javaparser.ast.body.MultiTypeParameter)

Example 9 with JavadocComment

use of com.github.javaparser.ast.comments.JavadocComment in project javaparser by javaparser.

the class NodeTest method hasJavaDocCommentPositiveCaseWithSetComment.

@Test
public void hasJavaDocCommentPositiveCaseWithSetComment() {
    ClassOrInterfaceDeclaration decl = new ClassOrInterfaceDeclaration(EnumSet.noneOf(Modifier.class), false, "Foo");
    decl.setComment(new JavadocComment("A comment"));
    assertEquals(true, decl.hasJavaDocComment());
}
Also used : JavadocComment(com.github.javaparser.ast.comments.JavadocComment) ClassOrInterfaceDeclaration(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration) Test(org.junit.Test)

Example 10 with JavadocComment

use of com.github.javaparser.ast.comments.JavadocComment in project javaparser by javaparser.

the class JavadocTest method toCommentForEmptyJavadoc.

@Test
public void toCommentForEmptyJavadoc() {
    Javadoc javadoc = new Javadoc(new JavadocDescription());
    assertEquals(new JavadocComment("" + EOL + "\t\t "), javadoc.toComment("\t\t"));
}
Also used : JavadocComment(com.github.javaparser.ast.comments.JavadocComment) JavadocDescription(com.github.javaparser.javadoc.description.JavadocDescription) Test(org.junit.Test)

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