/** Eliminates all non-normal variables from varInfos. See isNormalVar() for details. */
 private static VarInfo[] filterNonVars(VarInfo[] varInfos) {
   List<VarInfo> filteredList = new ArrayList<VarInfo>();
   for (int i = 0; i < varInfos.length; i++) {
     if (isNormalVar(varInfos[i])) {
       filteredList.add(varInfos[i]);
     } else {
       // System.out.println("filterNonVars removed " + varInfos[i].name.name());
     }
   }
   return filteredList.toArray(new VarInfo[0]);
 }
 /**
  * Creates a new instance of VariableManager.
  *
  * @param varInfos the varInfos for the variables to be managed.
  * @param condition the condition in which the variables are used.
  */
 private static VariableManager[] makeVariableManagerArray(
     VarInfo[] varInfos, String condition, String className) throws ParseException {
   List<VariableManager> variableManagerList = new ArrayList<VariableManager>();
   List<String> classVars = findPossibleClassVariables(condition);
   for (int i = 0; i < varInfos.length; i++) {
     VarInfo varInfo = varInfos[i];
     try {
       String compilableName = compilableName(varInfo, className);
       // System.out.println("varInfo " + varInfo.name.name() + ", compilableName=" +
       // compilableName + ", isNeeded=" + isNeeded(compilableName, classVars));
       if (isNeeded(compilableName, classVars)) {
         variableManagerList.add(new VariableManager(varInfo, condition, className));
       }
     } catch (ParseException e) {
       System.out.println("ParseException: " + e.toString());
     }
   }
   return variableManagerList.toArray(new VariableManager[0]);
 }
 /**
  * requires: condition is a string representation of a conditional
  *
  * @return a list of all possible variable variable names in condition. arrays appear with "[]" at
  *     the end if their elements or accessed in the condition.
  */
 private static List<String> findPossibleClassVariables(String condition) throws ParseException {
   NodeToken[] tokens = TokenExtractor.extractTokens(condition);
   // System.out.println("TokenExtractor.extractTokens(" + condition + ") ==> " +
   // ArraysMDE.toString(tokens));
   List<String> variables = new ArrayList<String>();
   if (tokens.length >= 1) {
     if (tokens[0].kind == IDENTIFIER && (tokens.length <= 1 || tokens[1].kind != LPAREN)) {
       variables.add(tokens[0].tokenImage);
     }
   }
   if (tokens.length >= 2) {
     if (tokens[1].kind == IDENTIFIER
         && (tokens.length <= 2 || tokens[2].kind != LPAREN)
         && (!variables.contains(tokens[1].tokenImage))) {
       variables.add(tokens[1].tokenImage);
     }
   }
   for (int i = 2; i < tokens.length - 1; i++) {
     NodeToken token = tokens[i];
     if (token.kind == IDENTIFIER
         && tokens[i - 1].kind != DOT
         && tokens[i + 1].kind != LPAREN
         && (!variables.contains(token.tokenImage))) {
       variables.add(token.tokenImage);
     }
   }
   if (tokens.length >= 3) {
     int lastIndex = tokens.length - 1;
     if (tokens[lastIndex].kind == IDENTIFIER
         && tokens[lastIndex - 1].kind != DOT
         && (!variables.contains(tokens[lastIndex].tokenImage))) {
       variables.add(tokens[lastIndex].tokenImage);
     }
   }
   // System.out.println("findPossibleClassVariables(" + condition + ") ==> " +
   // variables.toString());
   return variables;
 }
 /** Returns true if the variable represented by varInfo is used in this splitting condition. */
 private static boolean isNeeded(String name, List<String> vars) {
   return vars.contains(name);
 }