Search in sources :

Example 1 with AnnotationTypeDeclaration

use of com.google.devtools.j2objc.ast.AnnotationTypeDeclaration 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

AnnotationTypeDeclaration (com.google.devtools.j2objc.ast.AnnotationTypeDeclaration)1 AnnotationTypeMemberDeclaration (com.google.devtools.j2objc.ast.AnnotationTypeMemberDeclaration)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 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 ParenthesizedExpression (com.google.devtools.j2objc.ast.ParenthesizedExpression)1 PostfixExpression (com.google.devtools.j2objc.ast.PostfixExpression)1 PrefixExpression (com.google.devtools.j2objc.ast.PrefixExpression)1 ThisExpression (com.google.devtools.j2objc.ast.ThisExpression)1 VariableDeclarationExpression (com.google.devtools.j2objc.ast.VariableDeclarationExpression)1 JCTree (com.sun.tools.javac.tree.JCTree)1