diff options
author | Aleksey Kladov <[email protected]> | 2018-10-17 17:52:25 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-10-17 17:52:25 +0100 |
commit | 00cdde2c5218020b8f6ec751042a436aeef923c7 (patch) | |
tree | aa44f39e0433087c2f862789ed739348f982efdb /crates/ra_syntax/src/algo | |
parent | 2a704035f4b36a0db737f59a7c939d17656b516f (diff) |
Update rowan
Diffstat (limited to 'crates/ra_syntax/src/algo')
-rw-r--r-- | crates/ra_syntax/src/algo/mod.rs | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/algo/walk.rs | 28 |
2 files changed, 1 insertions, 29 deletions
diff --git a/crates/ra_syntax/src/algo/mod.rs b/crates/ra_syntax/src/algo/mod.rs index b4896c482..9d2014bc7 100644 --- a/crates/ra_syntax/src/algo/mod.rs +++ b/crates/ra_syntax/src/algo/mod.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | pub mod visit; | 1 | pub mod visit; |
2 | pub mod walk; | 2 | // pub mod walk; |
3 | 3 | ||
4 | use crate::{ | 4 | use crate::{ |
5 | text_utils::{contains_offset_nonstrict, is_subrange}, | 5 | text_utils::{contains_offset_nonstrict, is_subrange}, |
diff --git a/crates/ra_syntax/src/algo/walk.rs b/crates/ra_syntax/src/algo/walk.rs deleted file mode 100644 index 9afa86401..000000000 --- a/crates/ra_syntax/src/algo/walk.rs +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | use crate::{algo::generate, SyntaxNodeRef}; | ||
2 | |||
3 | #[derive(Debug, Copy, Clone)] | ||
4 | pub enum WalkEvent<'a> { | ||
5 | Enter(SyntaxNodeRef<'a>), | ||
6 | Exit(SyntaxNodeRef<'a>), | ||
7 | } | ||
8 | |||
9 | pub fn walk<'a>(root: SyntaxNodeRef<'a>) -> impl Iterator<Item = WalkEvent<'a>> { | ||
10 | generate(Some(WalkEvent::Enter(root)), move |pos| { | ||
11 | let next = match *pos { | ||
12 | WalkEvent::Enter(node) => match node.first_child() { | ||
13 | Some(child) => WalkEvent::Enter(child), | ||
14 | None => WalkEvent::Exit(node), | ||
15 | }, | ||
16 | WalkEvent::Exit(node) => { | ||
17 | if node == root { | ||
18 | return None; | ||
19 | } | ||
20 | match node.next_sibling() { | ||
21 | Some(sibling) => WalkEvent::Enter(sibling), | ||
22 | None => WalkEvent::Exit(node.parent().unwrap()), | ||
23 | } | ||
24 | } | ||
25 | }; | ||
26 | Some(next) | ||
27 | }) | ||
28 | } | ||