aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src/assists.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_editor/src/assists.rs')
-rw-r--r--crates/ra_editor/src/assists.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/crates/ra_editor/src/assists.rs b/crates/ra_editor/src/assists.rs
new file mode 100644
index 000000000..b6e6dd628
--- /dev/null
+++ b/crates/ra_editor/src/assists.rs
@@ -0,0 +1,34 @@
1//! This modules contains various "assits": suggestions for source code edits
2//! which are likely to occur at a given cursor positon. For example, if the
3//! cursor is on the `,`, a possible assist is swapping the elments around the
4//! comma.
5
6mod flip_comma;
7mod add_derive;
8mod add_impl;
9mod introduce_variable;
10mod change_visibility;
11
12use ra_text_edit::TextEdit;
13use ra_syntax::{Direction, SyntaxNodeRef, TextUnit};
14
15pub use self::{
16 flip_comma::flip_comma,
17 add_derive::add_derive,
18 add_impl::add_impl,
19 introduce_variable::introduce_variable,
20 change_visibility::change_visibility,
21};
22
23#[derive(Debug)]
24pub struct LocalEdit {
25 pub label: String,
26 pub edit: TextEdit,
27 pub cursor_position: Option<TextUnit>,
28}
29
30fn non_trivia_sibling(node: SyntaxNodeRef, direction: Direction) -> Option<SyntaxNodeRef> {
31 node.siblings(direction)
32 .skip(1)
33 .find(|node| !node.kind().is_trivia())
34}