//! Generated file, do not edit by hand, see `crate/ra_tools/src/codegen` use crate::{ ast::{self, AstChildren, AstNode}, SyntaxKind::{self, *}, SyntaxNode, }; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Alias { pub(crate) syntax: SyntaxNode, } impl AstNode for Alias { fn can_cast(kind: SyntaxKind) -> bool { match kind { ALIAS => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ast::NameOwner for Alias {} impl Alias {} #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ArgList { pub(crate) syntax: SyntaxNode, } impl AstNode for ArgList { fn can_cast(kind: SyntaxKind) -> bool { match kind { ARG_LIST => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ArgList { pub fn args(&self) -> AstChildren { AstChildren::new(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ArrayExpr { pub(crate) syntax: SyntaxNode, } impl AstNode for ArrayExpr { fn can_cast(kind: SyntaxKind) -> bool { match kind { ARRAY_EXPR => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ArrayExpr { pub fn exprs(&self) -> AstChildren { AstChildren::new(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ArrayType { pub(crate) syntax: SyntaxNode, } impl AstNode for ArrayType { fn can_cast(kind: SyntaxKind) -> bool { match kind { ARRAY_TYPE => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ArrayType { pub fn type_ref(&self) -> Option { AstChildren::new(&self.syntax).next() } pub fn expr(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct AssocTypeArg { pub(crate) syntax: SyntaxNode, } impl AstNode for AssocTypeArg { fn can_cast(kind: SyntaxKind) -> bool { match kind { ASSOC_TYPE_ARG => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl AssocTypeArg { pub fn name_ref(&self) -> Option { AstChildren::new(&self.syntax).next() } pub fn type_ref(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Attr { pub(crate) syntax: SyntaxNode, } impl AstNode for Attr { fn can_cast(kind: SyntaxKind) -> bool { match kind { ATTR => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl Attr { pub fn path(&self) -> Option { AstChildren::new(&self.syntax).next() } pub fn input(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AttrInput { Literal(Literal), TokenTree(TokenTree), } impl From for AttrInput { fn from(node: Literal) -> AttrInput { AttrInput::Literal(node) } } impl From for AttrInput { fn from(node: TokenTree) -> AttrInput { AttrInput::TokenTree(node) } } impl AstNode for AttrInput { fn can_cast(kind: SyntaxKind) -> bool { match kind { LITERAL | TOKEN_TREE => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { let res = match syntax.kind() { LITERAL => AttrInput::Literal(Literal { syntax }), TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }), _ => return None, }; Some(res) } fn syntax(&self) -> &SyntaxNode { match self { AttrInput::Literal(it) => &it.syntax, AttrInput::TokenTree(it) => &it.syntax, } } } impl AttrInput {} #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct AwaitExpr { pub(crate) syntax: SyntaxNode, } impl AstNode for AwaitExpr { fn can_cast(kind: SyntaxKind) -> bool { match kind { AWAIT_EXPR => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl AwaitExpr { pub fn expr(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct BinExpr { pub(crate) syntax: SyntaxNode, } impl AstNode for BinExpr { fn can_cast(kind: SyntaxKind) -> bool { match kind { BIN_EXPR => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl BinExpr {} #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct BindPat { pub(crate) syntax: SyntaxNode, } impl AstNode for BindPat { fn can_cast(kind: SyntaxKind) -> bool { match kind { BIND_PAT => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ast::NameOwner for BindPat {} impl BindPat { pub fn pat(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Block { pub(crate) syntax: SyntaxNode, } impl AstNode for Block { fn can_cast(kind: SyntaxKind) -> bool { match kind { BLOCK => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ast::AttrsOwner for Block {} impl Block { pub fn statements(&self) -> AstChildren { AstChildren::new(&self.syntax) } pub fn expr(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct BlockExpr { pub(crate) syntax: SyntaxNode, } impl AstNode for BlockExpr { fn can_cast(kind: SyntaxKind) -> bool { match kind { BLOCK_EXPR => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl BlockExpr { pub fn block(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct BoxExpr { pub(crate) syntax: SyntaxNode, } impl AstNode for BoxExpr { fn can_cast(kind: SyntaxKind) -> bool { match kind { BOX_EXPR => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl BoxExpr { pub fn expr(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct BoxPat { pub(crate) syntax: SyntaxNode, } impl AstNode for BoxPat { fn can_cast(kind: SyntaxKind) -> bool { match kind { BOX_PAT => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl BoxPat { pub fn pat(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct BreakExpr { pub(crate) syntax: SyntaxNode, } impl AstNode for BreakExpr { fn can_cast(kind: SyntaxKind) -> bool { match kind { BREAK_EXPR => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl BreakExpr { pub fn expr(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CallExpr { pub(crate) syntax: SyntaxNode, } impl AstNode for CallExpr { fn can_cast(kind: SyntaxKind) -> bool { match kind { CALL_EXPR => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ast::ArgListOwner for CallExpr {} impl CallExpr { pub fn expr(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CastExpr { pub(crate) syntax: SyntaxNode, } impl AstNode for CastExpr { fn can_cast(kind: SyntaxKind) -> bool { match kind { CAST_EXPR => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl CastExpr { pub fn expr(&self) -> Option { AstChildren::new(&self.syntax).next() } pub fn type_ref(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Condition { pub(crate) syntax: SyntaxNode, } impl AstNode for Condition { fn can_cast(kind: SyntaxKind) -> bool { match kind { CONDITION => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl Condition { pub fn pat(&self) -> Option { AstChildren::new(&self.syntax).next() } pub fn expr(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ConstDef { pub(crate) syntax: SyntaxNode, } impl AstNode for ConstDef { fn can_cast(kind: SyntaxKind) -> bool { match kind { CONST_DEF => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ast::VisibilityOwner for ConstDef {} impl ast::NameOwner for ConstDef {} impl ast::TypeParamsOwner for ConstDef {} impl ast::AttrsOwner for ConstDef {} impl ast::DocCommentsOwner for ConstDef {} impl ast::TypeAscriptionOwner for ConstDef {} impl ConstDef { pub fn body(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ContinueExpr { pub(crate) syntax: SyntaxNode, } impl AstNode for ContinueExpr { fn can_cast(kind: SyntaxKind) -> bool { match kind { CONTINUE_EXPR => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ContinueExpr {} #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct DotDotPat { pub(crate) syntax: SyntaxNode, } impl AstNode for DotDotPat { fn can_cast(kind: SyntaxKind) -> bool { match kind { DOT_DOT_PAT => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl DotDotPat {} #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct DynTraitType { pub(crate) syntax: SyntaxNode, } impl AstNode for DynTraitType { fn can_cast(kind: SyntaxKind) -> bool { match kind { DYN_TRAIT_TYPE => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ast::TypeBoundsOwner for DynTraitType {} impl DynTraitType {} #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct EnumDef { pub(crate) syntax: SyntaxNode, } impl AstNode for EnumDef { fn can_cast(kind: SyntaxKind) -> bool { match kind { ENUM_DEF => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ast::VisibilityOwner for EnumDef {} impl ast::NameOwner for EnumDef {} impl ast::TypeParamsOwner for EnumDef {} impl ast::AttrsOwner for EnumDef {} impl ast::DocCommentsOwner for EnumDef {} impl EnumDef { pub fn variant_list(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct EnumVariant { pub(crate) syntax: SyntaxNode, } impl AstNode for EnumVariant { fn can_cast(kind: SyntaxKind) -> bool { match kind { ENUM_VARIANT => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ast::NameOwner for EnumVariant {} impl ast::DocCommentsOwner for EnumVariant {} impl ast::AttrsOwner for EnumVariant {} impl EnumVariant { pub fn expr(&self) -> Option { AstChildren::new(&self.syntax).next() } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct EnumVariantList { pub(crate) syntax: SyntaxNode, } impl AstNode for EnumVariantList { fn can_cast(kind: SyntaxKind) -> bool { match kind { ENUM_VARIANT_LIST => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl EnumVariantList { pub fn variants(&self) -> AstChildren { AstChildren::new(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Expr { TupleExpr(TupleExpr), ArrayExpr(ArrayExpr), ParenExpr(ParenExpr), PathExpr(PathExpr), LambdaExpr(LambdaExpr), IfExpr(IfExpr), LoopExpr(LoopExpr), ForExpr(ForExpr), WhileExpr(WhileExpr), ContinueExpr(ContinueExpr), BreakExpr(BreakExpr), Label(Label), BlockExpr(BlockExpr), ReturnExpr(ReturnExpr), MatchExpr(MatchExpr), RecordLit(RecordLit), CallExpr(CallExpr), IndexExpr(IndexExpr), MethodCallExpr(MethodCallExpr), FieldExpr(FieldExpr), AwaitExpr(AwaitExpr), TryExpr(TryExpr), TryBlockExpr(TryBlockExpr), CastExpr(CastExpr), RefExpr(RefExpr), PrefixExpr(PrefixExpr), RangeExpr(RangeExpr), BinExpr(BinExpr), Literal(Literal), MacroCall(MacroCall), BoxExpr(BoxExpr), } impl From for Expr { fn from(node: TupleExpr) -> Expr { Expr::TupleExpr(node) } } impl From for Expr { fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) } } impl From for Expr { fn from(node: ParenExpr) -> Expr { Expr::ParenExpr(node) } } impl From for Expr { fn from(node: PathExpr) -> Expr { Expr::PathExpr(node) } } impl From for Expr { fn from(node: LambdaExpr) -> Expr { Expr::LambdaExpr(node) } } impl From for Expr { fn from(node: IfExpr) -> Expr { Expr::IfExpr(node) } } impl From for Expr { fn from(node: LoopExpr) -> Expr { Expr::LoopExpr(node) } } impl From for Expr { fn from(node: ForExpr) -> Expr { Expr::ForExpr(node) } } impl From for Expr { fn from(node: WhileExpr) -> Expr { Expr::WhileExpr(node) } } impl From for Expr { fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) } } impl From for Expr { fn from(node: BreakExpr) -> Expr { Expr::BreakExpr(node) } } impl From