Program: 136060
Project: 136060
Buggy source:
/** 
 * Calls SANY, that parses the root module. <br> <b>Note:</b> This method fills the error objects   {@link ParseSpecHandler#parseErrors} and{@link ParseSpecHandler#semanticErrors}. Call   {@link ParseSpecHandler#processParsingErrors(Spec)} to store thisinformation in the specification handle
 * @param doSemanticAnalysis if true, the semantical phase will be started
 * @param parseResource filename of the module to parse
 * @return status of parsing, one of the {@link IParseConstants} constants
 */
private ParseResult parseModule(IResource parseResource,boolean updateStorage){
  String moduleFilename=parseResource.getLocation().toOSString();
  int specStatus=0;
  Errors parseErrors=null;
  Errors semanticErrors=null;
  FilenameToStream resolver=new RCPNameToFileIStream(null);
  ToolIO.reset();
  ToolIO.setDefaultResolver(resolver);
  ToolIO.setMode(ToolIO.TOOL);
  SpecObj moduleSpec=new SpecObj(ResourceHelper.getModuleName(moduleFilename),resolver);
  PrintStream outputStr=ToolIO.out;
  try {
    SANY.frontEndInitialize(moduleSpec,outputStr);
    SANY.frontEndParse(moduleSpec,outputStr);
    SANY.frontEndSemanticAnalysis(moduleSpec,outputStr,true);
  }
 catch (  InitException e) {
    specStatus=IParseConstants.UNKNOWN_ERROR;
    return new ParseResult(specStatus,null,parseResource,parseErrors,semanticErrors);
  }
catch (  ParseException e) {
    specStatus=IParseConstants.SYNTAX_ERROR;
    parseErrors=moduleSpec.getParseErrors();
  }
catch (  SemanticException e) {
    specStatus=IParseConstants.SEMANTIC_ERROR;
  }
  if (specStatus > IParseConstants.SYNTAX_ERROR) {
    semanticErrors=moduleSpec.semanticErrors;
    if (semanticErrors != null) {
      if (semanticErrors.getNumMessages() > 0) {
        if (semanticErrors.isSuccess()) {
          specStatus=IParseConstants.SEMANTIC_WARNING;
        }
 else {
          specStatus=IParseConstants.SEMANTIC_ERROR;
        }
      }
    }
  }
  Vector userModules=new Vector();
  boolean rootModuleFound=false;
  final Vector resourcesToTimeStamp=new Vector();
  Enumeration enumerate=moduleSpec.parseUnitContext.keys();
  while (enumerate.hasMoreElements()) {
    String moduleName=(String)enumerate.nextElement();
    ParseUnit parseUnit=(ParseUnit)moduleSpec.parseUnitContext.get(moduleName);
    String absoluteFileName=null;
    if (parseUnit.getNis() != null && parseUnit.getNis().sourceFile() != null) {
      absoluteFileName=parseUnit.getNis().sourceFile().getAbsolutePath();
    }
    if (absoluteFileName == null) {
      throw new RuntimeException("String_Node_Str");
    }
    Module module=new Module(absoluteFileName);
    if (!module.isStandardModule() && updateStorage) {
      IResource moduleResource=ResourceHelper.getResourceByModuleName(moduleName);
      if (moduleResource != null && moduleResource.exists()) {
        resourcesToTimeStamp.add(moduleResource);
      }
    }
    if (specStatus > IParseConstants.SEMANTIC_ERROR) {
      ExternalModuleTable.ExternalModuleTableEntry emt=(ExternalModuleTable.ExternalModuleTableEntry)moduleSpec.getExternalModuleTable().moduleHashTable.get(UniqueString.uniqueStringOf(module.getModuleName()));
      if (emt != null) {
        module.setNode(emt.getModuleNode());
      }
    }
    if (module.getModuleName().equals(ResourceHelper.getModuleName(moduleFilename))) {
      rootModuleFound=true;
      module.setRoot(true);
    }
    if (module.isStandardModule()) {
    }
 else {
      userModules.addElement(module);
      if (module.getAbsolutePath().indexOf(parseResource.getProject().getLocation().toOSString()) != 0) {
        ResourceHelper.getLinkedFile(parseResource.getProject(),module.getAbsolutePath(),true);
      }
    }
  }
  try {
    ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable(){
      public void run(      IProgressMonitor monitor) throws CoreException {
        Iterator iterator=resourcesToTimeStamp.iterator();
        while (iterator.hasNext()) {
          IResource resource=(IResource)iterator.next();
          resource.setPersistentProperty(TLAParsingBuilderConstants.LAST_BUILT,String.valueOf(System.currentTimeMillis()));
        }
      }
    }
,new NullProgressMonitor());
  }
 catch (  CoreException e) {
    Activator.logError("String_Node_Str",e);
  }
  if (!rootModuleFound) {
    specStatus=IParseConstants.COULD_NOT_FIND_MODULE;
  }
  if (updateStorage) {
    Activator.getModuleDependencyStorage().put(parseResource.getName(),AdapterFactory.adaptModules(parseResource.getName(),userModules));
  }
  return new ParseResult(specStatus,moduleSpec,parseResource,parseErrors,semanticErrors);
}

Fixed version (ground truth):
/** 
 * Calls SANY, that parses the root module. <br> <b>Note:</b> This method fills the error objects   {@link ParseSpecHandler#parseErrors} and{@link ParseSpecHandler#semanticErrors}. Call   {@link ParseSpecHandler#processParsingErrors(Spec)} to store thisinformation in the specification handle
 * @param doSemanticAnalysis if true, the semantical phase will be started
 * @param parseResource filename of the module to parse
 * @return status of parsing, one of the {@link IParseConstants} constants
 */
