aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_assists/src/lib.rs2
-rw-r--r--crates/ra_ide/src/assists.rs19
2 files changed, 8 insertions, 13 deletions
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs
index 1b31d655b..5cec10088 100644
--- a/crates/ra_assists/src/lib.rs
+++ b/crates/ra_assists/src/lib.rs
@@ -17,13 +17,13 @@ mod doc_tests;
17pub mod utils; 17pub mod utils;
18pub mod ast_transform; 18pub mod ast_transform;
19 19
20use hir::Semantics;
20use ra_db::{FileId, FileRange}; 21use ra_db::{FileId, FileRange};
21use ra_ide_db::RootDatabase; 22use ra_ide_db::RootDatabase;
22use ra_syntax::{TextRange, TextSize}; 23use ra_syntax::{TextRange, TextSize};
23use ra_text_edit::TextEdit; 24use ra_text_edit::TextEdit;
24 25
25pub(crate) use crate::assist_ctx::{Assist, AssistCtx, AssistHandler}; 26pub(crate) use crate::assist_ctx::{Assist, AssistCtx, AssistHandler};
26use hir::Semantics;
27 27
28/// Unique identifier of the assist, should not be shown to the user 28/// Unique identifier of the assist, should not be shown to the user
29/// directly. 29/// directly.
diff --git a/crates/ra_ide/src/assists.rs b/crates/ra_ide/src/assists.rs
index 2b5d11681..389339a03 100644
--- a/crates/ra_ide/src/assists.rs
+++ b/crates/ra_ide/src/assists.rs
@@ -1,6 +1,6 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use ra_assists::{resolved_assists, AssistAction, AssistLabel}; 3use ra_assists::{resolved_assists, AssistAction};
4use ra_db::{FilePosition, FileRange}; 4use ra_db::{FilePosition, FileRange};
5use ra_ide_db::RootDatabase; 5use ra_ide_db::RootDatabase;
6 6
@@ -21,27 +21,22 @@ pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> {
21 .into_iter() 21 .into_iter()
22 .map(|assist| { 22 .map(|assist| {
23 let file_id = frange.file_id; 23 let file_id = frange.file_id;
24 let assist_label = &assist.label;
25 Assist { 24 Assist {
26 id: assist_label.id, 25 id: assist.label.id,
27 label: assist_label.label.clone(), 26 label: assist.label.label.clone(),
28 group_label: assist.group_label.map(|it| it.0), 27 group_label: assist.label.group.map(|it| it.0),
29 source_change: action_to_edit(assist.action, file_id, assist_label), 28 source_change: action_to_edit(assist.action, file_id, assist.label.label.clone()),
30 } 29 }
31 }) 30 })
32 .collect() 31 .collect()
33} 32}
34 33
35fn action_to_edit( 34fn action_to_edit(action: AssistAction, file_id: FileId, label: String) -> SourceChange {
36 action: AssistAction,
37 file_id: FileId,
38 assist_label: &AssistLabel,
39) -> SourceChange {
40 let file_id = match action.file { 35 let file_id = match action.file {
41 ra_assists::AssistFile::TargetFile(it) => it, 36 ra_assists::AssistFile::TargetFile(it) => it,
42 _ => file_id, 37 _ => file_id,
43 }; 38 };
44 let file_edit = SourceFileEdit { file_id, edit: action.edit }; 39 let file_edit = SourceFileEdit { file_id, edit: action.edit };
45 SourceChange::source_file_edit(assist_label.label.clone(), file_edit) 40 SourceChange::source_file_edit(label, file_edit)
46 .with_cursor_opt(action.cursor_position.map(|offset| FilePosition { offset, file_id })) 41 .with_cursor_opt(action.cursor_position.map(|offset| FilePosition { offset, file_id }))
47} 42}