Program: 136070
Project: 136070
Buggy source:
/** 
 * Instead of building, the model files are written to the disk.  The directory with the same name as the model is created as the sub-directory of the spec project. (if already present, the files inside will be deleted) Three new files are created: MC.tla, MC.cfg, MC.out All spec modules, including the root module are copied to this directory <br>3. method called on launch
 * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate2#buildForLaunch(org.eclipse.debug.core.ILaunchConfiguration,java.lang.String,org.eclipse.core.runtime.IProgressMonitor)
 */
public boolean buildForLaunch(ILaunchConfiguration config,String mode,IProgressMonitor monitor) throws CoreException {
  int STEP=100;
  try {
    monitor.beginTask("String_Node_Str",30);
    monitor.subTask("String_Node_Str");
    IProject project=ResourceHelper.getProject(specName);
    if (project == null) {
      throw new CoreException(new Status(IStatus.ERROR,TLCActivator.PLUGIN_ID,"String_Node_Str" + specName));
    }
    IFile specRootFile=ResourceHelper.getLinkedFile(project,specRootFilename,false);
    if (specRootFile == null) {
      throw new CoreException(new Status(IStatus.ERROR,TLCActivator.PLUGIN_ID,"String_Node_Str" + specRootFilename));
    }
    IFolder modelFolder=project.getFolder(modelName);
    IPath targetFolderPath=modelFolder.getProjectRelativePath().addTrailingSeparator();
    IFile tlaFile=project.getFile(targetFolderPath.append(ModelHelper.FILE_TLA));
    IFile cfgFile=project.getFile(targetFolderPath.append(ModelHelper.FILE_CFG));
    IFile outFile=project.getFile(targetFolderPath.append(ModelHelper.FILE_OUT));
    TLCActivator.logDebug("String_Node_Str" + targetFolderPath.toOSString());
    final IFile[] files=new IFile[]{tlaFile,cfgFile,outFile};
    if (modelFolder.exists()) {
      final IResource[] members=modelFolder.members();
      if (members.length == 0) {
        monitor.worked(STEP);
      }
 else {
        final boolean recover=config.getAttribute(LAUNCH_RECOVER,LAUNCH_RECOVER_DEFAULT);
        final IResource[] checkpoints=ModelHelper.getCheckpoints(config);
        ISchedulingRule deleteRule=ResourceHelper.getDeleteRule(members);
        ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable(){
          public void run(          IProgressMonitor monitor) throws CoreException {
            boolean checkFiles=recover;
            monitor.beginTask("String_Node_Str",members.length);
            for (int i=0; i < members.length; i++) {
              if (checkFiles) {
                if (checkpoints.length > 0 && checkpoints[0].equals(members[i])) {
                  checkFiles=false;
                  continue;
                }
              }
 else {
                try {
                  members[i].delete(IResource.FORCE,new SubProgressMonitor(monitor,1));
                }
 catch (                CoreException e) {
                  TLCActivator.logError("String_Node_Str" + members[i].getLocation(),e);
                }
              }
            }
            monitor.done();
          }
        }
,deleteRule,IWorkspace.AVOID_UPDATE,new SubProgressMonitor(monitor,STEP));
      }
    }
 else {
      modelFolder.create(IResource.DERIVED | IResource.FORCE,true,new SubProgressMonitor(monitor,STEP));
    }
    monitor.subTask("String_Node_Str");
    specRootFile.copy(targetFolderPath.append(specRootFile.getProjectRelativePath()),IResource.DERIVED | IResource.FORCE,new SubProgressMonitor(monitor,1));
    IResource specRootFileCopy=modelFolder.findMember(specRootFile.getProjectRelativePath());
    if (specRootFileCopy == null) {
      throw new CoreException(new Status(IStatus.ERROR,TLCActivator.PLUGIN_ID,"String_Node_Str" + specRootFilename + "String_Node_Str"+ targetFolderPath.toOSString()));
    }
    List extendedModules=ToolboxHandle.getExtendedModules(specRootFile.getName());
    IFile moduleFile=null;
    for (int i=0; i < extendedModules.size(); i++) {
      String module=(String)extendedModules.get(i);
      if (ToolboxHandle.isUserModule(module)) {
        moduleFile=ResourceHelper.getLinkedFile(project,module,false);
        if (moduleFile != null) {
          moduleFile.copy(targetFolderPath.append(moduleFile.getProjectRelativePath()),IResource.DERIVED | IResource.FORCE,new SubProgressMonitor(monitor,STEP / extendedModules.size()));
        }
      }
    }
    ISchedulingRule fileRule=MultiRule.combine(ResourceHelper.getModifyRule(files),ResourceHelper.getCreateRule(files));
    ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable(){
      public void run(      IProgressMonitor monitor) throws CoreException {
        for (int i=0; i < files.length; i++) {
          if (files[i].exists()) {
            files[i].setContents(new ByteArrayInputStream("String_Node_Str".getBytes()),IResource.DERIVED | IResource.FORCE,new SubProgressMonitor(monitor,1));
          }
 else {
            files[i].create(new ByteArrayInputStream("String_Node_Str".getBytes()),IResource.DERIVED | IResource.FORCE,new SubProgressMonitor(monitor,1));
          }
        }
      }
    }
,fileRule,IWorkspace.AVOID_UPDATE,new SubProgressMonitor(monitor,STEP));
    monitor.worked(STEP);
    monitor.subTask("String_Node_Str");
    ModelWriter writer=new ModelWriter();
    writer.addPrimer(ModelHelper.MC_MODEL_NAME,ResourceHelper.getModuleName(specRootFilename));
    List constants=ModelHelper.deserializeAssignmentList(config.getAttribute(MODEL_PARAMETER_CONSTANTS,new Vector()));
    TypedSet modelValues=TypedSet.parseSet(config.getAttribute(MODEL_PARAMETER_MODEL_VALUES,EMPTY_STRING));
    writer.addConstants(constants,modelValues,MODEL_PARAMETER_CONSTANTS,MODEL_PARAMETER_MODEL_VALUES);
    writer.addNewDefinitions(config.getAttribute(MODEL_PARAMETER_NEW_DEFINITIONS,EMPTY_STRING),MODEL_PARAMETER_NEW_DEFINITIONS);
    List overrides=ModelHelper.deserializeAssignmentList(config.getAttribute(MODEL_PARAMETER_DEFINITIONS,new Vector()));
    writer.addFormulaList(ModelWriter.createOverridesContent(overrides,ModelWriter.DEFOV_SCHEME),"String_Node_Str",MODEL_PARAMETER_DEFINITIONS);
    writer.addFormulaList(ModelWriter.createSourceContent(MODEL_PARAMETER_CONSTRAINT,ModelWriter.CONSTRAINT_SCHEME,config),"String_Node_Str",MODEL_PARAMETER_CONSTRAINT);
    writer.addFormulaList(ModelWriter.createSourceContent(MODEL_PARAMETER_ACTION_CONSTRAINT,ModelWriter.ACTIONCONSTRAINT_SCHEME,config),"String_Node_Str",MODEL_PARAMETER_ACTION_CONSTRAINT);
    int specType=config.getAttribute(MODEL_BEHAVIOR_SPEC_TYPE,MODEL_BEHAVIOR_TYPE_DEFAULT);
