diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-08 09:05:55 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-08 09:05:55 +0000 |
commit | 3f4be819125ce4a22edd86721fa56b5caba99c2e (patch) | |
tree | be93895ddc08c911585d9f7bc64623a3741f32c6 /crates/ra_syntax/src/utils.rs | |
parent | 4e444d2bc24d16284401444fd2154f63e0f96070 (diff) | |
parent | 122410d7aa34a32d468a3173858cbc8a2bbc68f5 (diff) |
Merge #449
449: switch to new rowan API r=matklad a=matklad
closes https://github.com/rust-analyzer/rust-analyzer/issues/448
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/utils.rs')
-rw-r--r-- | crates/ra_syntax/src/utils.rs | 17 |
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 @@ | |||
1 | use crate::{SourceFileNode, SyntaxKind, SyntaxNodeRef, WalkEvent, AstNode}; | 1 | use std::{str, fmt::Write}; |
2 | use std::fmt::Write; | 2 | |
3 | use std::str; | 3 | use 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. |
6 | pub fn dump_tree(syntax: SyntaxNodeRef) -> String { | 6 | pub 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 | ||
50 | pub fn check_fuzz_invariants(text: &str) { | 50 | pub 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 | ||
58 | pub(crate) fn validate_block_structure(root: SyntaxNodeRef) { | 57 | pub(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() { |