aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/assists.rs
blob: 7a9c6668174453dc6bdaeb142ac86570e8c0500d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;
            let file_edit = SourceFileEdit { file_id, edit: action.edit };
            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 }),
            }
        })
        .collect()
}