String expecting = "[A@A[2], A@D[0]]"; // shouldn't match overall root, just (A B)
assertEquals(expecting, found);
}
@Test public void testVisitPatternMultipleWithLabels() throws Exception {
TreeWizard wiz = new TreeWizard(adaptor, tokens);
CommonTree t = (CommonTree)wiz.create("(A B C (A[foo] B[bar]) (D (A[big] B[dog])))");
final List elements = new ArrayList();
wiz.visit(t, "(%a:A %b:B)",
new TreeWizard.ContextVisitor() {
public void visit(Object t, Object parent, int childIndex, Map labels) {
elements.add(adaptor.getText(t)+"@"+
(parent!=null?adaptor.getText(parent):"nil")+
"["+childIndex+"]"+labels.get("a")+"&"+labels.get("b"));