aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-03-19 10:38:26 +0000
committerAleksey Kladov <[email protected]>2020-03-19 10:38:26 +0000
commitef3bf906c477048076faa8e18b50fc34175f6c14 (patch)
tree7e0134f8a0bc0a41e8cbcea91231b7a7be95262b /crates/ra_syntax/src
parent5b0a7c7d162c6c30b8fd52309f4473659d647452 (diff)
Generalize
Diffstat (limited to 'crates/ra_syntax/src')
-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,