aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/syntax_node.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/syntax_node.rs')
-rw-r--r--crates/ra_syntax/src/syntax_node.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/ra_syntax/src/syntax_node.rs b/crates/ra_syntax/src/syntax_node.rs
index 64d884287..dc2352c76 100644
--- a/crates/ra_syntax/src/syntax_node.rs
+++ b/crates/ra_syntax/src/syntax_node.rs
@@ -10,6 +10,7 @@ use std::{
10 fmt::{self, Write}, 10 fmt::{self, Write},
11 any::Any, 11 any::Any,
12 borrow::Borrow, 12 borrow::Borrow,
13 iter::successors,
13}; 14};
14 15
15use ra_parser::ParseError; 16use ra_parser::ParseError;
@@ -195,7 +196,7 @@ impl SyntaxNode {
195 } 196 }
196 197
197 pub fn ancestors(&self) -> impl Iterator<Item = &SyntaxNode> { 198 pub fn ancestors(&self) -> impl Iterator<Item = &SyntaxNode> {
198 crate::algo::generate(Some(self), |&node| node.parent()) 199 successors(Some(self), |&node| node.parent())
199 } 200 }
200 201
201 pub fn descendants(&self) -> impl Iterator<Item = &SyntaxNode> { 202 pub fn descendants(&self) -> impl Iterator<Item = &SyntaxNode> {
@@ -213,7 +214,7 @@ impl SyntaxNode {
213 } 214 }
214 215
215 pub fn siblings(&self, direction: Direction) -> impl Iterator<Item = &SyntaxNode> { 216 pub fn siblings(&self, direction: Direction) -> impl Iterator<Item = &SyntaxNode> {
216 crate::algo::generate(Some(self), move |&node| match direction { 217 successors(Some(self), move |&node| match direction {
217 Direction::Next => node.next_sibling(), 218 Direction::Next => node.next_sibling(),
218 Direction::Prev => node.prev_sibling(), 219 Direction::Prev => node.prev_sibling(),
219 }) 220 })
@@ -224,7 +225,7 @@ impl SyntaxNode {
224 direction: Direction, 225 direction: Direction,
225 ) -> impl Iterator<Item = SyntaxElement> { 226 ) -> impl Iterator<Item = SyntaxElement> {
226 let me: SyntaxElement = self.into(); 227 let me: SyntaxElement = self.into();
227 crate::algo::generate(Some(me), move |el| match direction { 228 successors(Some(me), move |el| match direction {
228 Direction::Next => el.next_sibling_or_token(), 229 Direction::Next => el.next_sibling_or_token(),
229 Direction::Prev => el.prev_sibling_or_token(), 230 Direction::Prev => el.prev_sibling_or_token(),
230 }) 231 })
@@ -373,7 +374,7 @@ impl<'a> SyntaxToken<'a> {
373 direction: Direction, 374 direction: Direction,
374 ) -> impl Iterator<Item = SyntaxElement<'a>> { 375 ) -> impl Iterator<Item = SyntaxElement<'a>> {
375 let me: SyntaxElement = (*self).into(); 376 let me: SyntaxElement = (*self).into();
376 crate::algo::generate(Some(me), move |el| match direction { 377 successors(Some(me), move |el| match direction {
377 Direction::Next => el.next_sibling_or_token(), 378 Direction::Next => el.next_sibling_or_token(),
378 Direction::Prev => el.prev_sibling_or_token(), 379 Direction::Prev => el.prev_sibling_or_token(),
379 }) 380 })