aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-02-24 10:53:35 +0000
committerAleksey Kladov <[email protected]>2019-02-24 11:00:00 +0000
commitef442b8682909f2ab758f55507d4c2e81673cfa1 (patch)
treeea042b5ff65f74b9f336de62879eefaa7e8ca2bc /crates/ra_ide_api/src
parentf6f160391db945a0dcc2f73b38926d6919f7c566 (diff)
Assign IDs to assists
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/assists.rs16
-rw-r--r--crates/ra_ide_api/src/lib.rs3
2 files changed, 15 insertions, 4 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
3use crate::{SourceFileEdit, SourceChange, db::RootDatabase}; 3use crate::{SourceFileEdit, SourceChange, db::RootDatabase};
4 4
5pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<SourceChange> { 5pub use ra_assists::AssistId;
6
7#[derive(Debug)]
8pub struct Assist {
9 pub id: AssistId,
10 pub change: SourceChange,
11}
12
13pub(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}
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index 4b9fc9372..076a8396c 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -57,6 +57,7 @@ pub use crate::{
57 runnables::{Runnable, RunnableKind}, 57 runnables::{Runnable, RunnableKind},
58 navigation_target::NavigationTarget, 58 navigation_target::NavigationTarget,
59 references::ReferenceSearchResult, 59 references::ReferenceSearchResult,
60 assists::{Assist, AssistId},
60}; 61};
61pub use ra_ide_api_light::{ 62pub use ra_ide_api_light::{
62 Fold, FoldKind, HighlightedRange, Severity, StructureNode, LocalEdit, 63 Fold, FoldKind, HighlightedRange, Severity, StructureNode, LocalEdit,
@@ -368,7 +369,7 @@ impl Analysis {
368 369
369 /// Computes assists (aks code actons aka intentions) for the given 370 /// Computes assists (aks code actons aka intentions) for the given
370 /// position. 371 /// position.
371 pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<SourceChange>> { 372 pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<Assist>> {
372 self.with_db(|db| assists::assists(db, frange)) 373 self.with_db(|db| assists::assists(db, frange))
373 } 374 }
374 375