aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/algo.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/algo.rs b/crates/ra_syntax/src/algo.rs
index b87c7084e..344cf0fbe 100644
--- a/crates/ra_syntax/src/algo.rs
+++ b/crates/ra_syntax/src/algo.rs
@@ -73,6 +73,10 @@ pub fn least_common_ancestor(u: &SyntaxNode, v: &SyntaxNode) -> Option<SyntaxNod
73 v.ancestors().find(|it| u_ancestors.contains(it)) 73 v.ancestors().find(|it| u_ancestors.contains(it))
74} 74}
75 75
76pub fn neighbor<T: AstNode>(me: &T, direction: Direction) -> Option<T> {
77 me.syntax().siblings(direction).skip(1).find_map(T::cast)
78}
79
76#[derive(Debug, PartialEq, Eq, Clone, Copy)] 80#[derive(Debug, PartialEq, Eq, Clone, Copy)]
77pub enum InsertPosition<T> { 81pub enum InsertPosition<T> {
78 First, 82 First,