switch (specType) {
case MODEL_BEHAVIOR_TYPE_NO_SPEC:
      break;
case MODEL_BEHAVIOR_TYPE_SPEC_CLOSED:
    writer.addFormulaList(ModelWriter.createSourceContent(MODEL_BEHAVIOR_CLOSED_SPECIFICATION,ModelWriter.SPEC_SCHEME,config),"String_Node_Str",MODEL_BEHAVIOR_CLOSED_SPECIFICATION);
  break;
case MODEL_BEHAVIOR_TYPE_SPEC_INIT_NEXT:
writer.addFormulaList(ModelWriter.createSourceContent(MODEL_BEHAVIOR_SEPARATE_SPECIFICATION_INIT,ModelWriter.INIT_SCHEME,config),"String_Node_Str",MODEL_BEHAVIOR_SEPARATE_SPECIFICATION_INIT);
writer.addFormulaList(ModelWriter.createSourceContent(MODEL_BEHAVIOR_SEPARATE_SPECIFICATION_NEXT,ModelWriter.NEXT_SCHEME,config),"String_Node_Str",MODEL_BEHAVIOR_SEPARATE_SPECIFICATION_NEXT);
break;
}
writer.addFormulaList(ModelWriter.createFormulaListContent(config.getAttribute(MODEL_CORRECTNESS_INVARIANTS,new Vector()),ModelWriter.INVARIANT_SCHEME),"String_Node_Str",MODEL_CORRECTNESS_INVARIANTS);
writer.addFormulaList(ModelWriter.createFormulaListContent(config.getAttribute(MODEL_CORRECTNESS_PROPERTIES,new Vector()),ModelWriter.PROP_SCHEME),"String_Node_Str",MODEL_CORRECTNESS_PROPERTIES);
monitor.worked(STEP);
monitor.subTask("String_Node_Str");
writer.writeFiles(tlaFile,cfgFile,monitor);
modelFolder.refreshLocal(IResource.DEPTH_ONE,new SubProgressMonitor(monitor,STEP));
}
  finally {
monitor.done();
}
return false;
}

