diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-24 12:52:44 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-24 12:52:44 +0000 |
commit | 043991662c648d86876be44bc3405ee3a60c37a1 (patch) | |
tree | 45fcbfb58cce8650f67ce4f41e1b5564ef49bfb3 /crates/ra_ide_api/src/assists.rs | |
parent | f6f160391db945a0dcc2f73b38926d6919f7c566 (diff) | |
parent | c110e72a115bbec36413bd440812dfe9194c58e2 (diff) |
Merge #889
889: Refactor assits r=matklad a=matklad
* assign unique IDs to assists so that clients could do custom stuff
* specify kinds for assists,
* make introduce_variable a `refactoring.extract` and make it available only when expression is selected
* introduce marks to assists
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/assists.rs')
-rw-r--r-- | crates/ra_ide_api/src/assists.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_ide_api/src/assists.rs b/crates/ra_ide_api/src/assists.rs index 7a9c66681..3c0475a51 100644 --- a/crates/ra_ide_api/src/assists.rs +++ b/crates/ra_ide_api/src/assists.rs | |||
@@ -2,20 +2,30 @@ use ra_db::{FileRange, FilePosition}; | |||
2 | 2 | ||
3 | use crate::{SourceFileEdit, SourceChange, db::RootDatabase}; | 3 | use crate::{SourceFileEdit, SourceChange, db::RootDatabase}; |
4 | 4 | ||
5 | pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<SourceChange> { | 5 | pub use ra_assists::AssistId; |
6 | |||
7 | #[derive(Debug)] | ||
8 | pub struct Assist { | ||
9 | pub id: AssistId, | ||
10 | pub change: SourceChange, | ||
11 | } | ||
12 | |||
13 | pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> { | ||
6 | ra_assists::assists(db, frange) | 14 | ra_assists::assists(db, frange) |
7 | .into_iter() | 15 | .into_iter() |
8 | .map(|(label, action)| { | 16 | .map(|(label, action)| { |
9 | let file_id = frange.file_id; | 17 | let file_id = frange.file_id; |
10 | let file_edit = SourceFileEdit { file_id, edit: action.edit }; | 18 | let file_edit = SourceFileEdit { file_id, edit: action.edit }; |
11 | SourceChange { | 19 | let id = label.id; |
20 | let change = SourceChange { | ||
12 | label: label.label, | 21 | label: label.label, |
13 | source_file_edits: vec![file_edit], | 22 | source_file_edits: vec![file_edit], |
14 | file_system_edits: vec![], | 23 | file_system_edits: vec![], |
15 | cursor_position: action | 24 | cursor_position: action |
16 | .cursor_position | 25 | .cursor_position |
17 | .map(|offset| FilePosition { offset, file_id }), | 26 | .map(|offset| FilePosition { offset, file_id }), |
18 | } | 27 | }; |
28 | Assist { id, change } | ||
19 | }) | 29 | }) |
20 | .collect() | 30 | .collect() |
21 | } | 31 | } |