}
@SuppressWarnings("unchecked")
private TextChange createFileChange(IFile file, Pattern pattern, Collection/*FileMatch*/matches,
RefactoringStatus resultingStatus, Collection matchGroups) throws PatternSyntaxException, CoreException {
PositionTracker tracker = InternalSearchUI.getInstance().getPositionTracker();
TextFileChange change = new PyTextFileChange(Messages.format(
SearchMessages.ReplaceRefactoring_group_label_change_for_file, file.getName()), file);
change.setEdit(new MultiTextEdit());
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
manager.connect(file.getFullPath(), LocationKind.IFILE, null);
try {
ITextFileBuffer textFileBuffer = manager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
if (textFileBuffer == null) {
resultingStatus.addError(Messages.format(SearchMessages.ReplaceRefactoring_error_accessing_file_buffer,
file.getName()));
return null;
}
IDocument document = textFileBuffer.getDocument();
String lineDelimiter = TextUtilities.getDefaultLineDelimiter(document);
for (Iterator iterator = matches.iterator(); iterator.hasNext();) {
FileMatch match = (FileMatch) iterator.next();
int offset = match.getOffset();
int length = match.getLength();
Position currentPosition = tracker.getCurrentPosition(match);
if (currentPosition != null) {
offset = currentPosition.offset;
if (length != currentPosition.length) {
resultingStatus.addError(Messages.format(
SearchMessages.ReplaceRefactoring_error_match_content_changed, file.getName()));