AspectJFragment { {{ // Find all Variable-objects on the right-hand-side // (after the colon) of PointCut-objects static String usedVarsSpec = "from AspectJFragment via PCExp to Variable"; // the following strategy is equivalent and more robust // "from AspectJFragment via -> *,rhs,* to Variable"; // This is even better: // "from AspectJFragment via PointCut via -> *,rhs,* to Variable"; // Find all Variable-objects on the left-hand-side // (before the colon) of PointCut-objects static String definedVarsSpec = "from AspectJFragment via ArgDecl to Variable"; // the following strategy is equivalent and more robust // "from AspectJFragment via -> *,lhs,* to Variable"; // This is even better: // "from AspectJFragment via PointCut via -> *,lhs,* to Variable"; // HashSet implements the Set interface which contains method: // add(Object o) // Adds the specified element to this set if // it is not already present. HashSet collectVars(String travspec){ Visitor v = new Visitor(){ // construct a new empty set HashSet return_val = new HashSet(); void before(Variable v1) {return_val.add(v1);} public Object getReturnValue(){return return_val;} }; return (HashSet) Main.cg.traverse(this, travspec, v); } HashSet getUsedVars() { return this.collectVars(usedVarsSpec); } HashSet getDefinedVars() { return this.collectVars(definedVarsSpec); } }} }