diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-05 21:32:25 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-05 21:32:25 +0000 |
commit | f605f6e70a3a15b77900942933253d16dd3ce1f6 (patch) | |
tree | a7e8c5097124f8dae7ef15af4b85b1c208d3358c /crates/ra_syntax/src/utils.rs | |
parent | 43665eb166e1bd0319a1e13a97b753a536e4b4d2 (diff) | |
parent | 59405bfe4ad0afa0b7ff533c7bfbc3ad4170604c (diff) |
Merge #188
188: Introduce `SyntaxErrorKind` and `TextRange` to `SyntaxError` r=matklad a=aochagavia
Co-authored-by: Adolfo OchagavĂa <[email protected]>
Co-authored-by: Adolfo OchagavĂa <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/utils.rs')
-rw-r--r-- | crates/ra_syntax/src/utils.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_syntax/src/utils.rs b/crates/ra_syntax/src/utils.rs index 00f00139a..288d7edd4 100644 --- a/crates/ra_syntax/src/utils.rs +++ b/crates/ra_syntax/src/utils.rs | |||
@@ -4,7 +4,7 @@ use std::fmt::Write; | |||
4 | /// Parse a file and create a string representation of the resulting parse tree. | 4 | /// Parse a file and create a string representation of the resulting parse tree. |
5 | pub fn dump_tree(syntax: SyntaxNodeRef) -> String { | 5 | pub fn dump_tree(syntax: SyntaxNodeRef) -> String { |
6 | let mut errors: Vec<_> = syntax.root_data().to_vec(); | 6 | let mut errors: Vec<_> = syntax.root_data().to_vec(); |
7 | errors.sort_by_key(|e| e.offset); | 7 | errors.sort_by_key(|e| e.offset()); |
8 | let mut err_pos = 0; | 8 | let mut err_pos = 0; |
9 | let mut level = 0; | 9 | let mut level = 0; |
10 | let mut buf = String::new(); | 10 | let mut buf = String::new(); |
@@ -23,9 +23,9 @@ pub fn dump_tree(syntax: SyntaxNodeRef) -> String { | |||
23 | writeln!(buf, "{:?}", node).unwrap(); | 23 | writeln!(buf, "{:?}", node).unwrap(); |
24 | if node.first_child().is_none() { | 24 | if node.first_child().is_none() { |
25 | let off = node.range().end(); | 25 | let off = node.range().end(); |
26 | while err_pos < errors.len() && errors[err_pos].offset <= off { | 26 | while err_pos < errors.len() && errors[err_pos].offset() <= off { |
27 | indent!(); | 27 | indent!(); |
28 | writeln!(buf, "err: `{}`", errors[err_pos].msg).unwrap(); | 28 | writeln!(buf, "err: `{}`", errors[err_pos]).unwrap(); |
29 | err_pos += 1; | 29 | err_pos += 1; |
30 | } | 30 | } |
31 | } | 31 | } |
@@ -37,7 +37,7 @@ pub fn dump_tree(syntax: SyntaxNodeRef) -> String { | |||
37 | 37 | ||
38 | assert_eq!(level, 0); | 38 | assert_eq!(level, 0); |
39 | for err in errors[err_pos..].iter() { | 39 | for err in errors[err_pos..].iter() { |
40 | writeln!(buf, "err: `{}`", err.msg).unwrap(); | 40 | writeln!(buf, "err: `{}`", err).unwrap(); |
41 | } | 41 | } |
42 | 42 | ||
43 | buf | 43 | buf |