/* (non-Javadoc) * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ArrayCreation) */ public boolean visit(ArrayCreation node) { PTArrayCreation ac = InstantiationFactory.eINSTANCE.createPTArrayCreation(); ac.setType(resolver.resolveType(node.getType())); List acDims = ac.getDimensions(); List nDims = node.dimensions(); int nsize = nDims.size(); for (int i = 0; i < nsize; i++) { acDims.add(perform((Expression) nDims.get(i))); } ac.setInitializer((PTArrayInitializer) perform(node.getInitializer())); expression = ac; return false; }
/* * @see ASTVisitor#visit(ArrayCreation) */ public boolean visit(ArrayCreation node) { this.fBuffer.append("new "); // $NON-NLS-1$ ArrayType at = node.getType(); int dims = at.getDimensions(); Type elementType = at.getElementType(); elementType.accept(this); for (Iterator it = node.dimensions().iterator(); it.hasNext(); ) { this.fBuffer.append("["); // $NON-NLS-1$ Expression e = (Expression) it.next(); e.accept(this); this.fBuffer.append("]"); // $NON-NLS-1$ dims--; } // add empty "[]" for each extra array dimension for (int i = 0; i < dims; i++) { this.fBuffer.append("[]"); // $NON-NLS-1$ } if (node.getInitializer() != null) { node.getInitializer().accept(this); } return false; }