diff options
Diffstat (limited to 'crates/ra_mbe/src/subtree_source.rs')
-rw-r--r-- | crates/ra_mbe/src/subtree_source.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/ra_mbe/src/subtree_source.rs index 3229cfa8f..e979777fe 100644 --- a/crates/ra_mbe/src/subtree_source.rs +++ b/crates/ra_mbe/src/subtree_source.rs | |||
@@ -342,7 +342,7 @@ impl<'a> TokenSource for SubtreeTokenSource<'a> { | |||
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | struct TokenPeek<'a, I> | 345 | pub(crate) struct TokenPeek<'a, I> |
346 | where | 346 | where |
347 | I: Iterator<Item = &'a tt::TokenTree>, | 347 | I: Iterator<Item = &'a tt::TokenTree>, |
348 | { | 348 | { |
@@ -365,7 +365,7 @@ where | |||
365 | TokenPeek { iter: itertools::multipeek(iter) } | 365 | TokenPeek { iter: itertools::multipeek(iter) } |
366 | } | 366 | } |
367 | 367 | ||
368 | fn current_punct2(&mut self, p: &tt::Punct) -> Option<((char, char), bool)> { | 368 | pub fn current_punct2(&mut self, p: &tt::Punct) -> Option<((char, char), bool)> { |
369 | if p.spacing != tt::Spacing::Joint { | 369 | if p.spacing != tt::Spacing::Joint { |
370 | return None; | 370 | return None; |
371 | } | 371 | } |
@@ -375,7 +375,7 @@ where | |||
375 | Some(((p.char, p1.char), p1.spacing == tt::Spacing::Joint)) | 375 | Some(((p.char, p1.char), p1.spacing == tt::Spacing::Joint)) |
376 | } | 376 | } |
377 | 377 | ||
378 | fn current_punct3(&mut self, p: &tt::Punct) -> Option<((char, char, char), bool)> { | 378 | pub fn current_punct3(&mut self, p: &tt::Punct) -> Option<((char, char, char), bool)> { |
379 | self.current_punct2(p).and_then(|((p0, p1), last_joint)| { | 379 | self.current_punct2(p).and_then(|((p0, p1), last_joint)| { |
380 | if !last_joint { | 380 | if !last_joint { |
381 | None | 381 | None |
@@ -437,12 +437,16 @@ fn convert_delim(d: tt::Delimiter, closing: bool) -> TtToken { | |||
437 | } | 437 | } |
438 | 438 | ||
439 | fn convert_literal(l: &tt::Literal) -> TtToken { | 439 | fn convert_literal(l: &tt::Literal) -> TtToken { |
440 | TtToken { | 440 | let kind = classify_literal(&l.text) |
441 | kind: classify_literal(&l.text).unwrap().kind, | 441 | .map(|tkn| tkn.kind) |
442 | is_joint_to_next: false, | 442 | .or_else(|| match l.text.as_ref() { |
443 | text: l.text.clone(), | 443 | "true" => Some(SyntaxKind::TRUE_KW), |
444 | n_tokens: 1, | 444 | "false" => Some(SyntaxKind::FALSE_KW), |
445 | } | 445 | _ => None, |
446 | }) | ||
447 | .unwrap(); | ||
448 | |||
449 | TtToken { kind, is_joint_to_next: false, text: l.text.clone(), n_tokens: 1 } | ||
446 | } | 450 | } |
447 | 451 | ||
448 | fn convert_ident(ident: &tt::Ident) -> TtToken { | 452 | fn convert_ident(ident: &tt::Ident) -> TtToken { |