rust-analyzer/crates/ra_ide_api/src/assists.rs

22 lines
741 B
Rust
Raw Normal View History

2019-02-03 18:26:35 +00:00
use ra_db::{FileRange, FilePosition};
use crate::{SourceFileEdit, SourceChange, db::RootDatabase};
pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<SourceChange> {
ra_assists::assists(db, frange)
.into_iter()
.map(|(label, action)| {
let file_id = frange.file_id;
2019-02-08 11:49:43 +00:00
let file_edit = SourceFileEdit { file_id, edit: action.edit };
2019-02-03 18:26:35 +00:00
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 }),
}
})
2019-02-03 16:27:36 +00:00
.collect()
}