use of com.github.javaparser.ast.expr.MemberValuePair in project checker-framework by typetools.
the class StubParser method getAnnotation.
/**
* Convert {@code annotation} into an AnnotationMirror. Returns null if the annotation isn't
* supported by the checker or if some error occurred while converting it.
*/
private AnnotationMirror getAnnotation(AnnotationExpr annotation, Map<String, AnnotationMirror> allStubAnnotations) {
AnnotationMirror annoMirror;
if (annotation instanceof MarkerAnnotationExpr) {
String annoName = ((MarkerAnnotationExpr) annotation).getNameAsString();
annoMirror = allStubAnnotations.get(annoName);
} else if (annotation instanceof NormalAnnotationExpr) {
NormalAnnotationExpr nrmanno = (NormalAnnotationExpr) annotation;
String annoName = nrmanno.getNameAsString();
annoMirror = allStubAnnotations.get(annoName);
if (annoMirror == null) {
// Not a supported qualifier -> ignore
return null;
}
AnnotationBuilder builder = new AnnotationBuilder(processingEnv, annoMirror);
List<MemberValuePair> pairs = nrmanno.getPairs();
if (pairs != null) {
for (MemberValuePair mvp : pairs) {
String member = mvp.getNameAsString();
Expression exp = mvp.getValue();
boolean success = handleExpr(builder, member, exp);
if (!success) {
stubWarn("Annotation expression, %s, could not be processed for annotation: %s. ", exp, annotation);
return null;
}
}
}
return builder.build();
} else if (annotation instanceof SingleMemberAnnotationExpr) {
SingleMemberAnnotationExpr sglanno = (SingleMemberAnnotationExpr) annotation;
String annoName = sglanno.getNameAsString();
annoMirror = allStubAnnotations.get(annoName);
if (annoMirror == null) {
// Not a supported qualifier -> ignore
return null;
}
AnnotationBuilder builder = new AnnotationBuilder(processingEnv, annoMirror);
Expression valexpr = sglanno.getMemberValue();
boolean success = handleExpr(builder, "value", valexpr);
if (!success) {
stubWarn("Annotation expression, %s, could not be processed for annotation: %s. ", valexpr, annotation);
return null;
}
return builder.build();
} else {
ErrorReporter.errorAbort("StubParser: unknown annotation type: " + annotation);
// dead code
annoMirror = null;
}
return annoMirror;
}
use of com.github.javaparser.ast.expr.MemberValuePair in project javaparser by javaparser.
the class VoidVisitorAdapter method visit.
@Override
public void visit(final NormalAnnotationExpr n, final A arg) {
visitComment(n.getComment(), arg);
n.getName().accept(this, arg);
if (n.getPairs() != null) {
for (final MemberValuePair m : n.getPairs()) {
m.accept(this, arg);
}
}
}
Aggregations