aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-19 10:38:59 +0000
committerGitHub <[email protected]>2020-03-19 10:38:59 +0000
commit11f2c6908b23566703469f9ad7731425c23daedf (patch)
treee844c04028d229ddcb42f97fdd1f972010a8d3d2 /crates/ra_syntax
parent13af63a40393c0e299d7db2545aee0aeb1a5c2bc (diff)
parentef3bf906c477048076faa8e18b50fc34175f6c14 (diff)
Merge #3650
3650: Generalize r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
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,