diff options
author | Adolfo OchagavĂa <[email protected]> | 2018-11-04 15:45:22 +0000 |
---|---|---|
committer | Adolfo OchagavĂa <[email protected]> | 2018-11-04 20:16:38 +0000 |
commit | 3b42ddae601fbd73f672e82028e04c3abdf1252d (patch) | |
tree | d63c4114d2fccf1c085502dfd1048b4b5f68266b /crates/ra_syntax/src/utils.rs | |
parent | 576b9a0727ebbf00521bc1131cda808145696d06 (diff) |
Introduce SyntaxErrorKind and TextRange in SyntaxError
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..f55568d94 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.range.start()); |
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].range.start() <= off { |
27 | indent!(); | 27 | indent!(); |
28 | writeln!(buf, "err: `{}`", errors[err_pos].msg).unwrap(); | 28 | writeln!(buf, "err: `{}`", errors[err_pos].kind).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.kind).unwrap(); |
41 | } | 41 | } |
42 | 42 | ||
43 | buf | 43 | buf |