Search in sources :

Example 6 with Type

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

the class StatementGenerator method printMultiCatch.

private void printMultiCatch(CatchClause node) {
    SingleVariableDeclaration exception = node.getException();
    for (Type exceptionType : ((UnionType) exception.getType()).getTypes()) {
        buffer.append("@catch (");
        exceptionType.accept(this);
        buffer.append(" *");
        buffer.append(nameTable.getVariableQualifiedName(exception.getVariableElement()));
        buffer.append(") {\n");
        printStatements(node.getBody().getStatements());
        buffer.append("}\n");
    }
}
Also used : UnionType(com.google.devtools.j2objc.ast.UnionType) QualifiedType(com.google.devtools.j2objc.ast.QualifiedType) PrimitiveType(com.google.devtools.j2objc.ast.PrimitiveType) IntersectionType(com.google.devtools.j2objc.ast.IntersectionType) UnionType(com.google.devtools.j2objc.ast.UnionType) Type(com.google.devtools.j2objc.ast.Type) NameQualifiedType(com.google.devtools.j2objc.ast.NameQualifiedType) SimpleType(com.google.devtools.j2objc.ast.SimpleType) ArrayType(com.google.devtools.j2objc.ast.ArrayType) SingleVariableDeclaration(com.google.devtools.j2objc.ast.SingleVariableDeclaration)

Example 7 with Type

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

the class TreeConverter method convertArrayType.

private static TreeNode convertArrayType(org.eclipse.jdt.core.dom.ArrayType node) {
    ArrayType newNode = new ArrayType();
    convertType(node, newNode);
    // This could also be implemented as an element type and dimensions for JLS8, but we mainly deal
    // with ArrayTypes through the ArrayType(ITypeBinding) initializer, in the ArrayRewriter, for
    // which we use ITypeBinding's componentType anyway.
    Type componentType = (Type) Type.newType(BindingConverter.getType(node.resolveBinding().getComponentType()));
    return newNode.setComponentType(componentType);
}
Also used : ArrayType(com.google.devtools.j2objc.ast.ArrayType) ParameterizedType(com.google.devtools.j2objc.ast.ParameterizedType) QualifiedType(com.google.devtools.j2objc.ast.QualifiedType) AnnotatableType(com.google.devtools.j2objc.ast.AnnotatableType) Type(com.google.devtools.j2objc.ast.Type) NameQualifiedType(com.google.devtools.j2objc.ast.NameQualifiedType) SimpleType(com.google.devtools.j2objc.ast.SimpleType) DeclaredType(javax.lang.model.type.DeclaredType) ArrayType(com.google.devtools.j2objc.ast.ArrayType) PrimitiveType(com.google.devtools.j2objc.ast.PrimitiveType) IntersectionType(com.google.devtools.j2objc.ast.IntersectionType) UnionType(com.google.devtools.j2objc.ast.UnionType) ExecutableType(javax.lang.model.type.ExecutableType)

Example 8 with Type

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

the class TreeConverter method convertSingleVariableDeclaration.

private static TreeNode convertSingleVariableDeclaration(org.eclipse.jdt.core.dom.SingleVariableDeclaration node) {
    SingleVariableDeclaration newNode = new SingleVariableDeclaration();
    convertVariableDeclaration(node, newNode);
    for (Object modifier : node.modifiers()) {
        if (modifier instanceof org.eclipse.jdt.core.dom.Annotation) {
            newNode.addAnnotation((Annotation) TreeConverter.convert(modifier));
        }
    }
    return newNode.setType((Type) TreeConverter.convert(node.getType())).setIsVarargs(node.isVarargs());
}
Also used : ParameterizedType(com.google.devtools.j2objc.ast.ParameterizedType) QualifiedType(com.google.devtools.j2objc.ast.QualifiedType) AnnotatableType(com.google.devtools.j2objc.ast.AnnotatableType) Type(com.google.devtools.j2objc.ast.Type) NameQualifiedType(com.google.devtools.j2objc.ast.NameQualifiedType) SimpleType(com.google.devtools.j2objc.ast.SimpleType) DeclaredType(javax.lang.model.type.DeclaredType) ArrayType(com.google.devtools.j2objc.ast.ArrayType) PrimitiveType(com.google.devtools.j2objc.ast.PrimitiveType) IntersectionType(com.google.devtools.j2objc.ast.IntersectionType) UnionType(com.google.devtools.j2objc.ast.UnionType) ExecutableType(javax.lang.model.type.ExecutableType) SingleVariableDeclaration(com.google.devtools.j2objc.ast.SingleVariableDeclaration) NormalAnnotation(com.google.devtools.j2objc.ast.NormalAnnotation) PropertyAnnotation(com.google.devtools.j2objc.ast.PropertyAnnotation) Annotation(com.google.devtools.j2objc.ast.Annotation) SingleMemberAnnotation(com.google.devtools.j2objc.ast.SingleMemberAnnotation) MarkerAnnotation(com.google.devtools.j2objc.ast.MarkerAnnotation)

Aggregations

Type (com.google.devtools.j2objc.ast.Type)8 ArrayType (com.google.devtools.j2objc.ast.ArrayType)7 PrimitiveType (com.google.devtools.j2objc.ast.PrimitiveType)7 SimpleType (com.google.devtools.j2objc.ast.SimpleType)7 UnionType (com.google.devtools.j2objc.ast.UnionType)7 ParameterizedType (com.google.devtools.j2objc.ast.ParameterizedType)6 DeclaredType (javax.lang.model.type.DeclaredType)6 ExecutableType (javax.lang.model.type.ExecutableType)6 IntersectionType (com.google.devtools.j2objc.ast.IntersectionType)4 NameQualifiedType (com.google.devtools.j2objc.ast.NameQualifiedType)4 QualifiedType (com.google.devtools.j2objc.ast.QualifiedType)4 AnnotatableType (com.google.devtools.j2objc.ast.AnnotatableType)3 SingleVariableDeclaration (com.google.devtools.j2objc.ast.SingleVariableDeclaration)3 VarSymbol (com.sun.tools.javac.code.Symbol.VarSymbol)2 Annotation (com.google.devtools.j2objc.ast.Annotation)1 CastExpression (com.google.devtools.j2objc.ast.CastExpression)1 MarkerAnnotation (com.google.devtools.j2objc.ast.MarkerAnnotation)1 NormalAnnotation (com.google.devtools.j2objc.ast.NormalAnnotation)1 PropertyAnnotation (com.google.devtools.j2objc.ast.PropertyAnnotation)1 SingleMemberAnnotation (com.google.devtools.j2objc.ast.SingleMemberAnnotation)1