stackless traversal

This commit is contained in:
Aleksey Kladov
2018-07-30 23:45:10 +03:00
parent 70b3372921
commit aea86d154e
9 changed files with 86 additions and 16 deletions

View File

@@ -7,6 +7,7 @@ use libsyntax2::{
File,
utils::dump_tree,
SyntaxKind::*,
algo,
};
use neon::prelude::*;
@@ -17,11 +18,12 @@ pub struct Wrapper {
impl Wrapper {
fn highlight(&self) -> Vec<(TextRange, &'static str)> {
let mut res = Vec::new();
self.inner.for_each_node(|node| {
let syntax = self.inner.syntax();
for node in algo::walk::preorder(syntax.as_ref()) {
if node.kind() == ERROR {
res.push((node.range(), "error"))
}
});
}
res
}
}