Further improvements to the SourceChange convenience methods

Rename system_edit to file_system_edit, add more documentation, add
source_file_edit_from to create a SourceChange from `FileId` and `TextEdit`.
This commit is contained in:
Ville Penttinen 2019-03-25 09:03:10 +02:00
parent 22e1c7a112
commit b92fcbc956
4 changed files with 50 additions and 27 deletions

View file

@ -112,16 +112,14 @@ pub(crate) fn on_dot_typed(db: &RootDatabase, position: FilePosition) -> Option<
TextRange::from_to(position.offset - current_indent_len, position.offset),
target_indent.into(),
);
let res = SourceChange {
label: "reindent dot".to_string(),
source_file_edits: vec![SourceFileEdit { edit: edit.finish(), file_id: position.file_id }],
file_system_edits: vec![],
cursor_position: Some(FilePosition {
let res = SourceChange::source_file_edit_from("reindent dot", position.file_id, edit.finish())
.with_cursor(FilePosition {
offset: position.offset + target_indent_len - current_indent_len
+ TextUnit::of_char('.'),
file_id: position.file_id,
}),
};
});
Some(res)
}