From 4d38b0dce1884dab0da7394ccc979eef0a21076c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 15:18:14 +0200 Subject: Move Stmt Grammar --- crates/ra_syntax/src/ast/generated/nodes.rs | 169 ++++++++++++++-------------- 1 file changed, 85 insertions(+), 84 deletions(-) (limited to 'crates') diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 9064398a9..286be1032 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -473,6 +473,7 @@ pub struct LifetimeParam { pub(crate) syntax: SyntaxNode, } impl ast::AttrsOwner for LifetimeParam {} +impl ast::TypeBoundsOwner for LifetimeParam {} impl LifetimeParam { pub fn lifetime_token(&self) -> Option { support::token(&self.syntax, T![lifetime]) @@ -503,6 +504,19 @@ impl ConstParam { pub fn default_val(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct WherePred { + pub(crate) syntax: SyntaxNode, +} +impl ast::TypeBoundsOwner for WherePred {} +impl WherePred { + pub fn for_token(&self) -> Option { support::token(&self.syntax, T![for]) } + pub fn generic_param_list(&self) -> Option { support::child(&self.syntax) } + pub fn lifetime_token(&self) -> Option { + support::token(&self.syntax, T![lifetime]) + } + pub fn ty(&self) -> Option { support::child(&self.syntax) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Literal { pub(crate) syntax: SyntaxNode, } @@ -520,6 +534,29 @@ impl TokenTree { pub fn r_brack_token(&self) -> Option { support::token(&self.syntax, T![']']) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct LetStmt { + pub(crate) syntax: SyntaxNode, +} +impl ast::AttrsOwner for LetStmt {} +impl LetStmt { + pub fn let_token(&self) -> Option { support::token(&self.syntax, T![let]) } + pub fn pat(&self) -> Option { support::child(&self.syntax) } + pub fn colon_token(&self) -> Option { support::token(&self.syntax, T![:]) } + pub fn ty(&self) -> Option { support::child(&self.syntax) } + pub fn eq_token(&self) -> Option { support::token(&self.syntax, T![=]) } + pub fn initializer(&self) -> Option { support::child(&self.syntax) } + pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct ExprStmt { + pub(crate) syntax: SyntaxNode, +} +impl ast::AttrsOwner for ExprStmt {} +impl ExprStmt { + pub fn expr(&self) -> Option { support::child(&self.syntax) } + pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ParenType { pub(crate) syntax: SyntaxNode, } @@ -1179,42 +1216,6 @@ impl MacroStmts { pub fn expr(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct WherePred { - pub(crate) syntax: SyntaxNode, -} -impl ast::TypeBoundsOwner for WherePred {} -impl WherePred { - pub fn for_token(&self) -> Option { support::token(&self.syntax, T![for]) } - pub fn generic_param_list(&self) -> Option { support::child(&self.syntax) } - pub fn lifetime_token(&self) -> Option { - support::token(&self.syntax, T![lifetime]) - } - pub fn ty(&self) -> Option { support::child(&self.syntax) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ExprStmt { - pub(crate) syntax: SyntaxNode, -} -impl ast::AttrsOwner for ExprStmt {} -impl ExprStmt { - pub fn expr(&self) -> Option { support::child(&self.syntax) } - pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct LetStmt { - pub(crate) syntax: SyntaxNode, -} -impl ast::AttrsOwner for LetStmt {} -impl LetStmt { - pub fn let_token(&self) -> Option { support::token(&self.syntax, T![let]) } - pub fn pat(&self) -> Option { support::child(&self.syntax) } - pub fn colon_token(&self) -> Option { support::token(&self.syntax, T![:]) } - pub fn ty(&self) -> Option { support::child(&self.syntax) } - pub fn eq_token(&self) -> Option { support::token(&self.syntax, T![=]) } - pub fn initializer(&self) -> Option { support::child(&self.syntax) } - pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct PathSegment { pub(crate) syntax: SyntaxNode, } @@ -1880,6 +1881,17 @@ impl AstNode for ConstParam { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } +impl AstNode for WherePred { + fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_PRED } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} impl AstNode for Literal { fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } fn cast(syntax: SyntaxNode) -> Option { @@ -1902,6 +1914,28 @@ impl AstNode for TokenTree { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } +impl AstNode for LetStmt { + fn can_cast(kind: SyntaxKind) -> bool { kind == LET_STMT } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} +impl AstNode for ExprStmt { + fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} impl AstNode for ParenType { fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE } fn cast(syntax: SyntaxNode) -> Option { @@ -2672,39 +2706,6 @@ impl AstNode for MacroStmts { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for WherePred { - fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_PRED } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} -impl AstNode for ExprStmt { - fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} -impl AstNode for LetStmt { - fn can_cast(kind: SyntaxKind) -> bool { kind == LET_STMT } - fn cast(syntax: SyntaxNode) -> Option { - if Self::can_cast(syntax.kind()) { - Some(Self { syntax }) - } else { - None - } - } - fn syntax(&self) -> &SyntaxNode { &self.syntax } -} impl AstNode for PathSegment { fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } fn cast(syntax: SyntaxNode) -> Option { @@ -3671,6 +3672,11 @@ impl std::fmt::Display for ConstParam { std::fmt::Display::fmt(self.syntax(), f) } } +impl std::fmt::Display for WherePred { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} impl std::fmt::Display for Literal { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -3681,6 +3687,16 @@ impl std::fmt::Display for TokenTree { std::fmt::Display::fmt(self.syntax(), f) } } +impl std::fmt::Display for LetStmt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} +impl std::fmt::Display for ExprStmt { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} impl std::fmt::Display for ParenType { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -4031,21 +4047,6 @@ impl std::fmt::Display for MacroStmts { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for WherePred { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} -impl std::fmt::Display for ExprStmt { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} -impl std::fmt::Display for LetStmt { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - std::fmt::Display::fmt(self.syntax(), f) - } -} impl std::fmt::Display for PathSegment { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) -- cgit v1.2.3