aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/utils.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-27 12:12:14 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-27 12:12:14 +0000
commit55ab0c602e391537f5e1a84a617fdd817e6a4200 (patch)
tree3adb0077bd7d7a34376d87cbb0ae7ea5b942d532 /crates/ra_syntax/src/utils.rs
parentdbf03b674e7e1a49d9b32ec5ed656df2aedd3ed3 (diff)
parent49b0fe20ab6aa752df3764908b7c21f4b1827e52 (diff)
Merge #339
339: Fix assertion error for literals with suffixes r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/utils.rs')
-rw-r--r--crates/ra_syntax/src/utils.rs7
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 @@
1use crate::{SourceFileNode, SyntaxKind, SyntaxNodeRef, WalkEvent}; 1use crate::{SourceFileNode, SyntaxKind, SyntaxNodeRef, WalkEvent, AstNode};
2use std::fmt::Write; 2use std::fmt::Write;
3use std::str; 3use 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.
6pub fn dump_tree(syntax: SyntaxNodeRef) -> String { 6pub 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;