Fixed version (ground truth):
/** 
 * Instead of building, the model files are written to the disk.  The directory with the same name as the model is created as the sub-directory of the spec project. (if already present, the files inside will be deleted) Three new files are created: MC.tla, MC.cfg, MC.out All spec modules, including the root module are copied to this directory <br>3. method called on launch
 * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate2#buildForLaunch(org.eclipse.debug.core.ILaunchConfiguration,java.lang.String,org.eclipse.core.runtime.IProgressMonitor)
 */
public boolean buildForLaunch(ILaunchConfiguration config,String mode,IProgressMonitor monitor) throws CoreException {
  int STEP=100;
  try {
    monitor.beginTask("String_Node_Str",30);
    monitor.subTask("String_Node_Str");
    IProject project=ResourceHelper.getProject(specName);
    if (project == null) {
      throw new CoreException(new Status(IStatus.ERROR,TLCActivator.PLUGIN_ID,"String_Node_Str" + specName));
    }
    IFile specRootFile=ResourceHelper.getLinkedFile(project,specRootFilename,false);
    if (specRootFile == null) {
      throw new CoreException(new Status(IStatus.ERROR,TLCActivator.PLUGIN_ID,"String_Node_Str" + specRootFilename));
    }
    IFolder modelFolder=project.getFolder(modelName);
    IPath targetFolderPath=modelFolder.getProjectRelativePath().addTrailingSeparator();
    IFile tlaFile=project.getFile(targetFolderPath.append(ModelHelper.FILE_TLA));
    IFile cfgFile=project.getFile(targetFolderPath.append(ModelHelper.FILE_CFG));
    IFile outFile=project.getFile(targetFolderPath.append(ModelHelper.FILE_OUT));
    TLCActivator.logDebug("String_Node_Str" + targetFolderPath.toOSString());
    final IFile[] files=new IFile[]{tlaFile,cfgFile,outFile};
    if (modelFolder.exists()) {
      final IResource[] members=modelFolder.members();
      if (members.length == 0) {
        monitor.worked(STEP);
      }
 else {
        final boolean recover=config.getAttribute(LAUNCH_RECOVER,LAUNCH_RECOVER_DEFAULT);
        final IResource[] checkpoints=ModelHelper.getCheckpoints(config,true);
        ISchedulingRule deleteRule=ResourceHelper.getDeleteRule(members);
        ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable(){
          public void run(          IProgressMonitor monitor) throws CoreException {
            boolean checkFiles=recover;
            monitor.beginTask("String_Node_Str",members.length);
            for (int i=0; i < members.length; i++) {
              if (checkFiles) {
                if (checkpoints.length > 0 && checkpoints[0].equals(members[i])) {
                  checkFiles=false;
                  continue;
                }
              }
 else {
                try {
                  members[i].delete(IResource.FORCE,new SubProgressMonitor(monitor,1));
                }
 catch (                CoreException e) {
                  TLCActivator.logError("String_Node_Str" + members[i].getLocation(),e);
                }
              }
            }
            monitor.done();
          }
        }
,deleteRule,IWorkspace.AVOID_UPDATE,new SubProgressMonitor(monitor,STEP));
      }
    }
 else {
      modelFolder.create(IResource.DERIVED | IResource.FORCE,true,new SubProgressMonitor(monitor,STEP));
    }
    monitor.subTask("String_Node_Str");
    specRootFile.copy(targetFolderPath.append(specRootFile.getProjectRelativePath()),IResource.DERIVED | IResource.FORCE,new SubProgressMonitor(monitor,1));
    IResource specRootFileCopy=modelFolder.findMember(specRootFile.getProjectRelativePath());
    if (specRootFileCopy == null) {
      throw new CoreException(new Status(IStatus.ERROR,TLCActivator.PLUGIN_ID,"String_Node_Str" + specRootFilename + "String_Node_Str"+ targetFolderPath.toOSString()));
    }
    List extendedModules=ToolboxHandle.getExtendedModules(specRootFile.getName());
    IFile moduleFile=null;
    for (int i=0; i < extendedModules.size(); i++) {
      String module=(String)extendedModules.get(i);
      if (ToolboxHandle.isUserModule(module)) {
        moduleFile=ResourceHelper.getLinkedFile(project,module,false);
        if (moduleFile != null) {
          moduleFile.copy(targetFolderPath.append(moduleFile.getProjectRelativePath()),IResource.DERIVED | IResource.FORCE,new SubProgressMonitor(monitor,STEP / extendedModules.size()));
        }
      }
    }
    ISchedulingRule fileRule=MultiRule.combine(ResourceHelper.getModifyRule(files),ResourceHelper.getCreateRule(files));
    ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable(){
      public void run(      IProgressMonitor monitor) throws CoreException {
        for (int i=0; i < files.length; i++) {
          if (files[i].exists()) {
            files[i].setContents(new ByteArrayInputStream("String_Node_Str".getBytes()),IResource.DERIVED | IResource.FORCE,new SubProgressMonitor(monitor,1));
          }
 else {
            files[i].create(new ByteArrayInputStream("String_Node_Str".getBytes()),IResource.DERIVED | IResource.FORCE,new SubProgressMonitor(monitor,1));
          }
        }
      }
    }
,fileRule,IWorkspace.AVOID_UPDATE,new SubProgressMonitor(monitor,STEP));
    monitor.worked(STEP);
    monitor.subTask("String_Node_Str");
    ModelWriter writer=new ModelWriter();
    writer.addPrimer(ModelHelper.MC_MODEL_NAME,ResourceHelper.getModuleName(specRootFilename));
    List constants=ModelHelper.deserializeAssignmentList(config.getAttribute(MODEL_PARAMETER_CONSTANTS,new Vector()));
    TypedSet modelValues=TypedSet.parseSet(config.getAttribute(MODEL_PARAMETER_MODEL_VALUES,EMPTY_STRING));
    writer.addConstants(constants,modelValues,MODEL_PARAMETER_CONSTANTS,MODEL_PARAMETER_MODEL_VALUES);
    writer.addNewDefinitions(config.getAttribute(MODEL_PARAMETER_NEW_DEFINITIONS,EMPTY_STRING),MODEL_PARAMETER_NEW_DEFINITIONS);
    List overrides=ModelHelper.deserializeAssignmentList(config.getAttribute(MODEL_PARAMETER_DEFINITIONS,new Vector()));
    writer.addFormulaList(ModelWriter.createOverridesContent(overrides,ModelWriter.DEFOV_SCHEME),"String_Node_Str",MODEL_PARAMETER_DEFINITIONS);
    writer.addFormulaList(ModelWriter.createSourceContent(MODEL_PARAMETER_CONSTRAINT,ModelWriter.CONSTRAINT_SCHEME,config),"String_Node_Str",MODEL_PARAMETER_CONSTRAINT);
    writer.addFormulaList(ModelWriter.createSourceContent(MODEL_PARAMETER_ACTION_CONSTRAINT,ModelWriter.ACTIONCONSTRAINT_SCHEME,config),"String_Node_Str",MODEL_PARAMETER_ACTION_CONSTRAINT);
    int specType=config.getAttribute(MODEL_BEHAVIOR_SPEC_TYPE,MODEL_BEHAVIOR_TYPE_DEFAULT);
