2018-08-09 14:43:39 +00:00
|
|
|
use {
|
2018-08-11 09:28:59 +00:00
|
|
|
ast,
|
2018-08-17 19:00:13 +00:00
|
|
|
SyntaxNodeRef, AstNode,
|
2018-08-09 14:43:39 +00:00
|
|
|
SyntaxKind::*,
|
|
|
|
};
|
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// ArrayExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct ArrayExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for ArrayExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
ARRAY_EXPR => Some(ArrayExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> ArrayExpr<'a> {}
|
|
|
|
|
2018-08-14 09:38:20 +00:00
|
|
|
// ArrayType
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct ArrayType<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for ArrayType<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 09:38:20 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
ARRAY_TYPE => Some(ArrayType { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ArrayType<'a> {}
|
2018-08-14 09:38:20 +00:00
|
|
|
|
2018-08-16 09:51:40 +00:00
|
|
|
// Attr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct Attr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-16 09:51:40 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for Attr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-16 09:51:40 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
ATTR => Some(Attr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-16 09:51:40 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> Attr<'a> {
|
|
|
|
pub fn value(self) -> Option<TokenTree<'a>> {
|
2018-08-22 14:01:51 +00:00
|
|
|
super::child_opt(self)
|
2018-08-16 09:51:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// BinExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct BinExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for BinExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
BIN_EXPR => Some(BinExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> BinExpr<'a> {}
|
|
|
|
|
2018-08-26 09:09:28 +00:00
|
|
|
// BindPat
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct BindPat<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for BindPat<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
BIND_PAT => Some(BindPat { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> ast::NameOwner<'a> for BindPat<'a> {}
|
|
|
|
impl<'a> BindPat<'a> {}
|
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// Block
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct Block<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for Block<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
BLOCK => Some(Block { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
2018-08-26 09:09:28 +00:00
|
|
|
impl<'a> Block<'a> {
|
2018-08-27 07:12:28 +00:00
|
|
|
pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a {
|
2018-08-26 09:09:28 +00:00
|
|
|
super::children(self)
|
|
|
|
}
|
2018-08-27 07:12:28 +00:00
|
|
|
|
|
|
|
pub fn expr(self) -> Option<Expr<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2018-08-25 10:42:40 +00:00
|
|
|
|
|
|
|
// BlockExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct BlockExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for BlockExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
BLOCK_EXPR => Some(BlockExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
2018-08-27 09:22:09 +00:00
|
|
|
impl<'a> BlockExpr<'a> {
|
|
|
|
pub fn block(self) -> Option<Block<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
|
|
|
}
|
2018-08-25 10:42:40 +00:00
|
|
|
|
|
|
|
// BreakExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct BreakExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for BreakExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
BREAK_EXPR => Some(BreakExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> BreakExpr<'a> {}
|
|
|
|
|
|
|
|
// CallExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct CallExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for CallExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
CALL_EXPR => Some(CallExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> CallExpr<'a> {}
|
|
|
|
|
|
|
|
// CastExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct CastExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for CastExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
CAST_EXPR => Some(CastExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> CastExpr<'a> {}
|
|
|
|
|
2018-08-27 09:22:09 +00:00
|
|
|
// Condition
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct Condition<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for Condition<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
CONDITION => Some(Condition { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Condition<'a> {
|
|
|
|
pub fn pat(self) -> Option<Pat<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn expr(self) -> Option<Expr<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-13 15:36:16 +00:00
|
|
|
// ConstDef
|
2018-08-11 08:03:22 +00:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct ConstDef<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-11 08:03:22 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for ConstDef<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-11 08:03:22 +00:00
|
|
|
match syntax.kind() {
|
2018-08-13 15:36:16 +00:00
|
|
|
CONST_DEF => Some(ConstDef { syntax }),
|
2018-08-11 08:03:22 +00:00
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-11 08:03:22 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ast::NameOwner<'a> for ConstDef<'a> {}
|
2018-08-22 13:46:42 +00:00
|
|
|
impl<'a> ast::TypeParamsOwner<'a> for ConstDef<'a> {}
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {}
|
|
|
|
impl<'a> ConstDef<'a> {}
|
2018-08-11 08:03:22 +00:00
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// ContinueExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct ContinueExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for ContinueExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
CONTINUE_EXPR => Some(ContinueExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> ContinueExpr<'a> {}
|
|
|
|
|
2018-08-14 09:38:20 +00:00
|
|
|
// DynTraitType
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct DynTraitType<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for DynTraitType<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 09:38:20 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
DYN_TRAIT_TYPE => Some(DynTraitType { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> DynTraitType<'a> {}
|
2018-08-14 09:38:20 +00:00
|
|
|
|
2018-08-13 15:36:16 +00:00
|
|
|
// EnumDef
|
2018-08-11 07:56:40 +00:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct EnumDef<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-11 07:56:40 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for EnumDef<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-11 07:56:40 +00:00
|
|
|
match syntax.kind() {
|
2018-08-13 15:36:16 +00:00
|
|
|
ENUM_DEF => Some(EnumDef { syntax }),
|
2018-08-11 07:56:40 +00:00
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-11 07:56:40 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ast::NameOwner<'a> for EnumDef<'a> {}
|
2018-08-22 13:46:42 +00:00
|
|
|
impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {}
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {}
|
|
|
|
impl<'a> EnumDef<'a> {}
|
2018-08-11 07:56:40 +00:00
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// Expr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub enum Expr<'a> {
|
|
|
|
TupleExpr(TupleExpr<'a>),
|
|
|
|
ArrayExpr(ArrayExpr<'a>),
|
|
|
|
ParenExpr(ParenExpr<'a>),
|
|
|
|
PathExpr(PathExpr<'a>),
|
|
|
|
LambdaExpr(LambdaExpr<'a>),
|
|
|
|
IfExpr(IfExpr<'a>),
|
|
|
|
LoopExpr(LoopExpr<'a>),
|
|
|
|
ForExpr(ForExpr<'a>),
|
|
|
|
WhileExpr(WhileExpr<'a>),
|
|
|
|
ContinueExpr(ContinueExpr<'a>),
|
|
|
|
BreakExpr(BreakExpr<'a>),
|
|
|
|
Label(Label<'a>),
|
|
|
|
BlockExpr(BlockExpr<'a>),
|
|
|
|
ReturnExpr(ReturnExpr<'a>),
|
|
|
|
MatchExpr(MatchExpr<'a>),
|
|
|
|
MatchArmList(MatchArmList<'a>),
|
|
|
|
MatchArm(MatchArm<'a>),
|
|
|
|
MatchGuard(MatchGuard<'a>),
|
|
|
|
StructLit(StructLit<'a>),
|
|
|
|
NamedFieldList(NamedFieldList<'a>),
|
|
|
|
NamedField(NamedField<'a>),
|
|
|
|
CallExpr(CallExpr<'a>),
|
|
|
|
IndexExpr(IndexExpr<'a>),
|
|
|
|
MethodCallExpr(MethodCallExpr<'a>),
|
|
|
|
FieldExpr(FieldExpr<'a>),
|
|
|
|
TryExpr(TryExpr<'a>),
|
|
|
|
CastExpr(CastExpr<'a>),
|
|
|
|
RefExpr(RefExpr<'a>),
|
|
|
|
PrefixExpr(PrefixExpr<'a>),
|
|
|
|
RangeExpr(RangeExpr<'a>),
|
|
|
|
BinExpr(BinExpr<'a>),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for Expr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
TUPLE_EXPR => Some(Expr::TupleExpr(TupleExpr { syntax })),
|
|
|
|
ARRAY_EXPR => Some(Expr::ArrayExpr(ArrayExpr { syntax })),
|
|
|
|
PAREN_EXPR => Some(Expr::ParenExpr(ParenExpr { syntax })),
|
|
|
|
PATH_EXPR => Some(Expr::PathExpr(PathExpr { syntax })),
|
|
|
|
LAMBDA_EXPR => Some(Expr::LambdaExpr(LambdaExpr { syntax })),
|
|
|
|
IF_EXPR => Some(Expr::IfExpr(IfExpr { syntax })),
|
|
|
|
LOOP_EXPR => Some(Expr::LoopExpr(LoopExpr { syntax })),
|
|
|
|
FOR_EXPR => Some(Expr::ForExpr(ForExpr { syntax })),
|
|
|
|
WHILE_EXPR => Some(Expr::WhileExpr(WhileExpr { syntax })),
|
|
|
|
CONTINUE_EXPR => Some(Expr::ContinueExpr(ContinueExpr { syntax })),
|
|
|
|
BREAK_EXPR => Some(Expr::BreakExpr(BreakExpr { syntax })),
|
|
|
|
LABEL => Some(Expr::Label(Label { syntax })),
|
|
|
|
BLOCK_EXPR => Some(Expr::BlockExpr(BlockExpr { syntax })),
|
|
|
|
RETURN_EXPR => Some(Expr::ReturnExpr(ReturnExpr { syntax })),
|
|
|
|
MATCH_EXPR => Some(Expr::MatchExpr(MatchExpr { syntax })),
|
|
|
|
MATCH_ARM_LIST => Some(Expr::MatchArmList(MatchArmList { syntax })),
|
|
|
|
MATCH_ARM => Some(Expr::MatchArm(MatchArm { syntax })),
|
|
|
|
MATCH_GUARD => Some(Expr::MatchGuard(MatchGuard { syntax })),
|
|
|
|
STRUCT_LIT => Some(Expr::StructLit(StructLit { syntax })),
|
|
|
|
NAMED_FIELD_LIST => Some(Expr::NamedFieldList(NamedFieldList { syntax })),
|
|
|
|
NAMED_FIELD => Some(Expr::NamedField(NamedField { syntax })),
|
|
|
|
CALL_EXPR => Some(Expr::CallExpr(CallExpr { syntax })),
|
|
|
|
INDEX_EXPR => Some(Expr::IndexExpr(IndexExpr { syntax })),
|
|
|
|
METHOD_CALL_EXPR => Some(Expr::MethodCallExpr(MethodCallExpr { syntax })),
|
|
|
|
FIELD_EXPR => Some(Expr::FieldExpr(FieldExpr { syntax })),
|
|
|
|
TRY_EXPR => Some(Expr::TryExpr(TryExpr { syntax })),
|
|
|
|
CAST_EXPR => Some(Expr::CastExpr(CastExpr { syntax })),
|
|
|
|
REF_EXPR => Some(Expr::RefExpr(RefExpr { syntax })),
|
|
|
|
PREFIX_EXPR => Some(Expr::PrefixExpr(PrefixExpr { syntax })),
|
|
|
|
RANGE_EXPR => Some(Expr::RangeExpr(RangeExpr { syntax })),
|
|
|
|
BIN_EXPR => Some(Expr::BinExpr(BinExpr { syntax })),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> {
|
|
|
|
match self {
|
|
|
|
Expr::TupleExpr(inner) => inner.syntax(),
|
|
|
|
Expr::ArrayExpr(inner) => inner.syntax(),
|
|
|
|
Expr::ParenExpr(inner) => inner.syntax(),
|
|
|
|
Expr::PathExpr(inner) => inner.syntax(),
|
|
|
|
Expr::LambdaExpr(inner) => inner.syntax(),
|
|
|
|
Expr::IfExpr(inner) => inner.syntax(),
|
|
|
|
Expr::LoopExpr(inner) => inner.syntax(),
|
|
|
|
Expr::ForExpr(inner) => inner.syntax(),
|
|
|
|
Expr::WhileExpr(inner) => inner.syntax(),
|
|
|
|
Expr::ContinueExpr(inner) => inner.syntax(),
|
|
|
|
Expr::BreakExpr(inner) => inner.syntax(),
|
|
|
|
Expr::Label(inner) => inner.syntax(),
|
|
|
|
Expr::BlockExpr(inner) => inner.syntax(),
|
|
|
|
Expr::ReturnExpr(inner) => inner.syntax(),
|
|
|
|
Expr::MatchExpr(inner) => inner.syntax(),
|
|
|
|
Expr::MatchArmList(inner) => inner.syntax(),
|
|
|
|
Expr::MatchArm(inner) => inner.syntax(),
|
|
|
|
Expr::MatchGuard(inner) => inner.syntax(),
|
|
|
|
Expr::StructLit(inner) => inner.syntax(),
|
|
|
|
Expr::NamedFieldList(inner) => inner.syntax(),
|
|
|
|
Expr::NamedField(inner) => inner.syntax(),
|
|
|
|
Expr::CallExpr(inner) => inner.syntax(),
|
|
|
|
Expr::IndexExpr(inner) => inner.syntax(),
|
|
|
|
Expr::MethodCallExpr(inner) => inner.syntax(),
|
|
|
|
Expr::FieldExpr(inner) => inner.syntax(),
|
|
|
|
Expr::TryExpr(inner) => inner.syntax(),
|
|
|
|
Expr::CastExpr(inner) => inner.syntax(),
|
|
|
|
Expr::RefExpr(inner) => inner.syntax(),
|
|
|
|
Expr::PrefixExpr(inner) => inner.syntax(),
|
|
|
|
Expr::RangeExpr(inner) => inner.syntax(),
|
|
|
|
Expr::BinExpr(inner) => inner.syntax(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Expr<'a> {}
|
|
|
|
|
2018-08-27 07:01:31 +00:00
|
|
|
// ExprStmt
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct ExprStmt<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for ExprStmt<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
EXPR_STMT => Some(ExprStmt { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
2018-08-27 09:22:09 +00:00
|
|
|
impl<'a> ExprStmt<'a> {
|
|
|
|
pub fn expr(self) -> Option<Expr<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
|
|
|
}
|
2018-08-27 07:01:31 +00:00
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// FieldExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct FieldExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for FieldExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
FIELD_EXPR => Some(FieldExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> FieldExpr<'a> {}
|
|
|
|
|
2018-08-26 09:09:28 +00:00
|
|
|
// FieldPatList
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct FieldPatList<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for FieldPatList<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
FIELD_PAT_LIST => Some(FieldPatList { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> FieldPatList<'a> {}
|
|
|
|
|
2018-08-13 15:36:16 +00:00
|
|
|
// FnDef
|
2018-08-10 12:07:43 +00:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct FnDef<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-09 14:43:39 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for FnDef<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-09 14:43:39 +00:00
|
|
|
match syntax.kind() {
|
2018-08-13 15:36:16 +00:00
|
|
|
FN_DEF => Some(FnDef { syntax }),
|
2018-08-09 14:43:39 +00:00
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-09 14:43:39 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ast::NameOwner<'a> for FnDef<'a> {}
|
2018-08-22 13:46:42 +00:00
|
|
|
impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {}
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {}
|
2018-08-26 09:09:28 +00:00
|
|
|
impl<'a> FnDef<'a> {
|
|
|
|
pub fn param_list(self) -> Option<ParamList<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
2018-08-27 07:01:31 +00:00
|
|
|
|
|
|
|
pub fn body(self) -> Option<Block<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2018-08-11 06:55:32 +00:00
|
|
|
|
2018-08-14 09:38:20 +00:00
|
|
|
// FnPointerType
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct FnPointerType<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for FnPointerType<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 09:38:20 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
FN_POINTER_TYPE => Some(FnPointerType { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> FnPointerType<'a> {}
|
2018-08-14 09:38:20 +00:00
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// ForExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct ForExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for ForExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
FOR_EXPR => Some(ForExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
2018-08-27 09:22:09 +00:00
|
|
|
impl<'a> ForExpr<'a> {
|
2018-08-27 19:03:19 +00:00
|
|
|
pub fn pat(self) -> Option<Pat<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn iterable(self) -> Option<Expr<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
|
|
|
|
2018-08-27 09:22:09 +00:00
|
|
|
pub fn body(self) -> Option<Block<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
|
|
|
}
|
2018-08-25 10:42:40 +00:00
|
|
|
|
2018-08-14 09:38:20 +00:00
|
|
|
// ForType
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct ForType<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for ForType<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 09:38:20 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
FOR_TYPE => Some(ForType { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ForType<'a> {}
|
2018-08-14 09:38:20 +00:00
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// IfExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct IfExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for IfExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
IF_EXPR => Some(IfExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
2018-08-27 09:22:09 +00:00
|
|
|
impl<'a> IfExpr<'a> {
|
|
|
|
pub fn condition(self) -> Option<Condition<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
|
|
|
}
|
2018-08-25 10:42:40 +00:00
|
|
|
|
2018-08-14 08:20:09 +00:00
|
|
|
// ImplItem
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct ImplItem<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-14 08:20:09 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for ImplItem<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 08:20:09 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
IMPL_ITEM => Some(ImplItem { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-14 08:20:09 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ImplItem<'a> {}
|
2018-08-14 08:20:09 +00:00
|
|
|
|
2018-08-14 09:38:20 +00:00
|
|
|
// ImplTraitType
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct ImplTraitType<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for ImplTraitType<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 09:38:20 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
IMPL_TRAIT_TYPE => Some(ImplTraitType { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ImplTraitType<'a> {}
|
2018-08-14 09:38:20 +00:00
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// IndexExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct IndexExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for IndexExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
INDEX_EXPR => Some(IndexExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> IndexExpr<'a> {}
|
|
|
|
|
|
|
|
// Label
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct Label<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for Label<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
LABEL => Some(Label { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Label<'a> {}
|
|
|
|
|
|
|
|
// LambdaExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct LambdaExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for LambdaExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
LAMBDA_EXPR => Some(LambdaExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> LambdaExpr<'a> {}
|
|
|
|
|
2018-08-26 09:09:28 +00:00
|
|
|
// LetStmt
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct LetStmt<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for LetStmt<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
LET_STMT => Some(LetStmt { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> LetStmt<'a> {
|
|
|
|
pub fn pat(self) -> Option<Pat<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
2018-08-27 07:01:31 +00:00
|
|
|
|
|
|
|
pub fn initializer(self) -> Option<Expr<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// LoopExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct LoopExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for LoopExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
LOOP_EXPR => Some(LoopExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
2018-08-27 09:22:09 +00:00
|
|
|
impl<'a> LoopExpr<'a> {
|
|
|
|
pub fn body(self) -> Option<Block<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
|
|
|
}
|
2018-08-25 10:42:40 +00:00
|
|
|
|
|
|
|
// MatchArm
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct MatchArm<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for MatchArm<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
MATCH_ARM => Some(MatchArm { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> MatchArm<'a> {}
|
|
|
|
|
|
|
|
// MatchArmList
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct MatchArmList<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for MatchArmList<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
MATCH_ARM_LIST => Some(MatchArmList { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> MatchArmList<'a> {}
|
|
|
|
|
|
|
|
// MatchExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct MatchExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for MatchExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
MATCH_EXPR => Some(MatchExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> MatchExpr<'a> {}
|
|
|
|
|
|
|
|
// MatchGuard
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct MatchGuard<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for MatchGuard<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
MATCH_GUARD => Some(MatchGuard { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> MatchGuard<'a> {}
|
|
|
|
|
|
|
|
// MethodCallExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct MethodCallExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for MethodCallExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
METHOD_CALL_EXPR => Some(MethodCallExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> MethodCallExpr<'a> {}
|
|
|
|
|
2018-08-11 09:28:59 +00:00
|
|
|
// Module
|
2018-08-11 08:03:22 +00:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct Module<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-11 08:03:22 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for Module<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-11 08:03:22 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
MODULE => Some(Module { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-11 08:03:22 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ast::NameOwner<'a> for Module<'a> {}
|
|
|
|
impl<'a> ast::AttrsOwner<'a> for Module<'a> {}
|
2018-08-21 15:30:10 +00:00
|
|
|
impl<'a> Module<'a> {
|
|
|
|
pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a {
|
2018-08-22 14:01:51 +00:00
|
|
|
super::children(self)
|
2018-08-21 15:30:10 +00:00
|
|
|
}
|
|
|
|
}
|
2018-08-11 08:03:22 +00:00
|
|
|
|
2018-08-11 09:28:59 +00:00
|
|
|
// Name
|
2018-08-10 12:07:43 +00:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct Name<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-09 14:43:39 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for Name<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-09 14:43:39 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
NAME => Some(Name { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-09 14:43:39 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> Name<'a> {}
|
2018-08-11 06:55:32 +00:00
|
|
|
|
2018-08-13 13:35:17 +00:00
|
|
|
// NameRef
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct NameRef<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-13 13:35:17 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for NameRef<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-13 13:35:17 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
NAME_REF => Some(NameRef { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-13 13:35:17 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> NameRef<'a> {}
|
2018-08-13 13:35:17 +00:00
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// NamedField
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct NamedField<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for NamedField<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
NAMED_FIELD => Some(NamedField { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> NamedField<'a> {}
|
|
|
|
|
2018-08-24 16:27:30 +00:00
|
|
|
// NamedFieldDef
|
2018-08-14 11:45:56 +00:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-24 16:27:30 +00:00
|
|
|
pub struct NamedFieldDef<'a> {
|
2018-08-17 19:00:13 +00:00
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-14 11:45:56 +00:00
|
|
|
}
|
|
|
|
|
2018-08-24 16:27:30 +00:00
|
|
|
impl<'a> AstNode<'a> for NamedFieldDef<'a> {
|
2018-08-17 19:00:13 +00:00
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 11:45:56 +00:00
|
|
|
match syntax.kind() {
|
2018-08-24 16:27:30 +00:00
|
|
|
NAMED_FIELD_DEF => Some(NamedFieldDef { syntax }),
|
2018-08-14 11:45:56 +00:00
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-14 11:45:56 +00:00
|
|
|
}
|
|
|
|
|
2018-08-24 16:27:30 +00:00
|
|
|
impl<'a> ast::NameOwner<'a> for NamedFieldDef<'a> {}
|
|
|
|
impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {}
|
|
|
|
impl<'a> NamedFieldDef<'a> {}
|
2018-08-14 11:45:56 +00:00
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// NamedFieldList
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct NamedFieldList<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for NamedFieldList<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
NAMED_FIELD_LIST => Some(NamedFieldList { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> NamedFieldList<'a> {}
|
|
|
|
|
2018-08-14 09:38:20 +00:00
|
|
|
// NeverType
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct NeverType<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for NeverType<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 09:38:20 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
NEVER_TYPE => Some(NeverType { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> NeverType<'a> {}
|
2018-08-14 09:38:20 +00:00
|
|
|
|
2018-08-14 10:33:44 +00:00
|
|
|
// NominalDef
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub enum NominalDef<'a> {
|
|
|
|
StructDef(StructDef<'a>),
|
|
|
|
EnumDef(EnumDef<'a>),
|
2018-08-14 10:33:44 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for NominalDef<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 10:33:44 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
STRUCT_DEF => Some(NominalDef::StructDef(StructDef { syntax })),
|
|
|
|
ENUM_DEF => Some(NominalDef::EnumDef(EnumDef { syntax })),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> {
|
2018-08-14 10:33:44 +00:00
|
|
|
match self {
|
|
|
|
NominalDef::StructDef(inner) => inner.syntax(),
|
|
|
|
NominalDef::EnumDef(inner) => inner.syntax(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-22 15:05:43 +00:00
|
|
|
impl<'a> ast::NameOwner<'a> for NominalDef<'a> {}
|
2018-08-22 13:46:42 +00:00
|
|
|
impl<'a> ast::TypeParamsOwner<'a> for NominalDef<'a> {}
|
2018-08-22 15:05:43 +00:00
|
|
|
impl<'a> ast::AttrsOwner<'a> for NominalDef<'a> {}
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> NominalDef<'a> {}
|
2018-08-14 10:33:44 +00:00
|
|
|
|
2018-08-26 09:09:28 +00:00
|
|
|
// Param
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct Param<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for Param<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
PARAM => Some(Param { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Param<'a> {
|
|
|
|
pub fn pat(self) -> Option<Pat<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ParamList
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct ParamList<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for ParamList<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
PARAM_LIST => Some(ParamList { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> ParamList<'a> {
|
|
|
|
pub fn params(self) -> impl Iterator<Item = Param<'a>> + 'a {
|
|
|
|
super::children(self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// ParenExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct ParenExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for ParenExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
PAREN_EXPR => Some(ParenExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> ParenExpr<'a> {}
|
|
|
|
|
2018-08-14 09:38:20 +00:00
|
|
|
// ParenType
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct ParenType<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for ParenType<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 09:38:20 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
PAREN_TYPE => Some(ParenType { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ParenType<'a> {}
|
2018-08-14 09:38:20 +00:00
|
|
|
|
2018-08-26 09:09:28 +00:00
|
|
|
// Pat
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub enum Pat<'a> {
|
|
|
|
RefPat(RefPat<'a>),
|
|
|
|
BindPat(BindPat<'a>),
|
|
|
|
PlaceholderPat(PlaceholderPat<'a>),
|
|
|
|
PathPat(PathPat<'a>),
|
|
|
|
StructPat(StructPat<'a>),
|
|
|
|
FieldPatList(FieldPatList<'a>),
|
|
|
|
TupleStructPat(TupleStructPat<'a>),
|
|
|
|
TuplePat(TuplePat<'a>),
|
|
|
|
SlicePat(SlicePat<'a>),
|
|
|
|
RangePat(RangePat<'a>),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for Pat<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
REF_PAT => Some(Pat::RefPat(RefPat { syntax })),
|
|
|
|
BIND_PAT => Some(Pat::BindPat(BindPat { syntax })),
|
|
|
|
PLACEHOLDER_PAT => Some(Pat::PlaceholderPat(PlaceholderPat { syntax })),
|
|
|
|
PATH_PAT => Some(Pat::PathPat(PathPat { syntax })),
|
|
|
|
STRUCT_PAT => Some(Pat::StructPat(StructPat { syntax })),
|
|
|
|
FIELD_PAT_LIST => Some(Pat::FieldPatList(FieldPatList { syntax })),
|
|
|
|
TUPLE_STRUCT_PAT => Some(Pat::TupleStructPat(TupleStructPat { syntax })),
|
|
|
|
TUPLE_PAT => Some(Pat::TuplePat(TuplePat { syntax })),
|
|
|
|
SLICE_PAT => Some(Pat::SlicePat(SlicePat { syntax })),
|
|
|
|
RANGE_PAT => Some(Pat::RangePat(RangePat { syntax })),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> {
|
|
|
|
match self {
|
|
|
|
Pat::RefPat(inner) => inner.syntax(),
|
|
|
|
Pat::BindPat(inner) => inner.syntax(),
|
|
|
|
Pat::PlaceholderPat(inner) => inner.syntax(),
|
|
|
|
Pat::PathPat(inner) => inner.syntax(),
|
|
|
|
Pat::StructPat(inner) => inner.syntax(),
|
|
|
|
Pat::FieldPatList(inner) => inner.syntax(),
|
|
|
|
Pat::TupleStructPat(inner) => inner.syntax(),
|
|
|
|
Pat::TuplePat(inner) => inner.syntax(),
|
|
|
|
Pat::SlicePat(inner) => inner.syntax(),
|
|
|
|
Pat::RangePat(inner) => inner.syntax(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Pat<'a> {}
|
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// PathExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct PathExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for PathExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
PATH_EXPR => Some(PathExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> PathExpr<'a> {}
|
|
|
|
|
2018-08-26 09:09:28 +00:00
|
|
|
// PathPat
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct PathPat<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for PathPat<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
PATH_PAT => Some(PathPat { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> PathPat<'a> {}
|
|
|
|
|
2018-08-14 09:38:20 +00:00
|
|
|
// PathType
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct PathType<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for PathType<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 09:38:20 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
PATH_TYPE => Some(PathType { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> PathType<'a> {}
|
2018-08-14 09:38:20 +00:00
|
|
|
|
2018-08-26 09:09:28 +00:00
|
|
|
// PlaceholderPat
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct PlaceholderPat<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for PlaceholderPat<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
PLACEHOLDER_PAT => Some(PlaceholderPat { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> PlaceholderPat<'a> {}
|
|
|
|
|
2018-08-14 09:38:20 +00:00
|
|
|
// PlaceholderType
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct PlaceholderType<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for PlaceholderType<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 09:38:20 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
PLACEHOLDER_TYPE => Some(PlaceholderType { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> PlaceholderType<'a> {}
|
2018-08-14 09:38:20 +00:00
|
|
|
|
|
|
|
// PointerType
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct PointerType<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for PointerType<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 09:38:20 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
POINTER_TYPE => Some(PointerType { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> PointerType<'a> {}
|
2018-08-14 09:38:20 +00:00
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// PrefixExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct PrefixExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for PrefixExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
PREFIX_EXPR => Some(PrefixExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> PrefixExpr<'a> {}
|
|
|
|
|
|
|
|
// RangeExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct RangeExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for RangeExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
RANGE_EXPR => Some(RangeExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> RangeExpr<'a> {}
|
|
|
|
|
2018-08-26 09:09:28 +00:00
|
|
|
// RangePat
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct RangePat<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for RangePat<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
RANGE_PAT => Some(RangePat { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> RangePat<'a> {}
|
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// RefExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct RefExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for RefExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
REF_EXPR => Some(RefExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> RefExpr<'a> {}
|
|
|
|
|
2018-08-26 09:09:28 +00:00
|
|
|
// RefPat
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct RefPat<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for RefPat<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
REF_PAT => Some(RefPat { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> RefPat<'a> {}
|
|
|
|
|
2018-08-14 09:38:20 +00:00
|
|
|
// ReferenceType
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct ReferenceType<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for ReferenceType<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 09:38:20 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
REFERENCE_TYPE => Some(ReferenceType { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ReferenceType<'a> {}
|
2018-08-14 09:38:20 +00:00
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// ReturnExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct ReturnExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for ReturnExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
RETURN_EXPR => Some(ReturnExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> ReturnExpr<'a> {}
|
|
|
|
|
2018-08-25 08:44:17 +00:00
|
|
|
// Root
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct Root<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for Root<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
ROOT => Some(Root { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Root<'a> {
|
|
|
|
pub fn functions(self) -> impl Iterator<Item = FnDef<'a>> + 'a {
|
|
|
|
super::children(self)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a {
|
|
|
|
super::children(self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-26 09:09:28 +00:00
|
|
|
// SlicePat
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct SlicePat<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for SlicePat<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
SLICE_PAT => Some(SlicePat { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> SlicePat<'a> {}
|
|
|
|
|
2018-08-14 09:38:20 +00:00
|
|
|
// SliceType
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct SliceType<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for SliceType<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 09:38:20 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
SLICE_TYPE => Some(SliceType { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> SliceType<'a> {}
|
2018-08-14 09:38:20 +00:00
|
|
|
|
2018-08-13 15:36:16 +00:00
|
|
|
// StaticDef
|
2018-08-11 08:03:22 +00:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct StaticDef<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-11 08:03:22 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for StaticDef<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-11 08:03:22 +00:00
|
|
|
match syntax.kind() {
|
2018-08-13 15:36:16 +00:00
|
|
|
STATIC_DEF => Some(StaticDef { syntax }),
|
2018-08-11 08:03:22 +00:00
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-11 08:03:22 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ast::NameOwner<'a> for StaticDef<'a> {}
|
2018-08-22 13:46:42 +00:00
|
|
|
impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {}
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {}
|
|
|
|
impl<'a> StaticDef<'a> {}
|
2018-08-11 08:03:22 +00:00
|
|
|
|
2018-08-27 07:12:28 +00:00
|
|
|
// Stmt
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub enum Stmt<'a> {
|
|
|
|
ExprStmt(ExprStmt<'a>),
|
|
|
|
LetStmt(LetStmt<'a>),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for Stmt<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
EXPR_STMT => Some(Stmt::ExprStmt(ExprStmt { syntax })),
|
|
|
|
LET_STMT => Some(Stmt::LetStmt(LetStmt { syntax })),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> {
|
|
|
|
match self {
|
|
|
|
Stmt::ExprStmt(inner) => inner.syntax(),
|
|
|
|
Stmt::LetStmt(inner) => inner.syntax(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Stmt<'a> {}
|
|
|
|
|
2018-08-13 15:36:16 +00:00
|
|
|
// StructDef
|
2018-08-11 07:56:40 +00:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct StructDef<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-11 07:56:40 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for StructDef<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-11 07:56:40 +00:00
|
|
|
match syntax.kind() {
|
2018-08-13 15:36:16 +00:00
|
|
|
STRUCT_DEF => Some(StructDef { syntax }),
|
2018-08-11 07:56:40 +00:00
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-11 07:56:40 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ast::NameOwner<'a> for StructDef<'a> {}
|
2018-08-22 13:46:42 +00:00
|
|
|
impl<'a> ast::TypeParamsOwner<'a> for StructDef<'a> {}
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ast::AttrsOwner<'a> for StructDef<'a> {}
|
|
|
|
impl<'a> StructDef<'a> {
|
2018-08-24 16:27:30 +00:00
|
|
|
pub fn fields(self) -> impl Iterator<Item = NamedFieldDef<'a>> + 'a {
|
2018-08-22 14:01:51 +00:00
|
|
|
super::children(self)
|
2018-08-14 11:45:56 +00:00
|
|
|
}
|
|
|
|
}
|
2018-08-11 07:56:40 +00:00
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// StructLit
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct StructLit<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for StructLit<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
STRUCT_LIT => Some(StructLit { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> StructLit<'a> {}
|
|
|
|
|
2018-08-26 09:09:28 +00:00
|
|
|
// StructPat
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct StructPat<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for StructPat<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
STRUCT_PAT => Some(StructPat { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> StructPat<'a> {}
|
|
|
|
|
2018-08-16 09:51:40 +00:00
|
|
|
// TokenTree
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct TokenTree<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-16 09:51:40 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for TokenTree<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-16 09:51:40 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
TOKEN_TREE => Some(TokenTree { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-16 09:51:40 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> TokenTree<'a> {}
|
2018-08-16 09:51:40 +00:00
|
|
|
|
2018-08-13 15:36:16 +00:00
|
|
|
// TraitDef
|
2018-08-11 08:03:22 +00:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct TraitDef<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-11 08:03:22 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for TraitDef<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-11 08:03:22 +00:00
|
|
|
match syntax.kind() {
|
2018-08-13 15:36:16 +00:00
|
|
|
TRAIT_DEF => Some(TraitDef { syntax }),
|
2018-08-11 08:03:22 +00:00
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-11 08:03:22 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ast::NameOwner<'a> for TraitDef<'a> {}
|
|
|
|
impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {}
|
|
|
|
impl<'a> TraitDef<'a> {}
|
2018-08-11 08:03:22 +00:00
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// TryExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct TryExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for TryExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
TRY_EXPR => Some(TryExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> TryExpr<'a> {}
|
|
|
|
|
|
|
|
// TupleExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct TupleExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for TupleExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
TUPLE_EXPR => Some(TupleExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> TupleExpr<'a> {}
|
|
|
|
|
2018-08-26 09:09:28 +00:00
|
|
|
// TuplePat
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct TuplePat<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for TuplePat<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
TUPLE_PAT => Some(TuplePat { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> TuplePat<'a> {}
|
|
|
|
|
|
|
|
// TupleStructPat
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct TupleStructPat<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for TupleStructPat<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
TUPLE_STRUCT_PAT => Some(TupleStructPat { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> TupleStructPat<'a> {}
|
|
|
|
|
2018-08-14 09:38:20 +00:00
|
|
|
// TupleType
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct TupleType<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for TupleType<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 09:38:20 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
TUPLE_TYPE => Some(TupleType { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> TupleType<'a> {}
|
2018-08-14 09:38:20 +00:00
|
|
|
|
2018-08-13 15:36:16 +00:00
|
|
|
// TypeDef
|
2018-08-11 13:20:37 +00:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub struct TypeDef<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
2018-08-11 13:20:37 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> AstNode<'a> for TypeDef<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-11 13:20:37 +00:00
|
|
|
match syntax.kind() {
|
2018-08-13 15:36:16 +00:00
|
|
|
TYPE_DEF => Some(TypeDef { syntax }),
|
2018-08-11 13:20:37 +00:00
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
2018-08-11 13:20:37 +00:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ast::NameOwner<'a> for TypeDef<'a> {}
|
2018-08-22 13:46:42 +00:00
|
|
|
impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {}
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {}
|
|
|
|
impl<'a> TypeDef<'a> {}
|
2018-08-11 13:20:37 +00:00
|
|
|
|
2018-08-22 16:02:37 +00:00
|
|
|
// TypeParam
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct TypeParam<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for TypeParam<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
TYPE_PARAM => Some(TypeParam { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> ast::NameOwner<'a> for TypeParam<'a> {}
|
|
|
|
impl<'a> TypeParam<'a> {}
|
|
|
|
|
2018-08-22 13:46:42 +00:00
|
|
|
// TypeParamList
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct TypeParamList<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for TypeParamList<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
TYPE_PARAM_LIST => Some(TypeParamList { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
2018-08-22 16:02:37 +00:00
|
|
|
impl<'a> TypeParamList<'a> {
|
|
|
|
pub fn type_params(self) -> impl Iterator<Item = TypeParam<'a>> + 'a {
|
|
|
|
super::children(self)
|
|
|
|
}
|
|
|
|
}
|
2018-08-22 13:46:42 +00:00
|
|
|
|
2018-08-14 09:38:20 +00:00
|
|
|
// TypeRef
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-17 19:00:13 +00:00
|
|
|
pub enum TypeRef<'a> {
|
|
|
|
ParenType(ParenType<'a>),
|
|
|
|
TupleType(TupleType<'a>),
|
|
|
|
NeverType(NeverType<'a>),
|
|
|
|
PathType(PathType<'a>),
|
|
|
|
PointerType(PointerType<'a>),
|
|
|
|
ArrayType(ArrayType<'a>),
|
|
|
|
SliceType(SliceType<'a>),
|
|
|
|
ReferenceType(ReferenceType<'a>),
|
|
|
|
PlaceholderType(PlaceholderType<'a>),
|
|
|
|
FnPointerType(FnPointerType<'a>),
|
|
|
|
ForType(ForType<'a>),
|
|
|
|
ImplTraitType(ImplTraitType<'a>),
|
|
|
|
DynTraitType(DynTraitType<'a>),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for TypeRef<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
2018-08-14 09:38:20 +00:00
|
|
|
match syntax.kind() {
|
|
|
|
PAREN_TYPE => Some(TypeRef::ParenType(ParenType { syntax })),
|
|
|
|
TUPLE_TYPE => Some(TypeRef::TupleType(TupleType { syntax })),
|
|
|
|
NEVER_TYPE => Some(TypeRef::NeverType(NeverType { syntax })),
|
|
|
|
PATH_TYPE => Some(TypeRef::PathType(PathType { syntax })),
|
|
|
|
POINTER_TYPE => Some(TypeRef::PointerType(PointerType { syntax })),
|
|
|
|
ARRAY_TYPE => Some(TypeRef::ArrayType(ArrayType { syntax })),
|
|
|
|
SLICE_TYPE => Some(TypeRef::SliceType(SliceType { syntax })),
|
|
|
|
REFERENCE_TYPE => Some(TypeRef::ReferenceType(ReferenceType { syntax })),
|
|
|
|
PLACEHOLDER_TYPE => Some(TypeRef::PlaceholderType(PlaceholderType { syntax })),
|
|
|
|
FN_POINTER_TYPE => Some(TypeRef::FnPointerType(FnPointerType { syntax })),
|
|
|
|
FOR_TYPE => Some(TypeRef::ForType(ForType { syntax })),
|
|
|
|
IMPL_TRAIT_TYPE => Some(TypeRef::ImplTraitType(ImplTraitType { syntax })),
|
|
|
|
DYN_TRAIT_TYPE => Some(TypeRef::DynTraitType(DynTraitType { syntax })),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
2018-08-17 19:00:13 +00:00
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> {
|
2018-08-14 09:38:20 +00:00
|
|
|
match self {
|
|
|
|
TypeRef::ParenType(inner) => inner.syntax(),
|
|
|
|
TypeRef::TupleType(inner) => inner.syntax(),
|
|
|
|
TypeRef::NeverType(inner) => inner.syntax(),
|
|
|
|
TypeRef::PathType(inner) => inner.syntax(),
|
|
|
|
TypeRef::PointerType(inner) => inner.syntax(),
|
|
|
|
TypeRef::ArrayType(inner) => inner.syntax(),
|
|
|
|
TypeRef::SliceType(inner) => inner.syntax(),
|
|
|
|
TypeRef::ReferenceType(inner) => inner.syntax(),
|
|
|
|
TypeRef::PlaceholderType(inner) => inner.syntax(),
|
|
|
|
TypeRef::FnPointerType(inner) => inner.syntax(),
|
|
|
|
TypeRef::ForType(inner) => inner.syntax(),
|
|
|
|
TypeRef::ImplTraitType(inner) => inner.syntax(),
|
|
|
|
TypeRef::DynTraitType(inner) => inner.syntax(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-17 19:00:13 +00:00
|
|
|
impl<'a> TypeRef<'a> {}
|
2018-08-14 09:38:20 +00:00
|
|
|
|
2018-08-22 13:46:42 +00:00
|
|
|
// WhereClause
|
2018-08-22 08:56:36 +00:00
|
|
|
#[derive(Debug, Clone, Copy)]
|
2018-08-22 13:46:42 +00:00
|
|
|
pub struct WhereClause<'a> {
|
2018-08-22 08:56:36 +00:00
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
2018-08-22 13:46:42 +00:00
|
|
|
impl<'a> AstNode<'a> for WhereClause<'a> {
|
2018-08-22 08:56:36 +00:00
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
2018-08-22 13:46:42 +00:00
|
|
|
WHERE_CLAUSE => Some(WhereClause { syntax }),
|
2018-08-22 08:56:36 +00:00
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
2018-08-22 13:46:42 +00:00
|
|
|
impl<'a> WhereClause<'a> {}
|
2018-08-22 08:56:36 +00:00
|
|
|
|
2018-08-25 10:42:40 +00:00
|
|
|
// WhileExpr
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
pub struct WhileExpr<'a> {
|
|
|
|
syntax: SyntaxNodeRef<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> AstNode<'a> for WhileExpr<'a> {
|
|
|
|
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
|
|
|
|
match syntax.kind() {
|
|
|
|
WHILE_EXPR => Some(WhileExpr { syntax }),
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
|
|
|
|
}
|
|
|
|
|
2018-08-27 09:22:09 +00:00
|
|
|
impl<'a> WhileExpr<'a> {
|
|
|
|
pub fn condition(self) -> Option<Condition<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn body(self) -> Option<Block<'a>> {
|
|
|
|
super::child_opt(self)
|
|
|
|
}
|
|
|
|
}
|
2018-08-25 10:42:40 +00:00
|
|
|
|