diff options
author | Jonas Schievink <[email protected]> | 2021-05-24 19:29:48 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2021-05-24 19:29:48 +0100 |
commit | 489ae7a800b02dbdacc1f949c067fa557333e7a1 (patch) | |
tree | 05fd003ccc166e52cf81e305a1073d56aed572ff /crates/mbe/src/token_map.rs | |
parent | 27bf62b70eeb6f4cb620be5630c4c4506be3539f (diff) |
Make `TokenTextRange` private
Diffstat (limited to 'crates/mbe/src/token_map.rs')
-rw-r--r-- | crates/mbe/src/token_map.rs | 8 |
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}; | |||
2 | use syntax::{TextRange, TextSize}; | 2 | use syntax::{TextRange, TextSize}; |
3 | 3 | ||
4 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 4 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
5 | pub enum TokenTextRange { | 5 | enum TokenTextRange { |
6 | Token(TextRange), | 6 | Token(TextRange), |
7 | Delimiter(TextRange), | 7 | Delimiter(TextRange), |
8 | } | 8 | } |
9 | 9 | ||
10 | impl TokenTextRange { | 10 | impl 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) { |