aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/utils.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-17 20:00:13 +0100
committerAleksey Kladov <[email protected]>2018-08-17 20:00:13 +0100
commitd3c90ded2b9a4f75e101fa3abc60cd3aebc439c9 (patch)
tree6d2388eb68605331a0dd090269372bc98dd038cd /crates/libsyntax2/src/utils.rs
parent70097504f78c4c41368a0b864a94df95fb9c27f7 (diff)
Borrowed AST
Diffstat (limited to 'crates/libsyntax2/src/utils.rs')
-rw-r--r--crates/libsyntax2/src/utils.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/crates/libsyntax2/src/utils.rs b/crates/libsyntax2/src/utils.rs
index 4f60aa2a8..fbe48dd71 100644
--- a/crates/libsyntax2/src/utils.rs
+++ b/crates/libsyntax2/src/utils.rs
@@ -1,12 +1,11 @@
1use std::fmt::Write; 1use std::fmt::Write;
2use { 2use {
3 algo::walk::{walk, WalkEvent}, 3 algo::walk::{walk, WalkEvent},
4 SyntaxNode, TreeRoot, 4 SyntaxNodeRef, TreeRoot,
5}; 5};
6 6
7/// Parse a file and create a string representation of the resulting parse tree. 7/// Parse a file and create a string representation of the resulting parse tree.
8pub fn dump_tree(syntax: &SyntaxNode) -> String { 8pub fn dump_tree(syntax: SyntaxNodeRef) -> String {
9 let syntax = syntax.as_ref();
10 let mut errors: Vec<_> = syntax.root.syntax_root().errors.iter().cloned().collect(); 9 let mut errors: Vec<_> = syntax.root.syntax_root().errors.iter().cloned().collect();
11 errors.sort_by_key(|e| e.offset); 10 errors.sort_by_key(|e| e.offset);
12 let mut err_pos = 0; 11 let mut err_pos = 0;