From c9cfd57eeaa53657c0af7b9c4ba74d6b7b9889ed Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 20 Jul 2019 20:04:34 +0300 Subject: switch to upstream rowan's API --- crates/ra_mbe/src/syntax_bridge.rs | 13 +++++++------ crates/ra_mbe/src/tests.rs | 6 +++--- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'crates/ra_mbe') diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index 7ff0fc472..8225759e7 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs @@ -1,12 +1,13 @@ -use crate::subtree_source::SubtreeTokenSource; -use crate::ExpandError; use ra_parser::{ParseError, TreeSink}; use ra_syntax::{ - ast, AstNode, AstToken, Parse, SmolStr, SyntaxElement, SyntaxKind, SyntaxKind::*, SyntaxNode, + ast, AstNode, AstToken, NodeOrToken, Parse, SmolStr, SyntaxKind, SyntaxKind::*, SyntaxNode, SyntaxTreeBuilder, TextRange, TextUnit, T, }; use tt::buffer::{Cursor, TokenBuffer}; +use crate::subtree_source::SubtreeTokenSource; +use crate::ExpandError; + /// Maps `tt::TokenId` to the relative range of the original token. #[derive(Default)] pub struct TokenMap { @@ -200,7 +201,7 @@ fn convert_tt( } match child { - SyntaxElement::Token(token) => { + NodeOrToken::Token(token) => { if let Some(doc_tokens) = convert_doc_comment(&token) { token_trees.extend(doc_tokens); } else if token.kind().is_trivia() { @@ -210,7 +211,7 @@ fn convert_tt( let char = token.text().chars().next().unwrap(); let spacing = match child_iter.peek() { - Some(SyntaxElement::Token(token)) => { + Some(NodeOrToken::Token(token)) => { if token.kind().is_punct() { tt::Spacing::Joint } else { @@ -241,7 +242,7 @@ fn convert_tt( token_trees.push(child); } } - SyntaxElement::Node(node) => { + NodeOrToken::Node(node) => { let child = convert_tt(token_map, global_offset, &node)?.into(); token_trees.push(child); } diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs index 9151b6ecd..192e9007d 100644 --- a/crates/ra_mbe/src/tests.rs +++ b/crates/ra_mbe/src/tests.rs @@ -1,4 +1,4 @@ -use ra_syntax::{ast, AstNode}; +use ra_syntax::{ast, AstNode, NodeOrToken}; use super::*; @@ -118,11 +118,11 @@ pub fn debug_dump_ignore_spaces(node: &ra_syntax::SyntaxNode) -> String { match event { WalkEvent::Enter(element) => { match element { - ra_syntax::SyntaxElement::Node(node) => { + NodeOrToken::Node(node) => { indent!(); writeln!(buf, "{:?}", node.kind()).unwrap(); } - ra_syntax::SyntaxElement::Token(token) => match token.kind() { + NodeOrToken::Token(token) => match token.kind() { ra_syntax::SyntaxKind::WHITESPACE => {} _ => { indent!(); -- cgit v1.2.3