diff options
Diffstat (limited to 'crates/ra_ide/src/assists.rs')
-rw-r--r-- | crates/ra_ide/src/assists.rs | 28 |
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 | |||
3 | use ra_db::{FilePosition, FileRange}; | ||
4 | |||
5 | use crate::{db::RootDatabase, SourceChange, SourceFileEdit}; | ||
6 | |||
7 | pub use ra_assists::AssistId; | ||
8 | |||
9 | #[derive(Debug)] | ||
10 | pub struct Assist { | ||
11 | pub id: AssistId, | ||
12 | pub change: SourceChange, | ||
13 | } | ||
14 | |||
15 | pub(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 | } | ||