diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-27 12:12:14 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-27 12:12:14 +0000 |
commit | 55ab0c602e391537f5e1a84a617fdd817e6a4200 (patch) | |
tree | 3adb0077bd7d7a34376d87cbb0ae7ea5b942d532 /crates/ra_syntax/src/utils.rs | |
parent | dbf03b674e7e1a49d9b32ec5ed656df2aedd3ed3 (diff) | |
parent | 49b0fe20ab6aa752df3764908b7c21f4b1827e52 (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.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; |