diff options
author | Aleksey Kladov <[email protected]> | 2019-01-31 07:30:15 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-31 20:23:30 +0000 |
commit | 3bd4560d6eb6404f05c2c99a5755b86e9e896eb9 (patch) | |
tree | 3ff9bce589c5d455b57bf173a650480a9d172ccd /crates/ra_hir/src | |
parent | c09c6fc97c1d553dd348383eb98fc7a4788030cb (diff) |
convert punts and literals
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/macros.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/crates/ra_hir/src/macros.rs b/crates/ra_hir/src/macros.rs index 9ba381685..c23ad53cc 100644 --- a/crates/ra_hir/src/macros.rs +++ b/crates/ra_hir/src/macros.rs | |||
@@ -221,12 +221,24 @@ 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 = if child.kind() == TOKEN_TREE { | 224 | let child: tt::TokenTree = if child.kind() == TOKEN_TREE { |
225 | convert_tt(child)?.into() | 225 | convert_tt(child)?.into() |
226 | } else if child.kind().is_keyword() { | 226 | } else if child.kind().is_keyword() || child.kind() == IDENT { |
227 | let text = child.leaf_text().unwrap().clone(); | 227 | let text = child.leaf_text().unwrap().clone(); |
228 | tt::Leaf::from(tt::Ident { text }).into() | 228 | tt::Leaf::from(tt::Ident { text }).into() |
229 | } else if child.kind().is_punct() { | ||
230 | // FIXME: multibyte tokens | ||
231 | tt::Leaf::from(tt::Punct { | ||
232 | char: child.text().char_at(0)?, | ||
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() | ||
229 | } else { | 240 | } else { |
241 | log::error!("unknown kind: {:?}", child); | ||
230 | return None; | 242 | return None; |
231 | }; | 243 | }; |
232 | token_trees.push(child) | 244 | token_trees.push(child) |