diff --git a/crates/util/src/node_with_source.rs b/crates/util/src/node_with_source.rs index 3ce736822..af7ec0de6 100644 --- a/crates/util/src/node_with_source.rs +++ b/crates/util/src/node_with_source.rs @@ -69,6 +69,19 @@ impl<'a> NodeWithSource<'a> { end_byte: ts_range.end_byte(), } } + + pub fn print_node_tree(&self) { + let mut stack = vec![(self.node.clone(), 0)]; + while let Some((node, depth)) = stack.pop() { + let sort_id = node.kind_id(); + println!("{:indent$}{}: {:?}", "", sort_id, node, indent = depth * 2); + for i in (0..node.child_count()).rev() { + if let Some(child) = node.child(i) { + stack.push((child, depth + 1)); + } + } + } + } } impl<'a> PartialEq for NodeWithSource<'a> { diff --git a/resources/add_language.py b/resources/add_language.py index b4bfbeeeb..c2415e496 100644 --- a/resources/add_language.py +++ b/resources/add_language.py @@ -146,7 +146,7 @@ def main(args: Namespace): with open(grammar_js_path, "w") as f: f.write(updated_grammar_js) - # check if tree-sitter is installed: + # check if node is installed: try: output = check_output(["node", "--version"], cwd=repo_path).decode().strip() print("using", output)