From aea86d154ec5adde6adb05088a50f01380ffb8bf Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 30 Jul 2018 23:45:10 +0300 Subject: stackless traversal --- code/native/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'code/native') 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::{ 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 } } -- cgit v1.2.3