diff options
Diffstat (limited to 'crates/ra_syntax/src/yellow/mod.rs')
-rw-r--r-- | crates/ra_syntax/src/yellow/mod.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/yellow/mod.rs b/crates/ra_syntax/src/yellow/mod.rs index 2c57d8b41..95d277a2f 100644 --- a/crates/ra_syntax/src/yellow/mod.rs +++ b/crates/ra_syntax/src/yellow/mod.rs | |||
@@ -62,6 +62,15 @@ impl<'a> SyntaxNodeRef<'a> { | |||
62 | pub fn leaf_text(self) -> Option<&'a SmolStr> { | 62 | pub fn leaf_text(self) -> Option<&'a SmolStr> { |
63 | self.0.leaf_text() | 63 | self.0.leaf_text() |
64 | } | 64 | } |
65 | pub fn ancestors(self) -> impl Iterator<Item=SyntaxNodeRef<'a>> { | ||
66 | ::algo::generate(Some(self), |&node| node.parent()) | ||
67 | } | ||
68 | pub fn descendants(self) -> impl Iterator<Item=SyntaxNodeRef<'a>> { | ||
69 | ::algo::walk::walk(self).filter_map(|event| match event { | ||
70 | ::algo::walk::WalkEvent::Enter(node) => Some(node), | ||
71 | ::algo::walk::WalkEvent::Exit(_) => None, | ||
72 | }) | ||
73 | } | ||
65 | } | 74 | } |
66 | 75 | ||
67 | impl<R: TreeRoot<RaTypes>> SyntaxNode<R> { | 76 | impl<R: TreeRoot<RaTypes>> SyntaxNode<R> { |