MemberLookupExpr extends Expr { @Override public Expr getChild(int index) { if (index == 0) { return structure; } throw new IndexOutOfBoundsException("Index for MemberLookupExpr must be 0"); } MemberLookupExpr(Expr structure, String member); Expr getStructure(); void setStructure(Expr structure); String getMember(); void setMember(String member); @Override void accept(IAstVisitor visitor); @Override MemberLookupExpr clone(); @Override boolean hasChild(IAstNode candidateChild); @Override Expr getChild(int index); @Override void setChild(int index, Expr expr); @Override int getNumChildren();  }
@Test public void getChild() throws Exception { VariableIdentifierExpr v = new VariableIdentifierExpr("v"); MemberLookupExpr mle = new MemberLookupExpr( v, "foo"); assertEquals(v, mle.getChild(0)); assertEquals(mle.getStructure(), mle.getChild(0)); }
@Test(expected = IndexOutOfBoundsException.class) public void getChildException() throws Exception { new MemberLookupExpr(new VariableIdentifierExpr("v"), "foo").getChild(1); }