mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Introduce Location and make SyntaxError fields private
This commit is contained in:
parent
3b42ddae60
commit
fda8ddc5fe
10 changed files with 82 additions and 52 deletions
|
@ -4,7 +4,7 @@ use std::fmt::Write;
|
|||
/// Parse a file and create a string representation of the resulting parse tree.
|
||||
pub fn dump_tree(syntax: SyntaxNodeRef) -> String {
|
||||
let mut errors: Vec<_> = syntax.root_data().to_vec();
|
||||
errors.sort_by_key(|e| e.range.start());
|
||||
errors.sort_by_key(|e| e.offset());
|
||||
let mut err_pos = 0;
|
||||
let mut level = 0;
|
||||
let mut buf = String::new();
|
||||
|
@ -23,9 +23,9 @@ pub fn dump_tree(syntax: SyntaxNodeRef) -> String {
|
|||
writeln!(buf, "{:?}", node).unwrap();
|
||||
if node.first_child().is_none() {
|
||||
let off = node.range().end();
|
||||
while err_pos < errors.len() && errors[err_pos].range.start() <= off {
|
||||
while err_pos < errors.len() && errors[err_pos].offset() <= off {
|
||||
indent!();
|
||||
writeln!(buf, "err: `{}`", errors[err_pos].kind).unwrap();
|
||||
writeln!(buf, "err: `{}`", errors[err_pos]).unwrap();
|
||||
err_pos += 1;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ pub fn dump_tree(syntax: SyntaxNodeRef) -> String {
|
|||
|
||||
assert_eq!(level, 0);
|
||||
for err in errors[err_pos..].iter() {
|
||||
writeln!(buf, "err: `{}`", err.kind).unwrap();
|
||||
writeln!(buf, "err: `{}`", err).unwrap();
|
||||
}
|
||||
|
||||
buf
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue