aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-21 14:48:46 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-21 14:48:46 +0100
commit443061e75260e55bbaa741c5c85377b8d5c57e47 (patch)
treec28241dc1639480ba5154040e9f31384eabfed06 /crates/ra_mbe
parent1137fc47bbbc8d648db3bc669e41fd059a09dd1d (diff)
parent773ad2edb3b84bf20378a577bc4cd808384de078 (diff)
Merge #1570
1570: switch to upstream rowan's API r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_mbe')
-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!();