mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
Add convenience functions to SourceChange for creating single edits
This commit is contained in:
parent
449eea1161
commit
22e1c7a112
4 changed files with 63 additions and 44 deletions
|
@ -17,14 +17,9 @@ pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> {
|
|||
let file_id = frange.file_id;
|
||||
let file_edit = SourceFileEdit { file_id, edit: action.edit };
|
||||
let id = label.id;
|
||||
let change = SourceChange {
|
||||
label: label.label,
|
||||
source_file_edits: vec![file_edit],
|
||||
file_system_edits: vec![],
|
||||
cursor_position: action
|
||||
.cursor_position
|
||||
.map(|offset| FilePosition { offset, file_id }),
|
||||
};
|
||||
let change = SourceChange::source_edit(label.label, file_edit).with_cursor_opt(
|
||||
action.cursor_position.map(|offset| FilePosition { offset, file_id }),
|
||||
);
|
||||
Assist { id, change }
|
||||
})
|
||||
.collect()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue