aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/assists.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/assists.rs')
-rw-r--r--crates/ra_ide/src/assists.rs47
1 files changed, 0 insertions, 47 deletions
diff --git a/crates/ra_ide/src/assists.rs b/crates/ra_ide/src/assists.rs
deleted file mode 100644
index 2b5d11681..000000000
--- a/crates/ra_ide/src/assists.rs
+++ /dev/null
@@ -1,47 +0,0 @@
1//! FIXME: write short doc here
2
3use ra_assists::{resolved_assists, AssistAction, AssistLabel};
4use ra_db::{FilePosition, FileRange};
5use ra_ide_db::RootDatabase;
6
7use crate::{FileId, SourceChange, SourceFileEdit};
8
9pub use ra_assists::AssistId;
10
11#[derive(Debug)]
12pub struct Assist {
13 pub id: AssistId,
14 pub label: String,
15 pub group_label: Option<String>,
16 pub source_change: SourceChange,
17}
18
19pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> {
20 resolved_assists(db, frange)
21 .into_iter()
22 .map(|assist| {
23 let file_id = frange.file_id;
24 let assist_label = &assist.label;
25 Assist {
26 id: assist_label.id,
27 label: assist_label.label.clone(),
28 group_label: assist.group_label.map(|it| it.0),
29 source_change: action_to_edit(assist.action, file_id, assist_label),
30 }
31 })
32 .collect()
33}
34
35fn action_to_edit(
36 action: AssistAction,
37 file_id: FileId,
38 assist_label: &AssistLabel,
39) -> SourceChange {
40 let file_id = match action.file {
41 ra_assists::AssistFile::TargetFile(it) => it,
42 _ => file_id,
43 };
44 let file_edit = SourceFileEdit { file_id, edit: action.edit };
45 SourceChange::source_file_edit(assist_label.label.clone(), file_edit)
46 .with_cursor_opt(action.cursor_position.map(|offset| FilePosition { offset, file_id }))
47}