@Test public void setChild() throws Exception { assertEquals("A", expr.getChild(0).getText()); assertEquals("0", expr.getChild(1).getText()); expr.setChild(0, new VariableIdentifierExpr("B")); assertEquals("B", expr.getChild(0).getText()); assertEquals("0", expr.getChild(1).getText()); expr.setChild(1, new IntConstantExpr("3")); assertEquals("B", expr.getChild(0).getText()); assertEquals("3", expr.getChild(1).getText()); }
@Override public void setChild(int index, Expr expr) { if (index == 0) { array = expr; return; } if (index == 1) { this.index = expr; return; } throw new IndexOutOfBoundsException("Index for ArrayIndexExpr must be 0 or 1"); }
ArrayIndexExpr extends Expr { @Override public void setChild(int index, Expr expr) { if (index == 0) { array = expr; return; } if (index == 1) { this.index = expr; return; } throw new IndexOutOfBoundsException("Index for ArrayIndexExpr must be 0 or 1"); } }
ArrayIndexExpr extends Expr { @Override public void setChild(int index, Expr expr) { if (index == 0) { array = expr; return; } if (index == 1) { this.index = expr; return; } throw new IndexOutOfBoundsException("Index for ArrayIndexExpr must be 0 or 1"); } ArrayIndexExpr(Expr array, Expr index); }
ArrayIndexExpr extends Expr { @Override public void setChild(int index, Expr expr) { if (index == 0) { array = expr; return; } if (index == 1) { this.index = expr; return; } throw new IndexOutOfBoundsException("Index for ArrayIndexExpr must be 0 or 1"); } ArrayIndexExpr(Expr array, Expr index); Expr getArray(); Expr getIndex(); void setIndex(Expr index); @Override void accept(IAstVisitor visitor); @Override ArrayIndexExpr clone(); @Override boolean hasChild(IAstNode candidateChild); @Override Expr getChild(int index); @Override void setChild(int index, Expr expr); @Override int getNumChildren(); }
ArrayIndexExpr extends Expr { @Override public void setChild(int index, Expr expr) { if (index == 0) { array = expr; return; } if (index == 1) { this.index = expr; return; } throw new IndexOutOfBoundsException("Index for ArrayIndexExpr must be 0 or 1"); } ArrayIndexExpr(Expr array, Expr index); Expr getArray(); Expr getIndex(); void setIndex(Expr index); @Override void accept(IAstVisitor visitor); @Override ArrayIndexExpr clone(); @Override boolean hasChild(IAstNode candidateChild); @Override Expr getChild(int index); @Override void setChild(int index, Expr expr); @Override int getNumChildren();  }