aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/assists.rs23
1 files changed, 15 insertions, 8 deletions
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};
4 4
5use crate::{db::RootDatabase, FileId, SourceChange, SourceFileEdit}; 5use crate::{db::RootDatabase, FileId, SourceChange, SourceFileEdit};
6 6
7use itertools::Either;
7pub use ra_assists::AssistId; 8pub use ra_assists::AssistId;
8use ra_assists::{AssistAction, AssistLabel}; 9use ra_assists::{AssistAction, AssistLabel};
9 10
10#[derive(Debug)] 11#[derive(Debug)]
11pub struct Assist { 12pub struct Assist {
12 pub id: AssistId, 13 pub id: AssistId,
13 pub change: SourceChange,
14 pub label: String, 14 pub label: String,
15 pub alternative_changes: Vec<SourceChange>, 15 pub change_data: Either<SourceChange, Vec<SourceChange>>,
16} 16}
17 17
18pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> { 18pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> {
19 ra_assists::assists(db, frange) 19 ra_assists::assists(db, frange)
20 .into_iter() 20 .into_iter()
21 .map(|(assist_label, action, alternative_actions)| { 21 .map(|assist| {
22 let file_id = frange.file_id; 22 let file_id = frange.file_id;
23 let assist_label = &assist.label;
23 Assist { 24 Assist {
24 id: assist_label.id, 25 id: assist_label.id,
25 label: assist_label.label.clone(), 26 label: assist_label.label.clone(),
26 change: action_to_edit(action, file_id, &assist_label), 27 change_data: match assist.action_data {
27 alternative_changes: alternative_actions 28 Either::Left(action) => {
28 .into_iter() 29 Either::Left(action_to_edit(action, file_id, assist_label))
29 .map(|action| action_to_edit(action, file_id, &assist_label)) 30 }
30 .collect(), 31 Either::Right(actions) => Either::Right(
32 actions
33 .into_iter()
34 .map(|action| action_to_edit(action, file_id, assist_label))
35 .collect(),
36 ),
37 },
31 } 38 }
32 }) 39 })
33 .collect() 40 .collect()