Search in sources :

Example 1 with ArrayType

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

the class TreeConverter method convertArrayType.

private TreeNode convertArrayType(JCTree.JCArrayTypeTree node) {
    ArrayType newNode = new ArrayType();
    Type componentType = (Type) Type.newType(node.getType().type);
    return newNode.setComponentType(componentType).setTypeMirror(node.type);
}
Also used : ArrayType(com.google.devtools.j2objc.ast.ArrayType) ParameterizedType(com.google.devtools.j2objc.ast.ParameterizedType) Type(com.google.devtools.j2objc.ast.Type) 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) UnionType(com.google.devtools.j2objc.ast.UnionType) ExecutableType(javax.lang.model.type.ExecutableType)

Example 2 with ArrayType

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

the class TreeConverter method convertNewArray.

private TreeNode convertNewArray(JCTree.JCNewArray node) {
    ArrayCreation newNode = new ArrayCreation();
    List<Expression> dimensions = new ArrayList<>();
    for (JCTree.JCExpression dimension : node.getDimensions()) {
        dimensions.add((Expression) convert(dimension));
    }
    javax.lang.model.type.ArrayType type = (javax.lang.model.type.ArrayType) node.type;
    if (node.getInitializers() != null) {
        ArrayInitializer initializers = new ArrayInitializer(type);
        for (JCTree.JCExpression initializer : node.getInitializers()) {
            initializers.addExpression((Expression) convert(initializer));
        }
        newNode.setInitializer(initializers);
    }
    return newNode.setType((ArrayType) new ArrayType(type).setPosition(getPosition(node))).setDimensions(dimensions);
}
Also used : ArrayList(java.util.ArrayList) JCTree(com.sun.tools.javac.tree.JCTree) ArrayType(com.google.devtools.j2objc.ast.ArrayType) 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) ArrayCreation(com.google.devtools.j2objc.ast.ArrayCreation) ArrayInitializer(com.google.devtools.j2objc.ast.ArrayInitializer)

Example 3 with ArrayType

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

Aggregations

ArrayType (com.google.devtools.j2objc.ast.ArrayType)3 ParameterizedType (com.google.devtools.j2objc.ast.ParameterizedType)2 PrimitiveType (com.google.devtools.j2objc.ast.PrimitiveType)2 SimpleType (com.google.devtools.j2objc.ast.SimpleType)2 Type (com.google.devtools.j2objc.ast.Type)2 UnionType (com.google.devtools.j2objc.ast.UnionType)2 DeclaredType (javax.lang.model.type.DeclaredType)2 ExecutableType (javax.lang.model.type.ExecutableType)2 AnnotatableType (com.google.devtools.j2objc.ast.AnnotatableType)1 ArrayCreation (com.google.devtools.j2objc.ast.ArrayCreation)1 ArrayInitializer (com.google.devtools.j2objc.ast.ArrayInitializer)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 IntersectionType (com.google.devtools.j2objc.ast.IntersectionType)1 LambdaExpression (com.google.devtools.j2objc.ast.LambdaExpression)1 NameQualifiedType (com.google.devtools.j2objc.ast.NameQualifiedType)1