Example #1
0
 void recurseSetContext(PythonTree tree, expr_contextType context) {
   if (tree instanceof Context) {
     ((Context) tree).setContext(context);
   }
   if (tree instanceof GeneratorExp) {
     GeneratorExp g = (GeneratorExp) tree;
     recurseSetContext(g.getInternalElt(), context);
   } else if (tree instanceof ListComp) {
     ListComp lc = (ListComp) tree;
     recurseSetContext(lc.getInternalElt(), context);
   } else if (tree instanceof SetComp) {
     SetComp sc = (SetComp) tree;
     recurseSetContext(sc.getInternalElt(), context);
   } else if (tree instanceof DictComp) {
     DictComp dc = (DictComp) tree;
     recurseSetContext(dc.getInternalKey(), context);
     recurseSetContext(dc.getInternalValue(), context);
   } else if (!(tree instanceof ListComp)
       && (!(tree instanceof DictComp))
       && (!(tree instanceof SetComp))) {
     for (int i = 0; i < tree.getChildCount(); i++) {
       recurseSetContext(tree.getChild(i), context);
     }
   }
 }