diff options
Diffstat (limited to 'crates/ra_mbe/src/syntax_bridge.rs')
-rw-r--r-- | crates/ra_mbe/src/syntax_bridge.rs | 13 |
1 files changed, 7 insertions, 6 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 | } |