Program: 136094
Project: 136094
Buggy source:
/** 
 * Create a list of overrides. If the override is not in the spec's root module, then the config file will have     A <- [M] id . This means that A is defined in module M, and its definition is being overriden in the spec root module which is dependent upon M. The following is an example from Leslie Lamport that explains the code. Let's suppose we have ------ MODULE MA ---- IB == INSTANCE MB ... ================= ------ MODULE MB ---- IC == INSTANCE MC ... ================= ----- MODULE MC ------ Foo == ... ====================== where MA is the spec's root module.  The user will see in the override menu and override IB!IC!Foo Let OD be the OpDefNode for IB!IC!Foo in the semantic tree for module MA.  Then OD.getSource() is the OpDefNode for Foo in the semantic tree of module MC.  So we have OD.getSource().getOriginallyDefinedInModuleNode()  is the module node for MC, and OD.getSource().getOriginallyDefinedInModuleNode().getName().toString() = "MC" OD.getName().toString() = "Foo" and the config file should contain Foo <-[MC] ...
 * @param overrides
 * @param string
 * @return
 */
public static List createOverridesContent(List overrides,String labelingScheme){
  Vector resultContent=new Vector(overrides.size());
  String[] content;
  String id;
  Assignment formula;
  SpecObj specObj=ToolboxHandle.getCurrentSpec().getValidRootModule();
  OpDefNode[] opDefNodes=specObj.getExternalModuleTable().getRootModule().getOpDefs();
  Hashtable nodeTable=new Hashtable(opDefNodes.length);
  for (int j=0; j < opDefNodes.length; j++) {
    String key=opDefNodes[j].getName().toString();
    nodeTable.put(key,opDefNodes[j]);
  }
  for (int i=0; i < overrides.size(); i++) {
    id=getValidIdentifier(labelingScheme);
    formula=((Assignment)overrides.get(i));
    OpDefNode defNode=null;
    if (nodeTable.containsKey(formula.getLabel())) {
      defNode=(OpDefNode)nodeTable.get(formula.getLabel());
    }
    if (defNode == null) {
      content=null;
    }
 else {
      OpDefNode source=defNode.getSource();
      if (source == null) {
        content=new String[]{formula.getLabel() + ARROW + id,formula.getParametrizedLabel(id) + DEFINES_CR + formula.getRight()};
      }
 else       if (source.getSource() == source) {
        content=new String[]{source.getName().toString() + ARROW + "String_Node_Str"+ source.getOriginallyDefinedInModuleNode().getName().toString()+ "String_Node_Str"+ id,formula.getParametrizedLabel(id) + DEFINES_CR + formula.getRight()};
      }
 else {
        content=null;
      }
    }
    resultContent.add(content);
  }
  return resultContent;
}

Fixed version (ground truth):
/** 
 * Create a list of overrides. If the override is not in the spec's root module, then the config file will have     A <- [M] id . This means that A is defined in module M, and its definition is being overriden in the spec root module which is dependent upon M. The following is an example from Leslie Lamport that explains the code. Let's suppose we have ------ MODULE MA ---- IB == INSTANCE MB ... ================= ------ MODULE MB ---- IC == INSTANCE MC ... ================= ----- MODULE MC ------ Foo == ... ====================== where MA is the spec's root module.  The user will see in the override menu and override IB!IC!Foo Let OD be the OpDefNode for IB!IC!Foo in the semantic tree for module MA.  Then OD.getSource() is the OpDefNode for Foo in the semantic tree of module MC.  So we have OD.getSource().getOriginallyDefinedInModuleNode()  is the module node for MC, and OD.getSource().getOriginallyDefinedInModuleNode().getName().toString() = "MC" OD.getName().toString() = "Foo" and the config file should contain Foo <-[MC] ...
 * @param overrides
 * @param string
 * @return
 */
public static List createOverridesContent(List overrides,String labelingScheme){
  Vector resultContent=new Vector(overrides.size());
  String[] content;
  String id;
  Assignment formula;
  SpecObj specObj=ToolboxHandle.getCurrentSpec().getValidRootModule();
  OpDefNode[] opDefNodes=specObj.getExternalModuleTable().getRootModule().getOpDefs();
  Hashtable nodeTable=new Hashtable(opDefNodes.length);
  for (int j=0; j < opDefNodes.length; j++) {
    String key=opDefNodes[j].getName().toString();
    nodeTable.put(key,opDefNodes[j]);
  }
  for (int i=0; i < overrides.size(); i++) {
    id=getValidIdentifier(labelingScheme);
    formula=((Assignment)overrides.get(i));
    OpDefNode defNode=null;
    if (nodeTable.containsKey(formula.getLabel())) {
      defNode=(OpDefNode)nodeTable.get(formula.getLabel());
    }
    if (defNode == null) {
      content=null;
    }
 else {
      OpDefNode source=defNode.getSource();
      if (source == defNode) {
        content=new String[]{formula.getLabel() + ARROW + id,formula.getParametrizedLabel(id) + DEFINES_CR + formula.getRight()};
      }
 else       if (source.getSource() == source) {
        content=new String[]{source.getName().toString() + ARROW + "String_Node_Str"+ source.getOriginallyDefinedInModuleNode().getName().toString()+ "String_Node_Str"+ id,formula.getParametrizedLabel(id) + DEFINES_CR + formula.getRight()};
      }
 else {
        content=null;
      }
    }
    resultContent.add(content);
  }
  return resultContent;
}