switch (specType) {
case MODEL_BEHAVIOR_TYPE_NO_SPEC:
      break;
case MODEL_BEHAVIOR_TYPE_SPEC_CLOSED:
    writer.addFormulaList(ModelWriter.createSourceContent(MODEL_BEHAVIOR_CLOSED_SPECIFICATION,ModelWriter.SPEC_SCHEME,config),"String_Node_Str",MODEL_BEHAVIOR_CLOSED_SPECIFICATION);
  break;
case MODEL_BEHAVIOR_TYPE_SPEC_INIT_NEXT:
writer.addFormulaList(ModelWriter.createSourceContent(MODEL_BEHAVIOR_SEPARATE_SPECIFICATION_INIT,ModelWriter.INIT_SCHEME,config),"String_Node_Str",MODEL_BEHAVIOR_SEPARATE_SPECIFICATION_INIT);
writer.addFormulaList(ModelWriter.createSourceContent(MODEL_BEHAVIOR_SEPARATE_SPECIFICATION_NEXT,ModelWriter.NEXT_SCHEME,config),"String_Node_Str",MODEL_BEHAVIOR_SEPARATE_SPECIFICATION_NEXT);
break;
}
writer.addFormulaList(ModelWriter.createFormulaListContent(config.getAttribute(MODEL_CORRECTNESS_INVARIANTS,new Vector()),ModelWriter.INVARIANT_SCHEME),"String_Node_Str",MODEL_CORRECTNESS_INVARIANTS);
writer.addFormulaList(ModelWriter.createFormulaListContent(config.getAttribute(MODEL_CORRECTNESS_PROPERTIES,new Vector()),ModelWriter.PROP_SCHEME),"String_Node_Str",MODEL_CORRECTNESS_PROPERTIES);
monitor.worked(STEP);
monitor.subTask("String_Node_Str");
writer.writeFiles(tlaFile,cfgFile,monitor);
modelFolder.refreshLocal(IResource.DEPTH_ONE,new SubProgressMonitor(monitor,STEP));
}
  finally {
monitor.done();
}
return false;
}