diff options
author | Aleksey Kladov <[email protected]> | 2018-07-30 21:45:10 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-07-30 21:45:10 +0100 |
commit | aea86d154ec5adde6adb05088a50f01380ffb8bf (patch) | |
tree | fd10ec3e5379e24e40f3eff78cb1e035f4bb5c89 /code/native | |
parent | 70b337292117a9bb90e85056dcb4069f8bbc6c0a (diff) |
stackless traversal
Diffstat (limited to 'code/native')
-rw-r--r-- | code/native/src/lib.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/code/native/src/lib.rs b/code/native/src/lib.rs index dcf478cf5..068767fab 100644 --- a/code/native/src/lib.rs +++ b/code/native/src/lib.rs | |||
@@ -7,6 +7,7 @@ use libsyntax2::{ | |||
7 | File, | 7 | File, |
8 | utils::dump_tree, | 8 | utils::dump_tree, |
9 | SyntaxKind::*, | 9 | SyntaxKind::*, |
10 | algo, | ||
10 | }; | 11 | }; |
11 | use neon::prelude::*; | 12 | use neon::prelude::*; |
12 | 13 | ||
@@ -17,11 +18,12 @@ pub struct Wrapper { | |||
17 | impl Wrapper { | 18 | impl Wrapper { |
18 | fn highlight(&self) -> Vec<(TextRange, &'static str)> { | 19 | fn highlight(&self) -> Vec<(TextRange, &'static str)> { |
19 | let mut res = Vec::new(); | 20 | let mut res = Vec::new(); |
20 | self.inner.for_each_node(|node| { | 21 | let syntax = self.inner.syntax(); |
22 | for node in algo::walk::preorder(syntax.as_ref()) { | ||
21 | if node.kind() == ERROR { | 23 | if node.kind() == ERROR { |
22 | res.push((node.range(), "error")) | 24 | res.push((node.range(), "error")) |
23 | } | 25 | } |
24 | }); | 26 | } |
25 | res | 27 | res |
26 | } | 28 | } |
27 | } | 29 | } |