Search in sources :

Example 6 with EnumDeclaration

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

the class TranslationUtil method getInterfaceTypes.

public static List<TypeElement> getInterfaceTypes(AbstractTypeDeclaration node) {
    // Use the AST as the source of truth where possible.
    List<? extends TypeMirror> astInterfaces = null;
    if (node instanceof TypeDeclaration) {
        astInterfaces = ((TypeDeclaration) node).getSuperInterfaceTypeMirrors();
    } else if (node instanceof EnumDeclaration) {
        astInterfaces = ((EnumDeclaration) node).getSuperInterfaceTypeMirrors();
    } else {
        // AnnotationTypeDeclaration
        return ElementUtil.getInterfaces(node.getTypeElement());
    }
    List<TypeElement> result = new ArrayList<>();
    for (TypeMirror typeMirror : astInterfaces) {
        result.add(TypeUtil.asTypeElement(typeMirror));
    }
    return result;
}
Also used : TypeMirror(javax.lang.model.type.TypeMirror) TypeElement(javax.lang.model.element.TypeElement) ArrayList(java.util.ArrayList) TypeDeclaration(com.google.devtools.j2objc.ast.TypeDeclaration) AbstractTypeDeclaration(com.google.devtools.j2objc.ast.AbstractTypeDeclaration) EnumDeclaration(com.google.devtools.j2objc.ast.EnumDeclaration)

Aggregations

EnumDeclaration (com.google.devtools.j2objc.ast.EnumDeclaration)6 EnumConstantDeclaration (com.google.devtools.j2objc.ast.EnumConstantDeclaration)4 VariableDeclarationFragment (com.google.devtools.j2objc.ast.VariableDeclarationFragment)2 VariableElement (javax.lang.model.element.VariableElement)2 TypeMirror (javax.lang.model.type.TypeMirror)2 AbstractTypeDeclaration (com.google.devtools.j2objc.ast.AbstractTypeDeclaration)1 ArrayInitializer (com.google.devtools.j2objc.ast.ArrayInitializer)1 Block (com.google.devtools.j2objc.ast.Block)1 BodyDeclaration (com.google.devtools.j2objc.ast.BodyDeclaration)1 Initializer (com.google.devtools.j2objc.ast.Initializer)1 TreeNode (com.google.devtools.j2objc.ast.TreeNode)1 TypeDeclaration (com.google.devtools.j2objc.ast.TypeDeclaration)1 JCTree (com.sun.tools.javac.tree.JCTree)1 ArrayList (java.util.ArrayList)1 TypeElement (javax.lang.model.element.TypeElement)1