Search in sources :

Example 11 with JavadocComment

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

the class JavadocTest method toCommentForJavadocWithTwoLinesOfJustDescriptionAndOneBlockTag.

@Test
public void toCommentForJavadocWithTwoLinesOfJustDescriptionAndOneBlockTag() {
    Javadoc javadoc = new Javadoc(JavadocDescription.parseText("first line" + EOL + "second line"));
    javadoc.addBlockTag("foo", "something useful");
    assertEquals(new JavadocComment("" + EOL + "\t\t * first line" + EOL + "\t\t * second line" + EOL + "\t\t * " + EOL + "\t\t * @foo something useful" + EOL + "\t\t "), javadoc.toComment("\t\t"));
}
Also used : JavadocComment(com.github.javaparser.ast.comments.JavadocComment) Test(org.junit.Test)

Example 12 with JavadocComment

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

the class ApiManager method exploreDeclaration.

private void exploreDeclaration(ClassOrInterfaceDeclaration classDeclaration, Map<String, Javadoc> methodJavaDocs, String prefix) {
    String className = classDeclaration.getName();
    String newPrefix = S.blank(prefix) ? className : S.concat(prefix, ".", className);
    for (Node node : classDeclaration.getChildrenNodes()) {
        if (node instanceof ClassOrInterfaceDeclaration) {
            exploreDeclaration((ClassOrInterfaceDeclaration) node, methodJavaDocs, newPrefix);
        } else if (node instanceof MethodDeclaration) {
            MethodDeclaration methodDeclaration = (MethodDeclaration) node;
            List<AnnotationExpr> annoList = methodDeclaration.getAnnotations();
            boolean needJavadoc = false;
            if (null != annoList && !annoList.isEmpty()) {
                for (AnnotationExpr anno : annoList) {
                    String annoName = anno.getName().getName();
                    if (actionAnnotations.contains(annoName)) {
                        needJavadoc = true;
                        break;
                    }
                }
            }
            if (!needJavadoc) {
                continue;
            }
            Comment comment = methodDeclaration.getComment();
            if (!(comment instanceof JavadocComment)) {
                continue;
            }
            JavadocComment javadocComment = (JavadocComment) comment;
            Javadoc javadoc = JavadocParser.parse(javadocComment);
            methodJavaDocs.put(S.concat(newPrefix, ".", methodDeclaration.getName()), javadoc);
        }
    }
}
Also used : JavadocComment(com.github.javaparser.ast.comments.JavadocComment) Comment(com.github.javaparser.ast.comments.Comment) JavadocComment(com.github.javaparser.ast.comments.JavadocComment) AnnotationExpr(com.github.javaparser.ast.expr.AnnotationExpr) ClassOrInterfaceDeclaration(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) Node(com.github.javaparser.ast.Node) Javadoc(act.apidoc.javadoc.Javadoc)

Example 13 with JavadocComment

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

the class MbeASTVisitor method visit.

@Override
public void visit(final MethodDeclaration n, final Void arg) {
    final String signature = n.getDeclarationAsString(false, false);
    methods.add(signature);
    final Comment c = n.getComment();
    if (c instanceof JavadocComment) {
        methodJavadoc.put(signature, 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 14 with JavadocComment

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

the class ModifierVisitor method visit.

@Override
@Generated("com.github.javaparser.generator.core.visitor.ModifierVisitorGenerator")
public Visitable visit(final JavadocComment n, final A arg) {
    Comment comment = n.getComment().map(s -> (Comment) s.accept(this, arg)).orElse(null);
    n.setComment(comment);
    return n;
}
Also used : com.github.javaparser.ast.type(com.github.javaparser.ast.type) Pair(com.github.javaparser.utils.Pair) ArrayList(java.util.ArrayList) com.github.javaparser.ast.stmt(com.github.javaparser.ast.stmt) com.github.javaparser.ast.body(com.github.javaparser.ast.body) JavadocComment(com.github.javaparser.ast.comments.JavadocComment) Generated(javax.annotation.Generated) List(java.util.List) LineComment(com.github.javaparser.ast.comments.LineComment) Optional(java.util.Optional) com.github.javaparser.ast(com.github.javaparser.ast) Comment(com.github.javaparser.ast.comments.Comment) com.github.javaparser.ast.modules(com.github.javaparser.ast.modules) com.github.javaparser.ast.expr(com.github.javaparser.ast.expr) BlockComment(com.github.javaparser.ast.comments.BlockComment) JavadocComment(com.github.javaparser.ast.comments.JavadocComment) LineComment(com.github.javaparser.ast.comments.LineComment) Comment(com.github.javaparser.ast.comments.Comment) BlockComment(com.github.javaparser.ast.comments.BlockComment) Generated(javax.annotation.Generated)

Example 15 with JavadocComment

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

the class CloneVisitor method visit.

@Override
public Node visit(AnnotationMemberDeclaration _n, Object _arg) {
    JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
    List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
    Type type_ = cloneNodes(_n.getType(), _arg);
    Expression defaultValue = cloneNodes(_n.getDefaultValue(), _arg);
    Comment comment = cloneNodes(_n.getComment(), _arg);
    AnnotationMemberDeclaration r = new AnnotationMemberDeclaration(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), _n.getModifiers(), annotations, type_, _n.getName(), defaultValue);
    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) AnnotationMemberDeclaration(com.github.javaparser.ast.body.AnnotationMemberDeclaration)

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