Program: 136114
Project: 136114
Buggy source:
UseOrHideNode generateUseOrHide(TreeNode stn,ModuleNode cm) throws AbortException {
  int kind=UseKind;
  TreeNode heirs[]=stn.heirs();
  if (heirs[0].getKind() == TLAplusParserConstants.HIDE) {
    kind=HideKind;
  }
  ;
  int nextTok=1;
  if (heirs[0].getKind() == TLAplusParserConstants.PROOF) {
    nextTok++;
  }
  ;
  Vector vec=new Vector();
  if (heirs[nextTok].getKind() == TLAplusParserConstants.ONLY) {
    nextTok++;
  }
  ;
  while ((nextTok < heirs.length) && (heirs[nextTok].getKind() != TLAplusParserConstants.DF)) {
    if (heirs[nextTok].getKind() == TLAplusParserConstants.MODULE) {
      nextTok++;
      UniqueString moduleId=heirs[nextTok].getUS();
      ModuleNode moduleNode=symbolTable.resolveModule(moduleId);
      if ((moduleNode == null) && (moduleId == cm.getName())) {
        moduleNode=cm;
      }
      ;
      if (moduleNode != null) {
        vec.addElement(moduleNode);
      }
 else {
        errors.addError(heirs[nextTok].getLocation(),"String_Node_Str" + moduleId + "String_Node_Str");
      }
    }
 else {
      if (heirs[nextTok].getKind() == N_GeneralId) {
        vec.addElement(selectorToNode(genIdToSelector((SyntaxTreeNode)heirs[nextTok]),0,true,false,cm));
      }
 else       if (heirs[nextTok].getKind() == N_AssumeProve) {
        vec.addElement(generateAssumeProve(heirs[nextTok],cm));
      }
 else {
        vec.addElement(generateExpression(heirs[nextTok],cm));
      }
    }
    nextTok++;
    if ((nextTok < heirs.length) && (heirs[nextTok].getKind() == TLAplusParserConstants.COMMA)) {
      nextTok++;
    }
    ;
  }
  ;
  LevelNode[] facts=new LevelNode[vec.size()];
  for (int i=0; i < vec.size(); i++) {
    facts[i]=(LevelNode)vec.elementAt(i);
  }
  ;
  SymbolNode[] defs;
  if (nextTok >= heirs.length) {
    defs=new SymbolNode[0];
  }
 else {
    vec=new Vector();
    nextTok++;
    while (nextTok < heirs.length) {
      if (heirs[nextTok].getKind() == TLAplusParserConstants.MODULE) {
        nextTok++;
        UniqueString moduleId=heirs[nextTok].getUS();
        ModuleNode moduleNode=symbolTable.resolveModule(moduleId);
        if ((moduleNode == null) && (moduleId == cm.getName())) {
          moduleNode=cm;
        }
        ;
        if (moduleNode != null) {
          vec.addElement(moduleNode);
        }
 else {
          errors.addError(heirs[nextTok].getLocation(),"String_Node_Str" + moduleId + "String_Node_Str");
        }
      }
 else {
        Selector sel=genIdToSelector((SyntaxTreeNode)heirs[nextTok]);
        SemanticNode selToNd=selectorToNode(sel,-1,false,true,cm);
        if ((selToNd instanceof OpDefNode) || (selToNd instanceof ThmOrAssumpDefNode)) {
          SymbolNode def=(SymbolNode)selToNd;
          vec.addElement(def);
        }
 else {
          errors.addError(heirs[nextTok].getLocation(),"String_Node_Str");
        }
      }
      nextTok++;
      if ((nextTok < heirs.length) && (heirs[nextTok].getKind() == TLAplusParserConstants.COMMA)) {
        nextTok++;
      }
      ;
    }
    ;
    defs=new SymbolNode[vec.size()];
    for (int i=0; i < vec.size(); i++) {
      defs[i]=(SymbolNode)vec.elementAt(i);
    }
    ;
  }
  return new UseOrHideNode(kind,stn,facts,defs);
}

