diff options
Diffstat (limited to 'crates/ra_ide')
-rw-r--r-- | crates/ra_ide/src/assists.rs | 24 |
1 files changed, 6 insertions, 18 deletions
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 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use either::Either; | ||
4 | use ra_assists::{resolved_assists, AssistAction, AssistLabel}; | 3 | use ra_assists::{resolved_assists, AssistAction, AssistLabel}; |
5 | use ra_db::{FilePosition, FileRange}; | 4 | use ra_db::{FilePosition, FileRange}; |
6 | use ra_ide_db::RootDatabase; | 5 | use ra_ide_db::RootDatabase; |
@@ -13,7 +12,8 @@ pub use ra_assists::AssistId; | |||
13 | pub struct Assist { | 12 | pub struct Assist { |
14 | pub id: AssistId, | 13 | pub id: AssistId, |
15 | pub label: String, | 14 | pub label: String, |
16 | pub change_data: Either<SourceChange, Vec<SourceChange>>, | 15 | pub group_label: Option<String>, |
16 | pub source_change: SourceChange, | ||
17 | } | 17 | } |
18 | 18 | ||
19 | pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> { | 19 | pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> { |
@@ -25,17 +25,8 @@ pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> { | |||
25 | Assist { | 25 | Assist { |
26 | id: assist_label.id, | 26 | id: assist_label.id, |
27 | label: assist_label.label.clone(), | 27 | label: assist_label.label.clone(), |
28 | change_data: match assist.action_data { | 28 | group_label: assist.group_label.map(|it| it.0), |
29 | Either::Left(action) => { | 29 | source_change: action_to_edit(assist.action, file_id, assist_label), |
30 | Either::Left(action_to_edit(action, file_id, assist_label)) | ||
31 | } | ||
32 | Either::Right(actions) => Either::Right( | ||
33 | actions | ||
34 | .into_iter() | ||
35 | .map(|action| action_to_edit(action, file_id, assist_label)) | ||
36 | .collect(), | ||
37 | ), | ||
38 | }, | ||
39 | } | 30 | } |
40 | }) | 31 | }) |
41 | .collect() | 32 | .collect() |
@@ -47,9 +38,6 @@ fn action_to_edit( | |||
47 | assist_label: &AssistLabel, | 38 | assist_label: &AssistLabel, |
48 | ) -> SourceChange { | 39 | ) -> SourceChange { |
49 | let file_edit = SourceFileEdit { file_id, edit: action.edit }; | 40 | let file_edit = SourceFileEdit { file_id, edit: action.edit }; |
50 | SourceChange::source_file_edit( | 41 | SourceChange::source_file_edit(assist_label.label.clone(), file_edit) |
51 | action.label.unwrap_or_else(|| assist_label.label.clone()), | 42 | .with_cursor_opt(action.cursor_position.map(|offset| FilePosition { offset, file_id })) |
52 | file_edit, | ||
53 | ) | ||
54 | .with_cursor_opt(action.cursor_position.map(|offset| FilePosition { offset, file_id })) | ||
55 | } | 43 | } |