mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-10 12:18:49 +00:00
3435 lines
79 KiB
Rust
3435 lines
79 KiB
Rust
// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run
|
|
// Do not edit manually
|
|
|
|
//! This module contains auto-generated Rust AST. Like `SyntaxNode`s, AST nodes
|
|
//! are generic over ownership: `X<'a>` things are `Copy` references, `XNode`
|
|
//! are Arc-based. You can switch between the two variants using `.owned` and
|
|
//! `.borrowed` functions. Most of the code works with borowed mode, and only
|
|
//! this mode has all AST accessors.
|
|
|
|
#![cfg_attr(rustfmt, rustfmt_skip)]
|
|
|
|
use crate::{
|
|
SyntaxNode, SyntaxKind::*,
|
|
ast::{self, AstNode},
|
|
};
|
|
|
|
// Alias
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Alias {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for Alias {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
ALIAS => Some(Alias { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::NameOwner for Alias {}
|
|
impl Alias {}
|
|
|
|
// ArgList
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ArgList {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ArgList {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
ARG_LIST => Some(ArgList { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ArgList {
|
|
pub fn args(&self) -> impl Iterator<Item = Expr> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// ArrayExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ArrayExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ArrayExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
ARRAY_EXPR => Some(ArrayExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ArrayExpr {
|
|
pub fn exprs(&self) -> impl Iterator<Item = Expr> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// ArrayType
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ArrayType {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ArrayType {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
ARRAY_TYPE => Some(ArrayType { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ArrayType {
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// AssocTypeArg
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct AssocTypeArg {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for AssocTypeArg {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
ASSOC_TYPE_ARG => Some(AssocTypeArg { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl AssocTypeArg {
|
|
pub fn name_ref(&self) -> Option<NameRef> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// Attr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Attr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for Attr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
ATTR => Some(Attr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl Attr {
|
|
pub fn value(&self) -> Option<TokenTree> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// BinExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct BinExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for BinExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
BIN_EXPR => Some(BinExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl BinExpr {}
|
|
|
|
// BindPat
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct BindPat {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for BindPat {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
BIND_PAT => Some(BindPat { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::NameOwner for BindPat {}
|
|
impl BindPat {
|
|
pub fn pat(&self) -> Option<Pat> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// Block
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Block {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for Block {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
BLOCK => Some(Block { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::AttrsOwner for Block {}
|
|
impl Block {
|
|
pub fn statements(&self) -> impl Iterator<Item = Stmt> {
|
|
super::children(self)
|
|
}
|
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// BlockExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct BlockExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for BlockExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
BLOCK_EXPR => Some(BlockExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl BlockExpr {
|
|
pub fn block(&self) -> Option<Block> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// BreakExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct BreakExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for BreakExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
BREAK_EXPR => Some(BreakExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl BreakExpr {
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// CallExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct CallExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for CallExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
CALL_EXPR => Some(CallExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::ArgListOwner for CallExpr {}
|
|
impl CallExpr {
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// CastExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct CastExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for CastExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
CAST_EXPR => Some(CastExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl CastExpr {
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// Condition
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Condition {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for Condition {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
CONDITION => Some(Condition { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl Condition {
|
|
pub fn pat(&self) -> Option<Pat> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// ConstDef
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ConstDef {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ConstDef {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
CONST_DEF => Some(ConstDef { syntax }),
|
|
_ => 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<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// ContinueExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ContinueExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ContinueExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
CONTINUE_EXPR => Some(ContinueExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ContinueExpr {}
|
|
|
|
// DynTraitType
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct DynTraitType {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for DynTraitType {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
DYN_TRAIT_TYPE => Some(DynTraitType { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::TypeBoundsOwner for DynTraitType {}
|
|
impl DynTraitType {}
|
|
|
|
// EnumDef
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct EnumDef {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for EnumDef {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
ENUM_DEF => Some(EnumDef { syntax }),
|
|
_ => 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<EnumVariantList> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// EnumVariant
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct EnumVariant {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for EnumVariant {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
ENUM_VARIANT => Some(EnumVariant { syntax }),
|
|
_ => 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<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// EnumVariantList
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct EnumVariantList {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for EnumVariantList {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
ENUM_VARIANT_LIST => Some(EnumVariantList { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl EnumVariantList {
|
|
pub fn variants(&self) -> impl Iterator<Item = EnumVariant> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// Expr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Expr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub enum ExprKind {
|
|
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),
|
|
StructLit(StructLit),
|
|
CallExpr(CallExpr),
|
|
IndexExpr(IndexExpr),
|
|
MethodCallExpr(MethodCallExpr),
|
|
FieldExpr(FieldExpr),
|
|
TryExpr(TryExpr),
|
|
TryBlockExpr(TryBlockExpr),
|
|
CastExpr(CastExpr),
|
|
RefExpr(RefExpr),
|
|
PrefixExpr(PrefixExpr),
|
|
RangeExpr(RangeExpr),
|
|
BinExpr(BinExpr),
|
|
Literal(Literal),
|
|
MacroCall(MacroCall),
|
|
}
|
|
impl From<TupleExpr> for Expr {
|
|
fn from(n: TupleExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<ArrayExpr> for Expr {
|
|
fn from(n: ArrayExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<ParenExpr> for Expr {
|
|
fn from(n: ParenExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<PathExpr> for Expr {
|
|
fn from(n: PathExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<LambdaExpr> for Expr {
|
|
fn from(n: LambdaExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<IfExpr> for Expr {
|
|
fn from(n: IfExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<LoopExpr> for Expr {
|
|
fn from(n: LoopExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<ForExpr> for Expr {
|
|
fn from(n: ForExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<WhileExpr> for Expr {
|
|
fn from(n: WhileExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<ContinueExpr> for Expr {
|
|
fn from(n: ContinueExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<BreakExpr> for Expr {
|
|
fn from(n: BreakExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<Label> for Expr {
|
|
fn from(n: Label) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<BlockExpr> for Expr {
|
|
fn from(n: BlockExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<ReturnExpr> for Expr {
|
|
fn from(n: ReturnExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<MatchExpr> for Expr {
|
|
fn from(n: MatchExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<StructLit> for Expr {
|
|
fn from(n: StructLit) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<CallExpr> for Expr {
|
|
fn from(n: CallExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<IndexExpr> for Expr {
|
|
fn from(n: IndexExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<MethodCallExpr> for Expr {
|
|
fn from(n: MethodCallExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<FieldExpr> for Expr {
|
|
fn from(n: FieldExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<TryExpr> for Expr {
|
|
fn from(n: TryExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<TryBlockExpr> for Expr {
|
|
fn from(n: TryBlockExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<CastExpr> for Expr {
|
|
fn from(n: CastExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<RefExpr> for Expr {
|
|
fn from(n: RefExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<PrefixExpr> for Expr {
|
|
fn from(n: PrefixExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<RangeExpr> for Expr {
|
|
fn from(n: RangeExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<BinExpr> for Expr {
|
|
fn from(n: BinExpr) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<Literal> for Expr {
|
|
fn from(n: Literal) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<MacroCall> for Expr {
|
|
fn from(n: MacroCall) -> Expr {
|
|
Expr::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
|
|
|
|
impl AstNode for Expr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
| TUPLE_EXPR
|
|
| ARRAY_EXPR
|
|
| PAREN_EXPR
|
|
| PATH_EXPR
|
|
| LAMBDA_EXPR
|
|
| IF_EXPR
|
|
| LOOP_EXPR
|
|
| FOR_EXPR
|
|
| WHILE_EXPR
|
|
| CONTINUE_EXPR
|
|
| BREAK_EXPR
|
|
| LABEL
|
|
| BLOCK_EXPR
|
|
| RETURN_EXPR
|
|
| MATCH_EXPR
|
|
| STRUCT_LIT
|
|
| CALL_EXPR
|
|
| INDEX_EXPR
|
|
| METHOD_CALL_EXPR
|
|
| FIELD_EXPR
|
|
| TRY_EXPR
|
|
| TRY_BLOCK_EXPR
|
|
| CAST_EXPR
|
|
| REF_EXPR
|
|
| PREFIX_EXPR
|
|
| RANGE_EXPR
|
|
| BIN_EXPR
|
|
| LITERAL
|
|
| MACRO_CALL => Some(Expr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
impl Expr {
|
|
pub fn kind(&self) -> ExprKind {
|
|
match self.syntax.kind() {
|
|
TUPLE_EXPR => ExprKind::TupleExpr(TupleExpr::cast(self.syntax.clone()).unwrap()),
|
|
ARRAY_EXPR => ExprKind::ArrayExpr(ArrayExpr::cast(self.syntax.clone()).unwrap()),
|
|
PAREN_EXPR => ExprKind::ParenExpr(ParenExpr::cast(self.syntax.clone()).unwrap()),
|
|
PATH_EXPR => ExprKind::PathExpr(PathExpr::cast(self.syntax.clone()).unwrap()),
|
|
LAMBDA_EXPR => ExprKind::LambdaExpr(LambdaExpr::cast(self.syntax.clone()).unwrap()),
|
|
IF_EXPR => ExprKind::IfExpr(IfExpr::cast(self.syntax.clone()).unwrap()),
|
|
LOOP_EXPR => ExprKind::LoopExpr(LoopExpr::cast(self.syntax.clone()).unwrap()),
|
|
FOR_EXPR => ExprKind::ForExpr(ForExpr::cast(self.syntax.clone()).unwrap()),
|
|
WHILE_EXPR => ExprKind::WhileExpr(WhileExpr::cast(self.syntax.clone()).unwrap()),
|
|
CONTINUE_EXPR => ExprKind::ContinueExpr(ContinueExpr::cast(self.syntax.clone()).unwrap()),
|
|
BREAK_EXPR => ExprKind::BreakExpr(BreakExpr::cast(self.syntax.clone()).unwrap()),
|
|
LABEL => ExprKind::Label(Label::cast(self.syntax.clone()).unwrap()),
|
|
BLOCK_EXPR => ExprKind::BlockExpr(BlockExpr::cast(self.syntax.clone()).unwrap()),
|
|
RETURN_EXPR => ExprKind::ReturnExpr(ReturnExpr::cast(self.syntax.clone()).unwrap()),
|
|
MATCH_EXPR => ExprKind::MatchExpr(MatchExpr::cast(self.syntax.clone()).unwrap()),
|
|
STRUCT_LIT => ExprKind::StructLit(StructLit::cast(self.syntax.clone()).unwrap()),
|
|
CALL_EXPR => ExprKind::CallExpr(CallExpr::cast(self.syntax.clone()).unwrap()),
|
|
INDEX_EXPR => ExprKind::IndexExpr(IndexExpr::cast(self.syntax.clone()).unwrap()),
|
|
METHOD_CALL_EXPR => ExprKind::MethodCallExpr(MethodCallExpr::cast(self.syntax.clone()).unwrap()),
|
|
FIELD_EXPR => ExprKind::FieldExpr(FieldExpr::cast(self.syntax.clone()).unwrap()),
|
|
TRY_EXPR => ExprKind::TryExpr(TryExpr::cast(self.syntax.clone()).unwrap()),
|
|
TRY_BLOCK_EXPR => ExprKind::TryBlockExpr(TryBlockExpr::cast(self.syntax.clone()).unwrap()),
|
|
CAST_EXPR => ExprKind::CastExpr(CastExpr::cast(self.syntax.clone()).unwrap()),
|
|
REF_EXPR => ExprKind::RefExpr(RefExpr::cast(self.syntax.clone()).unwrap()),
|
|
PREFIX_EXPR => ExprKind::PrefixExpr(PrefixExpr::cast(self.syntax.clone()).unwrap()),
|
|
RANGE_EXPR => ExprKind::RangeExpr(RangeExpr::cast(self.syntax.clone()).unwrap()),
|
|
BIN_EXPR => ExprKind::BinExpr(BinExpr::cast(self.syntax.clone()).unwrap()),
|
|
LITERAL => ExprKind::Literal(Literal::cast(self.syntax.clone()).unwrap()),
|
|
MACRO_CALL => ExprKind::MacroCall(MacroCall::cast(self.syntax.clone()).unwrap()),
|
|
_ => unreachable!(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Expr {}
|
|
|
|
// ExprStmt
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ExprStmt {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ExprStmt {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
EXPR_STMT => Some(ExprStmt { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ExprStmt {
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// ExternCrateItem
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ExternCrateItem {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ExternCrateItem {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
EXTERN_CRATE_ITEM => Some(ExternCrateItem { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ExternCrateItem {
|
|
pub fn name_ref(&self) -> Option<NameRef> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn alias(&self) -> Option<Alias> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// FieldExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct FieldExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for FieldExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
FIELD_EXPR => Some(FieldExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl FieldExpr {
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn name_ref(&self) -> Option<NameRef> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// FieldPat
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct FieldPat {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for FieldPat {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
FIELD_PAT => Some(FieldPat { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::NameOwner for FieldPat {}
|
|
impl FieldPat {
|
|
pub fn pat(&self) -> Option<Pat> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// FieldPatList
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct FieldPatList {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for FieldPatList {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
FIELD_PAT_LIST => Some(FieldPatList { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl FieldPatList {
|
|
pub fn field_pats(&self) -> impl Iterator<Item = FieldPat> {
|
|
super::children(self)
|
|
}
|
|
|
|
pub fn bind_pats(&self) -> impl Iterator<Item = BindPat> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// FnDef
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct FnDef {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for FnDef {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
FN_DEF => Some(FnDef { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::VisibilityOwner for FnDef {}
|
|
impl ast::NameOwner for FnDef {}
|
|
impl ast::TypeParamsOwner for FnDef {}
|
|
impl ast::AttrsOwner for FnDef {}
|
|
impl ast::DocCommentsOwner for FnDef {}
|
|
impl FnDef {
|
|
pub fn param_list(&self) -> Option<ParamList> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn body(&self) -> Option<Block> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn ret_type(&self) -> Option<RetType> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// FnPointerType
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct FnPointerType {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for FnPointerType {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
FN_POINTER_TYPE => Some(FnPointerType { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl FnPointerType {
|
|
pub fn param_list(&self) -> Option<ParamList> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn ret_type(&self) -> Option<RetType> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// ForExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ForExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ForExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
FOR_EXPR => Some(ForExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::LoopBodyOwner for ForExpr {}
|
|
impl ForExpr {
|
|
pub fn pat(&self) -> Option<Pat> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn iterable(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// ForType
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ForType {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ForType {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
FOR_TYPE => Some(ForType { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ForType {
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// IfExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct IfExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for IfExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
IF_EXPR => Some(IfExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl IfExpr {
|
|
pub fn condition(&self) -> Option<Condition> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// ImplBlock
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ImplBlock {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ImplBlock {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
IMPL_BLOCK => Some(ImplBlock { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::TypeParamsOwner for ImplBlock {}
|
|
impl ast::AttrsOwner for ImplBlock {}
|
|
impl ImplBlock {
|
|
pub fn item_list(&self) -> Option<ItemList> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// ImplItem
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ImplItem {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub enum ImplItemKind {
|
|
FnDef(FnDef),
|
|
TypeAliasDef(TypeAliasDef),
|
|
ConstDef(ConstDef),
|
|
}
|
|
impl From<FnDef> for ImplItem {
|
|
fn from(n: FnDef) -> ImplItem {
|
|
ImplItem::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<TypeAliasDef> for ImplItem {
|
|
fn from(n: TypeAliasDef) -> ImplItem {
|
|
ImplItem::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<ConstDef> for ImplItem {
|
|
fn from(n: ConstDef) -> ImplItem {
|
|
ImplItem::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
|
|
|
|
impl AstNode for ImplItem {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
| FN_DEF
|
|
| TYPE_ALIAS_DEF
|
|
| CONST_DEF => Some(ImplItem { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
impl ImplItem {
|
|
pub fn kind(&self) -> ImplItemKind {
|
|
match self.syntax.kind() {
|
|
FN_DEF => ImplItemKind::FnDef(FnDef::cast(self.syntax.clone()).unwrap()),
|
|
TYPE_ALIAS_DEF => ImplItemKind::TypeAliasDef(TypeAliasDef::cast(self.syntax.clone()).unwrap()),
|
|
CONST_DEF => ImplItemKind::ConstDef(ConstDef::cast(self.syntax.clone()).unwrap()),
|
|
_ => unreachable!(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ImplItem {}
|
|
|
|
// ImplTraitType
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ImplTraitType {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ImplTraitType {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
IMPL_TRAIT_TYPE => Some(ImplTraitType { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::TypeBoundsOwner for ImplTraitType {}
|
|
impl ImplTraitType {}
|
|
|
|
// IndexExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct IndexExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for IndexExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
INDEX_EXPR => Some(IndexExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl IndexExpr {}
|
|
|
|
// ItemList
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ItemList {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ItemList {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
ITEM_LIST => Some(ItemList { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::FnDefOwner for ItemList {}
|
|
impl ast::ModuleItemOwner for ItemList {}
|
|
impl ItemList {
|
|
pub fn impl_items(&self) -> impl Iterator<Item = ImplItem> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// Label
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Label {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for Label {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
LABEL => Some(Label { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl Label {}
|
|
|
|
// LambdaExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct LambdaExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for LambdaExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
LAMBDA_EXPR => Some(LambdaExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl LambdaExpr {
|
|
pub fn param_list(&self) -> Option<ParamList> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn body(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// LetStmt
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct LetStmt {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for LetStmt {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
LET_STMT => Some(LetStmt { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::TypeAscriptionOwner for LetStmt {}
|
|
impl LetStmt {
|
|
pub fn pat(&self) -> Option<Pat> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn initializer(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// LifetimeArg
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct LifetimeArg {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for LifetimeArg {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
LIFETIME_ARG => Some(LifetimeArg { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl LifetimeArg {}
|
|
|
|
// LifetimeParam
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct LifetimeParam {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for LifetimeParam {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
LIFETIME_PARAM => Some(LifetimeParam { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::AttrsOwner for LifetimeParam {}
|
|
impl LifetimeParam {}
|
|
|
|
// Literal
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Literal {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for Literal {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
LITERAL => Some(Literal { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl Literal {}
|
|
|
|
// LiteralPat
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct LiteralPat {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for LiteralPat {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
LITERAL_PAT => Some(LiteralPat { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl LiteralPat {
|
|
pub fn literal(&self) -> Option<Literal> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// LoopExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct LoopExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for LoopExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
LOOP_EXPR => Some(LoopExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::LoopBodyOwner for LoopExpr {}
|
|
impl LoopExpr {}
|
|
|
|
// MacroCall
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct MacroCall {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for MacroCall {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
MACRO_CALL => Some(MacroCall { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::NameOwner for MacroCall {}
|
|
impl ast::AttrsOwner for MacroCall {}
|
|
impl ast::DocCommentsOwner for MacroCall {}
|
|
impl MacroCall {
|
|
pub fn token_tree(&self) -> Option<TokenTree> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn path(&self) -> Option<Path> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// MacroItems
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct MacroItems {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for MacroItems {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
MACRO_ITEMS => Some(MacroItems { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::ModuleItemOwner for MacroItems {}
|
|
impl ast::FnDefOwner for MacroItems {}
|
|
impl MacroItems {}
|
|
|
|
// MacroStmts
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct MacroStmts {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for MacroStmts {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
MACRO_STMTS => Some(MacroStmts { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl MacroStmts {
|
|
pub fn statements(&self) -> impl Iterator<Item = Stmt> {
|
|
super::children(self)
|
|
}
|
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// MatchArm
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct MatchArm {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for MatchArm {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
MATCH_ARM => Some(MatchArm { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::AttrsOwner for MatchArm {}
|
|
impl MatchArm {
|
|
pub fn pats(&self) -> impl Iterator<Item = Pat> {
|
|
super::children(self)
|
|
}
|
|
|
|
pub fn guard(&self) -> Option<MatchGuard> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// MatchArmList
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct MatchArmList {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for MatchArmList {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
MATCH_ARM_LIST => Some(MatchArmList { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::AttrsOwner for MatchArmList {}
|
|
impl MatchArmList {
|
|
pub fn arms(&self) -> impl Iterator<Item = MatchArm> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// MatchExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct MatchExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for MatchExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
MATCH_EXPR => Some(MatchExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl MatchExpr {
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn match_arm_list(&self) -> Option<MatchArmList> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// MatchGuard
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct MatchGuard {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for MatchGuard {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
MATCH_GUARD => Some(MatchGuard { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl MatchGuard {
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// MethodCallExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct MethodCallExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for MethodCallExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
METHOD_CALL_EXPR => Some(MethodCallExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::ArgListOwner for MethodCallExpr {}
|
|
impl MethodCallExpr {
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn name_ref(&self) -> Option<NameRef> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn type_arg_list(&self) -> Option<TypeArgList> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// Module
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Module {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for Module {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
MODULE => Some(Module { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::VisibilityOwner for Module {}
|
|
impl ast::NameOwner for Module {}
|
|
impl ast::AttrsOwner for Module {}
|
|
impl ast::DocCommentsOwner for Module {}
|
|
impl Module {
|
|
pub fn item_list(&self) -> Option<ItemList> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// ModuleItem
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ModuleItem {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub enum ModuleItemKind {
|
|
StructDef(StructDef),
|
|
EnumDef(EnumDef),
|
|
FnDef(FnDef),
|
|
TraitDef(TraitDef),
|
|
TypeAliasDef(TypeAliasDef),
|
|
ImplBlock(ImplBlock),
|
|
UseItem(UseItem),
|
|
ExternCrateItem(ExternCrateItem),
|
|
ConstDef(ConstDef),
|
|
StaticDef(StaticDef),
|
|
Module(Module),
|
|
}
|
|
impl From<StructDef> for ModuleItem {
|
|
fn from(n: StructDef) -> ModuleItem {
|
|
ModuleItem::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<EnumDef> for ModuleItem {
|
|
fn from(n: EnumDef) -> ModuleItem {
|
|
ModuleItem::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<FnDef> for ModuleItem {
|
|
fn from(n: FnDef) -> ModuleItem {
|
|
ModuleItem::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<TraitDef> for ModuleItem {
|
|
fn from(n: TraitDef) -> ModuleItem {
|
|
ModuleItem::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<TypeAliasDef> for ModuleItem {
|
|
fn from(n: TypeAliasDef) -> ModuleItem {
|
|
ModuleItem::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<ImplBlock> for ModuleItem {
|
|
fn from(n: ImplBlock) -> ModuleItem {
|
|
ModuleItem::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<UseItem> for ModuleItem {
|
|
fn from(n: UseItem) -> ModuleItem {
|
|
ModuleItem::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<ExternCrateItem> for ModuleItem {
|
|
fn from(n: ExternCrateItem) -> ModuleItem {
|
|
ModuleItem::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<ConstDef> for ModuleItem {
|
|
fn from(n: ConstDef) -> ModuleItem {
|
|
ModuleItem::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<StaticDef> for ModuleItem {
|
|
fn from(n: StaticDef) -> ModuleItem {
|
|
ModuleItem::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<Module> for ModuleItem {
|
|
fn from(n: Module) -> ModuleItem {
|
|
ModuleItem::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
|
|
|
|
impl AstNode for ModuleItem {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
| STRUCT_DEF
|
|
| ENUM_DEF
|
|
| FN_DEF
|
|
| TRAIT_DEF
|
|
| TYPE_ALIAS_DEF
|
|
| IMPL_BLOCK
|
|
| USE_ITEM
|
|
| EXTERN_CRATE_ITEM
|
|
| CONST_DEF
|
|
| STATIC_DEF
|
|
| MODULE => Some(ModuleItem { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
impl ModuleItem {
|
|
pub fn kind(&self) -> ModuleItemKind {
|
|
match self.syntax.kind() {
|
|
STRUCT_DEF => ModuleItemKind::StructDef(StructDef::cast(self.syntax.clone()).unwrap()),
|
|
ENUM_DEF => ModuleItemKind::EnumDef(EnumDef::cast(self.syntax.clone()).unwrap()),
|
|
FN_DEF => ModuleItemKind::FnDef(FnDef::cast(self.syntax.clone()).unwrap()),
|
|
TRAIT_DEF => ModuleItemKind::TraitDef(TraitDef::cast(self.syntax.clone()).unwrap()),
|
|
TYPE_ALIAS_DEF => ModuleItemKind::TypeAliasDef(TypeAliasDef::cast(self.syntax.clone()).unwrap()),
|
|
IMPL_BLOCK => ModuleItemKind::ImplBlock(ImplBlock::cast(self.syntax.clone()).unwrap()),
|
|
USE_ITEM => ModuleItemKind::UseItem(UseItem::cast(self.syntax.clone()).unwrap()),
|
|
EXTERN_CRATE_ITEM => ModuleItemKind::ExternCrateItem(ExternCrateItem::cast(self.syntax.clone()).unwrap()),
|
|
CONST_DEF => ModuleItemKind::ConstDef(ConstDef::cast(self.syntax.clone()).unwrap()),
|
|
STATIC_DEF => ModuleItemKind::StaticDef(StaticDef::cast(self.syntax.clone()).unwrap()),
|
|
MODULE => ModuleItemKind::Module(Module::cast(self.syntax.clone()).unwrap()),
|
|
_ => unreachable!(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ModuleItem {}
|
|
|
|
// Name
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Name {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for Name {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
NAME => Some(Name { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl Name {}
|
|
|
|
// NameRef
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct NameRef {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for NameRef {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
NAME_REF => Some(NameRef { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl NameRef {}
|
|
|
|
// NamedField
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct NamedField {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for NamedField {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
NAMED_FIELD => Some(NamedField { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl NamedField {
|
|
pub fn name_ref(&self) -> Option<NameRef> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// NamedFieldDef
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct NamedFieldDef {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for NamedFieldDef {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
NAMED_FIELD_DEF => Some(NamedFieldDef { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::VisibilityOwner for NamedFieldDef {}
|
|
impl ast::NameOwner for NamedFieldDef {}
|
|
impl ast::AttrsOwner for NamedFieldDef {}
|
|
impl ast::DocCommentsOwner for NamedFieldDef {}
|
|
impl ast::TypeAscriptionOwner for NamedFieldDef {}
|
|
impl NamedFieldDef {}
|
|
|
|
// NamedFieldDefList
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct NamedFieldDefList {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for NamedFieldDefList {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
NAMED_FIELD_DEF_LIST => Some(NamedFieldDefList { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl NamedFieldDefList {
|
|
pub fn fields(&self) -> impl Iterator<Item = NamedFieldDef> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// NamedFieldList
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct NamedFieldList {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for NamedFieldList {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
NAMED_FIELD_LIST => Some(NamedFieldList { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl NamedFieldList {
|
|
pub fn fields(&self) -> impl Iterator<Item = NamedField> {
|
|
super::children(self)
|
|
}
|
|
|
|
pub fn spread(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// NeverType
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct NeverType {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for NeverType {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
NEVER_TYPE => Some(NeverType { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl NeverType {}
|
|
|
|
// NominalDef
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct NominalDef {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub enum NominalDefKind {
|
|
StructDef(StructDef),
|
|
EnumDef(EnumDef),
|
|
}
|
|
impl From<StructDef> for NominalDef {
|
|
fn from(n: StructDef) -> NominalDef {
|
|
NominalDef::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<EnumDef> for NominalDef {
|
|
fn from(n: EnumDef) -> NominalDef {
|
|
NominalDef::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
|
|
|
|
impl AstNode for NominalDef {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
| STRUCT_DEF
|
|
| ENUM_DEF => Some(NominalDef { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
impl NominalDef {
|
|
pub fn kind(&self) -> NominalDefKind {
|
|
match self.syntax.kind() {
|
|
STRUCT_DEF => NominalDefKind::StructDef(StructDef::cast(self.syntax.clone()).unwrap()),
|
|
ENUM_DEF => NominalDefKind::EnumDef(EnumDef::cast(self.syntax.clone()).unwrap()),
|
|
_ => unreachable!(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ast::NameOwner for NominalDef {}
|
|
impl ast::TypeParamsOwner for NominalDef {}
|
|
impl ast::AttrsOwner for NominalDef {}
|
|
impl NominalDef {}
|
|
|
|
// Param
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Param {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for Param {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
PARAM => Some(Param { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::TypeAscriptionOwner for Param {}
|
|
impl Param {
|
|
pub fn pat(&self) -> Option<Pat> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// ParamList
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ParamList {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ParamList {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
PARAM_LIST => Some(ParamList { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ParamList {
|
|
pub fn params(&self) -> impl Iterator<Item = Param> {
|
|
super::children(self)
|
|
}
|
|
|
|
pub fn self_param(&self) -> Option<SelfParam> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// ParenExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ParenExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ParenExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
PAREN_EXPR => Some(ParenExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ParenExpr {
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// ParenType
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ParenType {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ParenType {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
PAREN_TYPE => Some(ParenType { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ParenType {
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// Pat
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Pat {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub enum PatKind {
|
|
RefPat(RefPat),
|
|
BindPat(BindPat),
|
|
PlaceholderPat(PlaceholderPat),
|
|
PathPat(PathPat),
|
|
StructPat(StructPat),
|
|
TupleStructPat(TupleStructPat),
|
|
TuplePat(TuplePat),
|
|
SlicePat(SlicePat),
|
|
RangePat(RangePat),
|
|
LiteralPat(LiteralPat),
|
|
}
|
|
impl From<RefPat> for Pat {
|
|
fn from(n: RefPat) -> Pat {
|
|
Pat::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<BindPat> for Pat {
|
|
fn from(n: BindPat) -> Pat {
|
|
Pat::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<PlaceholderPat> for Pat {
|
|
fn from(n: PlaceholderPat) -> Pat {
|
|
Pat::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<PathPat> for Pat {
|
|
fn from(n: PathPat) -> Pat {
|
|
Pat::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<StructPat> for Pat {
|
|
fn from(n: StructPat) -> Pat {
|
|
Pat::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<TupleStructPat> for Pat {
|
|
fn from(n: TupleStructPat) -> Pat {
|
|
Pat::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<TuplePat> for Pat {
|
|
fn from(n: TuplePat) -> Pat {
|
|
Pat::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<SlicePat> for Pat {
|
|
fn from(n: SlicePat) -> Pat {
|
|
Pat::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<RangePat> for Pat {
|
|
fn from(n: RangePat) -> Pat {
|
|
Pat::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<LiteralPat> for Pat {
|
|
fn from(n: LiteralPat) -> Pat {
|
|
Pat::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
|
|
|
|
impl AstNode for Pat {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
| REF_PAT
|
|
| BIND_PAT
|
|
| PLACEHOLDER_PAT
|
|
| PATH_PAT
|
|
| STRUCT_PAT
|
|
| TUPLE_STRUCT_PAT
|
|
| TUPLE_PAT
|
|
| SLICE_PAT
|
|
| RANGE_PAT
|
|
| LITERAL_PAT => Some(Pat { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
impl Pat {
|
|
pub fn kind(&self) -> PatKind {
|
|
match self.syntax.kind() {
|
|
REF_PAT => PatKind::RefPat(RefPat::cast(self.syntax.clone()).unwrap()),
|
|
BIND_PAT => PatKind::BindPat(BindPat::cast(self.syntax.clone()).unwrap()),
|
|
PLACEHOLDER_PAT => PatKind::PlaceholderPat(PlaceholderPat::cast(self.syntax.clone()).unwrap()),
|
|
PATH_PAT => PatKind::PathPat(PathPat::cast(self.syntax.clone()).unwrap()),
|
|
STRUCT_PAT => PatKind::StructPat(StructPat::cast(self.syntax.clone()).unwrap()),
|
|
TUPLE_STRUCT_PAT => PatKind::TupleStructPat(TupleStructPat::cast(self.syntax.clone()).unwrap()),
|
|
TUPLE_PAT => PatKind::TuplePat(TuplePat::cast(self.syntax.clone()).unwrap()),
|
|
SLICE_PAT => PatKind::SlicePat(SlicePat::cast(self.syntax.clone()).unwrap()),
|
|
RANGE_PAT => PatKind::RangePat(RangePat::cast(self.syntax.clone()).unwrap()),
|
|
LITERAL_PAT => PatKind::LiteralPat(LiteralPat::cast(self.syntax.clone()).unwrap()),
|
|
_ => unreachable!(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Pat {}
|
|
|
|
// Path
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Path {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for Path {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
PATH => Some(Path { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl Path {
|
|
pub fn segment(&self) -> Option<PathSegment> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn qualifier(&self) -> Option<Path> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// PathExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct PathExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for PathExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
PATH_EXPR => Some(PathExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl PathExpr {
|
|
pub fn path(&self) -> Option<Path> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// PathPat
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct PathPat {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for PathPat {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
PATH_PAT => Some(PathPat { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl PathPat {
|
|
pub fn path(&self) -> Option<Path> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// PathSegment
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct PathSegment {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for PathSegment {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
PATH_SEGMENT => Some(PathSegment { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl PathSegment {
|
|
pub fn name_ref(&self) -> Option<NameRef> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn type_arg_list(&self) -> Option<TypeArgList> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// PathType
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct PathType {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for PathType {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
PATH_TYPE => Some(PathType { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl PathType {
|
|
pub fn path(&self) -> Option<Path> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// PlaceholderPat
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct PlaceholderPat {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for PlaceholderPat {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
PLACEHOLDER_PAT => Some(PlaceholderPat { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl PlaceholderPat {}
|
|
|
|
// PlaceholderType
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct PlaceholderType {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for PlaceholderType {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
PLACEHOLDER_TYPE => Some(PlaceholderType { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl PlaceholderType {}
|
|
|
|
// PointerType
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct PointerType {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for PointerType {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
POINTER_TYPE => Some(PointerType { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl PointerType {
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// PosFieldDef
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct PosFieldDef {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for PosFieldDef {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
POS_FIELD_DEF => Some(PosFieldDef { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::VisibilityOwner for PosFieldDef {}
|
|
impl ast::AttrsOwner for PosFieldDef {}
|
|
impl PosFieldDef {
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// PosFieldDefList
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct PosFieldDefList {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for PosFieldDefList {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
POS_FIELD_DEF_LIST => Some(PosFieldDefList { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl PosFieldDefList {
|
|
pub fn fields(&self) -> impl Iterator<Item = PosFieldDef> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// PrefixExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct PrefixExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for PrefixExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
PREFIX_EXPR => Some(PrefixExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl PrefixExpr {
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// RangeExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct RangeExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for RangeExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
RANGE_EXPR => Some(RangeExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl RangeExpr {}
|
|
|
|
// RangePat
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct RangePat {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for RangePat {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
RANGE_PAT => Some(RangePat { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl RangePat {}
|
|
|
|
// RefExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct RefExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for RefExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
REF_EXPR => Some(RefExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl RefExpr {
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// RefPat
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct RefPat {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for RefPat {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
REF_PAT => Some(RefPat { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl RefPat {
|
|
pub fn pat(&self) -> Option<Pat> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// ReferenceType
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ReferenceType {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ReferenceType {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
REFERENCE_TYPE => Some(ReferenceType { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ReferenceType {
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// RetType
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct RetType {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for RetType {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
RET_TYPE => Some(RetType { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl RetType {
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// ReturnExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct ReturnExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for ReturnExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
RETURN_EXPR => Some(ReturnExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ReturnExpr {
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// SelfParam
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct SelfParam {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for SelfParam {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
SELF_PARAM => Some(SelfParam { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::TypeAscriptionOwner for SelfParam {}
|
|
impl SelfParam {}
|
|
|
|
// SlicePat
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct SlicePat {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for SlicePat {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
SLICE_PAT => Some(SlicePat { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl SlicePat {}
|
|
|
|
// SliceType
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct SliceType {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for SliceType {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
SLICE_TYPE => Some(SliceType { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl SliceType {
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// SourceFile
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct SourceFile {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for SourceFile {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
SOURCE_FILE => Some(SourceFile { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::ModuleItemOwner for SourceFile {}
|
|
impl ast::FnDefOwner for SourceFile {}
|
|
impl SourceFile {
|
|
pub fn modules(&self) -> impl Iterator<Item = Module> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// StaticDef
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct StaticDef {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for StaticDef {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
STATIC_DEF => Some(StaticDef { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::VisibilityOwner for StaticDef {}
|
|
impl ast::NameOwner for StaticDef {}
|
|
impl ast::TypeParamsOwner for StaticDef {}
|
|
impl ast::AttrsOwner for StaticDef {}
|
|
impl ast::DocCommentsOwner for StaticDef {}
|
|
impl ast::TypeAscriptionOwner for StaticDef {}
|
|
impl StaticDef {
|
|
pub fn body(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// Stmt
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Stmt {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub enum StmtKind {
|
|
ExprStmt(ExprStmt),
|
|
LetStmt(LetStmt),
|
|
}
|
|
impl From<ExprStmt> for Stmt {
|
|
fn from(n: ExprStmt) -> Stmt {
|
|
Stmt::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<LetStmt> for Stmt {
|
|
fn from(n: LetStmt) -> Stmt {
|
|
Stmt::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
|
|
|
|
impl AstNode for Stmt {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
| EXPR_STMT
|
|
| LET_STMT => Some(Stmt { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
impl Stmt {
|
|
pub fn kind(&self) -> StmtKind {
|
|
match self.syntax.kind() {
|
|
EXPR_STMT => StmtKind::ExprStmt(ExprStmt::cast(self.syntax.clone()).unwrap()),
|
|
LET_STMT => StmtKind::LetStmt(LetStmt::cast(self.syntax.clone()).unwrap()),
|
|
_ => unreachable!(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Stmt {}
|
|
|
|
// StructDef
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct StructDef {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for StructDef {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
STRUCT_DEF => Some(StructDef { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::VisibilityOwner for StructDef {}
|
|
impl ast::NameOwner for StructDef {}
|
|
impl ast::TypeParamsOwner for StructDef {}
|
|
impl ast::AttrsOwner for StructDef {}
|
|
impl ast::DocCommentsOwner for StructDef {}
|
|
impl StructDef {}
|
|
|
|
// StructLit
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct StructLit {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for StructLit {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
STRUCT_LIT => Some(StructLit { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl StructLit {
|
|
pub fn path(&self) -> Option<Path> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn named_field_list(&self) -> Option<NamedFieldList> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// StructPat
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct StructPat {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for StructPat {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
STRUCT_PAT => Some(StructPat { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl StructPat {
|
|
pub fn field_pat_list(&self) -> Option<FieldPatList> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn path(&self) -> Option<Path> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// TokenTree
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TokenTree {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for TokenTree {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
TOKEN_TREE => Some(TokenTree { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl TokenTree {}
|
|
|
|
// TraitDef
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TraitDef {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for TraitDef {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
TRAIT_DEF => Some(TraitDef { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::VisibilityOwner for TraitDef {}
|
|
impl ast::NameOwner for TraitDef {}
|
|
impl ast::AttrsOwner for TraitDef {}
|
|
impl ast::DocCommentsOwner for TraitDef {}
|
|
impl ast::TypeParamsOwner for TraitDef {}
|
|
impl ast::TypeBoundsOwner for TraitDef {}
|
|
impl TraitDef {
|
|
pub fn item_list(&self) -> Option<ItemList> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// TryBlockExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TryBlockExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for TryBlockExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
TRY_BLOCK_EXPR => Some(TryBlockExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::TryBlockBodyOwner for TryBlockExpr {}
|
|
impl TryBlockExpr {}
|
|
|
|
// TryExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TryExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for TryExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
TRY_EXPR => Some(TryExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl TryExpr {
|
|
pub fn expr(&self) -> Option<Expr> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// TupleExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TupleExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for TupleExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
TUPLE_EXPR => Some(TupleExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl TupleExpr {
|
|
pub fn exprs(&self) -> impl Iterator<Item = Expr> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// TuplePat
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TuplePat {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for TuplePat {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
TUPLE_PAT => Some(TuplePat { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl TuplePat {
|
|
pub fn args(&self) -> impl Iterator<Item = Pat> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// TupleStructPat
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TupleStructPat {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for TupleStructPat {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
TUPLE_STRUCT_PAT => Some(TupleStructPat { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl TupleStructPat {
|
|
pub fn args(&self) -> impl Iterator<Item = Pat> {
|
|
super::children(self)
|
|
}
|
|
|
|
pub fn path(&self) -> Option<Path> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// TupleType
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TupleType {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for TupleType {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
TUPLE_TYPE => Some(TupleType { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl TupleType {
|
|
pub fn fields(&self) -> impl Iterator<Item = TypeRef> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// TypeAliasDef
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TypeAliasDef {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for TypeAliasDef {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
TYPE_ALIAS_DEF => Some(TypeAliasDef { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::VisibilityOwner for TypeAliasDef {}
|
|
impl ast::NameOwner for TypeAliasDef {}
|
|
impl ast::TypeParamsOwner for TypeAliasDef {}
|
|
impl ast::AttrsOwner for TypeAliasDef {}
|
|
impl ast::DocCommentsOwner for TypeAliasDef {}
|
|
impl ast::TypeBoundsOwner for TypeAliasDef {}
|
|
impl TypeAliasDef {
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// TypeArg
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TypeArg {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for TypeArg {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
TYPE_ARG => Some(TypeArg { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl TypeArg {
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// TypeArgList
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TypeArgList {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for TypeArgList {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
TYPE_ARG_LIST => Some(TypeArgList { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl TypeArgList {
|
|
pub fn type_args(&self) -> impl Iterator<Item = TypeArg> {
|
|
super::children(self)
|
|
}
|
|
|
|
pub fn lifetime_args(&self) -> impl Iterator<Item = LifetimeArg> {
|
|
super::children(self)
|
|
}
|
|
|
|
pub fn assoc_type_args(&self) -> impl Iterator<Item = AssocTypeArg> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// TypeBound
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TypeBound {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for TypeBound {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
TYPE_BOUND => Some(TypeBound { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl TypeBound {
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// TypeBoundList
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TypeBoundList {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for TypeBoundList {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
TYPE_BOUND_LIST => Some(TypeBoundList { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl TypeBoundList {
|
|
pub fn bounds(&self) -> impl Iterator<Item = TypeBound> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// TypeParam
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TypeParam {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for TypeParam {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
TYPE_PARAM => Some(TypeParam { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::NameOwner for TypeParam {}
|
|
impl ast::AttrsOwner for TypeParam {}
|
|
impl ast::TypeBoundsOwner for TypeParam {}
|
|
impl ast::DefaultTypeParamOwner for TypeParam {}
|
|
impl TypeParam {}
|
|
|
|
// TypeParamList
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TypeParamList {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for TypeParamList {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
TYPE_PARAM_LIST => Some(TypeParamList { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl TypeParamList {
|
|
pub fn type_params(&self) -> impl Iterator<Item = TypeParam> {
|
|
super::children(self)
|
|
}
|
|
|
|
pub fn lifetime_params(&self) -> impl Iterator<Item = LifetimeParam> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// TypeRef
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct TypeRef {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
pub enum TypeRefKind {
|
|
ParenType(ParenType),
|
|
TupleType(TupleType),
|
|
NeverType(NeverType),
|
|
PathType(PathType),
|
|
PointerType(PointerType),
|
|
ArrayType(ArrayType),
|
|
SliceType(SliceType),
|
|
ReferenceType(ReferenceType),
|
|
PlaceholderType(PlaceholderType),
|
|
FnPointerType(FnPointerType),
|
|
ForType(ForType),
|
|
ImplTraitType(ImplTraitType),
|
|
DynTraitType(DynTraitType),
|
|
}
|
|
impl From<ParenType> for TypeRef {
|
|
fn from(n: ParenType) -> TypeRef {
|
|
TypeRef::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<TupleType> for TypeRef {
|
|
fn from(n: TupleType) -> TypeRef {
|
|
TypeRef::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<NeverType> for TypeRef {
|
|
fn from(n: NeverType) -> TypeRef {
|
|
TypeRef::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<PathType> for TypeRef {
|
|
fn from(n: PathType) -> TypeRef {
|
|
TypeRef::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<PointerType> for TypeRef {
|
|
fn from(n: PointerType) -> TypeRef {
|
|
TypeRef::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<ArrayType> for TypeRef {
|
|
fn from(n: ArrayType) -> TypeRef {
|
|
TypeRef::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<SliceType> for TypeRef {
|
|
fn from(n: SliceType) -> TypeRef {
|
|
TypeRef::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<ReferenceType> for TypeRef {
|
|
fn from(n: ReferenceType) -> TypeRef {
|
|
TypeRef::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<PlaceholderType> for TypeRef {
|
|
fn from(n: PlaceholderType) -> TypeRef {
|
|
TypeRef::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<FnPointerType> for TypeRef {
|
|
fn from(n: FnPointerType) -> TypeRef {
|
|
TypeRef::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<ForType> for TypeRef {
|
|
fn from(n: ForType) -> TypeRef {
|
|
TypeRef::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<ImplTraitType> for TypeRef {
|
|
fn from(n: ImplTraitType) -> TypeRef {
|
|
TypeRef::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
impl From<DynTraitType> for TypeRef {
|
|
fn from(n: DynTraitType) -> TypeRef {
|
|
TypeRef::cast(n.syntax).unwrap()
|
|
}
|
|
}
|
|
|
|
|
|
impl AstNode for TypeRef {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
| PAREN_TYPE
|
|
| TUPLE_TYPE
|
|
| NEVER_TYPE
|
|
| PATH_TYPE
|
|
| POINTER_TYPE
|
|
| ARRAY_TYPE
|
|
| SLICE_TYPE
|
|
| REFERENCE_TYPE
|
|
| PLACEHOLDER_TYPE
|
|
| FN_POINTER_TYPE
|
|
| FOR_TYPE
|
|
| IMPL_TRAIT_TYPE
|
|
| DYN_TRAIT_TYPE => Some(TypeRef { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
impl TypeRef {
|
|
pub fn kind(&self) -> TypeRefKind {
|
|
match self.syntax.kind() {
|
|
PAREN_TYPE => TypeRefKind::ParenType(ParenType::cast(self.syntax.clone()).unwrap()),
|
|
TUPLE_TYPE => TypeRefKind::TupleType(TupleType::cast(self.syntax.clone()).unwrap()),
|
|
NEVER_TYPE => TypeRefKind::NeverType(NeverType::cast(self.syntax.clone()).unwrap()),
|
|
PATH_TYPE => TypeRefKind::PathType(PathType::cast(self.syntax.clone()).unwrap()),
|
|
POINTER_TYPE => TypeRefKind::PointerType(PointerType::cast(self.syntax.clone()).unwrap()),
|
|
ARRAY_TYPE => TypeRefKind::ArrayType(ArrayType::cast(self.syntax.clone()).unwrap()),
|
|
SLICE_TYPE => TypeRefKind::SliceType(SliceType::cast(self.syntax.clone()).unwrap()),
|
|
REFERENCE_TYPE => TypeRefKind::ReferenceType(ReferenceType::cast(self.syntax.clone()).unwrap()),
|
|
PLACEHOLDER_TYPE => TypeRefKind::PlaceholderType(PlaceholderType::cast(self.syntax.clone()).unwrap()),
|
|
FN_POINTER_TYPE => TypeRefKind::FnPointerType(FnPointerType::cast(self.syntax.clone()).unwrap()),
|
|
FOR_TYPE => TypeRefKind::ForType(ForType::cast(self.syntax.clone()).unwrap()),
|
|
IMPL_TRAIT_TYPE => TypeRefKind::ImplTraitType(ImplTraitType::cast(self.syntax.clone()).unwrap()),
|
|
DYN_TRAIT_TYPE => TypeRefKind::DynTraitType(DynTraitType::cast(self.syntax.clone()).unwrap()),
|
|
_ => unreachable!(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl TypeRef {}
|
|
|
|
// UseItem
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct UseItem {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for UseItem {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
USE_ITEM => Some(UseItem { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::AttrsOwner for UseItem {}
|
|
impl UseItem {
|
|
pub fn use_tree(&self) -> Option<UseTree> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// UseTree
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct UseTree {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for UseTree {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
USE_TREE => Some(UseTree { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl UseTree {
|
|
pub fn path(&self) -> Option<Path> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn use_tree_list(&self) -> Option<UseTreeList> {
|
|
super::child_opt(self)
|
|
}
|
|
|
|
pub fn alias(&self) -> Option<Alias> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// UseTreeList
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct UseTreeList {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for UseTreeList {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
USE_TREE_LIST => Some(UseTreeList { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl UseTreeList {
|
|
pub fn use_trees(&self) -> impl Iterator<Item = UseTree> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// Visibility
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Visibility {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for Visibility {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
VISIBILITY => Some(Visibility { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl Visibility {}
|
|
|
|
// WhereClause
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct WhereClause {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for WhereClause {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
WHERE_CLAUSE => Some(WhereClause { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl WhereClause {
|
|
pub fn predicates(&self) -> impl Iterator<Item = WherePred> {
|
|
super::children(self)
|
|
}
|
|
}
|
|
|
|
// WherePred
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct WherePred {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for WherePred {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
WHERE_PRED => Some(WherePred { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::TypeBoundsOwner for WherePred {}
|
|
impl WherePred {
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|
|
// WhileExpr
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct WhileExpr {
|
|
pub(crate) syntax: SyntaxNode,
|
|
}
|
|
|
|
impl AstNode for WhileExpr {
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
|
match syntax.kind() {
|
|
WHILE_EXPR => Some(WhileExpr { syntax }),
|
|
_ => None,
|
|
}
|
|
}
|
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
|
}
|
|
|
|
|
|
impl ast::LoopBodyOwner for WhileExpr {}
|
|
impl WhileExpr {
|
|
pub fn condition(&self) -> Option<Condition> {
|
|
super::child_opt(self)
|
|
}
|
|
}
|
|
|