Example #1
0
 @Override
 public Void visitIndexExpression(IndexExpression node) {
   if (node.isCascaded()) {
     writer.print("..");
   } else {
     visit(node.getArray());
   }
   writer.print('[');
   visit(node.getIndex());
   writer.print(']');
   return null;
 }
 public void test_cascade_withAssignment() throws Exception {
   CascadeExpression cascade = parseExpression("new Map()..[3] = 4 ..[0] = 11;");
   Expression target = cascade.getTarget();
   for (Expression section : cascade.getCascadeSections()) {
     assertInstanceOf(AssignmentExpression.class, section);
     Expression lhs = ((AssignmentExpression) section).getLeftHandSide();
     assertInstanceOf(IndexExpression.class, lhs);
     IndexExpression index = (IndexExpression) lhs;
     assertTrue(index.isCascaded());
     assertSame(target, index.getRealTarget());
   }
 }