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

4483 lines
136 KiB
Rust
Raw Normal View History

2018-10-16 20:09:22 +02:00
// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run
2018-10-04 22:43:58 +02:00
// Do not edit manually
2018-11-06 20:06:58 +01: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-11-06 20:47:38 +01:00
use std::hash::{Hash, Hasher};
2018-10-15 18:55:32 +02:00
use crate::{
2018-08-11 11:28:59 +02:00
ast,
SyntaxNode, SyntaxNodeRef, AstNode,
2018-11-06 19:52:00 +01:00
yellow::{TreeRoot, RaTypes, OwnedRoot, RefRoot},
2018-08-09 16:43:39 +02:00
SyntaxKind::*,
};
2018-08-28 22:59:57 +02:00
// ArgList
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ArgListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-28 22:59:57 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ArgList<'a> = ArgListNode<RefRoot<'a>>;
2018-08-28 22:59:57 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ArgListNode<R1>> for ArgListNode<R2> {
fn eq(&self, other: &ArgListNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ArgListNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ArgListNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-28 22:59:57 +02:00
impl<'a> AstNode<'a> for ArgList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
ARG_LIST => Some(ArgList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ArgListNode<R> {
pub fn borrowed(&self) -> ArgList {
ArgListNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> ArgListNode {
ArgListNode { syntax: self.syntax.owned() }
2018-08-28 22:59:57 +02:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> ArgList<'a> {
pub fn args(self) -> impl Iterator<Item = Expr<'a>> + 'a {
super::children(self)
}
}
2018-11-01 11:41:04 +01:00
2018-11-06 19:52:00 +01:00
// ArrayExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ArrayExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ArrayExpr<'a> = ArrayExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ArrayExprNode<R1>> for ArrayExprNode<R2> {
fn eq(&self, other: &ArrayExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ArrayExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ArrayExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for ArrayExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
ARRAY_EXPR => Some(ArrayExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ArrayExprNode<R> {
pub fn borrowed(&self) -> ArrayExpr {
ArrayExprNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> ArrayExprNode {
ArrayExprNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> ArrayExpr<'a> {}
// ArrayType
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ArrayTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ArrayType<'a> = ArrayTypeNode<RefRoot<'a>>;
2018-08-14 11:38:20 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ArrayTypeNode<R1>> for ArrayTypeNode<R2> {
fn eq(&self, other: &ArrayTypeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ArrayTypeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ArrayTypeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for ArrayType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
ARRAY_TYPE => Some(ArrayType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ArrayTypeNode<R> {
pub fn borrowed(&self) -> ArrayType {
ArrayTypeNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> ArrayTypeNode {
ArrayTypeNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> ArrayType<'a> {
pub fn type_ref(self) -> Option<TypeRef<'a>> {
super::child_opt(self)
}
pub fn expr(self) -> Option<Expr<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// Attr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct AttrNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-16 11:51:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type Attr<'a> = AttrNode<RefRoot<'a>>;
2018-08-16 11:51:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<AttrNode<R1>> for AttrNode<R2> {
fn eq(&self, other: &AttrNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for AttrNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for AttrNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for Attr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-16 11:51:40 +02:00
match syntax.kind() {
ATTR => Some(Attr { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-16 11:51:40 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> AttrNode<R> {
pub fn borrowed(&self) -> Attr {
AttrNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> AttrNode {
AttrNode { syntax: self.syntax.owned() }
2018-08-16 11:51:40 +02:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> Attr<'a> {
pub fn value(self) -> Option<TokenTree<'a>> {
super::child_opt(self)
}
}
2018-11-01 11:41:04 +01:00
2018-11-06 19:52:00 +01:00
// BinExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct BinExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type BinExpr<'a> = BinExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<BinExprNode<R1>> for BinExprNode<R2> {
fn eq(&self, other: &BinExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for BinExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for BinExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for BinExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
BIN_EXPR => Some(BinExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> BinExprNode<R> {
pub fn borrowed(&self) -> BinExpr {
BinExprNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> BinExprNode {
BinExprNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> BinExpr<'a> {}
// BindPat
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct BindPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-26 11:09:28 +02:00
}
2018-11-06 19:52:00 +01:00
pub type BindPat<'a> = BindPatNode<RefRoot<'a>>;
2018-08-26 11:09:28 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<BindPatNode<R1>> for BindPatNode<R2> {
fn eq(&self, other: &BindPatNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for BindPatNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for BindPatNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-26 11:09:28 +02:00
impl<'a> AstNode<'a> for BindPat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
BIND_PAT => Some(BindPat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> BindPatNode<R> {
pub fn borrowed(&self) -> BindPat {
BindPatNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> BindPatNode {
BindPatNode { syntax: self.syntax.owned() }
}
}
2018-08-26 11:09:28 +02:00
impl<'a> ast::NameOwner<'a> for BindPat<'a> {}
impl<'a> BindPat<'a> {}
2018-08-25 12:42:40 +02:00
// Block
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct BlockNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type Block<'a> = BlockNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<BlockNode<R1>> for BlockNode<R2> {
fn eq(&self, other: &BlockNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for BlockNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for BlockNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for Block<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
BLOCK => Some(Block { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> BlockNode<R> {
pub fn borrowed(&self) -> Block {
BlockNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> BlockNode {
BlockNode { syntax: self.syntax.owned() }
}
}
2018-08-26 11:09:28 +02:00
impl<'a> Block<'a> {
2018-08-27 09:12:28 +02:00
pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a {
2018-08-26 11:09:28 +02:00
super::children(self)
}
pub fn expr(self) -> Option<Expr<'a>> {
2018-08-27 09:12:28 +02:00
super::child_opt(self)
}
2018-08-26 11:09:28 +02:00
}
2018-08-25 12:42:40 +02:00
// BlockExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct BlockExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type BlockExpr<'a> = BlockExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<BlockExprNode<R1>> for BlockExprNode<R2> {
fn eq(&self, other: &BlockExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for BlockExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for BlockExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for BlockExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
BLOCK_EXPR => Some(BlockExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> BlockExprNode<R> {
pub fn borrowed(&self) -> BlockExpr {
BlockExprNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> BlockExprNode {
BlockExprNode { syntax: self.syntax.owned() }
2018-08-27 11:22:09 +02:00
}
}
2018-08-25 12:42:40 +02:00
2018-11-06 19:52:00 +01:00
impl<'a> BlockExpr<'a> {
pub fn block(self) -> Option<Block<'a>> {
super::child_opt(self)
}
}
2018-11-01 11:41:04 +01:00
2018-11-06 19:52:00 +01:00
// BreakExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct BreakExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type BreakExpr<'a> = BreakExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<BreakExprNode<R1>> for BreakExprNode<R2> {
fn eq(&self, other: &BreakExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for BreakExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for BreakExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for BreakExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
BREAK_EXPR => Some(BreakExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> BreakExprNode<R> {
pub fn borrowed(&self) -> BreakExpr {
BreakExprNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> BreakExprNode {
BreakExprNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> BreakExpr<'a> {}
2018-11-11 20:27:00 +01:00
// Byte
#[derive(Debug, Clone, Copy,)]
pub struct ByteNode<R: TreeRoot<RaTypes> = OwnedRoot> {
pub(crate) syntax: SyntaxNode<R>,
}
pub type Byte<'a> = ByteNode<RefRoot<'a>>;
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ByteNode<R1>> for ByteNode<R2> {
fn eq(&self, other: &ByteNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ByteNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ByteNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
impl<'a> AstNode<'a> for Byte<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
BYTE => Some(Byte { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<R: TreeRoot<RaTypes>> ByteNode<R> {
pub fn borrowed(&self) -> Byte {
ByteNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> ByteNode {
ByteNode { syntax: self.syntax.owned() }
}
}
impl<'a> Byte<'a> {}
2018-11-11 20:41:43 +01:00
// ByteString
#[derive(Debug, Clone, Copy,)]
pub struct ByteStringNode<R: TreeRoot<RaTypes> = OwnedRoot> {
pub(crate) syntax: SyntaxNode<R>,
}
pub type ByteString<'a> = ByteStringNode<RefRoot<'a>>;
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ByteStringNode<R1>> for ByteStringNode<R2> {
fn eq(&self, other: &ByteStringNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ByteStringNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ByteStringNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
impl<'a> AstNode<'a> for ByteString<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
BYTE_STRING => Some(ByteString { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<R: TreeRoot<RaTypes>> ByteStringNode<R> {
pub fn borrowed(&self) -> ByteString {
ByteStringNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> ByteStringNode {
ByteStringNode { syntax: self.syntax.owned() }
}
}
impl<'a> ByteString<'a> {}
2018-11-06 19:52:00 +01:00
// CallExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct CallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type CallExpr<'a> = CallExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<CallExprNode<R1>> for CallExprNode<R2> {
fn eq(&self, other: &CallExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for CallExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for CallExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for CallExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
CALL_EXPR => Some(CallExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> CallExprNode<R> {
pub fn borrowed(&self) -> CallExpr {
CallExprNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> CallExprNode {
CallExprNode { syntax: self.syntax.owned() }
}
}
2018-09-03 01:01:43 +02:00
impl<'a> ast::ArgListOwner<'a> for CallExpr<'a> {}
impl<'a> CallExpr<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
2018-08-28 22:59:57 +02:00
super::child_opt(self)
}
}
2018-08-25 12:42:40 +02:00
// CastExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct CastExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type CastExpr<'a> = CastExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<CastExprNode<R1>> for CastExprNode<R2> {
fn eq(&self, other: &CastExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for CastExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for CastExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for CastExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
CAST_EXPR => Some(CastExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> CastExprNode<R> {
pub fn borrowed(&self) -> CastExpr {
CastExprNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> CastExprNode {
CastExprNode { syntax: self.syntax.owned() }
}
}
2018-11-06 19:52:00 +01:00
2018-12-20 21:56:28 +01:00
impl<'a> CastExpr<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
super::child_opt(self)
}
pub fn type_ref(self) -> Option<TypeRef<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// Char
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct CharNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
}
2018-11-06 19:52:00 +01:00
pub type Char<'a> = CharNode<RefRoot<'a>>;
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<CharNode<R1>> for CharNode<R2> {
fn eq(&self, other: &CharNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for CharNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for CharNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
impl<'a> AstNode<'a> for Char<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
CHAR => Some(Char { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> CharNode<R> {
pub fn borrowed(&self) -> Char {
CharNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> CharNode {
CharNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> Char<'a> {}
// Comment
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct CommentNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-10-11 16:25:35 +02:00
}
2018-11-06 19:52:00 +01:00
pub type Comment<'a> = CommentNode<RefRoot<'a>>;
2018-10-11 16:25:35 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<CommentNode<R1>> for CommentNode<R2> {
fn eq(&self, other: &CommentNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for CommentNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for CommentNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-10-11 16:25:35 +02:00
impl<'a> AstNode<'a> for Comment<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
COMMENT => Some(Comment { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> CommentNode<R> {
pub fn borrowed(&self) -> Comment {
CommentNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> CommentNode {
CommentNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> Comment<'a> {}
// Condition
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ConditionNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-27 11:22:09 +02:00
}
2018-11-06 19:52:00 +01:00
pub type Condition<'a> = ConditionNode<RefRoot<'a>>;
2018-08-27 11:22:09 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ConditionNode<R1>> for ConditionNode<R2> {
fn eq(&self, other: &ConditionNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ConditionNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ConditionNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-27 11:22:09 +02:00
impl<'a> AstNode<'a> for Condition<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
CONDITION => Some(Condition { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ConditionNode<R> {
pub fn borrowed(&self) -> Condition {
ConditionNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> ConditionNode {
ConditionNode { syntax: self.syntax.owned() }
}
}
impl<'a> Condition<'a> {
pub fn pat(self) -> Option<Pat<'a>> {
2018-08-27 11:22:09 +02:00
super::child_opt(self)
}
pub fn expr(self) -> Option<Expr<'a>> {
2018-08-27 11:22:09 +02:00
super::child_opt(self)
}
}
2018-08-13 17:36:16 +02:00
// ConstDef
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ConstDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-11 10:03:22 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ConstDef<'a> = ConstDefNode<RefRoot<'a>>;
2018-08-11 10:03:22 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ConstDefNode<R1>> for ConstDefNode<R2> {
fn eq(&self, other: &ConstDefNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ConstDefNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ConstDefNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for ConstDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 10:03:22 +02:00
match syntax.kind() {
2018-08-13 17:36:16 +02:00
CONST_DEF => Some(ConstDef { syntax }),
2018-08-11 10:03:22 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 10:03:22 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ConstDefNode<R> {
pub fn borrowed(&self) -> ConstDef {
ConstDefNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> ConstDefNode {
ConstDefNode { syntax: self.syntax.owned() }
}
}
2018-08-17 21:00:13 +02:00
impl<'a> ast::NameOwner<'a> for ConstDef<'a> {}
2018-08-22 15:46:42 +02:00
impl<'a> ast::TypeParamsOwner<'a> for ConstDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {}
2018-11-02 14:59:07 +01:00
impl<'a> ast::DocCommentsOwner<'a> for ConstDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> ConstDef<'a> {}
2018-08-11 10:03:22 +02:00
2018-08-25 12:42:40 +02:00
// ContinueExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ContinueExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ContinueExpr<'a> = ContinueExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ContinueExprNode<R1>> for ContinueExprNode<R2> {
fn eq(&self, other: &ContinueExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ContinueExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ContinueExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for ContinueExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
CONTINUE_EXPR => Some(ContinueExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ContinueExprNode<R> {
pub fn borrowed(&self) -> ContinueExpr {
ContinueExprNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> ContinueExprNode {
ContinueExprNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> ContinueExpr<'a> {}
// DynTraitType
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct DynTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
pub type DynTraitType<'a> = DynTraitTypeNode<RefRoot<'a>>;
2018-08-14 11:38:20 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<DynTraitTypeNode<R1>> for DynTraitTypeNode<R2> {
fn eq(&self, other: &DynTraitTypeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for DynTraitTypeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for DynTraitTypeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for DynTraitType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
DYN_TRAIT_TYPE => Some(DynTraitType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> DynTraitTypeNode<R> {
pub fn borrowed(&self) -> DynTraitType {
DynTraitTypeNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> DynTraitTypeNode {
DynTraitTypeNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> DynTraitType<'a> {}
// EnumDef
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct EnumDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-11 09:56:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type EnumDef<'a> = EnumDefNode<RefRoot<'a>>;
2018-08-11 09:56:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<EnumDefNode<R1>> for EnumDefNode<R2> {
fn eq(&self, other: &EnumDefNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for EnumDefNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for EnumDefNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for EnumDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 09:56:40 +02:00
match syntax.kind() {
2018-08-13 17:36:16 +02:00
ENUM_DEF => Some(EnumDef { syntax }),
2018-08-11 09:56:40 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 09:56:40 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> EnumDefNode<R> {
pub fn borrowed(&self) -> EnumDef {
EnumDefNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> EnumDefNode {
EnumDefNode { syntax: self.syntax.owned() }
}
}
2018-08-17 21:00:13 +02:00
impl<'a> ast::NameOwner<'a> for EnumDef<'a> {}
2018-08-22 15:46:42 +02:00
impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {}
2018-11-02 14:59:07 +01:00
impl<'a> ast::DocCommentsOwner<'a> for EnumDef<'a> {}
impl<'a> EnumDef<'a> {
pub fn variant_list(self) -> Option<EnumVariantList<'a>> {
super::child_opt(self)
}
}
// EnumVariant
#[derive(Debug, Clone, Copy,)]
pub struct EnumVariantNode<R: TreeRoot<RaTypes> = OwnedRoot> {
pub(crate) syntax: SyntaxNode<R>,
}
pub type EnumVariant<'a> = EnumVariantNode<RefRoot<'a>>;
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<EnumVariantNode<R1>> for EnumVariantNode<R2> {
fn eq(&self, other: &EnumVariantNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for EnumVariantNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for EnumVariantNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
impl<'a> AstNode<'a> for EnumVariant<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
ENUM_VARIANT => Some(EnumVariant { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<R: TreeRoot<RaTypes>> EnumVariantNode<R> {
pub fn borrowed(&self) -> EnumVariant {
EnumVariantNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> EnumVariantNode {
EnumVariantNode { syntax: self.syntax.owned() }
}
}
impl<'a> ast::NameOwner<'a> for EnumVariant<'a> {}
impl<'a> EnumVariant<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
super::child_opt(self)
}
}
// EnumVariantList
#[derive(Debug, Clone, Copy,)]
pub struct EnumVariantListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
pub(crate) syntax: SyntaxNode<R>,
}
pub type EnumVariantList<'a> = EnumVariantListNode<RefRoot<'a>>;
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<EnumVariantListNode<R1>> for EnumVariantListNode<R2> {
fn eq(&self, other: &EnumVariantListNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for EnumVariantListNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for EnumVariantListNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
impl<'a> AstNode<'a> for EnumVariantList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
ENUM_VARIANT_LIST => Some(EnumVariantList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<R: TreeRoot<RaTypes>> EnumVariantListNode<R> {
pub fn borrowed(&self) -> EnumVariantList {
EnumVariantListNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> EnumVariantListNode {
EnumVariantListNode { syntax: self.syntax.owned() }
}
}
impl<'a> EnumVariantList<'a> {
pub fn variants(self) -> impl Iterator<Item = EnumVariant<'a>> + 'a {
super::children(self)
}
}
2018-08-11 09:56:40 +02:00
2018-08-25 12:42:40 +02:00
// Expr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2018-08-25 12:42:40 +02:00
pub enum Expr<'a> {
TupleExpr(TupleExpr<'a>),
ArrayExpr(ArrayExpr<'a>),
ParenExpr(ParenExpr<'a>),
PathExpr(PathExpr<'a>),
LambdaExpr(LambdaExpr<'a>),
IfExpr(IfExpr<'a>),
LoopExpr(LoopExpr<'a>),
ForExpr(ForExpr<'a>),
WhileExpr(WhileExpr<'a>),
ContinueExpr(ContinueExpr<'a>),
BreakExpr(BreakExpr<'a>),
Label(Label<'a>),
BlockExpr(BlockExpr<'a>),
ReturnExpr(ReturnExpr<'a>),
MatchExpr(MatchExpr<'a>),
MatchArmList(MatchArmList<'a>),
MatchArm(MatchArm<'a>),
MatchGuard(MatchGuard<'a>),
StructLit(StructLit<'a>),
NamedFieldList(NamedFieldList<'a>),
NamedField(NamedField<'a>),
CallExpr(CallExpr<'a>),
IndexExpr(IndexExpr<'a>),
MethodCallExpr(MethodCallExpr<'a>),
FieldExpr(FieldExpr<'a>),
TryExpr(TryExpr<'a>),
CastExpr(CastExpr<'a>),
RefExpr(RefExpr<'a>),
PrefixExpr(PrefixExpr<'a>),
RangeExpr(RangeExpr<'a>),
BinExpr(BinExpr<'a>),
2018-08-28 13:21:37 +02:00
Literal(Literal<'a>),
2018-08-25 12:42:40 +02:00
}
impl<'a> AstNode<'a> for Expr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
TUPLE_EXPR => Some(Expr::TupleExpr(TupleExpr { syntax })),
ARRAY_EXPR => Some(Expr::ArrayExpr(ArrayExpr { syntax })),
PAREN_EXPR => Some(Expr::ParenExpr(ParenExpr { syntax })),
PATH_EXPR => Some(Expr::PathExpr(PathExpr { syntax })),
LAMBDA_EXPR => Some(Expr::LambdaExpr(LambdaExpr { syntax })),
IF_EXPR => Some(Expr::IfExpr(IfExpr { syntax })),
LOOP_EXPR => Some(Expr::LoopExpr(LoopExpr { syntax })),
FOR_EXPR => Some(Expr::ForExpr(ForExpr { syntax })),
WHILE_EXPR => Some(Expr::WhileExpr(WhileExpr { syntax })),
CONTINUE_EXPR => Some(Expr::ContinueExpr(ContinueExpr { syntax })),
BREAK_EXPR => Some(Expr::BreakExpr(BreakExpr { syntax })),
LABEL => Some(Expr::Label(Label { syntax })),
BLOCK_EXPR => Some(Expr::BlockExpr(BlockExpr { syntax })),
RETURN_EXPR => Some(Expr::ReturnExpr(ReturnExpr { syntax })),
MATCH_EXPR => Some(Expr::MatchExpr(MatchExpr { syntax })),
MATCH_ARM_LIST => Some(Expr::MatchArmList(MatchArmList { syntax })),
MATCH_ARM => Some(Expr::MatchArm(MatchArm { syntax })),
MATCH_GUARD => Some(Expr::MatchGuard(MatchGuard { syntax })),
STRUCT_LIT => Some(Expr::StructLit(StructLit { syntax })),
NAMED_FIELD_LIST => Some(Expr::NamedFieldList(NamedFieldList { syntax })),
NAMED_FIELD => Some(Expr::NamedField(NamedField { syntax })),
CALL_EXPR => Some(Expr::CallExpr(CallExpr { syntax })),
INDEX_EXPR => Some(Expr::IndexExpr(IndexExpr { syntax })),
METHOD_CALL_EXPR => Some(Expr::MethodCallExpr(MethodCallExpr { syntax })),
FIELD_EXPR => Some(Expr::FieldExpr(FieldExpr { syntax })),
TRY_EXPR => Some(Expr::TryExpr(TryExpr { syntax })),
CAST_EXPR => Some(Expr::CastExpr(CastExpr { syntax })),
REF_EXPR => Some(Expr::RefExpr(RefExpr { syntax })),
PREFIX_EXPR => Some(Expr::PrefixExpr(PrefixExpr { syntax })),
RANGE_EXPR => Some(Expr::RangeExpr(RangeExpr { syntax })),
BIN_EXPR => Some(Expr::BinExpr(BinExpr { syntax })),
2018-08-28 13:21:37 +02:00
LITERAL => Some(Expr::Literal(Literal { syntax })),
2018-08-25 12:42:40 +02:00
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> {
match self {
Expr::TupleExpr(inner) => inner.syntax(),
Expr::ArrayExpr(inner) => inner.syntax(),
Expr::ParenExpr(inner) => inner.syntax(),
Expr::PathExpr(inner) => inner.syntax(),
Expr::LambdaExpr(inner) => inner.syntax(),
Expr::IfExpr(inner) => inner.syntax(),
Expr::LoopExpr(inner) => inner.syntax(),
Expr::ForExpr(inner) => inner.syntax(),
Expr::WhileExpr(inner) => inner.syntax(),
Expr::ContinueExpr(inner) => inner.syntax(),
Expr::BreakExpr(inner) => inner.syntax(),
Expr::Label(inner) => inner.syntax(),
Expr::BlockExpr(inner) => inner.syntax(),
Expr::ReturnExpr(inner) => inner.syntax(),
Expr::MatchExpr(inner) => inner.syntax(),
Expr::MatchArmList(inner) => inner.syntax(),
Expr::MatchArm(inner) => inner.syntax(),
Expr::MatchGuard(inner) => inner.syntax(),
Expr::StructLit(inner) => inner.syntax(),
Expr::NamedFieldList(inner) => inner.syntax(),
Expr::NamedField(inner) => inner.syntax(),
Expr::CallExpr(inner) => inner.syntax(),
Expr::IndexExpr(inner) => inner.syntax(),
Expr::MethodCallExpr(inner) => inner.syntax(),
Expr::FieldExpr(inner) => inner.syntax(),
Expr::TryExpr(inner) => inner.syntax(),
Expr::CastExpr(inner) => inner.syntax(),
Expr::RefExpr(inner) => inner.syntax(),
Expr::PrefixExpr(inner) => inner.syntax(),
Expr::RangeExpr(inner) => inner.syntax(),
Expr::BinExpr(inner) => inner.syntax(),
2018-08-28 13:21:37 +02:00
Expr::Literal(inner) => inner.syntax(),
2018-08-25 12:42:40 +02:00
}
}
}
impl<'a> Expr<'a> {}
2018-08-27 09:01:31 +02:00
// ExprStmt
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ExprStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-27 09:01:31 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ExprStmt<'a> = ExprStmtNode<RefRoot<'a>>;
2018-08-27 09:01:31 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ExprStmtNode<R1>> for ExprStmtNode<R2> {
fn eq(&self, other: &ExprStmtNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ExprStmtNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ExprStmtNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-27 09:01:31 +02:00
impl<'a> AstNode<'a> for ExprStmt<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
EXPR_STMT => Some(ExprStmt { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ExprStmtNode<R> {
pub fn borrowed(&self) -> ExprStmt {
ExprStmtNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> ExprStmtNode {
ExprStmtNode { syntax: self.syntax.owned() }
2018-08-27 11:22:09 +02:00
}
}
2018-08-27 09:01:31 +02:00
2018-11-06 19:52:00 +01:00
impl<'a> ExprStmt<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
super::child_opt(self)
}
}
2018-11-01 11:41:04 +01:00
2018-11-06 19:52:00 +01:00
// ExternCrateItem
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ExternCrateItemNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-28 10:12:42 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ExternCrateItem<'a> = ExternCrateItemNode<RefRoot<'a>>;
2018-08-28 10:12:42 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ExternCrateItemNode<R1>> for ExternCrateItemNode<R2> {
fn eq(&self, other: &ExternCrateItemNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ExternCrateItemNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ExternCrateItemNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-28 10:12:42 +02:00
impl<'a> AstNode<'a> for ExternCrateItem<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
EXTERN_CRATE_ITEM => Some(ExternCrateItem { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ExternCrateItemNode<R> {
pub fn borrowed(&self) -> ExternCrateItem {
ExternCrateItemNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> ExternCrateItemNode {
ExternCrateItemNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> ExternCrateItem<'a> {}
// FieldExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct FieldExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type FieldExpr<'a> = FieldExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<FieldExprNode<R1>> for FieldExprNode<R2> {
fn eq(&self, other: &FieldExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for FieldExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for FieldExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for FieldExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
FIELD_EXPR => Some(FieldExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> FieldExprNode<R> {
pub fn borrowed(&self) -> FieldExpr {
FieldExprNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> FieldExprNode {
FieldExprNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
2018-12-25 13:54:38 +01:00
impl<'a> FieldExpr<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
super::child_opt(self)
}
pub fn name_ref(self) -> Option<NameRef<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// FieldPatList
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct FieldPatListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-26 11:09:28 +02:00
}
2018-11-06 19:52:00 +01:00
pub type FieldPatList<'a> = FieldPatListNode<RefRoot<'a>>;
2018-08-26 11:09:28 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<FieldPatListNode<R1>> for FieldPatListNode<R2> {
fn eq(&self, other: &FieldPatListNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for FieldPatListNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for FieldPatListNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-26 11:09:28 +02:00
impl<'a> AstNode<'a> for FieldPatList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
FIELD_PAT_LIST => Some(FieldPatList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> FieldPatListNode<R> {
pub fn borrowed(&self) -> FieldPatList {
FieldPatListNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> FieldPatListNode {
FieldPatListNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> FieldPatList<'a> {}
// FnDef
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct FnDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-09 16:43:39 +02:00
}
2018-11-06 19:52:00 +01:00
pub type FnDef<'a> = FnDefNode<RefRoot<'a>>;
2018-08-09 16:43:39 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<FnDefNode<R1>> for FnDefNode<R2> {
fn eq(&self, other: &FnDefNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for FnDefNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for FnDefNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for FnDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-09 16:43:39 +02:00
match syntax.kind() {
2018-08-13 17:36:16 +02:00
FN_DEF => Some(FnDef { syntax }),
2018-08-09 16:43:39 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-09 16:43:39 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> FnDefNode<R> {
pub fn borrowed(&self) -> FnDef {
FnDefNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> FnDefNode {
FnDefNode { syntax: self.syntax.owned() }
}
}
2018-08-17 21:00:13 +02:00
impl<'a> ast::NameOwner<'a> for FnDef<'a> {}
2018-08-22 15:46:42 +02:00
impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {}
impl<'a> ast::DocCommentsOwner<'a> for FnDef<'a> {}
impl<'a> FnDef<'a> {
pub fn param_list(self) -> Option<ParamList<'a>> {
2018-08-26 11:09:28 +02:00
super::child_opt(self)
}
pub fn body(self) -> Option<Block<'a>> {
2018-08-27 09:01:31 +02:00
super::child_opt(self)
}
pub fn ret_type(self) -> Option<RetType<'a>> {
2018-08-28 20:11:17 +02:00
super::child_opt(self)
}
2018-08-26 11:09:28 +02:00
}
2018-08-11 08:55:32 +02:00
2018-08-14 11:38:20 +02:00
// FnPointerType
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct FnPointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
pub type FnPointerType<'a> = FnPointerTypeNode<RefRoot<'a>>;
2018-08-14 11:38:20 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<FnPointerTypeNode<R1>> for FnPointerTypeNode<R2> {
fn eq(&self, other: &FnPointerTypeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for FnPointerTypeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for FnPointerTypeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for FnPointerType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
FN_POINTER_TYPE => Some(FnPointerType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> FnPointerTypeNode<R> {
pub fn borrowed(&self) -> FnPointerType {
FnPointerTypeNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> FnPointerTypeNode {
FnPointerTypeNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> FnPointerType<'a> {
pub fn param_list(self) -> Option<ParamList<'a>> {
super::child_opt(self)
}
pub fn ret_type(self) -> Option<RetType<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// ForExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ForExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ForExpr<'a> = ForExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ForExprNode<R1>> for ForExprNode<R2> {
fn eq(&self, other: &ForExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ForExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ForExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for ForExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
FOR_EXPR => Some(ForExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ForExprNode<R> {
pub fn borrowed(&self) -> ForExpr {
ForExprNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> ForExprNode {
ForExprNode { syntax: self.syntax.owned() }
}
}
2018-08-30 20:32:12 +02:00
impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {}
impl<'a> ForExpr<'a> {
pub fn pat(self) -> Option<Pat<'a>> {
2018-08-27 21:03:19 +02:00
super::child_opt(self)
}
pub fn iterable(self) -> Option<Expr<'a>> {
2018-08-27 21:03:19 +02:00
super::child_opt(self)
}
2018-08-27 11:22:09 +02:00
}
2018-08-25 12:42:40 +02:00
2018-08-14 11:38:20 +02:00
// ForType
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ForTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ForType<'a> = ForTypeNode<RefRoot<'a>>;
2018-08-14 11:38:20 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ForTypeNode<R1>> for ForTypeNode<R2> {
fn eq(&self, other: &ForTypeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ForTypeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ForTypeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for ForType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
FOR_TYPE => Some(ForType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ForTypeNode<R> {
pub fn borrowed(&self) -> ForType {
ForTypeNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> ForTypeNode {
ForTypeNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> ForType<'a> {
pub fn type_ref(self) -> Option<TypeRef<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// IfExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct IfExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type IfExpr<'a> = IfExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<IfExprNode<R1>> for IfExprNode<R2> {
fn eq(&self, other: &IfExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for IfExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for IfExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for IfExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
IF_EXPR => Some(IfExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> IfExprNode<R> {
pub fn borrowed(&self) -> IfExpr {
IfExprNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> IfExprNode {
IfExprNode { syntax: self.syntax.owned() }
2018-08-27 11:22:09 +02:00
}
}
2018-08-25 12:42:40 +02:00
2018-11-06 19:52:00 +01:00
impl<'a> IfExpr<'a> {
pub fn condition(self) -> Option<Condition<'a>> {
super::child_opt(self)
}
}
2018-11-01 11:41:04 +01:00
2018-11-06 19:52:00 +01:00
// ImplItem
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ImplItemNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-14 10:20:09 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ImplItem<'a> = ImplItemNode<RefRoot<'a>>;
2018-08-14 10:20:09 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ImplItemNode<R1>> for ImplItemNode<R2> {
fn eq(&self, other: &ImplItemNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ImplItemNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ImplItemNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for ImplItem<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 10:20:09 +02:00
match syntax.kind() {
IMPL_ITEM => Some(ImplItem { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 10:20:09 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ImplItemNode<R> {
pub fn borrowed(&self) -> ImplItem {
ImplItemNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> ImplItemNode {
ImplItemNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> ImplItem<'a> {}
// ImplTraitType
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ImplTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ImplTraitType<'a> = ImplTraitTypeNode<RefRoot<'a>>;
2018-08-14 11:38:20 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ImplTraitTypeNode<R1>> for ImplTraitTypeNode<R2> {
fn eq(&self, other: &ImplTraitTypeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ImplTraitTypeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ImplTraitTypeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for ImplTraitType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
IMPL_TRAIT_TYPE => Some(ImplTraitType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ImplTraitTypeNode<R> {
pub fn borrowed(&self) -> ImplTraitType {
ImplTraitTypeNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> ImplTraitTypeNode {
ImplTraitTypeNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> ImplTraitType<'a> {}
// IndexExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct IndexExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type IndexExpr<'a> = IndexExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<IndexExprNode<R1>> for IndexExprNode<R2> {
fn eq(&self, other: &IndexExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for IndexExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for IndexExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for IndexExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
INDEX_EXPR => Some(IndexExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> IndexExprNode<R> {
pub fn borrowed(&self) -> IndexExpr {
IndexExprNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> IndexExprNode {
IndexExprNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> IndexExpr<'a> {}
// ItemList
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ItemListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-09-03 14:10:06 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ItemList<'a> = ItemListNode<RefRoot<'a>>;
2018-09-03 14:10:06 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ItemListNode<R1>> for ItemListNode<R2> {
fn eq(&self, other: &ItemListNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ItemListNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ItemListNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-09-03 14:10:06 +02:00
impl<'a> AstNode<'a> for ItemList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
ITEM_LIST => Some(ItemList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ItemListNode<R> {
pub fn borrowed(&self) -> ItemList {
ItemListNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> ItemListNode {
ItemListNode { syntax: self.syntax.owned() }
}
}
2018-09-03 14:46:14 +02:00
impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {}
2018-09-08 00:35:20 +02:00
impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {}
impl<'a> ItemList<'a> {}
2018-09-03 14:10:06 +02:00
2018-08-25 12:42:40 +02:00
// Label
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct LabelNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type Label<'a> = LabelNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LabelNode<R1>> for LabelNode<R2> {
fn eq(&self, other: &LabelNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for LabelNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for LabelNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for Label<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
LABEL => Some(Label { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> LabelNode<R> {
pub fn borrowed(&self) -> Label {
LabelNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> LabelNode {
LabelNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> Label<'a> {}
// LambdaExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct LambdaExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type LambdaExpr<'a> = LambdaExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LambdaExprNode<R1>> for LambdaExprNode<R2> {
fn eq(&self, other: &LambdaExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for LambdaExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for LambdaExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for LambdaExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
LAMBDA_EXPR => Some(LambdaExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> LambdaExprNode<R> {
pub fn borrowed(&self) -> LambdaExpr {
LambdaExprNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> LambdaExprNode {
LambdaExprNode { syntax: self.syntax.owned() }
}
}
impl<'a> LambdaExpr<'a> {
pub fn param_list(self) -> Option<ParamList<'a>> {
2018-08-28 22:59:57 +02:00
super::child_opt(self)
}
pub fn body(self) -> Option<Expr<'a>> {
2018-08-28 22:59:57 +02:00
super::child_opt(self)
}
}
2018-08-25 12:42:40 +02:00
2018-08-26 11:09:28 +02:00
// LetStmt
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct LetStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-26 11:09:28 +02:00
}
2018-11-06 19:52:00 +01:00
pub type LetStmt<'a> = LetStmtNode<RefRoot<'a>>;
2018-08-26 11:09:28 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LetStmtNode<R1>> for LetStmtNode<R2> {
fn eq(&self, other: &LetStmtNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for LetStmtNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for LetStmtNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-26 11:09:28 +02:00
impl<'a> AstNode<'a> for LetStmt<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
LET_STMT => Some(LetStmt { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> LetStmtNode<R> {
pub fn borrowed(&self) -> LetStmt {
LetStmtNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> LetStmtNode {
LetStmtNode { syntax: self.syntax.owned() }
}
}
impl<'a> LetStmt<'a> {
pub fn pat(self) -> Option<Pat<'a>> {
2018-08-26 11:09:28 +02:00
super::child_opt(self)
}
2018-12-23 13:22:29 +01:00
pub fn type_ref(self) -> Option<TypeRef<'a>> {
super::child_opt(self)
}
pub fn initializer(self) -> Option<Expr<'a>> {
2018-08-27 09:01:31 +02:00
super::child_opt(self)
}
2018-08-26 11:09:28 +02:00
}
2018-08-28 22:59:57 +02:00
// Lifetime
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct LifetimeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-28 22:59:57 +02:00
}
2018-11-06 19:52:00 +01:00
pub type Lifetime<'a> = LifetimeNode<RefRoot<'a>>;
2018-08-28 22:59:57 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LifetimeNode<R1>> for LifetimeNode<R2> {
fn eq(&self, other: &LifetimeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for LifetimeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for LifetimeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-28 22:59:57 +02:00
impl<'a> AstNode<'a> for Lifetime<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
LIFETIME => Some(Lifetime { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> LifetimeNode<R> {
pub fn borrowed(&self) -> Lifetime {
LifetimeNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> LifetimeNode {
LifetimeNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> Lifetime<'a> {}
// LifetimeParam
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct LifetimeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-28 22:59:57 +02:00
}
2018-11-06 19:52:00 +01:00
pub type LifetimeParam<'a> = LifetimeParamNode<RefRoot<'a>>;
2018-08-28 22:59:57 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LifetimeParamNode<R1>> for LifetimeParamNode<R2> {
fn eq(&self, other: &LifetimeParamNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for LifetimeParamNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for LifetimeParamNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-28 22:59:57 +02:00
impl<'a> AstNode<'a> for LifetimeParam<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
LIFETIME_PARAM => Some(LifetimeParam { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> LifetimeParamNode<R> {
pub fn borrowed(&self) -> LifetimeParam {
LifetimeParamNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> LifetimeParamNode {
LifetimeParamNode { syntax: self.syntax.owned() }
2018-08-28 22:59:57 +02:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> LifetimeParam<'a> {
pub fn lifetime(self) -> Option<Lifetime<'a>> {
super::child_opt(self)
}
}
2018-11-01 11:41:04 +01:00
2018-11-06 19:52:00 +01:00
// Literal
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct LiteralNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-28 13:21:37 +02:00
}
2018-11-06 19:52:00 +01:00
pub type Literal<'a> = LiteralNode<RefRoot<'a>>;
2018-08-28 13:21:37 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LiteralNode<R1>> for LiteralNode<R2> {
fn eq(&self, other: &LiteralNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for LiteralNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for LiteralNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-28 13:21:37 +02:00
impl<'a> AstNode<'a> for Literal<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
LITERAL => Some(Literal { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> LiteralNode<R> {
pub fn borrowed(&self) -> Literal {
LiteralNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> LiteralNode {
LiteralNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> Literal<'a> {}
// LoopExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct LoopExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type LoopExpr<'a> = LoopExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<LoopExprNode<R1>> for LoopExprNode<R2> {
fn eq(&self, other: &LoopExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for LoopExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for LoopExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for LoopExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
LOOP_EXPR => Some(LoopExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> LoopExprNode<R> {
pub fn borrowed(&self) -> LoopExpr {
LoopExprNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> LoopExprNode {
LoopExprNode { syntax: self.syntax.owned() }
}
}
2018-08-30 20:32:12 +02:00
impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {}
impl<'a> LoopExpr<'a> {}
2018-08-25 12:42:40 +02:00
// MatchArm
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct MatchArmNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type MatchArm<'a> = MatchArmNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<MatchArmNode<R1>> for MatchArmNode<R2> {
fn eq(&self, other: &MatchArmNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for MatchArmNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for MatchArmNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for MatchArm<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
MATCH_ARM => Some(MatchArm { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> MatchArmNode<R> {
pub fn borrowed(&self) -> MatchArm {
MatchArmNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> MatchArmNode {
MatchArmNode { syntax: self.syntax.owned() }
}
}
2018-09-03 00:51:46 +02:00
impl<'a> MatchArm<'a> {
pub fn pats(self) -> impl Iterator<Item = Pat<'a>> + 'a {
super::children(self)
}
pub fn guard(self) -> Option<MatchGuard<'a>> {
2018-09-03 00:51:46 +02:00
super::child_opt(self)
}
pub fn expr(self) -> Option<Expr<'a>> {
2018-09-03 00:51:46 +02:00
super::child_opt(self)
}
}
2018-08-25 12:42:40 +02:00
// MatchArmList
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct MatchArmListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type MatchArmList<'a> = MatchArmListNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<MatchArmListNode<R1>> for MatchArmListNode<R2> {
fn eq(&self, other: &MatchArmListNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for MatchArmListNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for MatchArmListNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for MatchArmList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
MATCH_ARM_LIST => Some(MatchArmList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> MatchArmListNode<R> {
pub fn borrowed(&self) -> MatchArmList {
MatchArmListNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> MatchArmListNode {
MatchArmListNode { syntax: self.syntax.owned() }
2018-09-03 00:51:46 +02:00
}
}
2018-08-25 12:42:40 +02:00
2018-11-06 19:52:00 +01:00
impl<'a> MatchArmList<'a> {
pub fn arms(self) -> impl Iterator<Item = MatchArm<'a>> + 'a {
super::children(self)
}
}
2018-11-01 11:41:04 +01:00
2018-11-06 19:52:00 +01:00
// MatchExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct MatchExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type MatchExpr<'a> = MatchExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<MatchExprNode<R1>> for MatchExprNode<R2> {
fn eq(&self, other: &MatchExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for MatchExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for MatchExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for MatchExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
MATCH_EXPR => Some(MatchExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> MatchExprNode<R> {
pub fn borrowed(&self) -> MatchExpr {
MatchExprNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> MatchExprNode {
MatchExprNode { syntax: self.syntax.owned() }
}
}
impl<'a> MatchExpr<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
2018-09-03 00:51:46 +02:00
super::child_opt(self)
}
pub fn match_arm_list(self) -> Option<MatchArmList<'a>> {
2018-09-03 00:51:46 +02:00
super::child_opt(self)
}
}
2018-08-25 12:42:40 +02:00
// MatchGuard
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct MatchGuardNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type MatchGuard<'a> = MatchGuardNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<MatchGuardNode<R1>> for MatchGuardNode<R2> {
fn eq(&self, other: &MatchGuardNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for MatchGuardNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for MatchGuardNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for MatchGuard<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
MATCH_GUARD => Some(MatchGuard { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> MatchGuardNode<R> {
pub fn borrowed(&self) -> MatchGuard {
MatchGuardNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> MatchGuardNode {
MatchGuardNode { syntax: self.syntax.owned() }
}
}
2018-11-01 11:41:04 +01:00
2018-11-06 19:52:00 +01:00
impl<'a> MatchGuard<'a> {}
// MethodCallExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct MethodCallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type MethodCallExpr<'a> = MethodCallExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<MethodCallExprNode<R1>> for MethodCallExprNode<R2> {
fn eq(&self, other: &MethodCallExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for MethodCallExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for MethodCallExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for MethodCallExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
METHOD_CALL_EXPR => Some(MethodCallExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> MethodCallExprNode<R> {
pub fn borrowed(&self) -> MethodCallExpr {
MethodCallExprNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> MethodCallExprNode {
MethodCallExprNode { syntax: self.syntax.owned() }
}
}
2018-09-03 01:01:43 +02:00
impl<'a> ast::ArgListOwner<'a> for MethodCallExpr<'a> {}
impl<'a> MethodCallExpr<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
2018-09-03 01:01:43 +02:00
super::child_opt(self)
}
2018-12-25 15:15:40 +01:00
pub fn name_ref(self) -> Option<NameRef<'a>> {
super::child_opt(self)
}
2018-09-03 01:01:43 +02:00
}
2018-08-25 12:42:40 +02:00
2018-08-11 11:28:59 +02:00
// Module
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ModuleNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-11 10:03:22 +02:00
}
2018-11-06 19:52:00 +01:00
pub type Module<'a> = ModuleNode<RefRoot<'a>>;
2018-08-11 10:03:22 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ModuleNode<R1>> for ModuleNode<R2> {
fn eq(&self, other: &ModuleNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ModuleNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ModuleNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for Module<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 10:03:22 +02:00
match syntax.kind() {
MODULE => Some(Module { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 10:03:22 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ModuleNode<R> {
pub fn borrowed(&self) -> Module {
ModuleNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> ModuleNode {
ModuleNode { syntax: self.syntax.owned() }
}
}
2018-08-17 21:00:13 +02:00
impl<'a> ast::NameOwner<'a> for Module<'a> {}
impl<'a> ast::AttrsOwner<'a> for Module<'a> {}
2018-11-02 14:59:07 +01:00
impl<'a> ast::DocCommentsOwner<'a> for Module<'a> {}
impl<'a> Module<'a> {
pub fn item_list(self) -> Option<ItemList<'a>> {
2018-09-03 14:10:06 +02:00
super::child_opt(self)
2018-08-21 17:30:10 +02:00
}
}
2018-08-11 10:03:22 +02:00
2018-08-28 10:12:42 +02:00
// ModuleItem
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2018-08-28 10:12:42 +02:00
pub enum ModuleItem<'a> {
StructDef(StructDef<'a>),
EnumDef(EnumDef<'a>),
FnDef(FnDef<'a>),
TraitDef(TraitDef<'a>),
2018-09-01 11:30:53 +02:00
TypeDef(TypeDef<'a>),
2018-08-28 10:12:42 +02:00
ImplItem(ImplItem<'a>),
UseItem(UseItem<'a>),
ExternCrateItem(ExternCrateItem<'a>),
2018-08-28 18:35:09 +02:00
ConstDef(ConstDef<'a>),
StaticDef(StaticDef<'a>),
2018-08-30 19:37:33 +02:00
Module(Module<'a>),
2018-08-28 10:12:42 +02:00
}
impl<'a> AstNode<'a> for ModuleItem<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
STRUCT_DEF => Some(ModuleItem::StructDef(StructDef { syntax })),
ENUM_DEF => Some(ModuleItem::EnumDef(EnumDef { syntax })),
FN_DEF => Some(ModuleItem::FnDef(FnDef { syntax })),
TRAIT_DEF => Some(ModuleItem::TraitDef(TraitDef { syntax })),
2018-09-01 11:30:53 +02:00
TYPE_DEF => Some(ModuleItem::TypeDef(TypeDef { syntax })),
2018-08-28 10:12:42 +02:00
IMPL_ITEM => Some(ModuleItem::ImplItem(ImplItem { syntax })),
USE_ITEM => Some(ModuleItem::UseItem(UseItem { syntax })),
EXTERN_CRATE_ITEM => Some(ModuleItem::ExternCrateItem(ExternCrateItem { syntax })),
2018-08-28 18:35:09 +02:00
CONST_DEF => Some(ModuleItem::ConstDef(ConstDef { syntax })),
STATIC_DEF => Some(ModuleItem::StaticDef(StaticDef { syntax })),
2018-08-30 19:37:33 +02:00
MODULE => Some(ModuleItem::Module(Module { syntax })),
2018-08-28 10:12:42 +02:00
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> {
match self {
ModuleItem::StructDef(inner) => inner.syntax(),
ModuleItem::EnumDef(inner) => inner.syntax(),
ModuleItem::FnDef(inner) => inner.syntax(),
ModuleItem::TraitDef(inner) => inner.syntax(),
2018-09-01 11:30:53 +02:00
ModuleItem::TypeDef(inner) => inner.syntax(),
2018-08-28 10:12:42 +02:00
ModuleItem::ImplItem(inner) => inner.syntax(),
ModuleItem::UseItem(inner) => inner.syntax(),
ModuleItem::ExternCrateItem(inner) => inner.syntax(),
2018-08-28 18:35:09 +02:00
ModuleItem::ConstDef(inner) => inner.syntax(),
ModuleItem::StaticDef(inner) => inner.syntax(),
2018-08-30 19:37:33 +02:00
ModuleItem::Module(inner) => inner.syntax(),
2018-08-28 10:12:42 +02:00
}
}
}
impl<'a> ModuleItem<'a> {}
2018-08-11 11:28:59 +02:00
// Name
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct NameNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-09 16:43:39 +02:00
}
2018-11-06 19:52:00 +01:00
pub type Name<'a> = NameNode<RefRoot<'a>>;
2018-08-09 16:43:39 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NameNode<R1>> for NameNode<R2> {
fn eq(&self, other: &NameNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for NameNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for NameNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for Name<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-09 16:43:39 +02:00
match syntax.kind() {
NAME => Some(Name { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-09 16:43:39 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> NameNode<R> {
pub fn borrowed(&self) -> Name {
NameNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> NameNode {
NameNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> Name<'a> {}
// NameRef
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct NameRefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-13 15:35:17 +02:00
}
2018-11-06 19:52:00 +01:00
pub type NameRef<'a> = NameRefNode<RefRoot<'a>>;
2018-08-13 15:35:17 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NameRefNode<R1>> for NameRefNode<R2> {
fn eq(&self, other: &NameRefNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for NameRefNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for NameRefNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for NameRef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-13 15:35:17 +02:00
match syntax.kind() {
NAME_REF => Some(NameRef { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-13 15:35:17 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> NameRefNode<R> {
pub fn borrowed(&self) -> NameRef {
NameRefNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> NameRefNode {
NameRefNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> NameRef<'a> {}
// NamedField
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct NamedFieldNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type NamedField<'a> = NamedFieldNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NamedFieldNode<R1>> for NamedFieldNode<R2> {
fn eq(&self, other: &NamedFieldNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for NamedFieldNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for NamedFieldNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for NamedField<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
NAMED_FIELD => Some(NamedField { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> NamedFieldNode<R> {
pub fn borrowed(&self) -> NamedField {
NamedFieldNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> NamedFieldNode {
NamedFieldNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> NamedField<'a> {
pub fn name_ref(self) -> Option<NameRef<'a>> {
super::child_opt(self)
}
pub fn expr(self) -> Option<Expr<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// NamedFieldDef
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct NamedFieldDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-14 13:45:56 +02:00
}
2018-11-06 19:52:00 +01:00
pub type NamedFieldDef<'a> = NamedFieldDefNode<RefRoot<'a>>;
2018-08-14 13:45:56 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NamedFieldDefNode<R1>> for NamedFieldDefNode<R2> {
fn eq(&self, other: &NamedFieldDefNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for NamedFieldDefNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for NamedFieldDefNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-24 18:27:30 +02:00
impl<'a> AstNode<'a> for NamedFieldDef<'a> {
2018-08-17 21:00:13 +02:00
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 13:45:56 +02:00
match syntax.kind() {
2018-08-24 18:27:30 +02:00
NAMED_FIELD_DEF => Some(NamedFieldDef { syntax }),
2018-08-14 13:45:56 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 13:45:56 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> NamedFieldDefNode<R> {
pub fn borrowed(&self) -> NamedFieldDef {
NamedFieldDefNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> NamedFieldDefNode {
NamedFieldDefNode { syntax: self.syntax.owned() }
}
}
2018-08-24 18:27:30 +02:00
impl<'a> ast::NameOwner<'a> for NamedFieldDef<'a> {}
impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {}
impl<'a> NamedFieldDef<'a> {
pub fn type_ref(self) -> Option<TypeRef<'a>> {
super::child_opt(self)
}
}
// NamedFieldDefList
#[derive(Debug, Clone, Copy,)]
pub struct NamedFieldDefListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
pub(crate) syntax: SyntaxNode<R>,
}
pub type NamedFieldDefList<'a> = NamedFieldDefListNode<RefRoot<'a>>;
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NamedFieldDefListNode<R1>> for NamedFieldDefListNode<R2> {
fn eq(&self, other: &NamedFieldDefListNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for NamedFieldDefListNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for NamedFieldDefListNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
impl<'a> AstNode<'a> for NamedFieldDefList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
NAMED_FIELD_DEF_LIST => Some(NamedFieldDefList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<R: TreeRoot<RaTypes>> NamedFieldDefListNode<R> {
pub fn borrowed(&self) -> NamedFieldDefList {
NamedFieldDefListNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> NamedFieldDefListNode {
NamedFieldDefListNode { syntax: self.syntax.owned() }
}
}
impl<'a> NamedFieldDefList<'a> {
pub fn fields(self) -> impl Iterator<Item = NamedFieldDef<'a>> + 'a {
super::children(self)
}
}
2018-08-14 13:45:56 +02:00
2018-08-25 12:42:40 +02:00
// NamedFieldList
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct NamedFieldListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type NamedFieldList<'a> = NamedFieldListNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NamedFieldListNode<R1>> for NamedFieldListNode<R2> {
fn eq(&self, other: &NamedFieldListNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for NamedFieldListNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for NamedFieldListNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for NamedFieldList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
NAMED_FIELD_LIST => Some(NamedFieldList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> NamedFieldListNode<R> {
pub fn borrowed(&self) -> NamedFieldList {
NamedFieldListNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> NamedFieldListNode {
NamedFieldListNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> NamedFieldList<'a> {
pub fn fields(self) -> impl Iterator<Item = NamedField<'a>> + 'a {
super::children(self)
}
}
2018-11-06 19:52:00 +01:00
// NeverType
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct NeverTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
pub type NeverType<'a> = NeverTypeNode<RefRoot<'a>>;
2018-08-14 11:38:20 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<NeverTypeNode<R1>> for NeverTypeNode<R2> {
fn eq(&self, other: &NeverTypeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for NeverTypeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for NeverTypeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for NeverType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
NEVER_TYPE => Some(NeverType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> NeverTypeNode<R> {
pub fn borrowed(&self) -> NeverType {
NeverTypeNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> NeverTypeNode {
NeverTypeNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> NeverType<'a> {}
// NominalDef
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2018-08-17 21:00:13 +02:00
pub enum NominalDef<'a> {
StructDef(StructDef<'a>),
EnumDef(EnumDef<'a>),
2018-08-14 12:33:44 +02:00
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for NominalDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 12:33:44 +02:00
match syntax.kind() {
STRUCT_DEF => Some(NominalDef::StructDef(StructDef { syntax })),
ENUM_DEF => Some(NominalDef::EnumDef(EnumDef { syntax })),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> {
2018-08-14 12:33:44 +02:00
match self {
NominalDef::StructDef(inner) => inner.syntax(),
NominalDef::EnumDef(inner) => inner.syntax(),
}
}
}
2018-08-22 17:05:43 +02:00
impl<'a> ast::NameOwner<'a> for NominalDef<'a> {}
2018-08-22 15:46:42 +02:00
impl<'a> ast::TypeParamsOwner<'a> for NominalDef<'a> {}
2018-08-22 17:05:43 +02:00
impl<'a> ast::AttrsOwner<'a> for NominalDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> NominalDef<'a> {}
2018-08-14 12:33:44 +02:00
2018-08-26 11:09:28 +02:00
// Param
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ParamNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-26 11:09:28 +02:00
}
2018-11-06 19:52:00 +01:00
pub type Param<'a> = ParamNode<RefRoot<'a>>;
2018-08-26 11:09:28 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ParamNode<R1>> for ParamNode<R2> {
fn eq(&self, other: &ParamNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ParamNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ParamNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-26 11:09:28 +02:00
impl<'a> AstNode<'a> for Param<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PARAM => Some(Param { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ParamNode<R> {
pub fn borrowed(&self) -> Param {
ParamNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> ParamNode {
ParamNode { syntax: self.syntax.owned() }
2018-08-26 11:09:28 +02:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> Param<'a> {
pub fn pat(self) -> Option<Pat<'a>> {
super::child_opt(self)
}
2018-12-20 21:56:28 +01:00
pub fn type_ref(self) -> Option<TypeRef<'a>> {
super::child_opt(self)
}
}
2018-11-01 11:41:04 +01:00
2018-11-06 19:52:00 +01:00
// ParamList
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-26 11:09:28 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ParamList<'a> = ParamListNode<RefRoot<'a>>;
2018-08-26 11:09:28 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ParamListNode<R1>> for ParamListNode<R2> {
fn eq(&self, other: &ParamListNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ParamListNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ParamListNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-26 11:09:28 +02:00
impl<'a> AstNode<'a> for ParamList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PARAM_LIST => Some(ParamList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ParamListNode<R> {
pub fn borrowed(&self) -> ParamList {
ParamListNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> ParamListNode {
ParamListNode { syntax: self.syntax.owned() }
}
}
2018-08-26 11:09:28 +02:00
impl<'a> ParamList<'a> {
pub fn params(self) -> impl Iterator<Item = Param<'a>> + 'a {
super::children(self)
}
pub fn self_param(self) -> Option<SelfParam<'a>> {
2018-08-31 15:30:42 +02:00
super::child_opt(self)
}
2018-08-26 11:09:28 +02:00
}
2018-08-25 12:42:40 +02:00
// ParenExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ParenExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ParenExpr<'a> = ParenExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ParenExprNode<R1>> for ParenExprNode<R2> {
fn eq(&self, other: &ParenExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ParenExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ParenExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for ParenExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PAREN_EXPR => Some(ParenExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ParenExprNode<R> {
pub fn borrowed(&self) -> ParenExpr {
ParenExprNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> ParenExprNode {
ParenExprNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
2018-12-20 21:56:28 +01:00
impl<'a> ParenExpr<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// ParenType
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ParenTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ParenType<'a> = ParenTypeNode<RefRoot<'a>>;
2018-08-14 11:38:20 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ParenTypeNode<R1>> for ParenTypeNode<R2> {
fn eq(&self, other: &ParenTypeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ParenTypeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ParenTypeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for ParenType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
PAREN_TYPE => Some(ParenType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ParenTypeNode<R> {
pub fn borrowed(&self) -> ParenType {
ParenTypeNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> ParenTypeNode {
ParenTypeNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> ParenType<'a> {
pub fn type_ref(self) -> Option<TypeRef<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// Pat
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2018-08-26 11:09:28 +02:00
pub enum Pat<'a> {
RefPat(RefPat<'a>),
BindPat(BindPat<'a>),
PlaceholderPat(PlaceholderPat<'a>),
PathPat(PathPat<'a>),
StructPat(StructPat<'a>),
FieldPatList(FieldPatList<'a>),
TupleStructPat(TupleStructPat<'a>),
TuplePat(TuplePat<'a>),
SlicePat(SlicePat<'a>),
RangePat(RangePat<'a>),
}
impl<'a> AstNode<'a> for Pat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
REF_PAT => Some(Pat::RefPat(RefPat { syntax })),
BIND_PAT => Some(Pat::BindPat(BindPat { syntax })),
PLACEHOLDER_PAT => Some(Pat::PlaceholderPat(PlaceholderPat { syntax })),
PATH_PAT => Some(Pat::PathPat(PathPat { syntax })),
STRUCT_PAT => Some(Pat::StructPat(StructPat { syntax })),
FIELD_PAT_LIST => Some(Pat::FieldPatList(FieldPatList { syntax })),
TUPLE_STRUCT_PAT => Some(Pat::TupleStructPat(TupleStructPat { syntax })),
TUPLE_PAT => Some(Pat::TuplePat(TuplePat { syntax })),
SLICE_PAT => Some(Pat::SlicePat(SlicePat { syntax })),
RANGE_PAT => Some(Pat::RangePat(RangePat { syntax })),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> {
match self {
Pat::RefPat(inner) => inner.syntax(),
Pat::BindPat(inner) => inner.syntax(),
Pat::PlaceholderPat(inner) => inner.syntax(),
Pat::PathPat(inner) => inner.syntax(),
Pat::StructPat(inner) => inner.syntax(),
Pat::FieldPatList(inner) => inner.syntax(),
Pat::TupleStructPat(inner) => inner.syntax(),
Pat::TuplePat(inner) => inner.syntax(),
Pat::SlicePat(inner) => inner.syntax(),
Pat::RangePat(inner) => inner.syntax(),
}
}
}
impl<'a> Pat<'a> {}
2018-08-30 19:03:18 +02:00
// Path
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct PathNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-30 19:03:18 +02:00
}
2018-11-06 19:52:00 +01:00
pub type Path<'a> = PathNode<RefRoot<'a>>;
2018-08-30 19:03:18 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PathNode<R1>> for PathNode<R2> {
fn eq(&self, other: &PathNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for PathNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for PathNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-30 19:03:18 +02:00
impl<'a> AstNode<'a> for Path<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PATH => Some(Path { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> PathNode<R> {
pub fn borrowed(&self) -> Path {
PathNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> PathNode {
PathNode { syntax: self.syntax.owned() }
}
}
impl<'a> Path<'a> {
pub fn segment(self) -> Option<PathSegment<'a>> {
2018-08-30 19:37:33 +02:00
super::child_opt(self)
}
2018-10-24 17:37:25 +02:00
pub fn qualifier(self) -> Option<Path<'a>> {
super::child_opt(self)
}
2018-08-30 19:37:33 +02:00
}
2018-08-30 19:03:18 +02:00
2018-08-25 12:42:40 +02:00
// PathExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct PathExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type PathExpr<'a> = PathExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PathExprNode<R1>> for PathExprNode<R2> {
fn eq(&self, other: &PathExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for PathExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for PathExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for PathExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PATH_EXPR => Some(PathExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> PathExprNode<R> {
pub fn borrowed(&self) -> PathExpr {
PathExprNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> PathExprNode {
PathExprNode { syntax: self.syntax.owned() }
}
}
2018-08-25 12:42:40 +02:00
2018-11-06 19:52:00 +01:00
impl<'a> PathExpr<'a> {
pub fn path(self) -> Option<Path<'a>> {
super::child_opt(self)
}
}
2018-11-01 11:41:04 +01:00
2018-11-06 19:52:00 +01:00
// PathPat
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct PathPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-26 11:09:28 +02:00
}
2018-11-06 19:52:00 +01:00
pub type PathPat<'a> = PathPatNode<RefRoot<'a>>;
2018-08-26 11:09:28 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PathPatNode<R1>> for PathPatNode<R2> {
fn eq(&self, other: &PathPatNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for PathPatNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for PathPatNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-26 11:09:28 +02:00
impl<'a> AstNode<'a> for PathPat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PATH_PAT => Some(PathPat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> PathPatNode<R> {
pub fn borrowed(&self) -> PathPat {
PathPatNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> PathPatNode {
PathPatNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> PathPat<'a> {}
// PathSegment
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct PathSegmentNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-30 19:37:33 +02:00
}
2018-11-06 19:52:00 +01:00
pub type PathSegment<'a> = PathSegmentNode<RefRoot<'a>>;
2018-08-30 19:37:33 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PathSegmentNode<R1>> for PathSegmentNode<R2> {
fn eq(&self, other: &PathSegmentNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for PathSegmentNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for PathSegmentNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-30 19:37:33 +02:00
impl<'a> AstNode<'a> for PathSegment<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PATH_SEGMENT => Some(PathSegment { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> PathSegmentNode<R> {
pub fn borrowed(&self) -> PathSegment {
PathSegmentNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> PathSegmentNode {
PathSegmentNode { syntax: self.syntax.owned() }
2018-08-30 19:37:33 +02:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> PathSegment<'a> {
pub fn name_ref(self) -> Option<NameRef<'a>> {
super::child_opt(self)
}
}
2018-11-01 11:41:04 +01:00
2018-11-06 19:52:00 +01:00
// PathType
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct PathTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
pub type PathType<'a> = PathTypeNode<RefRoot<'a>>;
2018-08-14 11:38:20 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PathTypeNode<R1>> for PathTypeNode<R2> {
fn eq(&self, other: &PathTypeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for PathTypeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for PathTypeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for PathType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
PATH_TYPE => Some(PathType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> PathTypeNode<R> {
pub fn borrowed(&self) -> PathType {
PathTypeNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> PathTypeNode {
PathTypeNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
2018-12-22 22:17:55 +01:00
impl<'a> PathType<'a> {
pub fn path(self) -> Option<Path<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// PlaceholderPat
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct PlaceholderPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-26 11:09:28 +02:00
}
2018-11-06 19:52:00 +01:00
pub type PlaceholderPat<'a> = PlaceholderPatNode<RefRoot<'a>>;
2018-08-26 11:09:28 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PlaceholderPatNode<R1>> for PlaceholderPatNode<R2> {
fn eq(&self, other: &PlaceholderPatNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for PlaceholderPatNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for PlaceholderPatNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-26 11:09:28 +02:00
impl<'a> AstNode<'a> for PlaceholderPat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PLACEHOLDER_PAT => Some(PlaceholderPat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> PlaceholderPatNode<R> {
pub fn borrowed(&self) -> PlaceholderPat {
PlaceholderPatNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> PlaceholderPatNode {
PlaceholderPatNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> PlaceholderPat<'a> {}
// PlaceholderType
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct PlaceholderTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
pub type PlaceholderType<'a> = PlaceholderTypeNode<RefRoot<'a>>;
2018-08-14 11:38:20 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PlaceholderTypeNode<R1>> for PlaceholderTypeNode<R2> {
fn eq(&self, other: &PlaceholderTypeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for PlaceholderTypeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for PlaceholderTypeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for PlaceholderType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
PLACEHOLDER_TYPE => Some(PlaceholderType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> PlaceholderTypeNode<R> {
pub fn borrowed(&self) -> PlaceholderType {
PlaceholderTypeNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> PlaceholderTypeNode {
PlaceholderTypeNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> PlaceholderType<'a> {}
// PointerType
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct PointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
pub type PointerType<'a> = PointerTypeNode<RefRoot<'a>>;
2018-08-14 11:38:20 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PointerTypeNode<R1>> for PointerTypeNode<R2> {
fn eq(&self, other: &PointerTypeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for PointerTypeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for PointerTypeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for PointerType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
POINTER_TYPE => Some(PointerType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> PointerTypeNode<R> {
pub fn borrowed(&self) -> PointerType {
PointerTypeNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> PointerTypeNode {
PointerTypeNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> PointerType<'a> {
pub fn type_ref(self) -> Option<TypeRef<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// PosField
#[derive(Debug, Clone, Copy,)]
pub struct PosFieldNode<R: TreeRoot<RaTypes> = OwnedRoot> {
pub(crate) syntax: SyntaxNode<R>,
}
pub type PosField<'a> = PosFieldNode<RefRoot<'a>>;
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PosFieldNode<R1>> for PosFieldNode<R2> {
fn eq(&self, other: &PosFieldNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for PosFieldNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for PosFieldNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
impl<'a> AstNode<'a> for PosField<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
POS_FIELD => Some(PosField { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<R: TreeRoot<RaTypes>> PosFieldNode<R> {
pub fn borrowed(&self) -> PosField {
PosFieldNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> PosFieldNode {
PosFieldNode { syntax: self.syntax.owned() }
}
}
impl<'a> ast::AttrsOwner<'a> for PosField<'a> {}
impl<'a> PosField<'a> {
pub fn type_ref(self) -> Option<TypeRef<'a>> {
super::child_opt(self)
}
}
// PosFieldList
#[derive(Debug, Clone, Copy,)]
pub struct PosFieldListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
pub(crate) syntax: SyntaxNode<R>,
}
pub type PosFieldList<'a> = PosFieldListNode<RefRoot<'a>>;
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PosFieldListNode<R1>> for PosFieldListNode<R2> {
fn eq(&self, other: &PosFieldListNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for PosFieldListNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for PosFieldListNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
impl<'a> AstNode<'a> for PosFieldList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
POS_FIELD_LIST => Some(PosFieldList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<R: TreeRoot<RaTypes>> PosFieldListNode<R> {
pub fn borrowed(&self) -> PosFieldList {
PosFieldListNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> PosFieldListNode {
PosFieldListNode { syntax: self.syntax.owned() }
}
}
impl<'a> PosFieldList<'a> {
pub fn fields(self) -> impl Iterator<Item = PosField<'a>> + 'a {
super::children(self)
}
}
2018-11-06 19:52:00 +01:00
// PrefixExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct PrefixExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type PrefixExpr<'a> = PrefixExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<PrefixExprNode<R1>> for PrefixExprNode<R2> {
fn eq(&self, other: &PrefixExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for PrefixExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for PrefixExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for PrefixExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
PREFIX_EXPR => Some(PrefixExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> PrefixExprNode<R> {
pub fn borrowed(&self) -> PrefixExpr {
PrefixExprNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> PrefixExprNode {
PrefixExprNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
2018-12-20 21:56:28 +01:00
impl<'a> PrefixExpr<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// RangeExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct RangeExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type RangeExpr<'a> = RangeExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RangeExprNode<R1>> for RangeExprNode<R2> {
fn eq(&self, other: &RangeExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for RangeExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for RangeExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for RangeExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
RANGE_EXPR => Some(RangeExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> RangeExprNode<R> {
pub fn borrowed(&self) -> RangeExpr {
RangeExprNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> RangeExprNode {
RangeExprNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> RangeExpr<'a> {}
// RangePat
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct RangePatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-26 11:09:28 +02:00
}
2018-11-06 19:52:00 +01:00
pub type RangePat<'a> = RangePatNode<RefRoot<'a>>;
2018-08-26 11:09:28 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RangePatNode<R1>> for RangePatNode<R2> {
fn eq(&self, other: &RangePatNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for RangePatNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for RangePatNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-26 11:09:28 +02:00
impl<'a> AstNode<'a> for RangePat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
RANGE_PAT => Some(RangePat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> RangePatNode<R> {
pub fn borrowed(&self) -> RangePat {
RangePatNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> RangePatNode {
RangePatNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> RangePat<'a> {}
// RefExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct RefExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type RefExpr<'a> = RefExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RefExprNode<R1>> for RefExprNode<R2> {
fn eq(&self, other: &RefExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for RefExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for RefExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for RefExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
REF_EXPR => Some(RefExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> RefExprNode<R> {
pub fn borrowed(&self) -> RefExpr {
RefExprNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> RefExprNode {
RefExprNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
2018-12-20 21:56:28 +01:00
impl<'a> RefExpr<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// RefPat
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct RefPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-26 11:09:28 +02:00
}
2018-11-06 19:52:00 +01:00
pub type RefPat<'a> = RefPatNode<RefRoot<'a>>;
2018-08-26 11:09:28 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RefPatNode<R1>> for RefPatNode<R2> {
fn eq(&self, other: &RefPatNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for RefPatNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for RefPatNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-26 11:09:28 +02:00
impl<'a> AstNode<'a> for RefPat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
REF_PAT => Some(RefPat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> RefPatNode<R> {
pub fn borrowed(&self) -> RefPat {
RefPatNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> RefPatNode {
RefPatNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> RefPat<'a> {}
// ReferenceType
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ReferenceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ReferenceType<'a> = ReferenceTypeNode<RefRoot<'a>>;
2018-08-14 11:38:20 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ReferenceTypeNode<R1>> for ReferenceTypeNode<R2> {
fn eq(&self, other: &ReferenceTypeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ReferenceTypeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ReferenceTypeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for ReferenceType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
REFERENCE_TYPE => Some(ReferenceType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ReferenceTypeNode<R> {
pub fn borrowed(&self) -> ReferenceType {
ReferenceTypeNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> ReferenceTypeNode {
ReferenceTypeNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> ReferenceType<'a> {
pub fn type_ref(self) -> Option<TypeRef<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// RetType
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct RetTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-28 20:11:17 +02:00
}
2018-11-06 19:52:00 +01:00
pub type RetType<'a> = RetTypeNode<RefRoot<'a>>;
2018-08-28 20:11:17 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<RetTypeNode<R1>> for RetTypeNode<R2> {
fn eq(&self, other: &RetTypeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for RetTypeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for RetTypeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-28 20:11:17 +02:00
impl<'a> AstNode<'a> for RetType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
RET_TYPE => Some(RetType { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> RetTypeNode<R> {
pub fn borrowed(&self) -> RetType {
RetTypeNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> RetTypeNode {
RetTypeNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> RetType<'a> {
pub fn type_ref(self) -> Option<TypeRef<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// ReturnExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct ReturnExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type ReturnExpr<'a> = ReturnExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ReturnExprNode<R1>> for ReturnExprNode<R2> {
fn eq(&self, other: &ReturnExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for ReturnExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for ReturnExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for ReturnExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
RETURN_EXPR => Some(ReturnExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> ReturnExprNode<R> {
pub fn borrowed(&self) -> ReturnExpr {
ReturnExprNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> ReturnExprNode {
ReturnExprNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
2018-12-20 21:56:28 +01:00
impl<'a> ReturnExpr<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
2018-08-31 15:30:42 +02:00
// SelfParam
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct SelfParamNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-31 15:30:42 +02:00
}
2018-11-06 19:52:00 +01:00
pub type SelfParam<'a> = SelfParamNode<RefRoot<'a>>;
2018-08-31 15:30:42 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<SelfParamNode<R1>> for SelfParamNode<R2> {
fn eq(&self, other: &SelfParamNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for SelfParamNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for SelfParamNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-31 15:30:42 +02:00
impl<'a> AstNode<'a> for SelfParam<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
SELF_PARAM => Some(SelfParam { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> SelfParamNode<R> {
pub fn borrowed(&self) -> SelfParam {
SelfParamNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> SelfParamNode {
SelfParamNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> SelfParam<'a> {}
// SlicePat
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct SlicePatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-26 11:09:28 +02:00
}
2018-11-06 19:52:00 +01:00
pub type SlicePat<'a> = SlicePatNode<RefRoot<'a>>;
2018-08-26 11:09:28 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<SlicePatNode<R1>> for SlicePatNode<R2> {
fn eq(&self, other: &SlicePatNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for SlicePatNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for SlicePatNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-26 11:09:28 +02:00
impl<'a> AstNode<'a> for SlicePat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
SLICE_PAT => Some(SlicePat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> SlicePatNode<R> {
pub fn borrowed(&self) -> SlicePat {
SlicePatNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> SlicePatNode {
SlicePatNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> SlicePat<'a> {}
// SliceType
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct SliceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
pub type SliceType<'a> = SliceTypeNode<RefRoot<'a>>;
2018-08-14 11:38:20 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<SliceTypeNode<R1>> for SliceTypeNode<R2> {
fn eq(&self, other: &SliceTypeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for SliceTypeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for SliceTypeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for SliceType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
SLICE_TYPE => Some(SliceType { syntax }),
_ => None,
}
}
2018-11-06 19:52:00 +01:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<R: TreeRoot<RaTypes>> SliceTypeNode<R> {
pub fn borrowed(&self) -> SliceType {
SliceTypeNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> SliceTypeNode {
SliceTypeNode { syntax: self.syntax.owned() }
}
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
impl<'a> SliceType<'a> {
pub fn type_ref(self) -> Option<TypeRef<'a>> {
super::child_opt(self)
}
}
2018-08-14 11:38:20 +02:00
2018-11-07 16:38:43 +01:00
// SourceFile
#[derive(Debug, Clone, Copy,)]
pub struct SourceFileNode<R: TreeRoot<RaTypes> = OwnedRoot> {
pub(crate) syntax: SyntaxNode<R>,
}
pub type SourceFile<'a> = SourceFileNode<RefRoot<'a>>;
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<SourceFileNode<R1>> for SourceFileNode<R2> {
fn eq(&self, other: &SourceFileNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for SourceFileNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for SourceFileNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
impl<'a> AstNode<'a> for SourceFile<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
SOURCE_FILE => Some(SourceFile { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<R: TreeRoot<RaTypes>> SourceFileNode<R> {
pub fn borrowed(&self) -> SourceFile {
SourceFileNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> SourceFileNode {
SourceFileNode { syntax: self.syntax.owned() }
}
}
impl<'a> ast::ModuleItemOwner<'a> for SourceFile<'a> {}
impl<'a> ast::FnDefOwner<'a> for SourceFile<'a> {}
impl<'a> SourceFile<'a> {
pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a {
super::children(self)
}
}
2018-08-13 17:36:16 +02:00
// StaticDef
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct StaticDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-11 10:03:22 +02:00
}
2018-11-06 19:52:00 +01:00
pub type StaticDef<'a> = StaticDefNode<RefRoot<'a>>;
2018-08-11 10:03:22 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<StaticDefNode<R1>> for StaticDefNode<R2> {
fn eq(&self, other: &StaticDefNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for StaticDefNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for StaticDefNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for StaticDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 10:03:22 +02:00
match syntax.kind() {
2018-08-13 17:36:16 +02:00
STATIC_DEF => Some(StaticDef { syntax }),
2018-08-11 10:03:22 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 10:03:22 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> StaticDefNode<R> {
pub fn borrowed(&self) -> StaticDef {
StaticDefNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> StaticDefNode {
StaticDefNode { syntax: self.syntax.owned() }
}
}
2018-08-17 21:00:13 +02:00
impl<'a> ast::NameOwner<'a> for StaticDef<'a> {}
2018-08-22 15:46:42 +02:00
impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {}
2018-11-02 14:59:07 +01:00
impl<'a> ast::DocCommentsOwner<'a> for StaticDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> StaticDef<'a> {}
2018-08-11 10:03:22 +02:00
2018-08-27 09:12:28 +02:00
// Stmt
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2018-08-27 09:12:28 +02:00
pub enum Stmt<'a> {
ExprStmt(ExprStmt<'a>),
LetStmt(LetStmt<'a>),
}
impl<'a> AstNode<'a> for Stmt<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
EXPR_STMT => Some(Stmt::ExprStmt(ExprStmt { syntax })),
LET_STMT => Some(Stmt::LetStmt(LetStmt { syntax })),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> {
match self {
Stmt::ExprStmt(inner) => inner.syntax(),
Stmt::LetStmt(inner) => inner.syntax(),
}
}
}
impl<'a> Stmt<'a> {}
2018-11-08 15:42:00 +01:00
// String
#[derive(Debug, Clone, Copy,)]
pub struct StringNode<R: TreeRoot<RaTypes> = OwnedRoot> {
pub(crate) syntax: SyntaxNode<R>,
}
pub type String<'a> = StringNode<RefRoot<'a>>;
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<StringNode<R1>> for StringNode<R2> {
fn eq(&self, other: &StringNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for StringNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for StringNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
impl<'a> AstNode<'a> for String<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
STRING => Some(String { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<R: TreeRoot<RaTypes>> StringNode<R> {
pub fn borrowed(&self) -> String {
StringNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> StringNode {
StringNode { syntax: self.syntax.owned() }
}
}
impl<'a> String<'a> {}
2018-08-13 17:36:16 +02:00
// StructDef
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct StructDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-11 09:56:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type StructDef<'a> = StructDefNode<RefRoot<'a>>;
2018-08-11 09:56:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<StructDefNode<R1>> for StructDefNode<R2> {
fn eq(&self, other: &StructDefNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for StructDefNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for StructDefNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for StructDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 09:56:40 +02:00
match syntax.kind() {
2018-08-13 17:36:16 +02:00
STRUCT_DEF => Some(StructDef { syntax }),
2018-08-11 09:56:40 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 09:56:40 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> StructDefNode<R> {
pub fn borrowed(&self) -> StructDef {
StructDefNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> StructDefNode {
StructDefNode { syntax: self.syntax.owned() }
}
}
2018-08-17 21:00:13 +02:00
impl<'a> ast::NameOwner<'a> for StructDef<'a> {}
2018-08-22 15:46:42 +02:00
impl<'a> ast::TypeParamsOwner<'a> for StructDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> ast::AttrsOwner<'a> for StructDef<'a> {}
2018-11-02 14:59:07 +01:00
impl<'a> ast::DocCommentsOwner<'a> for StructDef<'a> {}
impl<'a> StructDef<'a> {}
2018-08-11 09:56:40 +02:00
2018-08-25 12:42:40 +02:00
// StructLit
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct StructLitNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type StructLit<'a> = StructLitNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<StructLitNode<R1>> for StructLitNode<R2> {
fn eq(&self, other: &StructLitNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for StructLitNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for StructLitNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for StructLit<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
STRUCT_LIT => Some(StructLit { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> StructLitNode<R> {
pub fn borrowed(&self) -> StructLit {
StructLitNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> StructLitNode {
StructLitNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> StructLit<'a> {
pub fn path(self) -> Option<Path<'a>> {
super::child_opt(self)
}
pub fn named_field_list(self) -> Option<NamedFieldList<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// StructPat
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct StructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-26 11:09:28 +02:00
}
2018-11-06 19:52:00 +01:00
pub type StructPat<'a> = StructPatNode<RefRoot<'a>>;
2018-08-26 11:09:28 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<StructPatNode<R1>> for StructPatNode<R2> {
fn eq(&self, other: &StructPatNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for StructPatNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for StructPatNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-26 11:09:28 +02:00
impl<'a> AstNode<'a> for StructPat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
STRUCT_PAT => Some(StructPat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> StructPatNode<R> {
pub fn borrowed(&self) -> StructPat {
StructPatNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> StructPatNode {
StructPatNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> StructPat<'a> {}
// TokenTree
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct TokenTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-16 11:51:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type TokenTree<'a> = TokenTreeNode<RefRoot<'a>>;
2018-08-16 11:51:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TokenTreeNode<R1>> for TokenTreeNode<R2> {
fn eq(&self, other: &TokenTreeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for TokenTreeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for TokenTreeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for TokenTree<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-16 11:51:40 +02:00
match syntax.kind() {
TOKEN_TREE => Some(TokenTree { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-16 11:51:40 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> TokenTreeNode<R> {
pub fn borrowed(&self) -> TokenTree {
TokenTreeNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> TokenTreeNode {
TokenTreeNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> TokenTree<'a> {}
// TraitDef
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct TraitDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-11 10:03:22 +02:00
}
2018-11-06 19:52:00 +01:00
pub type TraitDef<'a> = TraitDefNode<RefRoot<'a>>;
2018-08-11 10:03:22 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TraitDefNode<R1>> for TraitDefNode<R2> {
fn eq(&self, other: &TraitDefNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for TraitDefNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for TraitDefNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for TraitDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 10:03:22 +02:00
match syntax.kind() {
2018-08-13 17:36:16 +02:00
TRAIT_DEF => Some(TraitDef { syntax }),
2018-08-11 10:03:22 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 10:03:22 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> TraitDefNode<R> {
pub fn borrowed(&self) -> TraitDef {
TraitDefNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> TraitDefNode {
TraitDefNode { syntax: self.syntax.owned() }
}
}
2018-08-17 21:00:13 +02:00
impl<'a> ast::NameOwner<'a> for TraitDef<'a> {}
impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {}
2018-11-02 14:59:07 +01:00
impl<'a> ast::DocCommentsOwner<'a> for TraitDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> TraitDef<'a> {}
2018-08-11 10:03:22 +02:00
2018-08-25 12:42:40 +02:00
// TryExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct TryExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type TryExpr<'a> = TryExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TryExprNode<R1>> for TryExprNode<R2> {
fn eq(&self, other: &TryExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for TryExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for TryExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for TryExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
TRY_EXPR => Some(TryExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> TryExprNode<R> {
pub fn borrowed(&self) -> TryExpr {
TryExprNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> TryExprNode {
TryExprNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
2018-12-20 21:56:28 +01:00
impl<'a> TryExpr<'a> {
pub fn expr(self) -> Option<Expr<'a>> {
super::child_opt(self)
}
}
2018-11-06 19:52:00 +01:00
// TupleExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct TupleExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type TupleExpr<'a> = TupleExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TupleExprNode<R1>> for TupleExprNode<R2> {
fn eq(&self, other: &TupleExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for TupleExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for TupleExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for TupleExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
TUPLE_EXPR => Some(TupleExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> TupleExprNode<R> {
pub fn borrowed(&self) -> TupleExpr {
TupleExprNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> TupleExprNode {
TupleExprNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> TupleExpr<'a> {}
// TuplePat
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct TuplePatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-26 11:09:28 +02:00
}
2018-11-06 19:52:00 +01:00
pub type TuplePat<'a> = TuplePatNode<RefRoot<'a>>;
2018-08-26 11:09:28 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TuplePatNode<R1>> for TuplePatNode<R2> {
fn eq(&self, other: &TuplePatNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for TuplePatNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for TuplePatNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-26 11:09:28 +02:00
impl<'a> AstNode<'a> for TuplePat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
TUPLE_PAT => Some(TuplePat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> TuplePatNode<R> {
pub fn borrowed(&self) -> TuplePat {
TuplePatNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> TuplePatNode {
TuplePatNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> TuplePat<'a> {}
// TupleStructPat
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct TupleStructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-26 11:09:28 +02:00
}
2018-11-06 19:52:00 +01:00
pub type TupleStructPat<'a> = TupleStructPatNode<RefRoot<'a>>;
2018-08-26 11:09:28 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TupleStructPatNode<R1>> for TupleStructPatNode<R2> {
fn eq(&self, other: &TupleStructPatNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for TupleStructPatNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for TupleStructPatNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-26 11:09:28 +02:00
impl<'a> AstNode<'a> for TupleStructPat<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
TUPLE_STRUCT_PAT => Some(TupleStructPat { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> TupleStructPatNode<R> {
pub fn borrowed(&self) -> TupleStructPat {
TupleStructPatNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> TupleStructPatNode {
TupleStructPatNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> TupleStructPat<'a> {}
// TupleType
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct TupleTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
pub type TupleType<'a> = TupleTypeNode<RefRoot<'a>>;
2018-08-14 11:38:20 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TupleTypeNode<R1>> for TupleTypeNode<R2> {
fn eq(&self, other: &TupleTypeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for TupleTypeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for TupleTypeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for TupleType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
TUPLE_TYPE => Some(TupleType { syntax }),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:38:20 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> TupleTypeNode<R> {
pub fn borrowed(&self) -> TupleType {
TupleTypeNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> TupleTypeNode {
TupleTypeNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> TupleType<'a> {
pub fn fields(self) -> impl Iterator<Item = TypeRef<'a>> + 'a {
super::children(self)
}
}
2018-11-06 19:52:00 +01:00
// TypeDef
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct TypeDefNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-11 15:20:37 +02:00
}
2018-11-06 19:52:00 +01:00
pub type TypeDef<'a> = TypeDefNode<RefRoot<'a>>;
2018-08-11 15:20:37 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TypeDefNode<R1>> for TypeDefNode<R2> {
fn eq(&self, other: &TypeDefNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for TypeDefNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for TypeDefNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-17 21:00:13 +02:00
impl<'a> AstNode<'a> for TypeDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 15:20:37 +02:00
match syntax.kind() {
2018-08-13 17:36:16 +02:00
TYPE_DEF => Some(TypeDef { syntax }),
2018-08-11 15:20:37 +02:00
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 15:20:37 +02:00
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> TypeDefNode<R> {
pub fn borrowed(&self) -> TypeDef {
TypeDefNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> TypeDefNode {
TypeDefNode { syntax: self.syntax.owned() }
}
}
2018-08-17 21:00:13 +02:00
impl<'a> ast::NameOwner<'a> for TypeDef<'a> {}
2018-08-22 15:46:42 +02:00
impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {}
2018-11-02 14:59:07 +01:00
impl<'a> ast::DocCommentsOwner<'a> for TypeDef<'a> {}
2018-08-17 21:00:13 +02:00
impl<'a> TypeDef<'a> {}
2018-08-11 15:20:37 +02:00
2018-08-22 18:02:37 +02:00
// TypeParam
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct TypeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-22 18:02:37 +02:00
}
2018-11-06 19:52:00 +01:00
pub type TypeParam<'a> = TypeParamNode<RefRoot<'a>>;
2018-08-22 18:02:37 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TypeParamNode<R1>> for TypeParamNode<R2> {
fn eq(&self, other: &TypeParamNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for TypeParamNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for TypeParamNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-22 18:02:37 +02:00
impl<'a> AstNode<'a> for TypeParam<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
TYPE_PARAM => Some(TypeParam { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> TypeParamNode<R> {
pub fn borrowed(&self) -> TypeParam {
TypeParamNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> TypeParamNode {
TypeParamNode { syntax: self.syntax.owned() }
}
}
2018-08-22 18:02:37 +02:00
impl<'a> ast::NameOwner<'a> for TypeParam<'a> {}
impl<'a> TypeParam<'a> {}
2018-08-22 15:46:42 +02:00
// TypeParamList
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct TypeParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-22 15:46:42 +02:00
}
2018-11-06 19:52:00 +01:00
pub type TypeParamList<'a> = TypeParamListNode<RefRoot<'a>>;
2018-08-22 15:46:42 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<TypeParamListNode<R1>> for TypeParamListNode<R2> {
fn eq(&self, other: &TypeParamListNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for TypeParamListNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for TypeParamListNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-22 15:46:42 +02:00
impl<'a> AstNode<'a> for TypeParamList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
TYPE_PARAM_LIST => Some(TypeParamList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> TypeParamListNode<R> {
pub fn borrowed(&self) -> TypeParamList {
TypeParamListNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> TypeParamListNode {
TypeParamListNode { syntax: self.syntax.owned() }
}
}
2018-08-22 18:02:37 +02:00
impl<'a> TypeParamList<'a> {
pub fn type_params(self) -> impl Iterator<Item = TypeParam<'a>> + 'a {
super::children(self)
}
2018-08-28 22:59:57 +02:00
pub fn lifetime_params(self) -> impl Iterator<Item = LifetimeParam<'a>> + 'a {
super::children(self)
}
2018-08-22 18:02:37 +02:00
}
2018-08-22 15:46:42 +02:00
2018-08-14 11:38:20 +02:00
// TypeRef
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2018-08-17 21:00:13 +02:00
pub enum TypeRef<'a> {
ParenType(ParenType<'a>),
TupleType(TupleType<'a>),
NeverType(NeverType<'a>),
PathType(PathType<'a>),
PointerType(PointerType<'a>),
ArrayType(ArrayType<'a>),
SliceType(SliceType<'a>),
ReferenceType(ReferenceType<'a>),
PlaceholderType(PlaceholderType<'a>),
FnPointerType(FnPointerType<'a>),
ForType(ForType<'a>),
ImplTraitType(ImplTraitType<'a>),
DynTraitType(DynTraitType<'a>),
}
impl<'a> AstNode<'a> for TypeRef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:38:20 +02:00
match syntax.kind() {
PAREN_TYPE => Some(TypeRef::ParenType(ParenType { syntax })),
TUPLE_TYPE => Some(TypeRef::TupleType(TupleType { syntax })),
NEVER_TYPE => Some(TypeRef::NeverType(NeverType { syntax })),
PATH_TYPE => Some(TypeRef::PathType(PathType { syntax })),
POINTER_TYPE => Some(TypeRef::PointerType(PointerType { syntax })),
ARRAY_TYPE => Some(TypeRef::ArrayType(ArrayType { syntax })),
SLICE_TYPE => Some(TypeRef::SliceType(SliceType { syntax })),
REFERENCE_TYPE => Some(TypeRef::ReferenceType(ReferenceType { syntax })),
PLACEHOLDER_TYPE => Some(TypeRef::PlaceholderType(PlaceholderType { syntax })),
FN_POINTER_TYPE => Some(TypeRef::FnPointerType(FnPointerType { syntax })),
FOR_TYPE => Some(TypeRef::ForType(ForType { syntax })),
IMPL_TRAIT_TYPE => Some(TypeRef::ImplTraitType(ImplTraitType { syntax })),
DYN_TRAIT_TYPE => Some(TypeRef::DynTraitType(DynTraitType { syntax })),
_ => None,
}
}
2018-08-17 21:00:13 +02:00
fn syntax(self) -> SyntaxNodeRef<'a> {
2018-08-14 11:38:20 +02:00
match self {
TypeRef::ParenType(inner) => inner.syntax(),
TypeRef::TupleType(inner) => inner.syntax(),
TypeRef::NeverType(inner) => inner.syntax(),
TypeRef::PathType(inner) => inner.syntax(),
TypeRef::PointerType(inner) => inner.syntax(),
TypeRef::ArrayType(inner) => inner.syntax(),
TypeRef::SliceType(inner) => inner.syntax(),
TypeRef::ReferenceType(inner) => inner.syntax(),
TypeRef::PlaceholderType(inner) => inner.syntax(),
TypeRef::FnPointerType(inner) => inner.syntax(),
TypeRef::ForType(inner) => inner.syntax(),
TypeRef::ImplTraitType(inner) => inner.syntax(),
TypeRef::DynTraitType(inner) => inner.syntax(),
}
}
}
2018-08-17 21:00:13 +02:00
impl<'a> TypeRef<'a> {}
2018-08-14 11:38:20 +02:00
2018-08-28 10:12:42 +02:00
// UseItem
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct UseItemNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-28 10:12:42 +02:00
}
2018-11-06 19:52:00 +01:00
pub type UseItem<'a> = UseItemNode<RefRoot<'a>>;
2018-08-28 10:12:42 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<UseItemNode<R1>> for UseItemNode<R2> {
fn eq(&self, other: &UseItemNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for UseItemNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for UseItemNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-28 10:12:42 +02:00
impl<'a> AstNode<'a> for UseItem<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
USE_ITEM => Some(UseItem { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> UseItemNode<R> {
pub fn borrowed(&self) -> UseItem {
UseItemNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> UseItemNode {
UseItemNode { syntax: self.syntax.owned() }
2018-08-30 19:37:33 +02:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> UseItem<'a> {
pub fn use_tree(self) -> Option<UseTree<'a>> {
super::child_opt(self)
}
}
2018-11-01 11:41:04 +01:00
2018-11-06 19:52:00 +01:00
// UseTree
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct UseTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-30 19:37:33 +02:00
}
2018-11-06 19:52:00 +01:00
pub type UseTree<'a> = UseTreeNode<RefRoot<'a>>;
2018-08-30 19:37:33 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<UseTreeNode<R1>> for UseTreeNode<R2> {
fn eq(&self, other: &UseTreeNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for UseTreeNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for UseTreeNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-30 19:37:33 +02:00
impl<'a> AstNode<'a> for UseTree<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
USE_TREE => Some(UseTree { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> UseTreeNode<R> {
pub fn borrowed(&self) -> UseTree {
UseTreeNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> UseTreeNode {
UseTreeNode { syntax: self.syntax.owned() }
}
}
impl<'a> UseTree<'a> {
pub fn path(self) -> Option<Path<'a>> {
2018-08-30 19:37:33 +02:00
super::child_opt(self)
}
pub fn use_tree_list(self) -> Option<UseTreeList<'a>> {
2018-08-30 19:37:33 +02:00
super::child_opt(self)
}
}
// UseTreeList
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct UseTreeListNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-30 19:37:33 +02:00
}
2018-11-06 19:52:00 +01:00
pub type UseTreeList<'a> = UseTreeListNode<RefRoot<'a>>;
2018-08-30 19:37:33 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<UseTreeListNode<R1>> for UseTreeListNode<R2> {
fn eq(&self, other: &UseTreeListNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for UseTreeListNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for UseTreeListNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-30 19:37:33 +02:00
impl<'a> AstNode<'a> for UseTreeList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
USE_TREE_LIST => Some(UseTreeList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> UseTreeListNode<R> {
pub fn borrowed(&self) -> UseTreeList {
UseTreeListNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> UseTreeListNode {
UseTreeListNode { syntax: self.syntax.owned() }
2018-08-30 19:37:33 +02:00
}
}
2018-08-28 10:12:42 +02:00
2018-11-06 19:52:00 +01:00
impl<'a> UseTreeList<'a> {
pub fn use_trees(self) -> impl Iterator<Item = UseTree<'a>> + 'a {
super::children(self)
}
}
2018-11-01 11:41:04 +01:00
2018-11-06 19:52:00 +01:00
// WhereClause
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct WhereClauseNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-22 10:56:36 +02:00
}
2018-11-06 19:52:00 +01:00
pub type WhereClause<'a> = WhereClauseNode<RefRoot<'a>>;
2018-08-22 10:56:36 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<WhereClauseNode<R1>> for WhereClauseNode<R2> {
fn eq(&self, other: &WhereClauseNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for WhereClauseNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for WhereClauseNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-22 15:46:42 +02:00
impl<'a> AstNode<'a> for WhereClause<'a> {
2018-08-22 10:56:36 +02:00
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
2018-08-22 15:46:42 +02:00
WHERE_CLAUSE => Some(WhereClause { syntax }),
2018-08-22 10:56:36 +02:00
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> WhereClauseNode<R> {
pub fn borrowed(&self) -> WhereClause {
WhereClauseNode { syntax: self.syntax.borrowed() }
}
2018-11-06 19:52:00 +01:00
pub fn owned(&self) -> WhereClauseNode {
WhereClauseNode { syntax: self.syntax.owned() }
2018-11-01 11:41:04 +01:00
}
}
2018-11-06 19:52:00 +01:00
impl<'a> WhereClause<'a> {}
// WhileExpr
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct WhileExprNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
2018-08-25 12:42:40 +02:00
}
2018-11-06 19:52:00 +01:00
pub type WhileExpr<'a> = WhileExprNode<RefRoot<'a>>;
2018-08-25 12:42:40 +02:00
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<WhileExprNode<R1>> for WhileExprNode<R2> {
fn eq(&self, other: &WhileExprNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for WhileExprNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for WhileExprNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
2018-08-25 12:42:40 +02:00
impl<'a> AstNode<'a> for WhileExpr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
WHILE_EXPR => Some(WhileExpr { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> WhileExprNode<R> {
pub fn borrowed(&self) -> WhileExpr {
WhileExprNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> WhileExprNode {
WhileExprNode { syntax: self.syntax.owned() }
}
}
2018-08-30 20:32:12 +02:00
impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {}
impl<'a> WhileExpr<'a> {
pub fn condition(self) -> Option<Condition<'a>> {
2018-08-27 11:22:09 +02:00
super::child_opt(self)
}
}
2018-08-25 12:42:40 +02:00
// Whitespace
2018-11-06 20:47:38 +01:00
#[derive(Debug, Clone, Copy,)]
2018-11-06 19:52:00 +01:00
pub struct WhitespaceNode<R: TreeRoot<RaTypes> = OwnedRoot> {
2018-11-06 20:47:38 +01:00
pub(crate) syntax: SyntaxNode<R>,
}
2018-11-06 19:52:00 +01:00
pub type Whitespace<'a> = WhitespaceNode<RefRoot<'a>>;
2018-11-06 20:47:38 +01:00
impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<WhitespaceNode<R1>> for WhitespaceNode<R2> {
fn eq(&self, other: &WhitespaceNode<R1>) -> bool { self.syntax == other.syntax }
}
impl<R: TreeRoot<RaTypes>> Eq for WhitespaceNode<R> {}
impl<R: TreeRoot<RaTypes>> Hash for WhitespaceNode<R> {
fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) }
}
impl<'a> AstNode<'a> for Whitespace<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
WHITESPACE => Some(Whitespace { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-11-06 19:52:00 +01:00
impl<R: TreeRoot<RaTypes>> WhitespaceNode<R> {
pub fn borrowed(&self) -> Whitespace {
WhitespaceNode { syntax: self.syntax.borrowed() }
}
pub fn owned(&self) -> WhitespaceNode {
WhitespaceNode { syntax: self.syntax.owned() }
}
}
impl<'a> Whitespace<'a> {}