aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
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