Search in sources :

Example 6 with ArrayCreation

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

the class VarargsRewriter method endVisit.

@Override
public void endVisit(ArrayInitializer node) {
    if (!(node.getParent() instanceof ArrayCreation)) {
        ArrayCreation newArray = new ArrayCreation(node.getTypeMirror(), typeUtil);
        node.replaceWith(newArray);
        newArray.setInitializer(node);
    }
}
Also used : ArrayCreation(com.google.devtools.j2objc.ast.ArrayCreation)

Example 7 with ArrayCreation

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

the class TranslationUtil method createObjectArray.

public Expression createObjectArray(List<Expression> expressions, ArrayType arrayType) {
    if (expressions.isEmpty()) {
        return new ArrayCreation(arrayType, typeUtil, 0);
    }
    ArrayInitializer initializer = new ArrayInitializer(arrayType);
    initializer.getExpressions().addAll(expressions);
    return new ArrayCreation(initializer);
}
Also used : ArrayCreation(com.google.devtools.j2objc.ast.ArrayCreation) ArrayInitializer(com.google.devtools.j2objc.ast.ArrayInitializer)

Aggregations

ArrayCreation (com.google.devtools.j2objc.ast.ArrayCreation)7 ArrayInitializer (com.google.devtools.j2objc.ast.ArrayInitializer)5 Expression (com.google.devtools.j2objc.ast.Expression)5 ConditionalExpression (com.google.devtools.j2objc.ast.ConditionalExpression)4 InfixExpression (com.google.devtools.j2objc.ast.InfixExpression)4 ParenthesizedExpression (com.google.devtools.j2objc.ast.ParenthesizedExpression)4 PostfixExpression (com.google.devtools.j2objc.ast.PostfixExpression)4 PrefixExpression (com.google.devtools.j2objc.ast.PrefixExpression)4 ThisExpression (com.google.devtools.j2objc.ast.ThisExpression)4 VariableDeclarationExpression (com.google.devtools.j2objc.ast.VariableDeclarationExpression)4 ArrayList (java.util.ArrayList)4 ArrayType (com.google.devtools.j2objc.ast.ArrayType)3 CastExpression (com.google.devtools.j2objc.ast.CastExpression)3 FunctionalExpression (com.google.devtools.j2objc.ast.FunctionalExpression)3 InstanceofExpression (com.google.devtools.j2objc.ast.InstanceofExpression)3 LambdaExpression (com.google.devtools.j2objc.ast.LambdaExpression)3 AbstractTypeDeclaration (com.google.devtools.j2objc.ast.AbstractTypeDeclaration)1 ArrayAccess (com.google.devtools.j2objc.ast.ArrayAccess)1 Assignment (com.google.devtools.j2objc.ast.Assignment)1 Block (com.google.devtools.j2objc.ast.Block)1