private ParseResult parseModule(IResource parseResource,boolean updateStorage){
  String moduleFilename=parseResource.getLocation().toOSString();
  int specStatus=0;
  Errors parseErrors=null;
  Errors semanticErrors=null;
  FilenameToStream resolver=new RCPNameToFileIStream(null);
  ToolIO.reset();
  ToolIO.setDefaultResolver(resolver);
  ToolIO.setMode(ToolIO.TOOL);
  SpecObj moduleSpec=new SpecObj(ResourceHelper.getModuleName(moduleFilename),resolver);
  PrintStream outputStr=ToolIO.out;
  try {
    SANY.frontEndInitialize(moduleSpec,outputStr);
    SANY.frontEndParse(moduleSpec,outputStr);
    SANY.frontEndSemanticAnalysis(moduleSpec,outputStr,true);
  }
 catch (  InitException e) {
    specStatus=IParseConstants.UNKNOWN_ERROR;
    return new ParseResult(specStatus,null,parseResource,parseErrors,semanticErrors);
  }
catch (  ParseException e) {
    specStatus=IParseConstants.SYNTAX_ERROR;
    parseErrors=moduleSpec.getParseErrors();
  }
catch (  SemanticException e) {
    specStatus=IParseConstants.SEMANTIC_ERROR;
  }
  if (specStatus > IParseConstants.SYNTAX_ERROR) {
    semanticErrors=moduleSpec.semanticErrors;
    if (semanticErrors != null) {
      Errors globalContextErrors=moduleSpec.getGlobalContextErrors();
      String[] errors=globalContextErrors.getErrors();
      for (int i=0; i < errors.length; i++) {
        semanticErrors.addError(null,errors[i]);
      }
      String[] aborts=globalContextErrors.getAborts();
      for (int i=0; i < aborts.length; i++) {
        try {
          semanticErrors.addAbort(aborts[i],false);
        }
 catch (        AbortException e) {
          Activator.logDebug("String_Node_Str" + "String_Node_Str");
        }
      }
      String[] warnings=globalContextErrors.getWarnings();
      for (int i=0; i < warnings.length; i++) {
        semanticErrors.addWarning(null,warnings[i]);
      }
      if (semanticErrors.getNumMessages() > 0) {
        if (semanticErrors.isSuccess()) {
          specStatus=IParseConstants.SEMANTIC_WARNING;
        }
 else {
          specStatus=IParseConstants.SEMANTIC_ERROR;
        }
      }
    }
  }
  Vector userModules=new Vector();
  boolean rootModuleFound=false;
  final Vector resourcesToTimeStamp=new Vector();
  Enumeration enumerate=moduleSpec.parseUnitContext.keys();
  while (enumerate.hasMoreElements()) {
    String moduleName=(String)enumerate.nextElement();
    ParseUnit parseUnit=(ParseUnit)moduleSpec.parseUnitContext.get(moduleName);
    String absoluteFileName=null;
    if (parseUnit.getNis() != null && parseUnit.getNis().sourceFile() != null) {
      absoluteFileName=parseUnit.getNis().sourceFile().getAbsolutePath();
    }
    if (absoluteFileName == null) {
      throw new RuntimeException("String_Node_Str");
    }
    Module module=new Module(absoluteFileName);
    if (!module.isStandardModule() && updateStorage) {
      IResource moduleResource=ResourceHelper.getResourceByModuleName(moduleName);
      if (moduleResource != null && moduleResource.exists()) {
        resourcesToTimeStamp.add(moduleResource);
      }
    }
    if (specStatus > IParseConstants.SEMANTIC_ERROR) {
      ExternalModuleTable.ExternalModuleTableEntry emt=(ExternalModuleTable.ExternalModuleTableEntry)moduleSpec.getExternalModuleTable().moduleHashTable.get(UniqueString.uniqueStringOf(module.getModuleName()));
      if (emt != null) {
        module.setNode(emt.getModuleNode());
      }
    }
    if (module.getModuleName().equals(ResourceHelper.getModuleName(moduleFilename))) {
      rootModuleFound=true;
      module.setRoot(true);
    }
    if (module.isStandardModule()) {
    }
 else {
      userModules.addElement(module);
      if (module.getAbsolutePath().indexOf(parseResource.getProject().getLocation().toOSString()) != 0) {
        ResourceHelper.getLinkedFile(parseResource.getProject(),module.getAbsolutePath(),true);
      }
    }
  }
  try {
    ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable(){
      public void run(      IProgressMonitor monitor) throws CoreException {
        Iterator iterator=resourcesToTimeStamp.iterator();
        while (iterator.hasNext()) {
          IResource resource=(IResource)iterator.next();
          resource.setPersistentProperty(TLAParsingBuilderConstants.LAST_BUILT,String.valueOf(System.currentTimeMillis()));
        }
      }
    }
,new NullProgressMonitor());
  }
 catch (  CoreException e) {
    Activator.logError("String_Node_Str",e);
  }
  if (!rootModuleFound) {
    specStatus=IParseConstants.COULD_NOT_FIND_MODULE;
  }
  if (updateStorage) {
    Activator.getModuleDependencyStorage().put(parseResource.getName(),AdapterFactory.adaptModules(parseResource.getName(),userModules));
  }
  return new ParseResult(specStatus,moduleSpec,parseResource,parseErrors,semanticErrors);
}