diff options
Diffstat (limited to 'crates/ra_mbe/src')
-rw-r--r-- | crates/ra_mbe/src/syntax_bridge.rs | 13 | ||||
-rw-r--r-- | crates/ra_mbe/src/tests.rs | 6 |
2 files changed, 10 insertions, 9 deletions
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 @@ | |||
1 | use crate::subtree_source::SubtreeTokenSource; | ||
2 | use crate::ExpandError; | ||
3 | use ra_parser::{ParseError, TreeSink}; | 1 | use ra_parser::{ParseError, TreeSink}; |
4 | use ra_syntax::{ | 2 | use ra_syntax::{ |
5 | ast, AstNode, AstToken, Parse, SmolStr, SyntaxElement, SyntaxKind, SyntaxKind::*, SyntaxNode, | 3 | ast, AstNode, AstToken, NodeOrToken, Parse, SmolStr, SyntaxKind, SyntaxKind::*, SyntaxNode, |
6 | SyntaxTreeBuilder, TextRange, TextUnit, T, | 4 | SyntaxTreeBuilder, TextRange, TextUnit, T, |
7 | }; | 5 | }; |
8 | use tt::buffer::{Cursor, TokenBuffer}; | 6 | use tt::buffer::{Cursor, TokenBuffer}; |
9 | 7 | ||
8 | use crate::subtree_source::SubtreeTokenSource; | ||
9 | use crate::ExpandError; | ||
10 | |||
10 | /// Maps `tt::TokenId` to the relative range of the original token. | 11 | /// Maps `tt::TokenId` to the relative range of the original token. |
11 | #[derive(Default)] | 12 | #[derive(Default)] |
12 | pub struct TokenMap { | 13 | pub struct TokenMap { |
@@ -200,7 +201,7 @@ fn convert_tt( | |||
200 | } | 201 | } |
201 | 202 | ||
202 | match child { | 203 | match child { |
203 | SyntaxElement::Token(token) => { | 204 | NodeOrToken::Token(token) => { |
204 | if let Some(doc_tokens) = convert_doc_comment(&token) { | 205 | if let Some(doc_tokens) = convert_doc_comment(&token) { |
205 | token_trees.extend(doc_tokens); | 206 | token_trees.extend(doc_tokens); |
206 | } else if token.kind().is_trivia() { | 207 | } else if token.kind().is_trivia() { |
@@ -210,7 +211,7 @@ fn convert_tt( | |||
210 | let char = token.text().chars().next().unwrap(); | 211 | let char = token.text().chars().next().unwrap(); |
211 | 212 | ||
212 | let spacing = match child_iter.peek() { | 213 | let spacing = match child_iter.peek() { |
213 | Some(SyntaxElement::Token(token)) => { | 214 | Some(NodeOrToken::Token(token)) => { |
214 | if token.kind().is_punct() { | 215 | if token.kind().is_punct() { |
215 | tt::Spacing::Joint | 216 | tt::Spacing::Joint |
216 | } else { | 217 | } else { |
@@ -241,7 +242,7 @@ fn convert_tt( | |||
241 | token_trees.push(child); | 242 | token_trees.push(child); |
242 | } | 243 | } |
243 | } | 244 | } |
244 | SyntaxElement::Node(node) => { | 245 | NodeOrToken::Node(node) => { |
245 | let child = convert_tt(token_map, global_offset, &node)?.into(); | 246 | let child = convert_tt(token_map, global_offset, &node)?.into(); |
246 | token_trees.push(child); | 247 | token_trees.push(child); |
247 | } | 248 | } |
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 @@ | |||
1 | use ra_syntax::{ast, AstNode}; | 1 | use ra_syntax::{ast, AstNode, NodeOrToken}; |
2 | 2 | ||
3 | use super::*; | 3 | use super::*; |
4 | 4 | ||
@@ -118,11 +118,11 @@ pub fn debug_dump_ignore_spaces(node: &ra_syntax::SyntaxNode) -> String { | |||
118 | match event { | 118 | match event { |
119 | WalkEvent::Enter(element) => { | 119 | WalkEvent::Enter(element) => { |
120 | match element { | 120 | match element { |
121 | ra_syntax::SyntaxElement::Node(node) => { | 121 | NodeOrToken::Node(node) => { |
122 | indent!(); | 122 | indent!(); |
123 | writeln!(buf, "{:?}", node.kind()).unwrap(); | 123 | writeln!(buf, "{:?}", node.kind()).unwrap(); |
124 | } | 124 | } |
125 | ra_syntax::SyntaxElement::Token(token) => match token.kind() { | 125 | NodeOrToken::Token(token) => match token.kind() { |
126 | ra_syntax::SyntaxKind::WHITESPACE => {} | 126 | ra_syntax::SyntaxKind::WHITESPACE => {} |
127 | _ => { | 127 | _ => { |
128 | indent!(); | 128 | indent!(); |