aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/syntax_bridge.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-07-18 18:09:50 +0100
committerAleksey Kladov <[email protected]>2019-07-19 11:16:24 +0100
commit08fd402ef2ef1151a9b09cf11c5869b79f1959bb (patch)
treea1172066c2a564d7b0024d23099248415a9fee16 /crates/ra_mbe/src/syntax_bridge.rs
parentd402974aa0af6de290245a9d2a69a5d56c4fa610 (diff)
migrate mbe to the new rowan
Diffstat (limited to 'crates/ra_mbe/src/syntax_bridge.rs')
-rw-r--r--crates/ra_mbe/src/syntax_bridge.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs
index bfc351f81..64ed6a517 100644
--- a/crates/ra_mbe/src/syntax_bridge.rs
+++ b/crates/ra_mbe/src/syntax_bridge.rs
@@ -2,7 +2,7 @@ use crate::subtree_source::SubtreeTokenSource;
2use crate::ExpandError; 2use crate::ExpandError;
3use ra_parser::{ParseError, TreeSink}; 3use ra_parser::{ParseError, TreeSink};
4use ra_syntax::{ 4use ra_syntax::{
5 ast, AstNode, Parse, SmolStr, SyntaxElement, SyntaxKind, SyntaxKind::*, SyntaxNode, 5 ast, AstNode, AstToken, Parse, SmolStr, SyntaxElement, SyntaxKind, SyntaxKind::*, SyntaxNode,
6 SyntaxTreeBuilder, TextRange, TextUnit, T, 6 SyntaxTreeBuilder, TextRange, TextUnit, T,
7}; 7};
8use tt::buffer::{Cursor, TokenBuffer}; 8use tt::buffer::{Cursor, TokenBuffer};
@@ -116,8 +116,6 @@ impl TokenMap {
116/// and strips the ending `*/` 116/// and strips the ending `*/`
117/// And then quote the string, which is needed to convert to `tt::Literal` 117/// And then quote the string, which is needed to convert to `tt::Literal`
118fn doc_comment_text(comment: &ast::Comment) -> SmolStr { 118fn doc_comment_text(comment: &ast::Comment) -> SmolStr {
119 use ast::AstToken;
120
121 let prefix_len = comment.prefix().len(); 119 let prefix_len = comment.prefix().len();
122 let mut text = &comment.text()[prefix_len..]; 120 let mut text = &comment.text()[prefix_len..];
123 121
@@ -132,9 +130,8 @@ fn doc_comment_text(comment: &ast::Comment) -> SmolStr {
132 text.into() 130 text.into()
133} 131}
134 132
135fn convert_doc_comment<'a>(token: &ra_syntax::SyntaxToken<'a>) -> Option<Vec<tt::TokenTree>> { 133fn convert_doc_comment(token: &ra_syntax::SyntaxToken) -> Option<Vec<tt::TokenTree>> {
136 use ast::AstToken; 134 let comment = ast::Comment::cast(token.clone())?;
137 let comment = ast::Comment::cast(*token)?;
138 let doc = comment.kind().doc?; 135 let doc = comment.kind().doc?;
139 136
140 // Make `doc="\" Comments\"" 137 // Make `doc="\" Comments\""
@@ -245,7 +242,7 @@ fn convert_tt(
245 } 242 }
246 } 243 }
247 SyntaxElement::Node(node) => { 244 SyntaxElement::Node(node) => {
248 let child = convert_tt(token_map, global_offset, node)?.into(); 245 let child = convert_tt(token_map, global_offset, &node)?.into();
249 token_trees.push(child); 246 token_trees.push(child);
250 } 247 }
251 }; 248 };