aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/macros.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/macros.rs')
-rw-r--r--crates/ra_hir/src/macros.rs45
1 files changed, 25 insertions, 20 deletions
diff --git a/crates/ra_hir/src/macros.rs b/crates/ra_hir/src/macros.rs
index 4740e5337..0497d2168 100644
--- a/crates/ra_hir/src/macros.rs
+++ b/crates/ra_hir/src/macros.rs
@@ -221,27 +221,32 @@ fn convert_tt(tt: &SyntaxNode) -> Option<tt::Subtree> {
221 if child == first_child || child == last_child || child.kind().is_trivia() { 221 if child == first_child || child == last_child || child.kind().is_trivia() {
222 continue; 222 continue;
223 } 223 }
224 let child: tt::TokenTree = if child.kind() == TOKEN_TREE { 224 if child.kind().is_punct() {
225 convert_tt(child)?.into() 225 let leaves = child
226 } else if child.kind().is_keyword() || child.kind() == IDENT { 226 .leaf_text()
227 let text = child.leaf_text().unwrap().clone(); 227 .unwrap()
228 tt::Leaf::from(tt::Ident { text }).into() 228 .chars()
229 } else if child.kind().is_punct() { 229 .map(|char| tt::Punct { char })
230 // FIXME: multibyte tokens 230 .map(tt::Leaf::from)
231 tt::Leaf::from(tt::Punct { 231 .map(tt::TokenTree::from);
232 char: child.text().char_at(0)?, 232 token_trees.extend(leaves);
233 })
234 .into()
235 } else if child.kind().is_literal() {
236 tt::Leaf::from(tt::Literal {
237 text: child.leaf_text().unwrap().clone(),
238 })
239 .into()
240 } else { 233 } else {
241 log::error!("unknown kind: {:?}", child); 234 let child: tt::TokenTree = if child.kind() == TOKEN_TREE {
242 return None; 235 convert_tt(child)?.into()
243 }; 236 } else if child.kind().is_keyword() || child.kind() == IDENT {
244 token_trees.push(child) 237 let text = child.leaf_text().unwrap().clone();
238 tt::Leaf::from(tt::Ident { text }).into()
239 } else if child.kind().is_literal() {
240 tt::Leaf::from(tt::Literal {
241 text: child.leaf_text().unwrap().clone(),
242 })
243 .into()
244 } else {
245 log::error!("unknown kind: {:?}", child);
246 return None;
247 };
248 token_trees.push(child)
249 }
245 } 250 }
246 251
247 let res = tt::Subtree { 252 let res = tt::Subtree {