Program: 102012
Project: 102012
Buggy source:
/** 
 * Calculate changes to user-generated sql
 * @param file
 * @param pathPair
 * @param textFileChange
 * @throws Exception 
 */
public static void calculateSQLChanges(IFile file,PathPair pathPair,TextFileChange textFileChange) throws Exception {
  if (!ModelUtil.isModelFile(file)) {
    return;
  }
  IPath sourcePath=new Path(pathPair.getSourcePath());
  IPath targetPath=new Path(pathPair.getTargetPath());
  String sourceName=sourcePath.removeFileExtension().lastSegment();
  String targetName=targetPath.removeFileExtension().lastSegment();
  if (sourceName.equals(targetName))   return;
  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);
  BufferedReader reader=null;
  String line;
  int docOffset=0;
  char[] prefixChars={' ',',',';','\t','\n','('};
  try {
    reader=new BufferedReader(new FileReader(nativeFile));
    while ((line=reader.readLine()) != null) {
      if (line.contains(SQL_STATEMENT_START)) {
        for (        char prefixChar : prefixChars) {
          String toReplace=prefixChar + sourceName + '.';
          for (int lineOffset=line.indexOf(toReplace); lineOffset >= 0; lineOffset=line.indexOf(toReplace,lineOffset + 1)) {
            if (lineOffset < 0)             continue;
            int offset=docOffset + lineOffset + 1;
            ReplaceEdit edit=new ReplaceEdit(offset,sourceName.length(),targetName);
            fileChangeRootEdit.addChild(edit);
          }
        }
      }
      docOffset+=line.length() + 1;
      if (Platform.getOS().equalsIgnoreCase(Platform.WS_WIN32)) {
        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 calculateSQLChanges(IFile file,PathPair pathPair,TextFileChange textFileChange) throws Exception {
  if (!ModelUtil.isModelFile(file)) {
    return;
  }
  IPath sourcePath=new Path(pathPair.getSourcePath());
  IPath targetPath=new Path(pathPair.getTargetPath());
  String sourceName=sourcePath.removeFileExtension().lastSegment();
  String targetName=targetPath.removeFileExtension().lastSegment();
  if (sourceName.equals(targetName))   return;
  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);
  TextEdit fileChangeRootEdit=setRootEdit(textFileChange);
  BufferedReader reader=null;
  String line;
  int docOffset=0;
  char[] prefixChars={' ',',',';','\t','\n','('};
  try {
    reader=new BufferedReader(new FileReader(nativeFile));
    while ((line=reader.readLine()) != null) {
      if (line.contains(SQL_STATEMENT_START)) {
        for (        char prefixChar : prefixChars) {
          String toReplace=prefixChar + sourceName + '.';
          for (int lineOffset=line.indexOf(toReplace); lineOffset >= 0; lineOffset=line.indexOf(toReplace,lineOffset + 1)) {
            if (lineOffset < 0)             continue;
            int offset=docOffset + lineOffset + 1;
            ReplaceEdit edit=new ReplaceEdit(offset,sourceName.length(),targetName);
            fileChangeRootEdit.addChild(edit);
          }
        }
      }
      docOffset+=line.length() + 1;
      if (isWindows) {
        docOffset++;
      }
    }
  }
  finally {
    if (reader != null)     reader.close();
  }
}