aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/algo
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-10-02 16:14:33 +0100
committerAleksey Kladov <[email protected]>2018-10-02 16:14:33 +0100
commit1a2a8dec14ec04ea8eeccae99fd885e7a280e45b (patch)
treef94bb3a8bd47e3612ef29e815532c07d7871fa0f /crates/ra_syntax/src/algo
parentd323c81d5cc6a198239285abcede2166181d8f39 (diff)
Make siblings an inherent method
Diffstat (limited to 'crates/ra_syntax/src/algo')
-rw-r--r--crates/ra_syntax/src/algo/mod.rs16
1 files changed, 0 insertions, 16 deletions
diff --git a/crates/ra_syntax/src/algo/mod.rs b/crates/ra_syntax/src/algo/mod.rs
index 3716a6000..a6678093d 100644
--- a/crates/ra_syntax/src/algo/mod.rs
+++ b/crates/ra_syntax/src/algo/mod.rs
@@ -94,22 +94,6 @@ pub fn find_covering_node(root: SyntaxNodeRef, range: TextRange) -> SyntaxNodeRe
94 common_ancestor(left, right) 94 common_ancestor(left, right)
95} 95}
96 96
97#[derive(Debug)]
98pub enum Direction {
99 Forward,
100 Backward,
101}
102
103pub fn siblings<'a>(
104 node: SyntaxNodeRef<'a>,
105 direction: Direction
106) -> impl Iterator<Item=SyntaxNodeRef<'a>> {
107 generate(Some(node), move |&node| match direction {
108 Direction::Forward => node.next_sibling(),
109 Direction::Backward => node.prev_sibling(),
110 })
111}
112
113fn common_ancestor<'a>(n1: SyntaxNodeRef<'a>, n2: SyntaxNodeRef<'a>) -> SyntaxNodeRef<'a> { 97fn common_ancestor<'a>(n1: SyntaxNodeRef<'a>, n2: SyntaxNodeRef<'a>) -> SyntaxNodeRef<'a> {
114 for p in n1.ancestors() { 98 for p in n1.ancestors() {
115 if n2.ancestors().any(|a| a == p) { 99 if n2.ancestors().any(|a| a == p) {