From 78a21253b494e573885ac8336bff6e93b401046f Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 12 Jan 2020 00:40:36 +0200 Subject: Apply the api design suggestions --- crates/ra_ide/src/assists.rs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/assists.rs b/crates/ra_ide/src/assists.rs index db6e4e8b7..e30eee5f4 100644 --- a/crates/ra_ide/src/assists.rs +++ b/crates/ra_ide/src/assists.rs @@ -4,30 +4,37 @@ use ra_db::{FilePosition, FileRange}; use crate::{db::RootDatabase, FileId, SourceChange, SourceFileEdit}; +use itertools::Either; pub use ra_assists::AssistId; use ra_assists::{AssistAction, AssistLabel}; #[derive(Debug)] pub struct Assist { pub id: AssistId, - pub change: SourceChange, pub label: String, - pub alternative_changes: Vec, + pub change_data: Either>, } pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec { ra_assists::assists(db, frange) .into_iter() - .map(|(assist_label, action, alternative_actions)| { + .map(|assist| { let file_id = frange.file_id; + let assist_label = &assist.label; Assist { id: assist_label.id, label: assist_label.label.clone(), - change: action_to_edit(action, file_id, &assist_label), - alternative_changes: alternative_actions - .into_iter() - .map(|action| action_to_edit(action, file_id, &assist_label)) - .collect(), + 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(), + ), + }, } }) .collect() -- cgit v1.2.3