aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/utils.rs')
-rw-r--r--crates/ra_syntax/src/utils.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/crates/ra_syntax/src/utils.rs b/crates/ra_syntax/src/utils.rs
index 0a2b6afbc..2e1b42da0 100644
--- a/crates/ra_syntax/src/utils.rs
+++ b/crates/ra_syntax/src/utils.rs
@@ -1,11 +1,11 @@
1use crate::{SourceFileNode, SyntaxKind, SyntaxNodeRef, WalkEvent, AstNode}; 1use std::{str, fmt::Write};
2use std::fmt::Write; 2
3use std::str; 3use crate::{SourceFile, SyntaxKind, WalkEvent, AstNode, SyntaxNode};
4 4
5/// Parse a file and create a string representation of the resulting parse tree. 5/// Parse a file and create a string representation of the resulting parse tree.
6pub fn dump_tree(syntax: SyntaxNodeRef) -> String { 6pub fn dump_tree(syntax: &SyntaxNode) -> String {
7 let mut errors: Vec<_> = match syntax.ancestors().find_map(SourceFileNode::cast) { 7 let mut errors: Vec<_> = match syntax.ancestors().find_map(SourceFile::cast) {
8 Some(file) => file.owned().errors(), 8 Some(file) => file.errors(),
9 None => syntax.root_data().to_vec(), 9 None => syntax.root_data().to_vec(),
10 }; 10 };
11 errors.sort_by_key(|e| e.offset()); 11 errors.sort_by_key(|e| e.offset());
@@ -48,14 +48,13 @@ pub fn dump_tree(syntax: SyntaxNodeRef) -> String {
48} 48}
49 49
50pub fn check_fuzz_invariants(text: &str) { 50pub fn check_fuzz_invariants(text: &str) {
51 let file = SourceFileNode::parse(text); 51 let file = SourceFile::parse(text);
52 let root = file.syntax(); 52 let root = file.syntax();
53 validate_block_structure(root); 53 validate_block_structure(root);
54 let _ = file.ast();
55 let _ = file.errors(); 54 let _ = file.errors();
56} 55}
57 56
58pub(crate) fn validate_block_structure(root: SyntaxNodeRef) { 57pub(crate) fn validate_block_structure(root: &SyntaxNode) {
59 let mut stack = Vec::new(); 58 let mut stack = Vec::new();
60 for node in root.descendants() { 59 for node in root.descendants() {
61 match node.kind() { 60 match node.kind() {