From 30084a56a5731343bd4cec727646a6c55900234f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 9 Apr 2020 23:35:05 +0200 Subject: Simpler acessors for keywords --- crates/ra_syntax/src/ast/generated/tokens.rs | 916 +-------------------------- 1 file changed, 2 insertions(+), 914 deletions(-) (limited to 'crates/ra_syntax/src/ast/generated/tokens.rs') diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/ra_syntax/src/ast/generated/tokens.rs index e64b8bce6..7344b0e49 100644 --- a/crates/ra_syntax/src/ast/generated/tokens.rs +++ b/crates/ra_syntax/src/ast/generated/tokens.rs @@ -1046,906 +1046,6 @@ impl AstToken for Shreq { fn syntax(&self) -> &SyntaxToken { &self.syntax } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct AsKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for AsKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for AsKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == AS_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct AsyncKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for AsyncKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for AsyncKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == ASYNC_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct AwaitKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for AwaitKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for AwaitKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct BoxKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for BoxKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for BoxKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct BreakKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for BreakKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for BreakKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ConstKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for ConstKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for ConstKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ContinueKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for ContinueKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for ContinueKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct CrateKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for CrateKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for CrateKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == CRATE_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct DynKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for DynKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for DynKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ElseKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for ElseKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for ElseKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == ELSE_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct EnumKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for EnumKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for EnumKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ExternKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for ExternKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for ExternKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct FalseKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for FalseKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for FalseKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == FALSE_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct FnKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for FnKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for FnKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == FN_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ForKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for ForKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for ForKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct IfKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for IfKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for IfKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == IF_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ImplKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for ImplKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for ImplKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct InKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for InKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for InKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == IN_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct LetKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for LetKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for LetKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == LET_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct LoopKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for LoopKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for LoopKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct MacroKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for MacroKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for MacroKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct MatchKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for MatchKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for MatchKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ModKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for ModKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for ModKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == MOD_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct MoveKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for MoveKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for MoveKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == MOVE_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct MutKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for MutKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for MutKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == MUT_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct PubKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for PubKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for PubKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == PUB_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct RefKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for RefKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for RefKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == REF_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ReturnKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for ReturnKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for ReturnKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct SelfKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for SelfKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for SelfKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct StaticKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for StaticKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for StaticKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct StructKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for StructKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for StructKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct SuperKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for SuperKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for SuperKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == SUPER_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct TraitKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for TraitKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for TraitKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct TrueKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for TrueKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for TrueKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == TRUE_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct TryKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for TryKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for TryKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct TypeKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for TypeKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for TypeKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct UnsafeKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for UnsafeKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for UnsafeKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == UNSAFE_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct UseKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for UseKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for UseKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == USE_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct WhereKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for WhereKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for WhereKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct WhileKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for WhileKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for WhileKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct AutoKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for AutoKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for AutoKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == AUTO_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct DefaultKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for DefaultKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for DefaultKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == DEFAULT_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ExistentialKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for ExistentialKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for ExistentialKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == EXISTENTIAL_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct UnionKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for UnionKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for UnionKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct RawKw { - pub(crate) syntax: SyntaxToken, -} -impl std::fmt::Display for RawKw { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - std::fmt::Display::fmt(&self.syntax, f) - } -} -impl AstToken for RawKw { - fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_KW } - fn cast(syntax: SyntaxToken) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxToken { &self.syntax } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct IntNumber { pub(crate) syntax: SyntaxToken, } @@ -2687,8 +1787,6 @@ pub enum LiteralToken { FloatNumber(FloatNumber), String(String), RawString(RawString), - TrueKw(TrueKw), - FalseKw(FalseKw), ByteString(ByteString), RawByteString(RawByteString), Char(Char), @@ -2706,12 +1804,6 @@ impl From for LiteralToken { impl From for LiteralToken { fn from(node: RawString) -> LiteralToken { LiteralToken::RawString(node) } } -impl From for LiteralToken { - fn from(node: TrueKw) -> LiteralToken { LiteralToken::TrueKw(node) } -} -impl From for LiteralToken { - fn from(node: FalseKw) -> LiteralToken { LiteralToken::FalseKw(node) } -} impl From for LiteralToken { fn from(node: ByteString) -> LiteralToken { LiteralToken::ByteString(node) } } @@ -2732,8 +1824,8 @@ impl std::fmt::Display for LiteralToken { impl AstToken for LiteralToken { fn can_cast(kind: SyntaxKind) -> bool { match kind { - INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | TRUE_KW | FALSE_KW | BYTE_STRING - | RAW_BYTE_STRING | CHAR | BYTE => true, + INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | BYTE_STRING | RAW_BYTE_STRING + | CHAR | BYTE => true, _ => false, } } @@ -2743,8 +1835,6 @@ impl AstToken for LiteralToken { FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }), STRING => LiteralToken::String(String { syntax }), RAW_STRING => LiteralToken::RawString(RawString { syntax }), - TRUE_KW => LiteralToken::TrueKw(TrueKw { syntax }), - FALSE_KW => LiteralToken::FalseKw(FalseKw { syntax }), BYTE_STRING => LiteralToken::ByteString(ByteString { syntax }), RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }), CHAR => LiteralToken::Char(Char { syntax }), @@ -2759,8 +1849,6 @@ impl AstToken for LiteralToken { LiteralToken::FloatNumber(it) => &it.syntax, LiteralToken::String(it) => &it.syntax, LiteralToken::RawString(it) => &it.syntax, - LiteralToken::TrueKw(it) => &it.syntax, - LiteralToken::FalseKw(it) => &it.syntax, LiteralToken::ByteString(it) => &it.syntax, LiteralToken::RawByteString(it) => &it.syntax, LiteralToken::Char(it) => &it.syntax, -- cgit v1.2.3