Fixed version (ground truth):
UseOrHideNode generateUseOrHide(TreeNode stn,ModuleNode cm) throws AbortException {
  int kind=UseKind;
  TreeNode heirs[]=stn.heirs();
  boolean isOnly=false;
  if (heirs[0].getKind() == TLAplusParserConstants.HIDE) {
    kind=HideKind;
  }
  ;
  int nextTok=1;
  if (heirs[0].getKind() == TLAplusParserConstants.PROOF) {
    nextTok++;
  }
  ;
  Vector vec=new Vector();
  if (heirs[nextTok].getKind() == TLAplusParserConstants.ONLY) {
    isOnly=true;
    nextTok++;
  }
  ;
  while ((nextTok < heirs.length) && (heirs[nextTok].getKind() != TLAplusParserConstants.DF)) {
    if (heirs[nextTok].getKind() == TLAplusParserConstants.MODULE) {
      nextTok++;
      UniqueString moduleId=heirs[nextTok].getUS();
      ModuleNode moduleNode=symbolTable.resolveModule(moduleId);
      if ((moduleNode == null) && (moduleId == cm.getName())) {
        moduleNode=cm;
      }
      ;
      if (moduleNode != null) {
        vec.addElement(moduleNode);
      }
 else {
        errors.addError(heirs[nextTok].getLocation(),"String_Node_Str" + moduleId + "String_Node_Str");
      }
    }
 else {
      if (heirs[nextTok].getKind() == N_GeneralId) {
        vec.addElement(selectorToNode(genIdToSelector((SyntaxTreeNode)heirs[nextTok]),0,true,false,cm));
      }
 else       if (heirs[nextTok].getKind() == N_AssumeProve) {
        vec.addElement(generateAssumeProve(heirs[nextTok],cm));
      }
 else {
        vec.addElement(generateExpression(heirs[nextTok],cm));
      }
    }
    nextTok++;
    if ((nextTok < heirs.length) && (heirs[nextTok].getKind() == TLAplusParserConstants.COMMA)) {
      nextTok++;
    }
    ;
  }
  ;
  LevelNode[] facts=new LevelNode[vec.size()];
  for (int i=0; i < vec.size(); i++) {
    facts[i]=(LevelNode)vec.elementAt(i);
  }
  ;
  SymbolNode[] defs;
  if (nextTok >= heirs.length) {
    defs=new SymbolNode[0];
  }
 else {
    vec=new Vector();
    nextTok++;
    while (nextTok < heirs.length) {
      if (heirs[nextTok].getKind() == TLAplusParserConstants.MODULE) {
        nextTok++;
        UniqueString moduleId=heirs[nextTok].getUS();
        ModuleNode moduleNode=symbolTable.resolveModule(moduleId);
        if ((moduleNode == null) && (moduleId == cm.getName())) {
          moduleNode=cm;
        }
        ;
        if (moduleNode != null) {
          vec.addElement(moduleNode);
        }
 else {
          errors.addError(heirs[nextTok].getLocation(),"String_Node_Str" + moduleId + "String_Node_Str");
        }
      }
 else {
        Selector sel=genIdToSelector((SyntaxTreeNode)heirs[nextTok]);
        SemanticNode selToNd=selectorToNode(sel,-1,false,true,cm);
        if ((selToNd instanceof OpDefNode) || (selToNd instanceof ThmOrAssumpDefNode)) {
          SymbolNode def=(SymbolNode)selToNd;
          vec.addElement(def);
        }
 else {
          errors.addError(heirs[nextTok].getLocation(),"String_Node_Str");
        }
      }
      nextTok++;
      if ((nextTok < heirs.length) && (heirs[nextTok].getKind() == TLAplusParserConstants.COMMA)) {
        nextTok++;
      }
      ;
    }
    ;
    defs=new SymbolNode[vec.size()];
    for (int i=0; i < vec.size(); i++) {
      defs[i]=(SymbolNode)vec.elementAt(i);
    }
    ;
  }
  return new UseOrHideNode(kind,stn,facts,defs,isOnly);
}