/** * Builds a new {@link ArrayCreation} instance. * * @param typeBinding the type binding of the instantiated type * @param arrayInitializers the expressions forming the array initializer * @return a new array creation instance */ public ArrayCreation newArray(ITypeBinding typeBinding, Expression arrayInitializers) { final ArrayInitializer ai = ast.newArrayInitializer(); expressions(ai).add(arrayInitializers); final ArrayCreation ac = ast.newArrayCreation(); ac.setType((ArrayType) toType(ast, typeBinding)); ac.setInitializer(ai); return ac; }
@SuppressWarnings("unchecked") public ArrayCreation newArrayCreation(Type type, Collection<Expression> values) { ArrayCreation ac = ast.newArrayCreation(); ArrayInitializer initializer = ast.newArrayInitializer(); for (Expression expr : values) { initializer.expressions().add(expr); } ac.setInitializer(initializer); ac.setType(ast.newArrayType(type)); return ac; }
public Expression newArrayCreation(String canonicalName, ArrayInitializer initializer) { ArrayCreation ac = ast.newArrayCreation(); ac.setInitializer(initializer); ac.setType(ast.newArrayType(newType(canonicalName))); return ac; }