applyWith static method
Applies all collected edits to the source text and writes it back to the file.
Implementation
static void applyWith(SourceFile source, List<SourceFileEdit> edits) {
edits.sort((a, b) => b.start.compareTo(a.start));
for (final edit in edits) {
source.text = source.text.replaceRange(
edit.start,
edit.end,
edit.content,
);
}
// Write the updated text back to the file.
File(source.path).writeAsStringSync(source.text);
}