Program: 138387
Project: 138387
Buggy source:
/** 
 * update ModelElement files (Analysis, Report, IndicatorDefinition, Pattern, Rule).
 * @param parentFile
 * @param fileExtension
 * @param baseFolder
 * @param baseFile
 * @param createSubFolder
 * @param replaceStringMap
 * @return
 */
private boolean updateModelElements(File parentFile,String fileExtension,IFolder baseFolder,File baseFile,boolean createSubFolder,Map<String,String> replaceStringMap){
  boolean isImport=true;
  try {
    if (!parentFile.isFile()) {
      boolean updateSubFolders=true;
      if (createSubFolder) {
        updateSubFolders=createSubFolder(parentFile,baseFolder);
      }
      if (updateSubFolders) {
        File[] listFiles=parentFile.listFiles();
        for (        File file : listFiles) {
          updateModelElements(file,fileExtension,baseFolder,baseFile,createSubFolder,replaceStringMap);
        }
      }
    }
 else {
      if (parentFile.getName().endsWith(fileExtension)) {
        ModelElement modelElement=getModelElement(parentFile);
        if (modelElement != null) {
          IFolder fullPathFolder=getFullPathFolder(baseFolder,baseFile,parentFile);
          if (fileExtension.equals(FactoriesUtil.ANA)) {
            setReplaceChildNameForAna(modelElement);
          }
          ElementWriterFactory.getInstance().createPatternWriter().create(modelElement,fullPathFolder,isImport);
          IPath replatePrefixPath=fullPathFolder.getFullPath().removeFirstSegments(2);
          String oldFileNameFull=replatePrefixPath.append(parentFile.getName()).toString();
          String newFileNameFull=replatePrefixPath.append(getDefaultNewFileName(modelElement.getName(),fileExtension)).toString();
          replaceStringMap.put(oldFileNameFull,newFileNameFull);
        }
      }
    }
  }
 catch (  Exception e) {
    log.error(e,e);
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * update ModelElement files (Analysis, Report, IndicatorDefinition, Pattern, Rule).
 * @param parentFile
 * @param fileExtension
 * @param baseFolder
 * @param baseFile
 * @param createSubFolder
 * @param replaceStringMap
 * @return
 */
private boolean updateModelElements(File parentFile,String fileExtension,IFolder baseFolder,File baseFile,boolean createSubFolder,Map<String,String> replaceStringMap){
  boolean isImport=true;
  try {
    if (!parentFile.isFile()) {
      boolean updateSubFolders=true;
      if (createSubFolder) {
        updateSubFolders=createSubFolder(parentFile,baseFolder);
      }
      if (updateSubFolders) {
        File[] listFiles=parentFile.listFiles();
        for (        File file : listFiles) {
          updateModelElements(file,fileExtension,baseFolder,baseFile,createSubFolder,replaceStringMap);
        }
      }
    }
 else {
      if (parentFile.getName().endsWith(fileExtension)) {
        ModelElement modelElement=getModelElement(parentFile);
        if (modelElement != null) {
          IFolder fullPathFolder=getFullPathFolder(baseFolder,baseFile,parentFile);
          if (fileExtension.equals(FactoriesUtil.ANA)) {
            setReplaceChildNameForAna(modelElement);
          }
          String modelName=checkName(modelElement,fullPathFolder);
          modelElement.setName(modelName);
          ElementWriterFactory.getInstance().createPatternWriter().create(modelElement,fullPathFolder,isImport);
          IPath replatePrefixPath=fullPathFolder.getFullPath().removeFirstSegments(2);
          String oldFileNameFull=replatePrefixPath.append(parentFile.getName()).toString();
          String newFileNameFull=replatePrefixPath.append(getDefaultNewFileName(modelElement.getName(),fileExtension)).toString();
          replaceStringMap.put(oldFileNameFull,newFileNameFull);
        }
      }
    }
  }
 catch (  Exception e) {
    log.error(e,e);
    return false;
  }
  return true;
}