Program: 135994
Project: 135994
Buggy source:
/** 
 * This method is called when the TLC Model Checker / New Model command  is executed.  The last thing it does is call the Eclipse magic that calls the appropriate methods to open the model pages.  Thus, any initial settings of values in the model is done here by setting the appropriate attributes of the model.
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
  String parameter=event.getParameter(PARAM_SPEC_NAME);
  Spec spec=null;
  if (parameter != null) {
    spec=ToolboxHandle.getSpecByName(parameter);
  }
 else {
    spec=ToolboxHandle.getCurrentSpec();
  }
  if (spec == null) {
    System.out.println("String_Node_Str");
    return null;
  }
  IProject specProject=spec.getProject();
  SpecObj specObject=spec.getRootModule();
  if (specObject == null) {
    System.out.println("String_Node_Str");
    return null;
  }
  ILaunchManager launchManager=DebugPlugin.getDefault().getLaunchManager();
  ILaunchConfigurationType launchConfigurationType=launchManager.getLaunchConfigurationType(TLCModelLaunchDelegate.LAUNCH_CONFIGURATION_TYPE);
  modelName=ModelHelper.constructModelName(specProject);
  IInputValidator modelNameInputValidator=new ModelNameValidator(specProject);
  final InputDialog dialog=new InputDialog(UIHelper.getShellProvider().getShell(),"String_Node_Str","String_Node_Str",modelName,modelNameInputValidator);
  dialog.setBlockOnOpen(true);
  UIHelper.runUISync(new Runnable(){
    public void run(){
      int open=dialog.open();
switch (open) {
case Window.OK:
        modelName=dialog.getValue();
      break;
case Window.CANCEL:
    modelName=null;
}
}
}
);
if (modelName == null) {
return null;
}
ModuleNode moduleNode=specObject.getExternalModuleTable().getRootModule();
List constants=ModelHelper.createConstantsList(moduleNode);
Iterator iter=constants.iterator();
boolean done=false;
while ((!done) && iter.hasNext()) {
Assignment assign=(Assignment)iter.next();
if (assign.getLabel().equals("String_Node_Str")) {
assign.setRight("String_Node_Str");
done=true;
}
}
try {
ILaunchConfigurationWorkingCopy launchCopy=launchConfigurationType.newInstance(specProject,specProject.getName() + "String_Node_Str" + modelName);
launchCopy.setAttribute(SPEC_NAME,spec.getName());
launchCopy.setAttribute(MODEL_NAME,modelName);
if (constants.size() == 0) {
launchCopy.setAttribute(MODEL_PARAMETER_CONSTANTS,(List)null);
}
 else {
launchCopy.setAttribute(MODEL_PARAMETER_CONSTANTS,ModelHelper.serializeAssignmentList(constants));
}
OpDefNode[] defs=moduleNode.getOpDefs();
boolean foundSpec=false;
boolean foundInit=false;
boolean foundNext=false;
boolean foundTermination=false;
for (int i=0; i < defs.length; i++) {
if (defs[i].getName().toString().equals("String_Node_Str") && (defs[i].getLevel() == LevelNode.TemporalLevel)) {
  foundSpec=true;
}
 else if (defs[i].getName().toString().equals("String_Node_Str") && (defs[i].getLevel() == LevelNode.VariableLevel)) {
  foundInit=true;
}
 else if (defs[i].getName().toString().equals("String_Node_Str") && (defs[i].getLevel() == LevelNode.ActionLevel)) {
  foundNext=true;
}
 else if (defs[i].getName().toString().equals("String_Node_Str") && (defs[i].getLevel() == LevelNode.TemporalLevel)) {
  foundTermination=true;
}
}
if (foundSpec) {
launchCopy.setAttribute(IModelConfigurationConstants.MODEL_BEHAVIOR_CLOSED_SPECIFICATION,"String_Node_Str");
launchCopy.setAttribute(IModelConfigurationConstants.MODEL_BEHAVIOR_SPEC_TYPE,IModelConfigurationDefaults.MODEL_BEHAVIOR_TYPE_SPEC_CLOSED);
if (foundTermination) {
  Vector vec=new Vector();
  launchCopy.setAttribute(MODEL_PROPERTIES_EXPAND,"String_Node_Str");
  vec.add("String_Node_Str");
  launchCopy.setAttribute(IModelConfigurationConstants.MODEL_CORRECTNESS_PROPERTIES,vec);
}
}
 else if (foundInit && foundNext) {
launchCopy.setAttribute(IModelConfigurationConstants.MODEL_BEHAVIOR_SEPARATE_SPECIFICATION_INIT,"String_Node_Str");
launchCopy.setAttribute(IModelConfigurationConstants.MODEL_BEHAVIOR_SEPARATE_SPECIFICATION_NEXT,"String_Node_Str");
launchCopy.setAttribute(IModelConfigurationConstants.MODEL_BEHAVIOR_SPEC_TYPE,IModelConfigurationDefaults.MODEL_BEHAVIOR_TYPE_SPEC_INIT_NEXT);
}
ILaunchConfiguration launchSaved=launchCopy.doSave();
HashMap parameters=new HashMap();
parameters.put(OpenModelHandler.PARAM_MODEL_NAME,modelName);
UIHelper.runCommand(OpenModelHandler.COMMAND_ID,parameters);
return launchSaved;
}
 catch (CoreException e) {
TLCUIActivator.logError("String_Node_Str",e);
}
return null;
}

Fixed version (ground truth):
/** 
 * This method is called when the TLC Model Checker / New Model command  is executed.  The last thing it does is call the Eclipse magic that calls the appropriate methods to open the model pages.  Thus, any initial settings of values in the model is done here by setting the appropriate attributes of the model.
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
  String parameter=event.getParameter(PARAM_SPEC_NAME);
  Spec spec=null;
  if (parameter != null) {
    spec=ToolboxHandle.getSpecByName(parameter);
  }
 else {
    spec=ToolboxHandle.getCurrentSpec();
  }
  if (spec == null) {
    System.out.println("String_Node_Str");
    return null;
  }
  IProject specProject=spec.getProject();
  SpecObj specObject=spec.getRootModule();
  if (specObject == null) {
    System.out.println("String_Node_Str");
    return null;
  }
  ILaunchManager launchManager=DebugPlugin.getDefault().getLaunchManager();
  ILaunchConfigurationType launchConfigurationType=launchManager.getLaunchConfigurationType(TLCModelLaunchDelegate.LAUNCH_CONFIGURATION_TYPE);
  modelName=ModelHelper.constructModelName(specProject);
  IInputValidator modelNameInputValidator=new ModelNameValidator(specProject);
  final InputDialog dialog=new InputDialog(UIHelper.getShellProvider().getShell(),"String_Node_Str","String_Node_Str",modelName,modelNameInputValidator);
  dialog.setBlockOnOpen(true);
  UIHelper.runUISync(new Runnable(){
    public void run(){
      int open=dialog.open();
switch (open) {
case Window.OK:
        modelName=dialog.getValue();
      break;
case Window.CANCEL:
    modelName=null;
}
}
}
);
if (modelName == null) {
return null;
}
ModuleNode moduleNode=specObject.getExternalModuleTable().getRootModule();
List constants=ModelHelper.createConstantsList(moduleNode);
Iterator iter=constants.iterator();
boolean done=false;
while ((!done) && iter.hasNext()) {
Assignment assign=(Assignment)iter.next();
if (assign.getLabel().equals("String_Node_Str") && (assign.getParams().length == 0)) {
assign.setRight("String_Node_Str");
done=true;
}
}
try {
ILaunchConfigurationWorkingCopy launchCopy=launchConfigurationType.newInstance(specProject,specProject.getName() + "String_Node_Str" + modelName);
launchCopy.setAttribute(SPEC_NAME,spec.getName());
launchCopy.setAttribute(MODEL_NAME,modelName);
if (constants.size() == 0) {
launchCopy.setAttribute(MODEL_PARAMETER_CONSTANTS,(List)null);
}
 else {
launchCopy.setAttribute(MODEL_PARAMETER_CONSTANTS,ModelHelper.serializeAssignmentList(constants));
}
OpDefNode[] defs=moduleNode.getOpDefs();
boolean foundSpec=false;
boolean foundInit=false;
boolean foundNext=false;
boolean foundTermination=false;
for (int i=0; i < defs.length; i++) {
if (defs[i].getNumberOfArgs() == 0) {
  if (defs[i].getName().toString().equals("String_Node_Str") && (defs[i].getLevel() == LevelNode.TemporalLevel)) {
    foundSpec=true;
  }
 else   if (defs[i].getName().toString().equals("String_Node_Str") && (defs[i].getLevel() == LevelNode.VariableLevel)) {
    foundInit=true;
  }
 else   if (defs[i].getName().toString().equals("String_Node_Str") && (defs[i].getLevel() == LevelNode.ActionLevel)) {
    foundNext=true;
  }
 else   if (defs[i].getName().toString().equals("String_Node_Str") && (defs[i].getLevel() == LevelNode.TemporalLevel)) {
    foundTermination=true;
  }
}
}
if (foundSpec) {
launchCopy.setAttribute(IModelConfigurationConstants.MODEL_BEHAVIOR_CLOSED_SPECIFICATION,"String_Node_Str");
launchCopy.setAttribute(IModelConfigurationConstants.MODEL_BEHAVIOR_SPEC_TYPE,IModelConfigurationDefaults.MODEL_BEHAVIOR_TYPE_SPEC_CLOSED);
if (foundTermination) {
  Vector vec=new Vector();
  launchCopy.setAttribute(MODEL_PROPERTIES_EXPAND,"String_Node_Str");
  vec.add("String_Node_Str");
  launchCopy.setAttribute(IModelConfigurationConstants.MODEL_CORRECTNESS_PROPERTIES,vec);
}
}
 else if (foundInit || foundNext) {
launchCopy.setAttribute(IModelConfigurationConstants.MODEL_BEHAVIOR_SPEC_TYPE,IModelConfigurationDefaults.MODEL_BEHAVIOR_TYPE_SPEC_INIT_NEXT);
if (foundInit) {
  launchCopy.setAttribute(IModelConfigurationConstants.MODEL_BEHAVIOR_SEPARATE_SPECIFICATION_INIT,"String_Node_Str");
}
if (foundNext) {
  launchCopy.setAttribute(IModelConfigurationConstants.MODEL_BEHAVIOR_SEPARATE_SPECIFICATION_NEXT,"String_Node_Str");
}
}
ILaunchConfiguration launchSaved=launchCopy.doSave();
HashMap parameters=new HashMap();
parameters.put(OpenModelHandler.PARAM_MODEL_NAME,modelName);
UIHelper.runCommand(OpenModelHandler.COMMAND_ID,parameters);
return launchSaved;
}
 catch (CoreException e) {
TLCUIActivator.logError("String_Node_Str",e);
}
return null;
}