From 9769c5140c9c406a4cc880e698593a6c4bcc6826 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 9 Feb 2020 15:32:53 +0100 Subject: Simplify Assists interface Instead of building a physical tree structure, just "tag" related assists with the same group --- crates/ra_ide/src/assists.rs | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/assists.rs b/crates/ra_ide/src/assists.rs index b60b1a60d..40d56a4f7 100644 --- a/crates/ra_ide/src/assists.rs +++ b/crates/ra_ide/src/assists.rs @@ -1,6 +1,5 @@ //! FIXME: write short doc here -use either::Either; use ra_assists::{resolved_assists, AssistAction, AssistLabel}; use ra_db::{FilePosition, FileRange}; use ra_ide_db::RootDatabase; @@ -13,7 +12,8 @@ pub use ra_assists::AssistId; pub struct Assist { pub id: AssistId, pub label: String, - pub change_data: Either>, + pub group_label: Option, + pub source_change: SourceChange, } pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec { @@ -25,17 +25,8 @@ pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec { Assist { id: assist_label.id, label: assist_label.label.clone(), - change_data: match assist.action_data { - Either::Left(action) => { - Either::Left(action_to_edit(action, file_id, assist_label)) - } - Either::Right(actions) => Either::Right( - actions - .into_iter() - .map(|action| action_to_edit(action, file_id, assist_label)) - .collect(), - ), - }, + group_label: assist.group_label.map(|it| it.0), + source_change: action_to_edit(assist.action, file_id, assist_label), } }) .collect() @@ -47,9 +38,6 @@ fn action_to_edit( assist_label: &AssistLabel, ) -> SourceChange { let file_edit = SourceFileEdit { file_id, edit: action.edit }; - SourceChange::source_file_edit( - action.label.unwrap_or_else(|| assist_label.label.clone()), - file_edit, - ) - .with_cursor_opt(action.cursor_position.map(|offset| FilePosition { offset, file_id })) + SourceChange::source_file_edit(assist_label.label.clone(), file_edit) + .with_cursor_opt(action.cursor_position.map(|offset| FilePosition { offset, file_id })) } -- cgit v1.2.3