Program: 102021
Project: 102021
Buggy source:
/** 
 * Calculate changes to user-generated sql
 * @param file
 * @param pathPair
 * @param textFileChange
 * @throws Exception 
 */
public static void calculateModelImportsElementLChanges(IFile file,PathPair pathPair,TextFileChange textFileChange) throws Exception {
  File nativeFile=ModelUtil.getLocation(file).makeAbsolute().toFile();
  if (nativeFile == null || !nativeFile.exists())   throw new Exception(getString("String_Node_Str",file.getFullPath()));
  TextEdit fileChangeRootEdit=setRootEdit(textFileChange);
  boolean isWindows=Platform.getOS().equals(Platform.WS_WIN32);
  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)) {
        StringBuilder sb=new StringBuilder(line);
        if (pathPair.getSourcePath().equals(pathPair.getTargetPath())) {
          docOffset+=line.length() + 1;
          continue;
        }
        int lineOffset=line.indexOf(pathPair.getSourcePath());
        if (lineOffset > 0) {
          int offset=docOffset + lineOffset;
          ReplaceEdit edit=new ReplaceEdit(offset,pathPair.getSourcePath().length(),pathPair.getTargetPath());
          fileChangeRootEdit.addChild(edit);
        }
        lineOffset=line.indexOf(pathPair.getSourceNameNoExtension());
        if (lineOffset > 0) {
          int offset=docOffset + lineOffset;
          ReplaceEdit edit=new ReplaceEdit(offset,pathPair.getSourceNameNoExtension().length(),pathPair.getTargetNameNoExtension());
          fileChangeRootEdit.addChild(edit);
        }
      }
      docOffset+=line.length() + 1;
      if (isWindows) {
        docOffset++;
      }
    }
  }
  finally {
    if (reader != null)     reader.close();
  }
}

Fixed version (ground truth):
/** 
 * Calculate changes to user-generated sql
 * @param file
 * @param pathPair
 * @param textFileChange
 * @throws Exception 
 */
public static void calculateModelImportsElementLChanges(IFile file,PathPair pathPair,TextFileChange textFileChange) throws Exception {
  File nativeFile=ModelUtil.getLocation(file).makeAbsolute().toFile();
  if (nativeFile == null || !nativeFile.exists())   throw new Exception(getString("String_Node_Str",file.getFullPath()));
  TextEdit fileChangeRootEdit=setRootEdit(textFileChange);
  boolean isWindows=Platform.getOS().equals(Platform.WS_WIN32);
  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)) {
        StringBuilder sb=new StringBuilder(line);
        if (pathPair.getSourcePath().equals(pathPair.getTargetPath())) {
          docOffset+=line.length() + 1;
          continue;
        }
        int lineOffset=line.indexOf(pathPair.getSourcePath().replace('\\','/'));
        if (lineOffset > 0) {
          int offset=docOffset + lineOffset;
          ReplaceEdit edit=new ReplaceEdit(offset,pathPair.getSourcePath().length(),pathPair.getTargetPath().replace('\\','/'));
          fileChangeRootEdit.addChild(edit);
        }
        lineOffset=line.indexOf(pathPair.getSourceNameNoExtension());
        if (lineOffset > 0) {
          int offset=docOffset + lineOffset;
          ReplaceEdit edit=new ReplaceEdit(offset,pathPair.getSourceNameNoExtension().length(),pathPair.getTargetNameNoExtension());
          fileChangeRootEdit.addChild(edit);
        }
      }
      docOffset+=line.length() + 1;
      if (isWindows) {
        docOffset++;
      }
    }
  }
  finally {
    if (reader != null)     reader.close();
  }
}