Replacement[] repls = (Replacement[]) changes.toArray(new Replacement[n]);
Arrays.sort(repls);
StringCopier copier = new StringCopier(source);
for (int i = 0; i < n; ++i) {
Replacement repl = repls[i];
copier.commit(repl.text, repl.start, repl.end);
}
char[] results = copier.finish();
return new CompilationUnitProviderWithAlternateSource(cup, results);