aboutsummaryrefslogtreecommitdiff
path: root/crates/mbe/src/token_map.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/mbe/src/token_map.rs')
-rw-r--r--crates/mbe/src/token_map.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/mbe/src/token_map.rs b/crates/mbe/src/token_map.rs
index 58c9f5aa5..0567475be 100644
--- a/crates/mbe/src/token_map.rs
+++ b/crates/mbe/src/token_map.rs
@@ -2,13 +2,13 @@ use parser::{SyntaxKind, T};
2use syntax::{TextRange, TextSize}; 2use syntax::{TextRange, TextSize};
3 3
4#[derive(Debug, PartialEq, Eq, Clone, Copy)] 4#[derive(Debug, PartialEq, Eq, Clone, Copy)]
5pub enum TokenTextRange { 5enum TokenTextRange {
6 Token(TextRange), 6 Token(TextRange),
7 Delimiter(TextRange), 7 Delimiter(TextRange),
8} 8}
9 9
10impl TokenTextRange { 10impl TokenTextRange {
11 pub fn by_kind(self, kind: SyntaxKind) -> Option<TextRange> { 11 fn by_kind(self, kind: SyntaxKind) -> Option<TextRange> {
12 match self { 12 match self {
13 TokenTextRange::Token(it) => Some(it), 13 TokenTextRange::Token(it) => Some(it),
14 TokenTextRange::Delimiter(it) => match kind { 14 TokenTextRange::Delimiter(it) => match kind {
@@ -42,9 +42,9 @@ impl TokenMap {
42 Some(token_id) 42 Some(token_id)
43 } 43 }
44 44
45 pub fn range_by_token(&self, token_id: tt::TokenId) -> Option<TokenTextRange> { 45 pub fn range_by_token(&self, token_id: tt::TokenId, kind: SyntaxKind) -> Option<TextRange> {
46 let &(_, range) = self.entries.iter().find(|(tid, _)| *tid == token_id)?; 46 let &(_, range) = self.entries.iter().find(|(tid, _)| *tid == token_id)?;
47 Some(range) 47 range.by_kind(kind)
48 } 48 }
49 49
50 pub(crate) fn shrink_to_fit(&mut self) { 50 pub(crate) fn shrink_to_fit(&mut self) {