aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2019-07-21 22:10:29 +0100
committerKirill Bulatov <[email protected]>2019-07-21 22:10:29 +0100
commit31aef808d96b779dbc8ce41e27857965e79bd96f (patch)
tree254d69a1ec3abe6d70b2dd9737ef699f33f88f62 /crates/ra_mbe/src
parentba76017d2eb1b7606106c15478ac658dc32b6dbd (diff)
parentd690249bc81bc265cb3d1836c2922325f4fdb8af (diff)
Merge branch 'master' into add-type-lenses
Diffstat (limited to 'crates/ra_mbe/src')
-rw-r--r--crates/ra_mbe/src/syntax_bridge.rs13
-rw-r--r--crates/ra_mbe/src/tests.rs6
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 @@
1use crate::subtree_source::SubtreeTokenSource;
2use crate::ExpandError;
3use ra_parser::{ParseError, TreeSink}; 1use ra_parser::{ParseError, TreeSink};
4use ra_syntax::{ 2use 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};
8use tt::buffer::{Cursor, TokenBuffer}; 6use tt::buffer::{Cursor, TokenBuffer};
9 7
8use crate::subtree_source::SubtreeTokenSource;
9use 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)]
12pub struct TokenMap { 13pub 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 @@
1use ra_syntax::{ast, AstNode}; 1use ra_syntax::{ast, AstNode, NodeOrToken};
2 2
3use super::*; 3use 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!();