1
Fork 0

Recover wrong cased keywords starting functions

This commit is contained in:
Maybe Waffle 2022-09-13 22:48:29 +04:00
parent 3694429d09
commit 38b0865248
8 changed files with 205 additions and 51 deletions

View file

@ -618,6 +618,15 @@ impl Token {
self.is_non_raw_ident_where(|id| id.name == kw)
}
/// Returns `true` if the token is a given keyword, `kw` or if `case_insensitive` is true and this token is an identifier equal to `kw` ignoring the case.
pub fn is_keyword_case(&self, kw: Symbol, case_insensitive: bool) -> bool {
self.is_keyword(kw)
|| (case_insensitive
&& self.is_non_raw_ident_where(|id| {
id.name.as_str().to_lowercase() == kw.as_str().to_lowercase()
}))
}
pub fn is_path_segment_keyword(&self) -> bool {
self.is_non_raw_ident_where(Ident::is_path_segment_keyword)
}