Search in sources :

Example 36 with FunctionInvocation

use of com.google.devtools.j2objc.ast.FunctionInvocation in project j2objc by google.

the class TranslationUtil method createAnnotation.

public Expression createAnnotation(AnnotationMirror annotationMirror) {
    DeclaredType type = annotationMirror.getAnnotationType();
    TypeElement typeElem = (TypeElement) type.asElement();
    FunctionElement element = new FunctionElement("create_" + nameTable.getFullName(typeElem), type, typeElem);
    FunctionInvocation invocation = new FunctionInvocation(element, type);
    Map<? extends ExecutableElement, ? extends AnnotationValue> values = typeUtil.elementUtil().getElementValuesWithDefaults(annotationMirror);
    for (ExecutableElement member : ElementUtil.getSortedAnnotationMembers(typeElem)) {
        TypeMirror valueType = member.getReturnType();
        element.addParameters(valueType);
        invocation.addArgument(createAnnotationValue(valueType, values.get(member)));
    }
    return invocation;
}
Also used : FunctionElement(com.google.devtools.j2objc.types.FunctionElement) FunctionInvocation(com.google.devtools.j2objc.ast.FunctionInvocation) TypeMirror(javax.lang.model.type.TypeMirror) TypeElement(javax.lang.model.element.TypeElement) ExecutableElement(javax.lang.model.element.ExecutableElement) DeclaredType(javax.lang.model.type.DeclaredType)

Aggregations

FunctionInvocation (com.google.devtools.j2objc.ast.FunctionInvocation)36 FunctionElement (com.google.devtools.j2objc.types.FunctionElement)26 TypeMirror (javax.lang.model.type.TypeMirror)23 Expression (com.google.devtools.j2objc.ast.Expression)21 PrefixExpression (com.google.devtools.j2objc.ast.PrefixExpression)14 ThisExpression (com.google.devtools.j2objc.ast.ThisExpression)13 ExecutableElement (javax.lang.model.element.ExecutableElement)11 TypeElement (javax.lang.model.element.TypeElement)11 CastExpression (com.google.devtools.j2objc.ast.CastExpression)10 ExpressionStatement (com.google.devtools.j2objc.ast.ExpressionStatement)10 ParenthesizedExpression (com.google.devtools.j2objc.ast.ParenthesizedExpression)10 InfixExpression (com.google.devtools.j2objc.ast.InfixExpression)9 SimpleName (com.google.devtools.j2objc.ast.SimpleName)9 PointerType (com.google.devtools.j2objc.types.PointerType)9 VariableElement (javax.lang.model.element.VariableElement)9 CommaExpression (com.google.devtools.j2objc.ast.CommaExpression)8 GeneratedExecutableElement (com.google.devtools.j2objc.types.GeneratedExecutableElement)8 GeneratedVariableElement (com.google.devtools.j2objc.types.GeneratedVariableElement)6 InstanceofExpression (com.google.devtools.j2objc.ast.InstanceofExpression)5 NativeExpression (com.google.devtools.j2objc.ast.NativeExpression)5