diff options
author | Aleksey Kladov <[email protected]> | 2018-12-27 12:07:51 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-12-27 12:07:51 +0000 |
commit | a912b261d3e6c95430bf2116b15b3af2e112bc4b (patch) | |
tree | 1e92a83d19c9a7837f23f09b1a8875bee45742b2 /crates/ra_syntax/src | |
parent | 359e70d1b20402ca9cc8731909daecfab598e55d (diff) |
dump validation errors
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/utils.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/utils.rs b/crates/ra_syntax/src/utils.rs index 5bbdf80bb..0a2b6afbc 100644 --- a/crates/ra_syntax/src/utils.rs +++ b/crates/ra_syntax/src/utils.rs | |||
@@ -1,10 +1,13 @@ | |||
1 | use crate::{SourceFileNode, SyntaxKind, SyntaxNodeRef, WalkEvent}; | 1 | use crate::{SourceFileNode, SyntaxKind, SyntaxNodeRef, WalkEvent, AstNode}; |
2 | use std::fmt::Write; | 2 | use std::fmt::Write; |
3 | use std::str; | 3 | use std::str; |
4 | 4 | ||
5 | /// Parse a file and create a string representation of the resulting parse tree. | 5 | /// Parse a file and create a string representation of the resulting parse tree. |
6 | pub fn dump_tree(syntax: SyntaxNodeRef) -> String { | 6 | pub fn dump_tree(syntax: SyntaxNodeRef) -> String { |
7 | let mut errors: Vec<_> = syntax.root_data().to_vec(); | 7 | let mut errors: Vec<_> = match syntax.ancestors().find_map(SourceFileNode::cast) { |
8 | Some(file) => file.owned().errors(), | ||
9 | None => syntax.root_data().to_vec(), | ||
10 | }; | ||
8 | errors.sort_by_key(|e| e.offset()); | 11 | errors.sort_by_key(|e| e.offset()); |
9 | let mut err_pos = 0; | 12 | let mut err_pos = 0; |
10 | let mut level = 0; | 13 | let mut level = 0; |