From d91a98ec843ec8562c58ccb01a1e29d00cc744dc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 7 Jan 2019 16:15:47 +0300 Subject: switch ra_syntax to new rowan API --- crates/ra_syntax/src/utils.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'crates/ra_syntax/src/utils.rs') 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 @@ -use crate::{SourceFileNode, SyntaxKind, SyntaxNodeRef, WalkEvent, AstNode}; -use std::fmt::Write; -use std::str; +use std::{str, fmt::Write}; + +use crate::{SourceFile, SyntaxKind, WalkEvent, AstNode, SyntaxNode}; /// Parse a file and create a string representation of the resulting parse tree. -pub fn dump_tree(syntax: SyntaxNodeRef) -> String { - let mut errors: Vec<_> = match syntax.ancestors().find_map(SourceFileNode::cast) { - Some(file) => file.owned().errors(), +pub fn dump_tree(syntax: &SyntaxNode) -> String { + let mut errors: Vec<_> = match syntax.ancestors().find_map(SourceFile::cast) { + Some(file) => file.errors(), None => syntax.root_data().to_vec(), }; errors.sort_by_key(|e| e.offset()); @@ -48,14 +48,13 @@ pub fn dump_tree(syntax: SyntaxNodeRef) -> String { } pub fn check_fuzz_invariants(text: &str) { - let file = SourceFileNode::parse(text); + let file = SourceFile::parse(text); let root = file.syntax(); validate_block_structure(root); - let _ = file.ast(); let _ = file.errors(); } -pub(crate) fn validate_block_structure(root: SyntaxNodeRef) { +pub(crate) fn validate_block_structure(root: &SyntaxNode) { let mut stack = Vec::new(); for node in root.descendants() { match node.kind() { -- cgit v1.2.3