From 7980a7e19a679e0bc128f2c142609f7f4a197bf6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jul 2020 18:04:57 +0200 Subject: Minor --- crates/ra_syntax/src/ast/generated/nodes.rs | 130 +++++++++++++--------------- 1 file changed, 62 insertions(+), 68 deletions(-) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 158544fa2..e049548c9 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -624,6 +624,19 @@ impl CastExpr { pub fn ty(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct ClosureExpr { + pub(crate) syntax: SyntaxNode, +} +impl ast::AttrsOwner for ClosureExpr {} +impl ClosureExpr { + pub fn static_token(&self) -> Option { support::token(&self.syntax, T![static]) } + pub fn async_token(&self) -> Option { support::token(&self.syntax, T![async]) } + pub fn move_token(&self) -> Option { support::token(&self.syntax, T![move]) } + pub fn param_list(&self) -> Option { support::child(&self.syntax) } + pub fn ret_type(&self) -> Option { support::child(&self.syntax) } + pub fn body(&self) -> Option { support::child(&self.syntax) } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ContinueExpr { pub(crate) syntax: SyntaxNode, } @@ -690,28 +703,6 @@ impl IndexExpr { pub fn r_brack_token(&self) -> Option { support::token(&self.syntax, T![']']) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct Label { - pub(crate) syntax: SyntaxNode, -} -impl Label { - pub fn lifetime_token(&self) -> Option { - support::token(&self.syntax, T![lifetime]) - } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ClosureExpr { - pub(crate) syntax: SyntaxNode, -} -impl ast::AttrsOwner for ClosureExpr {} -impl ClosureExpr { - pub fn static_token(&self) -> Option { support::token(&self.syntax, T![static]) } - pub fn async_token(&self) -> Option { support::token(&self.syntax, T![async]) } - pub fn move_token(&self) -> Option { support::token(&self.syntax, T![move]) } - pub fn param_list(&self) -> Option { support::child(&self.syntax) } - pub fn ret_type(&self) -> Option { support::child(&self.syntax) } - pub fn body(&self) -> Option { support::child(&self.syntax) } -} -#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct LoopExpr { pub(crate) syntax: SyntaxNode, } @@ -835,6 +826,15 @@ impl WhileExpr { pub fn condition(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct Label { + pub(crate) syntax: SyntaxNode, +} +impl Label { + pub fn lifetime_token(&self) -> Option { + support::token(&self.syntax, T![lifetime]) + } +} +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RecordExprFieldList { pub(crate) syntax: SyntaxNode, } @@ -1337,14 +1337,13 @@ pub enum Expr { BreakExpr(BreakExpr), CallExpr(CallExpr), CastExpr(CastExpr), + ClosureExpr(ClosureExpr), ContinueExpr(ContinueExpr), EffectExpr(EffectExpr), FieldExpr(FieldExpr), ForExpr(ForExpr), IfExpr(IfExpr), IndexExpr(IndexExpr), - Label(Label), - ClosureExpr(ClosureExpr), Literal(Literal), LoopExpr(LoopExpr), MacroCall(MacroCall), @@ -2017,6 +2016,17 @@ impl AstNode for CastExpr { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } +impl AstNode for ClosureExpr { + fn can_cast(kind: SyntaxKind) -> bool { kind == CLOSURE_EXPR } + 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 ContinueExpr { fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR } fn cast(syntax: SyntaxNode) -> Option { @@ -2083,28 +2093,6 @@ impl AstNode for IndexExpr { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for Label { - fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL } - 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 ClosureExpr { - fn can_cast(kind: SyntaxKind) -> bool { kind == CLOSURE_EXPR } - 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 LoopExpr { fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR } fn cast(syntax: SyntaxNode) -> Option { @@ -2248,6 +2236,17 @@ impl AstNode for WhileExpr { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } +impl AstNode for Label { + fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL } + 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 RecordExprFieldList { fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_EXPR_FIELD_LIST } fn cast(syntax: SyntaxNode) -> Option { @@ -3086,6 +3085,9 @@ impl From for Expr { impl From for Expr { fn from(node: CastExpr) -> Expr { Expr::CastExpr(node) } } +impl From for Expr { + fn from(node: ClosureExpr) -> Expr { Expr::ClosureExpr(node) } +} impl From for Expr { fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) } } @@ -3104,12 +3106,6 @@ impl From for Expr { impl From for Expr { fn from(node: IndexExpr) -> Expr { Expr::IndexExpr(node) } } -impl From