/* * @see ASTVisitor#visit(ArrayAccess) */ @Override public boolean visit(ArrayAccess node) { node.getArray().accept(this); this.fBuffer.append("["); // $NON-NLS-1$ node.getIndex().accept(this); this.fBuffer.append("]"); // $NON-NLS-1$ return false; }
/* (non-Javadoc) * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.ArrayAccess) */ public boolean visit(ArrayAccess node) { PTArrayAccess aa = InstantiationFactory.eINSTANCE.createPTArrayAccess(); List indexes = aa.getIndexes(); Expression arrayExp = node; while (arrayExp.getNodeType() == ASTNode.ARRAY_ACCESS) { // Visit the index to get the index expression. ArrayAccess array = (ArrayAccess) arrayExp; indexes.add( 0, perform( array .getIndex())); // We're trying to create the final expression from inside out, the // indexes are created in reverse order. arrayExp = array.getArray(); } aa.setArray(perform(arrayExp)); // Final arrayExp is the true expression. expression = aa; // Set the return expression for this visit. return false; }