Make --dump-ts less verbose

Saying Node at each node is redundant and distracting.
pull/223/head
Wilfred Hughes 2022-04-03 15:22:10 +07:00
parent 01678f8556
commit 3bdf8c3e80
1 changed files with 9 additions and 11 deletions

@ -651,20 +651,18 @@ fn print_cursor(src: &str, cursor: &mut ts::TreeCursor, depth: usize) {
let node = cursor.node();
node.end_position();
let formatted_node = format!(
"{} {} - {}",
node.kind().replace('\n', "\\n"),
node.start_position(),
node.end_position()
);
if node.child_count() == 0 {
let node_src = &src[node.start_byte()..node.end_byte()];
println!(
"{}{} {:?}",
" ".repeat(depth),
format!("{:?}", node).replace('\n', "\\n"),
node_src
);
println!("{}{} {:?}", " ".repeat(depth), formatted_node, node_src);
} else {
println!(
"{}{}",
" ".repeat(depth),
format!("{:?}", node).replace('\n', "\\n"),
);
println!("{}{}", " ".repeat(depth), formatted_node,);
}
if cursor.goto_first_child() {