Search in sources :

Example 6 with AnnotationTypeMemberDeclaration

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

the class TreeConverter method convertAnnotationTypeDeclaration.

private TreeNode convertAnnotationTypeDeclaration(JCTree.JCClassDecl node) {
    AnnotationTypeDeclaration newNode = new AnnotationTypeDeclaration();
    convertBodyDeclaration(node, node.getModifiers(), newNode, node.sym);
    for (JCTree bodyDecl : node.getMembers()) {
        if (bodyDecl.getKind() == Kind.METHOD) {
            JCTree.JCMethodDecl methodDecl = (JCTree.JCMethodDecl) bodyDecl;
            AnnotationTypeMemberDeclaration newMember = new AnnotationTypeMemberDeclaration().setDefault((Expression) convert(methodDecl.defaultValue)).setExecutableElement(methodDecl.sym);
            newMember.setModifiers((int) methodDecl.getModifiers().flags).setAnnotations(convertAnnotations(methodDecl.mods)).setJavadoc((Javadoc) getAssociatedJavaDoc(methodDecl, methodDecl.sym));
            newNode.addBodyDeclaration(newMember);
        } else {
            newNode.addBodyDeclaration((BodyDeclaration) convert(bodyDecl));
        }
    }
    return newNode.setName(convertSimpleName(node.sym, node.type, getNamePosition(node))).setTypeElement(node.sym);
}
Also used : AnnotationTypeMemberDeclaration(com.google.devtools.j2objc.ast.AnnotationTypeMemberDeclaration) PostfixExpression(com.google.devtools.j2objc.ast.PostfixExpression) InstanceofExpression(com.google.devtools.j2objc.ast.InstanceofExpression) Expression(com.google.devtools.j2objc.ast.Expression) ConditionalExpression(com.google.devtools.j2objc.ast.ConditionalExpression) InfixExpression(com.google.devtools.j2objc.ast.InfixExpression) ParenthesizedExpression(com.google.devtools.j2objc.ast.ParenthesizedExpression) LambdaExpression(com.google.devtools.j2objc.ast.LambdaExpression) PrefixExpression(com.google.devtools.j2objc.ast.PrefixExpression) ThisExpression(com.google.devtools.j2objc.ast.ThisExpression) FunctionalExpression(com.google.devtools.j2objc.ast.FunctionalExpression) CastExpression(com.google.devtools.j2objc.ast.CastExpression) VariableDeclarationExpression(com.google.devtools.j2objc.ast.VariableDeclarationExpression) AnnotationTypeDeclaration(com.google.devtools.j2objc.ast.AnnotationTypeDeclaration) JCTree(com.sun.tools.javac.tree.JCTree)

Aggregations

AnnotationTypeMemberDeclaration (com.google.devtools.j2objc.ast.AnnotationTypeMemberDeclaration)6 GeneratedExecutableElement (com.google.devtools.j2objc.types.GeneratedExecutableElement)4 ExecutableElement (javax.lang.model.element.ExecutableElement)4 TypeElement (javax.lang.model.element.TypeElement)3 GeneratedVariableElement (com.google.devtools.j2objc.types.GeneratedVariableElement)2 VariableElement (javax.lang.model.element.VariableElement)2 AnnotationTypeDeclaration (com.google.devtools.j2objc.ast.AnnotationTypeDeclaration)1 Block (com.google.devtools.j2objc.ast.Block)1 BodyDeclaration (com.google.devtools.j2objc.ast.BodyDeclaration)1 CastExpression (com.google.devtools.j2objc.ast.CastExpression)1 ConditionalExpression (com.google.devtools.j2objc.ast.ConditionalExpression)1 Expression (com.google.devtools.j2objc.ast.Expression)1 FieldDeclaration (com.google.devtools.j2objc.ast.FieldDeclaration)1 FunctionalExpression (com.google.devtools.j2objc.ast.FunctionalExpression)1 InfixExpression (com.google.devtools.j2objc.ast.InfixExpression)1 InstanceofExpression (com.google.devtools.j2objc.ast.InstanceofExpression)1 LambdaExpression (com.google.devtools.j2objc.ast.LambdaExpression)1 MethodDeclaration (com.google.devtools.j2objc.ast.MethodDeclaration)1 ParenthesizedExpression (com.google.devtools.j2objc.ast.ParenthesizedExpression)1 PostfixExpression (com.google.devtools.j2objc.ast.PostfixExpression)1