final TextSearchRequestor collector = new TextSearchRequestor() {
@Override
public boolean acceptPatternMatch(final TextSearchMatchAccess matchAccess) throws CoreException {
final IFile file = matchAccess.getFile();
TextFileChange change = changes.get(file);
if (change == null) {
final TextChange textChange = getTextChange(file);
if (textChange != null) {
return false;
}
change = new TextFileChange(file.getName(), file);
change.setEdit(new MultiTextEdit());
changes.put(file, change);
}
final ReplaceEdit edit = new ReplaceEdit(matchAccess.getMatchOffset(), matchAccess.getMatchLength(), replacement);
change.addEdit(edit);
change.addTextEditGroup(new TextEditGroup("Update " + QWickieActivator.WICKET_ID, edit));
return true;
}
};
TextSearchEngine.create().search(scope, collector, pattern, paramIProgressMonitor);