public boolean removeUnusedVariables(TestCase t){
  List<Integer> toDelete=new ArrayList<Integer>();
  boolean hasDeleted=false;
  int num=0;
  for (  Statement s : t) {
    if (s instanceof PrimitiveStatement) {
      VariableReference var=s.getReturnValue();
      if (!t.hasReferences(var)) {
        toDelete.add(num);
        hasDeleted=true;
      }
    }
    num++;
  }
  Collections.sort(toDelete,Collections.reverseOrder());
  for (  Integer position : toDelete) {
    t.remove(position);
  }
  return hasDeleted;
}

public boolean removeUnusedVariables ( TestCase t ) { List < Integer > toDelete = new ArrayList < Integer > ( ) ; boolean hasDeleted = false ; int num = 0 ; for ( Statement s : t ) { if ( s instanceof PrimitiveStatement ) { VariableReference var = s . getReturnValue ( ) ; if ( ! t . hasReferences ( var ) ) { toDelete . add ( num ) ; hasDeleted = true ; } } num ++ ; } Collections . sort ( toDelete , Collections . reverseOrder ( ) ) ; for ( Integer position : toDelete ) { t . remove ( position ) ; } return hasDeleted ; }
remove all unreferenced variables
