From 757e593b253b4df7e6fc8bf15a4d4f34c9d484c5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 27 Nov 2019 21:32:33 +0300 Subject: rename ra_ide_api -> ra_ide --- crates/ra_ide/src/assists.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 crates/ra_ide/src/assists.rs (limited to 'crates/ra_ide/src/assists.rs') diff --git a/crates/ra_ide/src/assists.rs b/crates/ra_ide/src/assists.rs new file mode 100644 index 000000000..e00589733 --- /dev/null +++ b/crates/ra_ide/src/assists.rs @@ -0,0 +1,28 @@ +//! FIXME: write short doc here + +use ra_db::{FilePosition, FileRange}; + +use crate::{db::RootDatabase, SourceChange, SourceFileEdit}; + +pub use ra_assists::AssistId; + +#[derive(Debug)] +pub struct Assist { + pub id: AssistId, + pub change: SourceChange, +} + +pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec { + 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 }; + let id = label.id; + let change = SourceChange::source_file_edit(label.label, file_edit).with_cursor_opt( + action.cursor_position.map(|offset| FilePosition { offset, file_id }), + ); + Assist { id, change } + }) + .collect() +} -- cgit v1.2.3