aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/algo
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-10-17 17:53:00 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-10-17 17:53:00 +0100
commit4dbf0379ccd5c7643d48658f0ecc224add5a5c5c (patch)
treeaa44f39e0433087c2f862789ed739348f982efdb /crates/ra_syntax/src/algo
parent2a704035f4b36a0db737f59a7c939d17656b516f (diff)
parent00cdde2c5218020b8f6ec751042a436aeef923c7 (diff)
Merge #141
141: Update rowan r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/algo')
-rw-r--r--crates/ra_syntax/src/algo/mod.rs2
-rw-r--r--crates/ra_syntax/src/algo/walk.rs28
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 @@
1pub mod visit; 1pub mod visit;
2pub mod walk; 2// pub mod walk;
3 3
4use crate::{ 4use 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 @@
1use crate::{algo::generate, SyntaxNodeRef};
2
3#[derive(Debug, Copy, Clone)]
4pub enum WalkEvent<'a> {
5 Enter(SyntaxNodeRef<'a>),
6 Exit(SyntaxNodeRef<'a>),
7}
8
9pub 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}