예제 #1
0
  /**
   * 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;
  }
예제 #2
0
 @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;
 }
예제 #3
0
 public Expression newArrayCreation(String canonicalName, ArrayInitializer initializer) {
   ArrayCreation ac = ast.newArrayCreation();
   ac.setInitializer(initializer);
   ac.setType(ast.newArrayType(newType(canonicalName)));
   return ac;
 }