Borrowed AST

This commit is contained in:
Aleksey Kladov 2018-08-17 22:00:13 +03:00
parent 70097504f7
commit d3c90ded2b
16 changed files with 350 additions and 343 deletions

View file

@ -1,12 +1,11 @@
use std::fmt::Write;
use {
algo::walk::{walk, WalkEvent},
SyntaxNode, TreeRoot,
SyntaxNodeRef, TreeRoot,
};
/// Parse a file and create a string representation of the resulting parse tree.
pub fn dump_tree(syntax: &SyntaxNode) -> String {
let syntax = syntax.as_ref();
pub fn dump_tree(syntax: SyntaxNodeRef) -> String {
let mut errors: Vec<_> = syntax.root.syntax_root().errors.iter().cloned().collect();
errors.sort_by_key(|e| e.offset);
let mut err_pos = 0;