diff options
author | vsrs <[email protected]> | 2020-05-08 17:34:34 +0100 |
---|---|---|
committer | vsrs <[email protected]> | 2020-05-08 17:34:34 +0100 |
commit | 0ef17ef1ee9fb0ce7149176d12f4d225f6d01401 (patch) | |
tree | fa2f168120f36f8dbef5dc1e85fea0c0071639c2 /crates/ra_ide/src/assists.rs | |
parent | 1be6320ea6cf7830195f80681fa0f43cc340da7e (diff) | |
parent | d3eb9d8eafbebca7da95fa8a4813b92eb5080500 (diff) |
Merge remote-tracking branch 'upstream/master' into uniformed_debug_lens
# Conflicts:
# editors/code/src/commands/runnables.ts
Diffstat (limited to 'crates/ra_ide/src/assists.rs')
-rw-r--r-- | crates/ra_ide/src/assists.rs | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/crates/ra_ide/src/assists.rs b/crates/ra_ide/src/assists.rs deleted file mode 100644 index 389339a03..000000000 --- a/crates/ra_ide/src/assists.rs +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | //! FIXME: write short doc here | ||
2 | |||
3 | use ra_assists::{resolved_assists, AssistAction}; | ||
4 | use ra_db::{FilePosition, FileRange}; | ||
5 | use ra_ide_db::RootDatabase; | ||
6 | |||
7 | use crate::{FileId, SourceChange, SourceFileEdit}; | ||
8 | |||
9 | pub use ra_assists::AssistId; | ||
10 | |||
11 | #[derive(Debug)] | ||
12 | pub struct Assist { | ||
13 | pub id: AssistId, | ||
14 | pub label: String, | ||
15 | pub group_label: Option<String>, | ||
16 | pub source_change: SourceChange, | ||
17 | } | ||
18 | |||
19 | pub(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 | Assist { | ||
25 | id: assist.label.id, | ||
26 | label: assist.label.label.clone(), | ||
27 | group_label: assist.label.group.map(|it| it.0), | ||
28 | source_change: action_to_edit(assist.action, file_id, assist.label.label.clone()), | ||
29 | } | ||
30 | }) | ||
31 | .collect() | ||
32 | } | ||
33 | |||
34 | fn action_to_edit(action: AssistAction, file_id: FileId, label: String) -> SourceChange { | ||
35 | let file_id = match action.file { | ||
36 | ra_assists::AssistFile::TargetFile(it) => it, | ||
37 | _ => file_id, | ||
38 | }; | ||
39 | let file_edit = SourceFileEdit { file_id, edit: action.edit }; | ||
40 | SourceChange::source_file_edit(label, file_edit) | ||
41 | .with_cursor_opt(action.cursor_position.map(|offset| FilePosition { offset, file_id })) | ||
42 | } | ||