use of com.github.javaparser.ast.expr.AnnotationExpr in project javaparser by javaparser.
the class CloneVisitor method visit.
@Override
public Node visit(ArrayCreationLevel _n, Object _arg) {
List<AnnotationExpr> ann = visit(_n.getAnnotations(), _arg);
Expression dimension_ = cloneNodes(_n.getDimension(), _arg);
ArrayCreationLevel r = new ArrayCreationLevel(_n.getRange(), dimension_, ann);
Comment comment = cloneNodes(_n.getComment(), _arg);
r.setComment(comment);
return r;
}
use of com.github.javaparser.ast.expr.AnnotationExpr in project javaparser by javaparser.
the class CloneVisitor method visit.
@Override
public Node visit(IntersectionType _n, Object _arg) {
List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
List<ReferenceType> elements = visit(_n.getElements(), _arg);
IntersectionType r = new IntersectionType(_n.getRange(), elements);
Comment comment = cloneNodes(_n.getComment(), _arg);
r.setComment(comment);
r.setAnnotations(annotations);
return r;
}
use of com.github.javaparser.ast.expr.AnnotationExpr in project javaparser by javaparser.
the class ModifierVisitorAdapter method visit.
@Override
public Node visit(final VariableDeclarationExpr n, final A arg) {
visitComment(n, arg);
final List<AnnotationExpr> annotations = n.getAnnotations();
if (annotations != null) {
for (int i = 0; i < annotations.size(); i++) {
annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg));
}
removeNulls(annotations);
}
final Type type = (Type) n.getElementType().accept(this, arg);
if (type == null) {
return null;
}
n.setElementType(type);
final List<VariableDeclarator> vars = n.getVariables();
for (int i = 0; i < vars.size(); ) {
final VariableDeclarator decl = (VariableDeclarator) vars.get(i).accept(this, arg);
if (decl == null) {
vars.remove(i);
} else {
vars.set(i++, decl);
}
}
if (vars.isEmpty()) {
return null;
}
return n;
}
use of com.github.javaparser.ast.expr.AnnotationExpr 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);
}
}
}
use of com.github.javaparser.ast.expr.AnnotationExpr in project checker-framework by typetools.
the class StubParser method annotateDecl.
private void annotateDecl(Map<String, Set<AnnotationMirror>> declAnnos, Element elt, List<AnnotationExpr> annotations) {
if (annotations == null) {
return;
}
Set<AnnotationMirror> annos = AnnotationUtils.createAnnotationSet();
for (AnnotationExpr annotation : annotations) {
AnnotationMirror annoMirror = getAnnotation(annotation, allStubAnnotations);
if (annoMirror != null) {
Target target = annoMirror.getAnnotationType().asElement().getAnnotation(Target.class);
// Only add the declaration annotation if the annotation applies to the element.
if (AnnotationUtils.getElementKindsForTarget(target).contains(elt.getKind())) {
annos.add(annoMirror);
}
}
}
String key = ElementUtils.getVerboseName(elt);
putOrAddToMap(declAnnos, key, annos);
}
Aggregations