if (node.getType() == null) {
set(node, init == null ? new ArrayInitializer() : init);
return;
}
ArrayCreation crea = new ArrayCreation();
JCTree type = node.getType();
java.util.List<Position> inits = Lists.newArrayList();
while (type instanceof JCArrayTypeTree) {
inits.add(getPosition(type));
type = ((JCArrayTypeTree) type).getType();
}
crea.rawComponentTypeReference(toTree(type, FlagKey.TYPE_REFERENCE));
if (node.getDimensions() != null) for (JCExpression dim : node.getDimensions()) {
crea.astDimensions().addToEnd(setPos(dim, new ArrayDimension().rawDimension(toTree(dim))));
}
if (init != null) crea.astDimensions().addToEnd(new ArrayDimension());
// new boolean [][][] {} in javac has one less dimension for some reason.
for (Position i : inits) {
ArrayDimension dim = new ArrayDimension();
dim.setPosition(i);
crea.astDimensions().addToEnd(dim);
}
crea.astInitializer(init);
set(node, crea);
}