aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-07-30 21:45:10 +0100
committerAleksey Kladov <[email protected]>2018-07-30 21:45:10 +0100
commitaea86d154ec5adde6adb05088a50f01380ffb8bf (patch)
treefd10ec3e5379e24e40f3eff78cb1e035f4bb5c89 /code
parent70b337292117a9bb90e85056dcb4069f8bbc6c0a (diff)
stackless traversal
Diffstat (limited to 'code')
-rw-r--r--code/native/src/lib.rs6
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};
11use neon::prelude::*; 12use neon::prelude::*;
12 13
@@ -17,11 +18,12 @@ pub struct Wrapper {
17impl Wrapper { 18impl 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}