Search in sources :

Example 11 with Annotation

use of scenelib.annotations.Annotation in project checker-framework by typetools.

the class ToIndexFileConverter method visitType.

/**
 * Copies information from an AST type node to an {@link ATypeElement}.
 */
private Void visitType(Type type, final ATypeElement elem) {
    List<AnnotationExpr> exprs = type.getAnnotations();
    if (exprs != null) {
        for (AnnotationExpr expr : exprs) {
            Annotation anno = extractAnnotation(expr);
            if (anno != null) {
                elem.tlAnnotationsHere.add(anno);
            }
        }
    }
    visitInnerTypes(type, elem);
    return null;
}
Also used : AnnotationExpr(com.github.javaparser.ast.expr.AnnotationExpr) Annotation(scenelib.annotations.Annotation)

Example 12 with Annotation

use of scenelib.annotations.Annotation in project checker-framework by typetools.

the class ToIndexFileConverter method visitDecl.

/**
 * Copies information from an AST declaration node to an {@link ADeclaration}. Called by
 * visitors for BodyDeclaration subclasses.
 */
private Void visitDecl(BodyDeclaration<?> decl, ADeclaration elem) {
    NodeList<AnnotationExpr> annoExprs = decl.getAnnotations();
    if (annoExprs != null) {
        for (AnnotationExpr annoExpr : annoExprs) {
            Annotation anno = extractAnnotation(annoExpr);
            elem.tlAnnotationsHere.add(anno);
        }
    }
    return null;
}
Also used : AnnotationExpr(com.github.javaparser.ast.expr.AnnotationExpr) Annotation(scenelib.annotations.Annotation)

Example 13 with Annotation

use of scenelib.annotations.Annotation in project checker-framework by typetools.

the class ToIndexFileConverter method visit.

@Override
public Void visit(ConstructorDeclaration decl, AElement elem) {
    List<Parameter> params = decl.getParameters();
    List<AnnotationExpr> rcvrAnnos = decl.getAnnotations();
    BlockStmt body = decl.getBody();
    StringBuilder sb = new StringBuilder("<init>(");
    AClass clazz = (AClass) elem;
    AMethod method;
    // an empty list.
    if (params != null) {
        for (Parameter param : params) {
            Type ptype = param.getType();
            sb.append(getJVML(ptype));
        }
    }
    sb.append(")V");
    method = clazz.methods.vivify(sb.toString());
    visitDecl(decl, method);
    if (params != null) {
        for (int i = 0; i < params.size(); i++) {
            Parameter param = params.get(i);
            AField field = method.parameters.vivify(i);
            visitType(param.getType(), field.type);
        }
    }
    if (rcvrAnnos != null) {
        for (AnnotationExpr expr : rcvrAnnos) {
            Annotation anno = extractAnnotation(expr);
            method.receiver.tlAnnotationsHere.add(anno);
        }
    }
    return body == null ? null : body.accept(this, method);
// return super.visit(decl, elem);
}
Also used : ClassOrInterfaceType(com.github.javaparser.ast.type.ClassOrInterfaceType) Type(com.github.javaparser.ast.type.Type) ReferenceType(com.github.javaparser.ast.type.ReferenceType) VoidType(com.github.javaparser.ast.type.VoidType) ArrayType(com.github.javaparser.ast.type.ArrayType) PrimitiveType(com.github.javaparser.ast.type.PrimitiveType) WildcardType(com.github.javaparser.ast.type.WildcardType) AnnotationExpr(com.github.javaparser.ast.expr.AnnotationExpr) BlockStmt(com.github.javaparser.ast.stmt.BlockStmt) ReceiverParameter(com.github.javaparser.ast.body.ReceiverParameter) Parameter(com.github.javaparser.ast.body.Parameter) TypeParameter(com.github.javaparser.ast.type.TypeParameter) AClass(scenelib.annotations.el.AClass) AMethod(scenelib.annotations.el.AMethod) Annotation(scenelib.annotations.Annotation) AField(scenelib.annotations.el.AField)

Aggregations

Annotation (scenelib.annotations.Annotation)13 AnnotationExpr (com.github.javaparser.ast.expr.AnnotationExpr)5 AClass (scenelib.annotations.el.AClass)4 HashSet (java.util.HashSet)3 AField (scenelib.annotations.el.AField)3 AMethod (scenelib.annotations.el.AMethod)3 Parameter (com.github.javaparser.ast.body.Parameter)2 ReceiverParameter (com.github.javaparser.ast.body.ReceiverParameter)2 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)2 ArrayType (com.github.javaparser.ast.type.ArrayType)2 ClassOrInterfaceType (com.github.javaparser.ast.type.ClassOrInterfaceType)2 PrimitiveType (com.github.javaparser.ast.type.PrimitiveType)2 ReferenceType (com.github.javaparser.ast.type.ReferenceType)2 Type (com.github.javaparser.ast.type.Type)2 TypeParameter (com.github.javaparser.ast.type.TypeParameter)2 VoidType (com.github.javaparser.ast.type.VoidType)2 WildcardType (com.github.javaparser.ast.type.WildcardType)2 ArrayList (java.util.ArrayList)2 AnnotationMirror (javax.lang.model.element.AnnotationMirror)2 AnnotatedArrayType (org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedArrayType)2