Program: 102014
Project: 102014
Buggy source:
/** 
 * Calculates a   {@link TextFileChange} for all the substitutions that need to take place in thegiven file based on the collection of path pairs.
 * @param file
 * @param pathPairs
 * @return text file change
 * @throws Exception
 */
public static TextFileChange calculateTextChanges(IFile file,Collection<PathPair> pathPairs) throws Exception {
  File nativeFile=ModelUtil.getLocation(file).makeAbsolute().toFile();
  if (nativeFile == null || !nativeFile.exists())   throw new Exception(getString("String_Node_Str",file.getFullPath()));
  TextFileChange textFileChange=new TextFileChange(file.getName(),file);
  TextEdit fileChangeRootEdit=setRootEdit(textFileChange);
  if (pathPairs.isEmpty()) {
    return textFileChange;
  }
  BufferedReader reader=null;
  String line;
  int docOffset=0;
  try {
    reader=new BufferedReader(new FileReader(nativeFile));
    while ((line=reader.readLine()) != null) {
      if (!line.contains(MODEL_IMPORTS_ELEMENT_START)) {
        for (        PathPair pathPair : pathPairs) {
          if (pathPair.getSourcePath().equals(pathPair.getTargetPath())) {
            continue;
          }
          int lineOffset=line.indexOf(pathPair.getSourcePath().replace('\\','/'));
          if (lineOffset < 0)           continue;
          int offset=docOffset + lineOffset;
          ReplaceEdit edit=new ReplaceEdit(offset,pathPair.getSourcePath().length(),pathPair.getTargetPath().replace('\\','/'));
          fileChangeRootEdit.addChild(edit);
        }
      }
      docOffset+=line.length() + 1;
      if (Platform.getOS().equalsIgnoreCase(Platform.WS_WIN32)) {
        docOffset++;
      }
    }
  }
  finally {
    if (reader != null)     reader.close();
  }
  return textFileChange;
}

Fixed version (ground truth):
/** 
 * Calculates a   {@link TextFileChange} for all the substitutions that need to take place in thegiven file based on the collection of path pairs.
 * @param file
 * @param pathPairs
 * @return text file change
 * @throws Exception
 */
public static TextFileChange calculateTextChanges(IFile file,Collection<PathPair> pathPairs) throws Exception {
  File nativeFile=ModelUtil.getLocation(file).makeAbsolute().toFile();
  if (nativeFile == null || !nativeFile.exists())   throw new Exception(getString("String_Node_Str",file.getFullPath()));
  boolean isWindows=hasWindowsLineTerminator(nativeFile);
  TextFileChange textFileChange=new TextFileChange(file.getName(),file);
  TextEdit fileChangeRootEdit=setRootEdit(textFileChange);
  if (pathPairs.isEmpty()) {
    return textFileChange;
  }
  BufferedReader reader=null;
  String line;
  int docOffset=0;
  try {
    reader=new BufferedReader(new FileReader(nativeFile));
    while ((line=reader.readLine()) != null) {
      if (!line.contains(MODEL_IMPORTS_ELEMENT_START)) {
        for (        PathPair pathPair : pathPairs) {
          if (pathPair.getSourcePath().equals(pathPair.getTargetPath())) {
            continue;
          }
          String sourcePath=pathPair.getSourcePath().replace('\\','/');
          boolean sourcePathHasSlash=sourcePath.indexOf('/') > -1;
          int lineOffset=line.indexOf(sourcePath);
          if (lineOffset < 0)           continue;
          if (sourcePathHasSlash || line.charAt(lineOffset - 1) == '"') {
            int offset=docOffset + lineOffset;
            ReplaceEdit edit=new ReplaceEdit(offset,pathPair.getSourcePath().length(),pathPair.getTargetPath().replace('\\','/'));
            fileChangeRootEdit.addChild(edit);
          }
        }
      }
      docOffset+=line.length() + 1;
      if (isWindows) {
        docOffset++;
      }
    }
  }
  finally {
    if (reader != null)     reader.close();
  }
  return textFileChange;
}