aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/assists.rs
diff options
context:
space:
mode:
authorSeivan Heidari <[email protected]>2019-11-28 07:19:14 +0000
committerSeivan Heidari <[email protected]>2019-11-28 07:19:14 +0000
commit18a0937585b836ec5ed054b9ae48e0156ab6d9ef (patch)
tree9de2c0267ddcc00df717f90034d0843d751a851b /crates/ra_ide/src/assists.rs
parenta7394b44c870f585eacfeb3036a33471aff49ff8 (diff)
parent484acc8a61d599662ed63a4cbda091d38a982551 (diff)
Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer into feature/themes
Diffstat (limited to 'crates/ra_ide/src/assists.rs')
-rw-r--r--crates/ra_ide/src/assists.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/ra_ide/src/assists.rs b/crates/ra_ide/src/assists.rs
new file mode 100644
index 000000000..e00589733
--- /dev/null
+++ b/crates/ra_ide/src/assists.rs
@@ -0,0 +1,28 @@
1//! FIXME: write short doc here
2
3use ra_db::{FilePosition, FileRange};
4
5use crate::{db::RootDatabase, SourceChange, SourceFileEdit};
6
7pub use ra_assists::AssistId;
8
9#[derive(Debug)]
10pub struct Assist {
11 pub id: AssistId,
12 pub change: SourceChange,
13}
14
15pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> {
16 ra_assists::assists(db, frange)
17 .into_iter()
18 .map(|(label, action)| {
19 let file_id = frange.file_id;
20 let file_edit = SourceFileEdit { file_id, edit: action.edit };
21 let id = label.id;
22 let change = SourceChange::source_file_edit(label.label, file_edit).with_cursor_opt(
23 action.cursor_position.map(|offset| FilePosition { offset, file_id }),
24 );
25 Assist { id, change }
26 })
27 .collect()
28}