rust-analyzer/crates/ra_syntax/src/ast/generated.rs

3436 lines
79 KiB
Rust
Raw Normal View History

2018-10-16 18:09:22 +00:00
// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run
2018-10-04 20:43:58 +00:00
// Do not edit manually
2018-11-06 19:06:58 +00:00
//! 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)]
2018-10-15 16:55:32 +00:00
use crate::{
2019-01-07 13:16:02 +00:00
SyntaxNode, SyntaxKind::*,
ast::{self, AstNode},
2018-08-09 14:43:39 +00:00
};
2019-02-01 23:18:10 +00:00
// Alias
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-02-01 23:18:10 +00:00
pub struct Alias {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for Alias {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-02-01 23:18:10 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
ALIAS => Some(Alias { syntax }),
2019-02-01 23:18:10 +00:00
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl ast::NameOwner for Alias {}
impl Alias {}
2018-08-28 20:59:57 +00:00
// ArgList
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ArgList {
pub(crate) syntax: SyntaxNode,
2018-08-28 20:59:57 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for ArgList {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-28 20:59:57 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
ARG_LIST => Some(ArgList { syntax }),
2018-08-28 20:59:57 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl ArgList {
2019-07-18 16:23:05 +00:00
pub fn args(&self) -> impl Iterator<Item = Expr> {
2018-11-06 18:52:00 +00:00
super::children(self)
}
}
2018-11-01 10:41:04 +00:00
2018-11-06 18:52:00 +00:00
// ArrayExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ArrayExpr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for ArrayExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
ARRAY_EXPR => Some(ArrayExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-13 13:46:10 +00:00
impl ArrayExpr {
2019-07-18 16:23:05 +00:00
pub fn exprs(&self) -> impl Iterator<Item = Expr> {
2019-01-13 13:46:10 +00:00
super::children(self)
}
}
2018-11-06 18:52:00 +00:00
// ArrayType
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ArrayType {
pub(crate) syntax: SyntaxNode,
2018-08-14 09:38:20 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for ArrayType {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
ARRAY_TYPE => Some(ArrayType { syntax }),
2018-08-14 09:38:20 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ArrayType {
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// AssocTypeArg
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AssocTypeArg {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for AssocTypeArg {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
ASSOC_TYPE_ARG => Some(AssocTypeArg { syntax }),
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl AssocTypeArg {
2019-07-18 16:23:05 +00:00
pub fn name_ref(&self) -> Option<NameRef> {
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// Attr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct Attr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for Attr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-16 09:51:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
ATTR => Some(Attr { syntax }),
2018-08-16 09:51:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl Attr {
2019-07-18 16:23:05 +00:00
pub fn value(&self) -> Option<TokenTree> {
2018-11-06 18:52:00 +00:00
super::child_opt(self)
}
}
2018-11-01 10:41:04 +00:00
2018-11-06 18:52:00 +00:00
// BinExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct BinExpr {
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for BinExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
BIN_EXPR => Some(BinExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl BinExpr {}
2018-11-06 18:52:00 +00:00
// BindPat
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct BindPat {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for BindPat {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-26 09:09:28 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
BIND_PAT => Some(BindPat { syntax }),
2018-08-26 09:09:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ast::NameOwner for BindPat {}
impl BindPat {
2019-07-18 16:23:05 +00:00
pub fn pat(&self) -> Option<Pat> {
super::child_opt(self)
}
}
2018-08-26 09:09:28 +00:00
2018-08-25 10:42:40 +00:00
// Block
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct Block {
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for Block {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
BLOCK => Some(Block { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
impl ast::AttrsOwner for Block {}
2019-01-07 13:16:02 +00:00
impl Block {
2019-07-18 16:23:05 +00:00
pub fn statements(&self) -> impl Iterator<Item = Stmt> {
2018-08-26 09:09:28 +00:00
super::children(self)
}
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2018-08-27 07:12:28 +00:00
super::child_opt(self)
}
2018-08-26 09:09:28 +00:00
}
2018-08-25 10:42:40 +00:00
// BlockExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct BlockExpr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for BlockExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
BLOCK_EXPR => Some(BlockExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl BlockExpr {
2019-07-18 16:23:05 +00:00
pub fn block(&self) -> Option<Block> {
2018-11-06 18:52:00 +00:00
super::child_opt(self)
}
}
2018-11-01 10:41:04 +00:00
2018-11-06 18:52:00 +00:00
// BreakExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct BreakExpr {
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for BreakExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
BREAK_EXPR => Some(BreakExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl BreakExpr {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2019-01-05 15:32:07 +00:00
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// CallExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct CallExpr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for CallExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
CALL_EXPR => Some(CallExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ast::ArgListOwner for CallExpr {}
impl CallExpr {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2018-08-28 20:59:57 +00:00
super::child_opt(self)
}
}
2018-08-25 10:42:40 +00:00
// CastExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct CastExpr {
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for CastExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
CAST_EXPR => Some(CastExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl CastExpr {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2018-12-20 20:56:28 +00:00
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
2018-12-20 20:56:28 +00:00
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// Condition
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct Condition {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for Condition {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-27 09:22:09 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
CONDITION => Some(Condition { syntax }),
2018-08-27 09:22:09 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl Condition {
2019-07-18 16:23:05 +00:00
pub fn pat(&self) -> Option<Pat> {
2018-08-27 09:22:09 +00:00
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2018-08-27 09:22:09 +00:00
super::child_opt(self)
}
}
2018-08-13 15:36:16 +00:00
// ConstDef
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ConstDef {
pub(crate) syntax: SyntaxNode,
2018-08-11 08:03:22 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for ConstDef {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-11 08:03:22 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
CONST_DEF => Some(ConstDef { syntax }),
2018-08-11 08:03:22 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
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 {
2019-07-18 16:23:05 +00:00
pub fn body(&self) -> Option<Expr> {
super::child_opt(self)
}
}
2018-08-11 08:03:22 +00:00
2018-08-25 10:42:40 +00:00
// ContinueExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ContinueExpr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for ContinueExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
CONTINUE_EXPR => Some(ContinueExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ContinueExpr {}
2018-11-06 18:52:00 +00:00
// DynTraitType
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct DynTraitType {
pub(crate) syntax: SyntaxNode,
2018-08-14 09:38:20 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for DynTraitType {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
DYN_TRAIT_TYPE => Some(DynTraitType { syntax }),
2018-08-14 09:38:20 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-03-31 07:56:48 +00:00
impl ast::TypeBoundsOwner for DynTraitType {}
2019-01-07 13:16:02 +00:00
impl DynTraitType {}
2018-11-06 18:52:00 +00:00
// EnumDef
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct EnumDef {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for EnumDef {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-11 07:56:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
ENUM_DEF => Some(EnumDef { syntax }),
2018-08-11 07:56:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
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 {
2019-07-18 16:23:05 +00:00
pub fn variant_list(&self) -> Option<EnumVariantList> {
super::child_opt(self)
}
}
// EnumVariant
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct EnumVariant {
pub(crate) syntax: SyntaxNode,
}
2019-01-07 13:16:02 +00:00
impl AstNode for EnumVariant {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
ENUM_VARIANT => Some(EnumVariant { syntax }),
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl ast::NameOwner for EnumVariant {}
2019-01-23 20:59:19 +00:00
impl ast::DocCommentsOwner for EnumVariant {}
2019-02-05 22:05:46 +00:00
impl ast::AttrsOwner for EnumVariant {}
2019-01-07 13:16:02 +00:00
impl EnumVariant {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
super::child_opt(self)
}
}
// EnumVariantList
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct EnumVariantList {
pub(crate) syntax: SyntaxNode,
}
2019-01-07 13:16:02 +00:00
impl AstNode for EnumVariantList {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
ENUM_VARIANT_LIST => Some(EnumVariantList { syntax }),
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl EnumVariantList {
2019-07-18 16:23:05 +00:00
pub fn variants(&self) -> impl Iterator<Item = EnumVariant> {
super::children(self)
}
}
2018-08-11 07:56:40 +00:00
2018-08-25 10:42:40 +00:00
// Expr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct Expr {
pub(crate) syntax: SyntaxNode,
}
2018-08-25 10:42:40 +00:00
2019-07-18 16:23:05 +00:00
#[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),
2019-01-07 13:16:02 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<TupleExpr> for Expr {
fn from(n: TupleExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<ArrayExpr> for Expr {
fn from(n: ArrayExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<ParenExpr> for Expr {
fn from(n: ParenExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<PathExpr> for Expr {
fn from(n: PathExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<LambdaExpr> for Expr {
fn from(n: LambdaExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<IfExpr> for Expr {
fn from(n: IfExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<LoopExpr> for Expr {
fn from(n: LoopExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<ForExpr> for Expr {
fn from(n: ForExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<WhileExpr> for Expr {
fn from(n: WhileExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<ContinueExpr> for Expr {
fn from(n: ContinueExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<BreakExpr> for Expr {
fn from(n: BreakExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<Label> for Expr {
fn from(n: Label) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<BlockExpr> for Expr {
fn from(n: BlockExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<ReturnExpr> for Expr {
fn from(n: ReturnExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<MatchExpr> for Expr {
fn from(n: MatchExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<StructLit> for Expr {
fn from(n: StructLit) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<CallExpr> for Expr {
fn from(n: CallExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<IndexExpr> for Expr {
fn from(n: IndexExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<MethodCallExpr> for Expr {
fn from(n: MethodCallExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<FieldExpr> for Expr {
fn from(n: FieldExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<TryExpr> for Expr {
fn from(n: TryExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<TryBlockExpr> for Expr {
fn from(n: TryBlockExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-06-06 11:36:16 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<CastExpr> for Expr {
fn from(n: CastExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<RefExpr> for Expr {
fn from(n: RefExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<PrefixExpr> for Expr {
fn from(n: PrefixExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<RangeExpr> for Expr {
fn from(n: RangeExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<BinExpr> for Expr {
fn from(n: BinExpr) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<Literal> for Expr {
fn from(n: Literal) -> Expr {
Expr::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<MacroCall> for Expr {
fn from(n: MacroCall) -> Expr {
Expr::cast(n.syntax).unwrap()
}
}
2019-02-24 13:57:05 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for Expr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-01-07 13:16:02 +00:00
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
2019-06-06 11:36:16 +00:00
| TRY_BLOCK_EXPR
2019-01-07 13:16:02 +00:00
| CAST_EXPR
| REF_EXPR
| PREFIX_EXPR
| RANGE_EXPR
| BIN_EXPR
| LITERAL
2019-07-18 16:23:05 +00:00
| MACRO_CALL => Some(Expr { syntax }),
2019-01-07 13:16:02 +00:00
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl Expr {
pub fn kind(&self) -> ExprKind {
match self.syntax.kind() {
2019-07-18 16:23:05 +00:00
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()),
2019-01-07 13:16:02 +00:00
_ => unreachable!(),
}
}
}
impl Expr {}
2018-08-25 10:42:40 +00:00
2018-08-27 07:01:31 +00:00
// ExprStmt
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ExprStmt {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for ExprStmt {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-27 07:01:31 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
EXPR_STMT => Some(ExprStmt { syntax }),
2018-08-27 07:01:31 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl ExprStmt {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2018-11-06 18:52:00 +00:00
super::child_opt(self)
}
}
2018-11-01 10:41:04 +00:00
2018-11-06 18:52:00 +00:00
// ExternCrateItem
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ExternCrateItem {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for ExternCrateItem {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-28 08:12:42 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
EXTERN_CRATE_ITEM => Some(ExternCrateItem { syntax }),
2018-08-28 08:12:42 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
impl ExternCrateItem {
2019-07-18 16:23:05 +00:00
pub fn name_ref(&self) -> Option<NameRef> {
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn alias(&self) -> Option<Alias> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// FieldExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct FieldExpr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for FieldExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
FIELD_EXPR => Some(FieldExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl FieldExpr {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2018-12-25 12:54:38 +00:00
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn name_ref(&self) -> Option<NameRef> {
2018-12-25 12:54:38 +00:00
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// FieldPat
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct FieldPat {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for FieldPat {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
FIELD_PAT => Some(FieldPat { syntax }),
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl ast::NameOwner for FieldPat {}
impl FieldPat {
2019-07-18 16:23:05 +00:00
pub fn pat(&self) -> Option<Pat> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// FieldPatList
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct FieldPatList {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for FieldPatList {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-26 09:09:28 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
FIELD_PAT_LIST => Some(FieldPatList { syntax }),
2018-08-26 09:09:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
impl FieldPatList {
2019-07-18 16:23:05 +00:00
pub fn field_pats(&self) -> impl Iterator<Item = FieldPat> {
super::children(self)
}
2019-07-18 16:23:05 +00:00
pub fn bind_pats(&self) -> impl Iterator<Item = BindPat> {
super::children(self)
}
}
2018-11-06 18:52:00 +00:00
// FnDef
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct FnDef {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for FnDef {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-09 14:43:39 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
FN_DEF => Some(FnDef { syntax }),
2018-08-09 14:43:39 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
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 {
2019-07-18 16:23:05 +00:00
pub fn param_list(&self) -> Option<ParamList> {
2018-08-26 09:09:28 +00:00
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn body(&self) -> Option<Block> {
2018-08-27 07:01:31 +00:00
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn ret_type(&self) -> Option<RetType> {
2018-08-28 18:11:17 +00:00
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
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct FnPointerType {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for FnPointerType {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
FN_POINTER_TYPE => Some(FnPointerType { syntax }),
2018-08-14 09:38:20 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl FnPointerType {
2019-07-18 16:23:05 +00:00
pub fn param_list(&self) -> Option<ParamList> {
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn ret_type(&self) -> Option<RetType> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// ForExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ForExpr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for ForExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
FOR_EXPR => Some(ForExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ast::LoopBodyOwner for ForExpr {}
impl ForExpr {
2019-07-18 16:23:05 +00:00
pub fn pat(&self) -> Option<Pat> {
2018-08-27 19:03:19 +00:00
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn iterable(&self) -> Option<Expr> {
2018-08-27 19:03:19 +00:00
super::child_opt(self)
}
2018-08-27 09:22:09 +00:00
}
2018-08-25 10:42:40 +00:00
2018-08-14 09:38:20 +00:00
// ForType
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ForType {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for ForType {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
FOR_TYPE => Some(ForType { syntax }),
2018-08-14 09:38:20 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ForType {
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// IfExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct IfExpr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for IfExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
IF_EXPR => Some(IfExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl IfExpr {
2019-07-18 16:23:05 +00:00
pub fn condition(&self) -> Option<Condition> {
2018-11-06 18:52:00 +00:00
super::child_opt(self)
}
}
2018-11-01 10:41:04 +00:00
// ImplBlock
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ImplBlock {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for ImplBlock {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 08:20:09 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
IMPL_BLOCK => Some(ImplBlock { syntax }),
2018-08-14 08:20:09 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-02-16 20:19:24 +00:00
impl ast::TypeParamsOwner for ImplBlock {}
2019-04-14 22:03:54 +00:00
impl ast::AttrsOwner for ImplBlock {}
2019-01-07 13:16:02 +00:00
impl ImplBlock {
2019-07-18 16:23:05 +00:00
pub fn item_list(&self) -> Option<ItemList> {
super::child_opt(self)
}
}
// ImplItem
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ImplItem {
pub(crate) syntax: SyntaxNode,
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ImplItemKind {
FnDef(FnDef),
TypeAliasDef(TypeAliasDef),
ConstDef(ConstDef),
}
2019-07-18 16:23:05 +00:00
impl From<FnDef> for ImplItem {
fn from(n: FnDef) -> ImplItem {
ImplItem::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<TypeAliasDef> for ImplItem {
fn from(n: TypeAliasDef) -> ImplItem {
ImplItem::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<ConstDef> for ImplItem {
fn from(n: ConstDef) -> ImplItem {
ImplItem::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-01-07 13:16:02 +00:00
impl AstNode for ImplItem {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-01-07 13:16:02 +00:00
| FN_DEF
| TYPE_ALIAS_DEF
2019-07-18 16:23:05 +00:00
| CONST_DEF => Some(ImplItem { syntax }),
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl ImplItem {
pub fn kind(&self) -> ImplItemKind {
match self.syntax.kind() {
2019-07-18 16:23:05 +00:00
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()),
2019-01-07 13:16:02 +00:00
_ => unreachable!(),
}
}
}
2019-01-07 13:16:02 +00:00
impl ImplItem {}
2018-11-06 18:52:00 +00:00
// ImplTraitType
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ImplTraitType {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for ImplTraitType {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
IMPL_TRAIT_TYPE => Some(ImplTraitType { syntax }),
2018-08-14 09:38:20 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-03-31 07:56:48 +00:00
impl ast::TypeBoundsOwner for ImplTraitType {}
2019-01-07 13:16:02 +00:00
impl ImplTraitType {}
2018-11-06 18:52:00 +00:00
// IndexExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct IndexExpr {
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for IndexExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
INDEX_EXPR => Some(IndexExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl IndexExpr {}
2018-11-06 18:52:00 +00:00
// ItemList
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ItemList {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for ItemList {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-09-03 12:10:06 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
ITEM_LIST => Some(ItemList { syntax }),
2018-09-03 12:10:06 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ast::FnDefOwner for ItemList {}
impl ast::ModuleItemOwner for ItemList {}
impl ItemList {
2019-07-18 16:23:05 +00:00
pub fn impl_items(&self) -> impl Iterator<Item = ImplItem> {
super::children(self)
}
}
2018-09-03 12:10:06 +00:00
2018-08-25 10:42:40 +00:00
// Label
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct Label {
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for Label {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
LABEL => Some(Label { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl Label {}
2018-11-06 18:52:00 +00:00
// LambdaExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct LambdaExpr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for LambdaExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
LAMBDA_EXPR => Some(LambdaExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl LambdaExpr {
2019-07-18 16:23:05 +00:00
pub fn param_list(&self) -> Option<ParamList> {
2018-08-28 20:59:57 +00:00
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn body(&self) -> Option<Expr> {
2018-08-28 20:59:57 +00:00
super::child_opt(self)
}
}
2018-08-25 10:42:40 +00:00
2018-08-26 09:09:28 +00:00
// LetStmt
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct LetStmt {
pub(crate) syntax: SyntaxNode,
2018-08-26 09:09:28 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for LetStmt {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-26 09:09:28 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
LET_STMT => Some(LetStmt { syntax }),
2018-08-26 09:09:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
impl ast::TypeAscriptionOwner for LetStmt {}
2019-01-07 13:16:02 +00:00
impl LetStmt {
2019-07-18 16:23:05 +00:00
pub fn pat(&self) -> Option<Pat> {
2018-08-26 09:09:28 +00:00
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn initializer(&self) -> Option<Expr> {
2018-08-27 07:01:31 +00:00
super::child_opt(self)
}
2018-08-26 09:09:28 +00:00
}
// LifetimeArg
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LifetimeArg {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for LifetimeArg {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
LIFETIME_ARG => Some(LifetimeArg { syntax }),
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-03-30 10:25:53 +00:00
impl LifetimeArg {}
2018-11-06 18:52:00 +00:00
// LifetimeParam
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct LifetimeParam {
pub(crate) syntax: SyntaxNode,
2018-08-28 20:59:57 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for LifetimeParam {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-28 20:59:57 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
LIFETIME_PARAM => Some(LifetimeParam { syntax }),
2018-08-28 20:59:57 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl ast::AttrsOwner for LifetimeParam {}
2019-03-30 10:25:53 +00:00
impl LifetimeParam {}
2018-11-01 10:41:04 +00:00
2018-11-06 18:52:00 +00:00
// Literal
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct Literal {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for Literal {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-28 11:21:37 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
LITERAL => Some(Literal { syntax }),
2018-08-28 11:21:37 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-14 18:30:21 +00:00
2019-03-30 10:25:53 +00:00
impl Literal {}
2019-01-14 18:30:21 +00:00
// LiteralPat
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct LiteralPat {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for LiteralPat {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
LITERAL_PAT => Some(LiteralPat { syntax }),
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl LiteralPat {
2019-07-18 16:23:05 +00:00
pub fn literal(&self) -> Option<Literal> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// LoopExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct LoopExpr {
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for LoopExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
LOOP_EXPR => Some(LoopExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ast::LoopBodyOwner for LoopExpr {}
impl LoopExpr {}
2018-08-25 10:42:40 +00:00
2018-12-28 10:27:30 +00:00
// MacroCall
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct MacroCall {
pub(crate) syntax: SyntaxNode,
2018-12-28 10:27:30 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for MacroCall {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-12-28 10:27:30 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
MACRO_CALL => Some(MacroCall { syntax }),
2018-12-28 10:27:30 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-12-28 10:27:30 +00:00
2019-02-11 16:23:13 +00:00
impl ast::NameOwner for MacroCall {}
impl ast::AttrsOwner for MacroCall {}
2019-04-24 20:16:50 +00:00
impl ast::DocCommentsOwner for MacroCall {}
2019-01-07 13:16:02 +00:00
impl MacroCall {
2019-07-18 16:23:05 +00:00
pub fn token_tree(&self) -> Option<TokenTree> {
2018-12-28 10:27:30 +00:00
super::child_opt(self)
}
2018-12-28 13:59:58 +00:00
2019-07-18 16:23:05 +00:00
pub fn path(&self) -> Option<Path> {
2018-12-28 13:59:58 +00:00
super::child_opt(self)
}
2018-12-28 10:27:30 +00:00
}
// MacroItems
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MacroItems {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for MacroItems {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
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
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MacroStmts {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for MacroStmts {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
MACRO_STMTS => Some(MacroStmts { syntax }),
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl MacroStmts {
2019-07-18 16:23:05 +00:00
pub fn statements(&self) -> impl Iterator<Item = Stmt> {
super::children(self)
}
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
super::child_opt(self)
}
}
2018-08-25 10:42:40 +00:00
// MatchArm
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct MatchArm {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for MatchArm {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
MATCH_ARM => Some(MatchArm { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
impl ast::AttrsOwner for MatchArm {}
2019-01-07 13:16:02 +00:00
impl MatchArm {
2019-07-18 16:23:05 +00:00
pub fn pats(&self) -> impl Iterator<Item = Pat> {
2018-09-02 22:51:46 +00:00
super::children(self)
}
2019-07-18 16:23:05 +00:00
pub fn guard(&self) -> Option<MatchGuard> {
2018-09-02 22:51:46 +00:00
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2018-09-02 22:51:46 +00:00
super::child_opt(self)
}
}
2018-08-25 10:42:40 +00:00
// MatchArmList
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct MatchArmList {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for MatchArmList {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
MATCH_ARM_LIST => Some(MatchArmList { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-08-25 10:42:40 +00:00
impl ast::AttrsOwner for MatchArmList {}
2019-01-07 13:16:02 +00:00
impl MatchArmList {
2019-07-18 16:23:05 +00:00
pub fn arms(&self) -> impl Iterator<Item = MatchArm> {
2018-11-06 18:52:00 +00:00
super::children(self)
}
}
2018-11-01 10:41:04 +00:00
2018-11-06 18:52:00 +00:00
// MatchExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct MatchExpr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for MatchExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
MATCH_EXPR => Some(MatchExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl MatchExpr {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2018-09-02 22:51:46 +00:00
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn match_arm_list(&self) -> Option<MatchArmList> {
2018-09-02 22:51:46 +00:00
super::child_opt(self)
}
}
2018-08-25 10:42:40 +00:00
// MatchGuard
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct MatchGuard {
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for MatchGuard {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
MATCH_GUARD => Some(MatchGuard { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-28 22:06:11 +00:00
impl MatchGuard {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2019-01-28 22:06:11 +00:00
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// MethodCallExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct MethodCallExpr {
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for MethodCallExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
METHOD_CALL_EXPR => Some(MethodCallExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ast::ArgListOwner for MethodCallExpr {}
impl MethodCallExpr {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2018-09-02 23:01:43 +00:00
super::child_opt(self)
}
2018-12-25 14:15:40 +00:00
2019-07-18 16:23:05 +00:00
pub fn name_ref(&self) -> Option<NameRef> {
2018-12-25 14:15:40 +00:00
super::child_opt(self)
}
2019-02-16 22:05:57 +00:00
2019-07-18 16:23:05 +00:00
pub fn type_arg_list(&self) -> Option<TypeArgList> {
2019-02-16 22:05:57 +00:00
super::child_opt(self)
}
2018-09-02 23:01:43 +00:00
}
2018-08-25 10:42:40 +00:00
2018-08-11 09:28:59 +00:00
// Module
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct Module {
pub(crate) syntax: SyntaxNode,
2018-08-11 08:03:22 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for Module {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-11 08:03:22 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
MODULE => Some(Module { syntax }),
2018-08-11 08:03:22 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ast::VisibilityOwner for Module {}
impl ast::NameOwner for Module {}
impl ast::AttrsOwner for Module {}
impl ast::DocCommentsOwner for Module {}
impl Module {
2019-07-18 16:23:05 +00:00
pub fn item_list(&self) -> Option<ItemList> {
2018-09-03 12:10:06 +00:00
super::child_opt(self)
2018-08-21 15:30:10 +00:00
}
}
2018-08-11 08:03:22 +00:00
2018-08-28 08:12:42 +00:00
// ModuleItem
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ModuleItem {
pub(crate) syntax: SyntaxNode,
}
2018-08-28 08:12:42 +00:00
2019-07-18 16:23:05 +00:00
#[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),
2019-01-07 13:16:02 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<StructDef> for ModuleItem {
fn from(n: StructDef) -> ModuleItem {
ModuleItem::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<EnumDef> for ModuleItem {
fn from(n: EnumDef) -> ModuleItem {
ModuleItem::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<FnDef> for ModuleItem {
fn from(n: FnDef) -> ModuleItem {
ModuleItem::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<TraitDef> for ModuleItem {
fn from(n: TraitDef) -> ModuleItem {
ModuleItem::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<TypeAliasDef> for ModuleItem {
fn from(n: TypeAliasDef) -> ModuleItem {
ModuleItem::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<ImplBlock> for ModuleItem {
fn from(n: ImplBlock) -> ModuleItem {
ModuleItem::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<UseItem> for ModuleItem {
fn from(n: UseItem) -> ModuleItem {
ModuleItem::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<ExternCrateItem> for ModuleItem {
fn from(n: ExternCrateItem) -> ModuleItem {
ModuleItem::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<ConstDef> for ModuleItem {
fn from(n: ConstDef) -> ModuleItem {
ModuleItem::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<StaticDef> for ModuleItem {
fn from(n: StaticDef) -> ModuleItem {
ModuleItem::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<Module> for ModuleItem {
fn from(n: Module) -> ModuleItem {
ModuleItem::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-01-07 13:16:02 +00:00
impl AstNode for ModuleItem {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-01-07 13:16:02 +00:00
match syntax.kind() {
| STRUCT_DEF
| ENUM_DEF
| FN_DEF
| TRAIT_DEF
| TYPE_ALIAS_DEF
2019-01-07 13:16:02 +00:00
| IMPL_BLOCK
| USE_ITEM
| EXTERN_CRATE_ITEM
| CONST_DEF
| STATIC_DEF
2019-07-18 16:23:05 +00:00
| MODULE => Some(ModuleItem { syntax }),
2019-01-07 13:16:02 +00:00
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl ModuleItem {
pub fn kind(&self) -> ModuleItemKind {
match self.syntax.kind() {
2019-07-18 16:23:05 +00:00
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()),
2019-01-07 13:16:02 +00:00
_ => unreachable!(),
}
}
}
impl ModuleItem {}
2018-08-28 08:12:42 +00:00
2018-08-11 09:28:59 +00:00
// Name
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct Name {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for Name {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-09 14:43:39 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
NAME => Some(Name { syntax }),
2018-08-09 14:43:39 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl Name {}
2018-11-06 18:52:00 +00:00
// NameRef
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct NameRef {
pub(crate) syntax: SyntaxNode,
2018-08-13 13:35:17 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for NameRef {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-13 13:35:17 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
NAME_REF => Some(NameRef { syntax }),
2018-08-13 13:35:17 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl NameRef {}
2018-11-06 18:52:00 +00:00
// NamedField
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct NamedField {
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for NamedField {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
NAMED_FIELD => Some(NamedField { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl NamedField {
2019-07-18 16:23:05 +00:00
pub fn name_ref(&self) -> Option<NameRef> {
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// NamedFieldDef
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct NamedFieldDef {
pub(crate) syntax: SyntaxNode,
2018-08-14 11:45:56 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for NamedFieldDef {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 11:45:56 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
NAMED_FIELD_DEF => Some(NamedFieldDef { syntax }),
2018-08-14 11:45:56 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ast::VisibilityOwner for NamedFieldDef {}
impl ast::NameOwner for NamedFieldDef {}
impl ast::AttrsOwner for NamedFieldDef {}
2019-01-25 19:29:56 +00:00
impl ast::DocCommentsOwner for NamedFieldDef {}
impl ast::TypeAscriptionOwner for NamedFieldDef {}
impl NamedFieldDef {}
// NamedFieldDefList
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct NamedFieldDefList {
pub(crate) syntax: SyntaxNode,
}
2019-01-07 13:16:02 +00:00
impl AstNode for NamedFieldDefList {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
NAMED_FIELD_DEF_LIST => Some(NamedFieldDefList { syntax }),
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl NamedFieldDefList {
2019-07-18 16:23:05 +00:00
pub fn fields(&self) -> impl Iterator<Item = NamedFieldDef> {
super::children(self)
}
}
2018-08-14 11:45:56 +00:00
2018-08-25 10:42:40 +00:00
// NamedFieldList
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct NamedFieldList {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for NamedFieldList {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
NAMED_FIELD_LIST => Some(NamedFieldList { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl NamedFieldList {
2019-07-18 16:23:05 +00:00
pub fn fields(&self) -> impl Iterator<Item = NamedField> {
super::children(self)
}
2019-04-10 21:00:56 +00:00
2019-07-18 16:23:05 +00:00
pub fn spread(&self) -> Option<Expr> {
2019-04-10 21:00:56 +00:00
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// NeverType
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct NeverType {
pub(crate) syntax: SyntaxNode,
2018-08-14 09:38:20 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for NeverType {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
NEVER_TYPE => Some(NeverType { syntax }),
2018-08-14 09:38:20 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl NeverType {}
2018-11-06 18:52:00 +00:00
// NominalDef
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct NominalDef {
pub(crate) syntax: SyntaxNode,
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum NominalDefKind {
StructDef(StructDef),
EnumDef(EnumDef),
2018-08-14 10:33:44 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<StructDef> for NominalDef {
fn from(n: StructDef) -> NominalDef {
NominalDef::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<EnumDef> for NominalDef {
fn from(n: EnumDef) -> NominalDef {
NominalDef::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2018-08-14 10:33:44 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for NominalDef {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 10:33:44 +00:00
match syntax.kind() {
2019-01-07 13:16:02 +00:00
| STRUCT_DEF
2019-07-18 16:23:05 +00:00
| ENUM_DEF => Some(NominalDef { syntax }),
2018-08-14 10:33:44 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl NominalDef {
pub fn kind(&self) -> NominalDefKind {
match self.syntax.kind() {
2019-07-18 16:23:05 +00:00
STRUCT_DEF => NominalDefKind::StructDef(StructDef::cast(self.syntax.clone()).unwrap()),
ENUM_DEF => NominalDefKind::EnumDef(EnumDef::cast(self.syntax.clone()).unwrap()),
2019-01-07 13:16:02 +00:00
_ => unreachable!(),
2018-08-14 10:33:44 +00:00
}
}
}
2019-01-07 13:16:02 +00:00
impl ast::NameOwner for NominalDef {}
impl ast::TypeParamsOwner for NominalDef {}
impl ast::AttrsOwner for NominalDef {}
impl NominalDef {}
2018-08-14 10:33:44 +00:00
2018-08-26 09:09:28 +00:00
// Param
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct Param {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for Param {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-26 09:09:28 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
PARAM => Some(Param { syntax }),
2018-08-26 09:09:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl ast::TypeAscriptionOwner for Param {}
2019-01-07 13:16:02 +00:00
impl Param {
2019-07-18 16:23:05 +00:00
pub fn pat(&self) -> Option<Pat> {
2018-11-06 18:52:00 +00:00
super::child_opt(self)
}
}
2018-11-01 10:41:04 +00:00
2018-11-06 18:52:00 +00:00
// ParamList
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ParamList {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for ParamList {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-26 09:09:28 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
PARAM_LIST => Some(ParamList { syntax }),
2018-08-26 09:09:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ParamList {
2019-07-18 16:23:05 +00:00
pub fn params(&self) -> impl Iterator<Item = Param> {
2018-08-26 09:09:28 +00:00
super::children(self)
}
2019-07-18 16:23:05 +00:00
pub fn self_param(&self) -> Option<SelfParam> {
2018-08-31 13:30:42 +00:00
super::child_opt(self)
}
2018-08-26 09:09:28 +00:00
}
2018-08-25 10:42:40 +00:00
// ParenExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ParenExpr {
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for ParenExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
PAREN_EXPR => Some(ParenExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ParenExpr {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2018-12-20 20:56:28 +00:00
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// ParenType
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ParenType {
pub(crate) syntax: SyntaxNode,
2018-08-14 09:38:20 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for ParenType {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
PAREN_TYPE => Some(ParenType { syntax }),
2018-08-14 09:38:20 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ParenType {
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// Pat
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct Pat {
pub(crate) syntax: SyntaxNode,
}
2019-07-18 16:23:05 +00:00
#[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),
2019-01-07 13:16:02 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<RefPat> for Pat {
fn from(n: RefPat) -> Pat {
Pat::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<BindPat> for Pat {
fn from(n: BindPat) -> Pat {
Pat::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<PlaceholderPat> for Pat {
fn from(n: PlaceholderPat) -> Pat {
Pat::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<PathPat> for Pat {
fn from(n: PathPat) -> Pat {
Pat::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<StructPat> for Pat {
fn from(n: StructPat) -> Pat {
Pat::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<TupleStructPat> for Pat {
fn from(n: TupleStructPat) -> Pat {
Pat::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<TuplePat> for Pat {
fn from(n: TuplePat) -> Pat {
Pat::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<SlicePat> for Pat {
fn from(n: SlicePat) -> Pat {
Pat::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<RangePat> for Pat {
fn from(n: RangePat) -> Pat {
Pat::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<LiteralPat> for Pat {
fn from(n: LiteralPat) -> Pat {
Pat::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-01-07 13:16:02 +00:00
impl AstNode for Pat {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-26 09:09:28 +00:00
match syntax.kind() {
2019-01-07 13:16:02 +00:00
| REF_PAT
| BIND_PAT
| PLACEHOLDER_PAT
| PATH_PAT
| STRUCT_PAT
| TUPLE_STRUCT_PAT
| TUPLE_PAT
| SLICE_PAT
| RANGE_PAT
2019-07-18 16:23:05 +00:00
| LITERAL_PAT => Some(Pat { syntax }),
2018-08-26 09:09:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl Pat {
pub fn kind(&self) -> PatKind {
match self.syntax.kind() {
2019-07-18 16:23:05 +00:00
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()),
2019-01-07 13:16:02 +00:00
_ => unreachable!(),
2018-08-26 09:09:28 +00:00
}
}
}
2019-01-07 13:16:02 +00:00
impl Pat {}
2018-08-26 09:09:28 +00:00
2018-08-30 17:03:18 +00:00
// Path
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct Path {
pub(crate) syntax: SyntaxNode,
2018-08-30 17:03:18 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for Path {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-30 17:03:18 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
PATH => Some(Path { syntax }),
2018-08-30 17:03:18 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl Path {
2019-07-18 16:23:05 +00:00
pub fn segment(&self) -> Option<PathSegment> {
2018-08-30 17:37:33 +00:00
super::child_opt(self)
}
2018-10-24 15:37:25 +00:00
2019-07-18 16:23:05 +00:00
pub fn qualifier(&self) -> Option<Path> {
2018-10-24 15:37:25 +00:00
super::child_opt(self)
}
2018-08-30 17:37:33 +00:00
}
2018-08-30 17:03:18 +00:00
2018-08-25 10:42:40 +00:00
// PathExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct PathExpr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for PathExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
PATH_EXPR => Some(PathExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-08-25 10:42:40 +00:00
2019-01-07 13:16:02 +00:00
impl PathExpr {
2019-07-18 16:23:05 +00:00
pub fn path(&self) -> Option<Path> {
2018-11-06 18:52:00 +00:00
super::child_opt(self)
}
}
2018-11-01 10:41:04 +00:00
2018-11-06 18:52:00 +00:00
// PathPat
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct PathPat {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for PathPat {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-26 09:09:28 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
PATH_PAT => Some(PathPat { syntax }),
2018-08-26 09:09:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-15 14:24:04 +00:00
impl PathPat {
2019-07-18 16:23:05 +00:00
pub fn path(&self) -> Option<Path> {
2019-01-15 14:24:04 +00:00
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// PathSegment
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct PathSegment {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for PathSegment {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-30 17:37:33 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
PATH_SEGMENT => Some(PathSegment { syntax }),
2018-08-30 17:37:33 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl PathSegment {
2019-07-18 16:23:05 +00:00
pub fn name_ref(&self) -> Option<NameRef> {
2018-11-06 18:52:00 +00:00
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn type_arg_list(&self) -> Option<TypeArgList> {
super::child_opt(self)
}
}
2018-11-01 10:41:04 +00:00
2018-11-06 18:52:00 +00:00
// PathType
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct PathType {
pub(crate) syntax: SyntaxNode,
2018-08-14 09:38:20 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for PathType {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
PATH_TYPE => Some(PathType { syntax }),
2018-08-14 09:38:20 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl PathType {
2019-07-18 16:23:05 +00:00
pub fn path(&self) -> Option<Path> {
2018-12-22 21:17:55 +00:00
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// PlaceholderPat
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct PlaceholderPat {
pub(crate) syntax: SyntaxNode,
2018-08-26 09:09:28 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for PlaceholderPat {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-26 09:09:28 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
PLACEHOLDER_PAT => Some(PlaceholderPat { syntax }),
2018-08-26 09:09:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl PlaceholderPat {}
2018-11-06 18:52:00 +00:00
// PlaceholderType
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct PlaceholderType {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for PlaceholderType {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
PLACEHOLDER_TYPE => Some(PlaceholderType { syntax }),
2018-08-14 09:38:20 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl PlaceholderType {}
2018-11-06 18:52:00 +00:00
// PointerType
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct PointerType {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for PointerType {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
POINTER_TYPE => Some(PointerType { syntax }),
2018-08-14 09:38:20 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl PointerType {
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// PosFieldDef
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PosFieldDef {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
}
impl AstNode for PosFieldDef {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
POS_FIELD_DEF => Some(PosFieldDef { syntax }),
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl ast::VisibilityOwner for PosFieldDef {}
impl ast::AttrsOwner for PosFieldDef {}
impl PosFieldDef {
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
super::child_opt(self)
}
}
// PosFieldDefList
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PosFieldDefList {
2019-01-07 13:16:02 +00:00
pub(crate) syntax: SyntaxNode,
}
impl AstNode for PosFieldDefList {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
POS_FIELD_DEF_LIST => Some(PosFieldDefList { syntax }),
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl PosFieldDefList {
2019-07-18 16:23:05 +00:00
pub fn fields(&self) -> impl Iterator<Item = PosFieldDef> {
super::children(self)
}
}
2018-11-06 18:52:00 +00:00
// PrefixExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct PrefixExpr {
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for PrefixExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
PREFIX_EXPR => Some(PrefixExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl PrefixExpr {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2018-12-20 20:56:28 +00:00
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// RangeExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct RangeExpr {
pub(crate) syntax: SyntaxNode,
2018-08-25 10:42:40 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for RangeExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
RANGE_EXPR => Some(RangeExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl RangeExpr {}
2018-11-06 18:52:00 +00:00
// RangePat
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct RangePat {
pub(crate) syntax: SyntaxNode,
2018-08-26 09:09:28 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for RangePat {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-26 09:09:28 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
RANGE_PAT => Some(RangePat { syntax }),
2018-08-26 09:09:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl RangePat {}
2018-11-06 18:52:00 +00:00
// RefExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct RefExpr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for RefExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
REF_EXPR => Some(RefExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl RefExpr {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2018-12-20 20:56:28 +00:00
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// RefPat
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct RefPat {
pub(crate) syntax: SyntaxNode,
2018-08-26 09:09:28 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for RefPat {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-26 09:09:28 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
REF_PAT => Some(RefPat { syntax }),
2018-08-26 09:09:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-13 10:34:57 +00:00
impl RefPat {
2019-07-18 16:23:05 +00:00
pub fn pat(&self) -> Option<Pat> {
2019-01-13 10:34:57 +00:00
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// ReferenceType
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ReferenceType {
pub(crate) syntax: SyntaxNode,
2018-08-14 09:38:20 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for ReferenceType {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
REFERENCE_TYPE => Some(ReferenceType { syntax }),
2018-08-14 09:38:20 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ReferenceType {
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// RetType
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct RetType {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for RetType {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-28 18:11:17 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
RET_TYPE => Some(RetType { syntax }),
2018-08-28 18:11:17 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl RetType {
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// ReturnExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct ReturnExpr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for ReturnExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
RETURN_EXPR => Some(ReturnExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ReturnExpr {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2018-12-20 20:56:28 +00:00
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
2018-08-31 13:30:42 +00:00
// SelfParam
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct SelfParam {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for SelfParam {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-31 13:30:42 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
SELF_PARAM => Some(SelfParam { syntax }),
2018-08-31 13:30:42 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
impl ast::TypeAscriptionOwner for SelfParam {}
2019-03-30 10:25:53 +00:00
impl SelfParam {}
2018-11-06 18:52:00 +00:00
// SlicePat
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct SlicePat {
pub(crate) syntax: SyntaxNode,
2018-08-26 09:09:28 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for SlicePat {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-26 09:09:28 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
SLICE_PAT => Some(SlicePat { syntax }),
2018-08-26 09:09:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl SlicePat {}
2018-11-06 18:52:00 +00:00
// SliceType
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct SliceType {
pub(crate) syntax: SyntaxNode,
2018-08-14 09:38:20 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for SliceType {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
SLICE_TYPE => Some(SliceType { syntax }),
2018-08-14 09:38:20 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl SliceType {
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
super::child_opt(self)
}
}
2018-08-14 09:38:20 +00:00
2018-11-07 15:38:43 +00:00
// SourceFile
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct SourceFile {
pub(crate) syntax: SyntaxNode,
2018-11-07 15:38:43 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for SourceFile {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-11-07 15:38:43 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
SOURCE_FILE => Some(SourceFile { syntax }),
2018-11-07 15:38:43 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-07 15:38:43 +00:00
2019-01-07 13:16:02 +00:00
impl ast::ModuleItemOwner for SourceFile {}
impl ast::FnDefOwner for SourceFile {}
impl SourceFile {
2019-07-18 16:23:05 +00:00
pub fn modules(&self) -> impl Iterator<Item = Module> {
2018-11-07 15:38:43 +00:00
super::children(self)
}
}
2018-08-13 15:36:16 +00:00
// StaticDef
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct StaticDef {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for StaticDef {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-11 08:03:22 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
STATIC_DEF => Some(StaticDef { syntax }),
2018-08-11 08:03:22 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
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 {
2019-07-18 16:23:05 +00:00
pub fn body(&self) -> Option<Expr> {
super::child_opt(self)
}
}
2018-08-11 08:03:22 +00:00
2018-08-27 07:12:28 +00:00
// Stmt
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct Stmt {
pub(crate) syntax: SyntaxNode,
}
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum StmtKind {
ExprStmt(ExprStmt),
LetStmt(LetStmt),
2018-08-27 07:12:28 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<ExprStmt> for Stmt {
fn from(n: ExprStmt) -> Stmt {
Stmt::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<LetStmt> for Stmt {
fn from(n: LetStmt) -> Stmt {
Stmt::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2018-08-27 07:12:28 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for Stmt {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-27 07:12:28 +00:00
match syntax.kind() {
2019-01-07 13:16:02 +00:00
| EXPR_STMT
2019-07-18 16:23:05 +00:00
| LET_STMT => Some(Stmt { syntax }),
2018-08-27 07:12:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl Stmt {
pub fn kind(&self) -> StmtKind {
match self.syntax.kind() {
2019-07-18 16:23:05 +00:00
EXPR_STMT => StmtKind::ExprStmt(ExprStmt::cast(self.syntax.clone()).unwrap()),
LET_STMT => StmtKind::LetStmt(LetStmt::cast(self.syntax.clone()).unwrap()),
2019-01-07 13:16:02 +00:00
_ => unreachable!(),
2018-08-27 07:12:28 +00:00
}
}
}
2019-01-07 13:16:02 +00:00
impl Stmt {}
2018-08-27 07:12:28 +00:00
2018-08-13 15:36:16 +00:00
// StructDef
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct StructDef {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for StructDef {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-11 07:56:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
STRUCT_DEF => Some(StructDef { syntax }),
2018-08-11 07:56:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
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 {}
2018-08-11 07:56:40 +00:00
2018-08-25 10:42:40 +00:00
// StructLit
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct StructLit {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for StructLit {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
STRUCT_LIT => Some(StructLit { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl StructLit {
2019-07-18 16:23:05 +00:00
pub fn path(&self) -> Option<Path> {
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn named_field_list(&self) -> Option<NamedFieldList> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// StructPat
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct StructPat {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for StructPat {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-26 09:09:28 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
STRUCT_PAT => Some(StructPat { syntax }),
2018-08-26 09:09:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
impl StructPat {
2019-07-18 16:23:05 +00:00
pub fn field_pat_list(&self) -> Option<FieldPatList> {
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn path(&self) -> Option<Path> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// TokenTree
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct TokenTree {
pub(crate) syntax: SyntaxNode,
2018-08-16 09:51:40 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for TokenTree {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-16 09:51:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
TOKEN_TREE => Some(TokenTree { syntax }),
2018-08-16 09:51:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl TokenTree {}
2018-11-06 18:52:00 +00:00
// TraitDef
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct TraitDef {
pub(crate) syntax: SyntaxNode,
2018-08-11 08:03:22 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for TraitDef {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-11 08:03:22 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
TRAIT_DEF => Some(TraitDef { syntax }),
2018-08-11 08:03:22 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ast::VisibilityOwner for TraitDef {}
impl ast::NameOwner for TraitDef {}
impl ast::AttrsOwner for TraitDef {}
impl ast::DocCommentsOwner for TraitDef {}
2019-01-24 22:31:32 +00:00
impl ast::TypeParamsOwner for TraitDef {}
2019-03-31 07:56:48 +00:00
impl ast::TypeBoundsOwner for TraitDef {}
2019-03-24 16:36:15 +00:00
impl TraitDef {
2019-07-18 16:23:05 +00:00
pub fn item_list(&self) -> Option<ItemList> {
2019-03-24 16:36:15 +00:00
super::child_opt(self)
}
}
2018-08-11 08:03:22 +00:00
2019-06-06 11:36:16 +00:00
// TryBlockExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-06-06 11:36:16 +00:00
pub struct TryBlockExpr {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for TryBlockExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-06-06 11:36:16 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
TRY_BLOCK_EXPR => Some(TryBlockExpr { syntax }),
2019-06-06 11:36:16 +00:00
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl ast::TryBlockBodyOwner for TryBlockExpr {}
impl TryBlockExpr {}
2018-08-25 10:42:40 +00:00
// TryExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct TryExpr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for TryExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
TRY_EXPR => Some(TryExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl TryExpr {
2019-07-18 16:23:05 +00:00
pub fn expr(&self) -> Option<Expr> {
2018-12-20 20:56:28 +00:00
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// TupleExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct TupleExpr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for TupleExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
TUPLE_EXPR => Some(TupleExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-13 11:52:25 +00:00
impl TupleExpr {
2019-07-18 16:23:05 +00:00
pub fn exprs(&self) -> impl Iterator<Item = Expr> {
2019-01-13 11:52:25 +00:00
super::children(self)
}
}
2018-11-06 18:52:00 +00:00
// TuplePat
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct TuplePat {
pub(crate) syntax: SyntaxNode,
2018-08-26 09:09:28 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for TuplePat {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-26 09:09:28 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
TUPLE_PAT => Some(TuplePat { syntax }),
2018-08-26 09:09:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-15 14:24:04 +00:00
impl TuplePat {
2019-07-18 16:23:05 +00:00
pub fn args(&self) -> impl Iterator<Item = Pat> {
2019-01-15 14:24:04 +00:00
super::children(self)
}
}
2018-11-06 18:52:00 +00:00
// TupleStructPat
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct TupleStructPat {
pub(crate) syntax: SyntaxNode,
2018-08-26 09:09:28 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for TupleStructPat {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-26 09:09:28 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
TUPLE_STRUCT_PAT => Some(TupleStructPat { syntax }),
2018-08-26 09:09:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl TupleStructPat {
2019-07-18 16:23:05 +00:00
pub fn args(&self) -> impl Iterator<Item = Pat> {
super::children(self)
}
2019-07-18 16:23:05 +00:00
pub fn path(&self) -> Option<Path> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// TupleType
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct TupleType {
pub(crate) syntax: SyntaxNode,
2018-08-14 09:38:20 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for TupleType {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
TUPLE_TYPE => Some(TupleType { syntax }),
2018-08-14 09:38:20 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl TupleType {
2019-07-18 16:23:05 +00:00
pub fn fields(&self) -> impl Iterator<Item = TypeRef> {
super::children(self)
}
}
2018-11-06 18:52:00 +00:00
// TypeAliasDef
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypeAliasDef {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for TypeAliasDef {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
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 {}
2019-03-31 07:56:48 +00:00
impl ast::TypeBoundsOwner for TypeAliasDef {}
impl TypeAliasDef {
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
super::child_opt(self)
}
}
// TypeArg
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypeArg {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for TypeArg {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
TYPE_ARG => Some(TypeArg { syntax }),
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl TypeArg {
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
super::child_opt(self)
}
}
// TypeArgList
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypeArgList {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for TypeArgList {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
TYPE_ARG_LIST => Some(TypeArgList { syntax }),
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl TypeArgList {
2019-07-18 16:23:05 +00:00
pub fn type_args(&self) -> impl Iterator<Item = TypeArg> {
super::children(self)
}
2019-07-18 16:23:05 +00:00
pub fn lifetime_args(&self) -> impl Iterator<Item = LifetimeArg> {
super::children(self)
}
2019-07-18 16:23:05 +00:00
pub fn assoc_type_args(&self) -> impl Iterator<Item = AssocTypeArg> {
super::children(self)
}
}
// TypeBound
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypeBound {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for TypeBound {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
TYPE_BOUND => Some(TypeBound { syntax }),
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl TypeBound {
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
super::child_opt(self)
}
}
// TypeBoundList
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypeBoundList {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for TypeBoundList {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
TYPE_BOUND_LIST => Some(TypeBoundList { syntax }),
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl TypeBoundList {
2019-07-18 16:23:05 +00:00
pub fn bounds(&self) -> impl Iterator<Item = TypeBound> {
super::children(self)
}
}
2018-08-22 16:02:37 +00:00
// TypeParam
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct TypeParam {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for TypeParam {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-22 16:02:37 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
TYPE_PARAM => Some(TypeParam { syntax }),
2018-08-22 16:02:37 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ast::NameOwner for TypeParam {}
impl ast::AttrsOwner for TypeParam {}
2019-03-31 07:56:48 +00:00
impl ast::TypeBoundsOwner for TypeParam {}
impl ast::DefaultTypeParamOwner for TypeParam {}
2019-01-07 13:16:02 +00:00
impl TypeParam {}
2018-08-22 16:02:37 +00:00
2018-08-22 13:46:42 +00:00
// TypeParamList
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct TypeParamList {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for TypeParamList {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-22 13:46:42 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
TYPE_PARAM_LIST => Some(TypeParamList { syntax }),
2018-08-22 13:46:42 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl TypeParamList {
2019-07-18 16:23:05 +00:00
pub fn type_params(&self) -> impl Iterator<Item = TypeParam> {
2018-08-22 16:02:37 +00:00
super::children(self)
}
2018-08-28 20:59:57 +00:00
2019-07-18 16:23:05 +00:00
pub fn lifetime_params(&self) -> impl Iterator<Item = LifetimeParam> {
2018-08-28 20:59:57 +00:00
super::children(self)
}
2018-08-22 16:02:37 +00:00
}
2018-08-22 13:46:42 +00:00
2018-08-14 09:38:20 +00:00
// TypeRef
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct TypeRef {
pub(crate) syntax: SyntaxNode,
}
2018-08-14 09:38:20 +00:00
2019-07-18 16:23:05 +00:00
#[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),
2019-01-07 13:16:02 +00:00
}
2019-07-18 16:23:05 +00:00
impl From<ParenType> for TypeRef {
fn from(n: ParenType) -> TypeRef {
TypeRef::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<TupleType> for TypeRef {
fn from(n: TupleType) -> TypeRef {
TypeRef::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<NeverType> for TypeRef {
fn from(n: NeverType) -> TypeRef {
TypeRef::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<PathType> for TypeRef {
fn from(n: PathType) -> TypeRef {
TypeRef::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<PointerType> for TypeRef {
fn from(n: PointerType) -> TypeRef {
TypeRef::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<ArrayType> for TypeRef {
fn from(n: ArrayType) -> TypeRef {
TypeRef::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<SliceType> for TypeRef {
fn from(n: SliceType) -> TypeRef {
TypeRef::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<ReferenceType> for TypeRef {
fn from(n: ReferenceType) -> TypeRef {
TypeRef::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<PlaceholderType> for TypeRef {
fn from(n: PlaceholderType) -> TypeRef {
TypeRef::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<FnPointerType> for TypeRef {
fn from(n: FnPointerType) -> TypeRef {
TypeRef::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<ForType> for TypeRef {
fn from(n: ForType) -> TypeRef {
TypeRef::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<ImplTraitType> for TypeRef {
fn from(n: ImplTraitType) -> TypeRef {
TypeRef::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-07-18 16:23:05 +00:00
impl From<DynTraitType> for TypeRef {
fn from(n: DynTraitType) -> TypeRef {
TypeRef::cast(n.syntax).unwrap()
2019-02-24 13:57:05 +00:00
}
}
2019-01-07 13:16:02 +00:00
impl AstNode for TypeRef {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-01-07 13:16:02 +00:00
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
2019-07-18 16:23:05 +00:00
| DYN_TRAIT_TYPE => Some(TypeRef { syntax }),
2019-01-07 13:16:02 +00:00
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl TypeRef {
pub fn kind(&self) -> TypeRefKind {
match self.syntax.kind() {
2019-07-18 16:23:05 +00:00
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()),
2019-01-07 13:16:02 +00:00
_ => unreachable!(),
}
}
}
impl TypeRef {}
2018-08-14 09:38:20 +00:00
2018-08-28 08:12:42 +00:00
// UseItem
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct UseItem {
pub(crate) syntax: SyntaxNode,
2018-08-28 08:12:42 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for UseItem {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-28 08:12:42 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
USE_ITEM => Some(UseItem { syntax }),
2018-08-28 08:12:42 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-02-10 19:44:34 +00:00
impl ast::AttrsOwner for UseItem {}
2019-01-07 13:16:02 +00:00
impl UseItem {
2019-07-18 16:23:05 +00:00
pub fn use_tree(&self) -> Option<UseTree> {
2018-11-06 18:52:00 +00:00
super::child_opt(self)
}
}
2018-11-01 10:41:04 +00:00
2018-11-06 18:52:00 +00:00
// UseTree
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct UseTree {
pub(crate) syntax: SyntaxNode,
2018-08-30 17:37:33 +00:00
}
2018-11-06 19:47:38 +00:00
2019-01-07 13:16:02 +00:00
impl AstNode for UseTree {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-30 17:37:33 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
USE_TREE => Some(UseTree { syntax }),
2018-08-30 17:37:33 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl UseTree {
2019-07-18 16:23:05 +00:00
pub fn path(&self) -> Option<Path> {
2018-08-30 17:37:33 +00:00
super::child_opt(self)
}
2019-07-18 16:23:05 +00:00
pub fn use_tree_list(&self) -> Option<UseTreeList> {
2018-08-30 17:37:33 +00:00
super::child_opt(self)
}
2019-02-01 23:18:10 +00:00
2019-07-18 16:23:05 +00:00
pub fn alias(&self) -> Option<Alias> {
2019-02-01 23:18:10 +00:00
super::child_opt(self)
}
2018-08-30 17:37:33 +00:00
}
// UseTreeList
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct UseTreeList {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for UseTreeList {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-30 17:37:33 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
USE_TREE_LIST => Some(UseTreeList { syntax }),
2018-08-30 17:37:33 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-07 13:16:02 +00:00
impl UseTreeList {
2019-07-18 16:23:05 +00:00
pub fn use_trees(&self) -> impl Iterator<Item = UseTree> {
2018-11-06 18:52:00 +00:00
super::children(self)
}
}
2018-11-01 10:41:04 +00:00
2019-01-03 10:47:28 +00:00
// Visibility
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct Visibility {
pub(crate) syntax: SyntaxNode,
2019-01-03 10:47:28 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for Visibility {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2019-01-03 10:47:28 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
VISIBILITY => Some(Visibility { syntax }),
2019-01-03 10:47:28 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2019-01-03 10:47:28 +00:00
2019-01-07 13:16:02 +00:00
impl Visibility {}
2019-01-03 10:47:28 +00:00
2018-11-06 18:52:00 +00:00
// WhereClause
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct WhereClause {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for WhereClause {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-22 08:56:36 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
WHERE_CLAUSE => Some(WhereClause { syntax }),
2018-08-22 08:56:36 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
impl WhereClause {
2019-07-18 16:23:05 +00:00
pub fn predicates(&self) -> impl Iterator<Item = WherePred> {
super::children(self)
}
}
// WherePred
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct WherePred {
pub(crate) syntax: SyntaxNode,
}
impl AstNode for WherePred {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
match syntax.kind() {
2019-07-18 16:23:05 +00:00
WHERE_PRED => Some(WherePred { syntax }),
_ => None,
}
}
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
impl ast::TypeBoundsOwner for WherePred {}
impl WherePred {
2019-07-18 16:23:05 +00:00
pub fn type_ref(&self) -> Option<TypeRef> {
super::child_opt(self)
}
}
2018-11-06 18:52:00 +00:00
// WhileExpr
2019-07-18 16:23:05 +00:00
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2019-01-07 13:16:02 +00:00
pub struct WhileExpr {
pub(crate) syntax: SyntaxNode,
2018-11-06 19:47:38 +00:00
}
2019-01-07 13:16:02 +00:00
impl AstNode for WhileExpr {
2019-07-18 16:23:05 +00:00
fn cast(syntax: SyntaxNode) -> Option<Self> {
2018-08-25 10:42:40 +00:00
match syntax.kind() {
2019-07-18 16:23:05 +00:00
WHILE_EXPR => Some(WhileExpr { syntax }),
2018-08-25 10:42:40 +00:00
_ => None,
}
}
2019-01-07 13:16:02 +00:00
fn syntax(&self) -> &SyntaxNode { &self.syntax }
}
2018-11-06 18:52:00 +00:00
2019-01-07 13:16:02 +00:00
impl ast::LoopBodyOwner for WhileExpr {}
impl WhileExpr {
2019-07-18 16:23:05 +00:00
pub fn condition(&self) -> Option<Condition> {
2018-08-27 09:22:09 +00:00
super::child_opt(self)
}
}
2018-08-25 10:42:40 +00:00