From fdd4df97ba5ce1f59abf9e945052fc6f3e077c3a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 6 May 2020 15:26:40 +0200 Subject: Use SourceChange for assists --- crates/ra_ide/src/assists.rs | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete 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 deleted file mode 100644 index 389339a03..000000000 --- a/crates/ra_ide/src/assists.rs +++ /dev/null @@ -1,42 +0,0 @@ -//! FIXME: write short doc here - -use ra_assists::{resolved_assists, AssistAction}; -use ra_db::{FilePosition, FileRange}; -use ra_ide_db::RootDatabase; - -use crate::{FileId, SourceChange, SourceFileEdit}; - -pub use ra_assists::AssistId; - -#[derive(Debug)] -pub struct Assist { - pub id: AssistId, - pub label: String, - pub group_label: Option, - pub source_change: SourceChange, -} - -pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec { - resolved_assists(db, frange) - .into_iter() - .map(|assist| { - let file_id = frange.file_id; - Assist { - id: assist.label.id, - label: assist.label.label.clone(), - group_label: assist.label.group.map(|it| it.0), - source_change: action_to_edit(assist.action, file_id, assist.label.label.clone()), - } - }) - .collect() -} - -fn action_to_edit(action: AssistAction, file_id: FileId, label: String) -> SourceChange { - let file_id = match action.file { - ra_assists::AssistFile::TargetFile(it) => it, - _ => file_id, - }; - let file_edit = SourceFileEdit { file_id, edit: action.edit }; - SourceChange::source_file_edit(label, file_edit) - .with_cursor_opt(action.cursor_position.map(|offset| FilePosition { offset, file_id })) -} -- cgit v1.2.3