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