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

700 lines
18 KiB
Rust
Raw Normal View History

2018-08-09 14:43:39 +00:00
use {
2018-08-11 09:28:59 +00:00
ast,
2018-08-17 19:00:13 +00:00
SyntaxNodeRef, AstNode,
2018-08-09 14:43:39 +00:00
SyntaxKind::*,
};
2018-08-14 09:38:20 +00:00
// ArrayType
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct ArrayType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for ArrayType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
ARRAY_TYPE => Some(ArrayType { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> ArrayType<'a> {}
2018-08-14 09:38:20 +00:00
2018-08-16 09:51:40 +00:00
// Attr
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct Attr<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-16 09:51:40 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for Attr<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-16 09:51:40 +00:00
match syntax.kind() {
ATTR => Some(Attr { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-16 09:51:40 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> Attr<'a> {
pub fn value(self) -> Option<TokenTree<'a>> {
2018-08-22 14:01:51 +00:00
super::child_opt(self)
2018-08-16 09:51:40 +00:00
}
}
2018-08-13 15:36:16 +00:00
// ConstDef
2018-08-11 08:03:22 +00:00
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct ConstDef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-11 08:03:22 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for ConstDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 08:03:22 +00:00
match syntax.kind() {
2018-08-13 15:36:16 +00:00
CONST_DEF => Some(ConstDef { syntax }),
2018-08-11 08:03:22 +00:00
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 08:03:22 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> ast::NameOwner<'a> for ConstDef<'a> {}
2018-08-22 13:46:42 +00:00
impl<'a> ast::TypeParamsOwner<'a> for ConstDef<'a> {}
2018-08-17 19:00:13 +00:00
impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {}
impl<'a> ConstDef<'a> {}
2018-08-11 08:03:22 +00:00
2018-08-14 09:38:20 +00:00
// DynTraitType
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct DynTraitType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for DynTraitType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
DYN_TRAIT_TYPE => Some(DynTraitType { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> DynTraitType<'a> {}
2018-08-14 09:38:20 +00:00
2018-08-13 15:36:16 +00:00
// EnumDef
2018-08-11 07:56:40 +00:00
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct EnumDef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-11 07:56:40 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for EnumDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 07:56:40 +00:00
match syntax.kind() {
2018-08-13 15:36:16 +00:00
ENUM_DEF => Some(EnumDef { syntax }),
2018-08-11 07:56:40 +00:00
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 07:56:40 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> ast::NameOwner<'a> for EnumDef<'a> {}
2018-08-22 13:46:42 +00:00
impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {}
2018-08-17 19:00:13 +00:00
impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {}
impl<'a> EnumDef<'a> {}
2018-08-11 07:56:40 +00:00
2018-08-11 09:28:59 +00:00
// File
2018-08-10 12:07:43 +00:00
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct File<'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 File<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-09 14:43:39 +00:00
match syntax.kind() {
FILE => Some(File { 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> File<'a> {
pub fn functions(self) -> impl Iterator<Item = FnDef<'a>> + 'a {
2018-08-22 14:01:51 +00:00
super::children(self)
2018-08-11 06:55:32 +00:00
}
2018-08-21 15:30:10 +00:00
pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a {
2018-08-22 14:01:51 +00:00
super::children(self)
2018-08-21 15:30:10 +00:00
}
2018-08-11 06:55:32 +00:00
}
2018-08-13 15:36:16 +00:00
// FnDef
2018-08-10 12:07:43 +00:00
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct FnDef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-09 14:43:39 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for FnDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-09 14:43:39 +00:00
match syntax.kind() {
2018-08-13 15:36:16 +00:00
FN_DEF => Some(FnDef { syntax }),
2018-08-09 14:43:39 +00:00
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-09 14:43:39 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> ast::NameOwner<'a> for FnDef<'a> {}
2018-08-22 13:46:42 +00:00
impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {}
2018-08-17 19:00:13 +00:00
impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {}
impl<'a> FnDef<'a> {}
2018-08-11 06:55:32 +00:00
2018-08-14 09:38:20 +00:00
// FnPointerType
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct FnPointerType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for FnPointerType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
FN_POINTER_TYPE => Some(FnPointerType { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> FnPointerType<'a> {}
2018-08-14 09:38:20 +00:00
// ForType
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct ForType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for ForType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
FOR_TYPE => Some(ForType { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> ForType<'a> {}
2018-08-14 09:38:20 +00:00
2018-08-14 08:20:09 +00:00
// ImplItem
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct ImplItem<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 08:20:09 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for ImplItem<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 08:20:09 +00:00
match syntax.kind() {
IMPL_ITEM => Some(ImplItem { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 08:20:09 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> ImplItem<'a> {}
2018-08-14 08:20:09 +00:00
2018-08-14 09:38:20 +00:00
// ImplTraitType
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct ImplTraitType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for ImplTraitType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
IMPL_TRAIT_TYPE => Some(ImplTraitType { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> ImplTraitType<'a> {}
2018-08-14 09:38:20 +00:00
2018-08-11 09:28:59 +00:00
// Module
2018-08-11 08:03:22 +00:00
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct Module<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-11 08:03:22 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for Module<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 08:03:22 +00:00
match syntax.kind() {
MODULE => Some(Module { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 08:03:22 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> ast::NameOwner<'a> for Module<'a> {}
impl<'a> ast::AttrsOwner<'a> for Module<'a> {}
2018-08-21 15:30:10 +00:00
impl<'a> Module<'a> {
pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a {
2018-08-22 14:01:51 +00:00
super::children(self)
2018-08-21 15:30:10 +00:00
}
}
2018-08-11 08:03:22 +00:00
2018-08-11 09:28:59 +00:00
// Name
2018-08-10 12:07:43 +00:00
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct Name<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-09 14:43:39 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for Name<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-09 14:43:39 +00:00
match syntax.kind() {
NAME => Some(Name { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-09 14:43:39 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> Name<'a> {}
2018-08-11 06:55:32 +00:00
2018-08-13 13:35:17 +00:00
// NameRef
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct NameRef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-13 13:35:17 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for NameRef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-13 13:35:17 +00:00
match syntax.kind() {
NAME_REF => Some(NameRef { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-13 13:35:17 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> NameRef<'a> {}
2018-08-13 13:35:17 +00:00
2018-08-24 16:27:30 +00:00
// NamedFieldDef
2018-08-14 11:45:56 +00:00
#[derive(Debug, Clone, Copy)]
2018-08-24 16:27:30 +00:00
pub struct NamedFieldDef<'a> {
2018-08-17 19:00:13 +00:00
syntax: SyntaxNodeRef<'a>,
2018-08-14 11:45:56 +00:00
}
2018-08-24 16:27:30 +00:00
impl<'a> AstNode<'a> for NamedFieldDef<'a> {
2018-08-17 19:00:13 +00:00
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 11:45:56 +00:00
match syntax.kind() {
2018-08-24 16:27:30 +00:00
NAMED_FIELD_DEF => Some(NamedFieldDef { syntax }),
2018-08-14 11:45:56 +00:00
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 11:45:56 +00:00
}
2018-08-24 16:27:30 +00:00
impl<'a> ast::NameOwner<'a> for NamedFieldDef<'a> {}
impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {}
impl<'a> NamedFieldDef<'a> {}
2018-08-14 11:45:56 +00:00
2018-08-14 09:38:20 +00:00
// NeverType
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct NeverType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for NeverType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
NEVER_TYPE => Some(NeverType { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> NeverType<'a> {}
2018-08-14 09:38:20 +00:00
2018-08-14 10:33:44 +00:00
// NominalDef
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub enum NominalDef<'a> {
StructDef(StructDef<'a>),
EnumDef(EnumDef<'a>),
2018-08-14 10:33:44 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for NominalDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 10:33:44 +00:00
match syntax.kind() {
STRUCT_DEF => Some(NominalDef::StructDef(StructDef { syntax })),
ENUM_DEF => Some(NominalDef::EnumDef(EnumDef { syntax })),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> {
2018-08-14 10:33:44 +00:00
match self {
NominalDef::StructDef(inner) => inner.syntax(),
NominalDef::EnumDef(inner) => inner.syntax(),
}
}
}
2018-08-22 15:05:43 +00:00
impl<'a> ast::NameOwner<'a> for NominalDef<'a> {}
2018-08-22 13:46:42 +00:00
impl<'a> ast::TypeParamsOwner<'a> for NominalDef<'a> {}
2018-08-22 15:05:43 +00:00
impl<'a> ast::AttrsOwner<'a> for NominalDef<'a> {}
2018-08-17 19:00:13 +00:00
impl<'a> NominalDef<'a> {}
2018-08-14 10:33:44 +00:00
2018-08-14 09:38:20 +00:00
// ParenType
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct ParenType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for ParenType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
PAREN_TYPE => Some(ParenType { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> ParenType<'a> {}
2018-08-14 09:38:20 +00:00
// PathType
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct PathType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for PathType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
PATH_TYPE => Some(PathType { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> PathType<'a> {}
2018-08-14 09:38:20 +00:00
// PlaceholderType
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct PlaceholderType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for PlaceholderType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
PLACEHOLDER_TYPE => Some(PlaceholderType { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> PlaceholderType<'a> {}
2018-08-14 09:38:20 +00:00
// PointerType
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct PointerType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for PointerType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
POINTER_TYPE => Some(PointerType { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> PointerType<'a> {}
2018-08-14 09:38:20 +00:00
// ReferenceType
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct ReferenceType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for ReferenceType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
REFERENCE_TYPE => Some(ReferenceType { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> ReferenceType<'a> {}
2018-08-14 09:38:20 +00:00
// SliceType
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct SliceType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for SliceType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
SLICE_TYPE => Some(SliceType { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> SliceType<'a> {}
2018-08-14 09:38:20 +00:00
2018-08-13 15:36:16 +00:00
// StaticDef
2018-08-11 08:03:22 +00:00
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct StaticDef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-11 08:03:22 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for StaticDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 08:03:22 +00:00
match syntax.kind() {
2018-08-13 15:36:16 +00:00
STATIC_DEF => Some(StaticDef { syntax }),
2018-08-11 08:03:22 +00:00
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 08:03:22 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> ast::NameOwner<'a> for StaticDef<'a> {}
2018-08-22 13:46:42 +00:00
impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {}
2018-08-17 19:00:13 +00:00
impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {}
impl<'a> StaticDef<'a> {}
2018-08-11 08:03:22 +00:00
2018-08-13 15:36:16 +00:00
// StructDef
2018-08-11 07:56:40 +00:00
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct StructDef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-11 07:56:40 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for StructDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 07:56:40 +00:00
match syntax.kind() {
2018-08-13 15:36:16 +00:00
STRUCT_DEF => Some(StructDef { syntax }),
2018-08-11 07:56:40 +00:00
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 07:56:40 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> ast::NameOwner<'a> for StructDef<'a> {}
2018-08-22 13:46:42 +00:00
impl<'a> ast::TypeParamsOwner<'a> for StructDef<'a> {}
2018-08-17 19:00:13 +00:00
impl<'a> ast::AttrsOwner<'a> for StructDef<'a> {}
impl<'a> StructDef<'a> {
2018-08-24 16:27:30 +00:00
pub fn fields(self) -> impl Iterator<Item = NamedFieldDef<'a>> + 'a {
2018-08-22 14:01:51 +00:00
super::children(self)
2018-08-14 11:45:56 +00:00
}
}
2018-08-11 07:56:40 +00:00
2018-08-16 09:51:40 +00:00
// TokenTree
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct TokenTree<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-16 09:51:40 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for TokenTree<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-16 09:51:40 +00:00
match syntax.kind() {
TOKEN_TREE => Some(TokenTree { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-16 09:51:40 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> TokenTree<'a> {}
2018-08-16 09:51:40 +00:00
2018-08-13 15:36:16 +00:00
// TraitDef
2018-08-11 08:03:22 +00:00
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct TraitDef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-11 08:03:22 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for TraitDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 08:03:22 +00:00
match syntax.kind() {
2018-08-13 15:36:16 +00:00
TRAIT_DEF => Some(TraitDef { syntax }),
2018-08-11 08:03:22 +00:00
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 08:03:22 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> ast::NameOwner<'a> for TraitDef<'a> {}
impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {}
impl<'a> TraitDef<'a> {}
2018-08-11 08:03:22 +00:00
2018-08-14 09:38:20 +00:00
// TupleType
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct TupleType<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for TupleType<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
TUPLE_TYPE => Some(TupleType { syntax }),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-14 09:38:20 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> TupleType<'a> {}
2018-08-14 09:38:20 +00:00
2018-08-13 15:36:16 +00:00
// TypeDef
2018-08-11 13:20:37 +00:00
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub struct TypeDef<'a> {
syntax: SyntaxNodeRef<'a>,
2018-08-11 13:20:37 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> AstNode<'a> for TypeDef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-11 13:20:37 +00:00
match syntax.kind() {
2018-08-13 15:36:16 +00:00
TYPE_DEF => Some(TypeDef { syntax }),
2018-08-11 13:20:37 +00:00
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
2018-08-11 13:20:37 +00:00
}
2018-08-17 19:00:13 +00:00
impl<'a> ast::NameOwner<'a> for TypeDef<'a> {}
2018-08-22 13:46:42 +00:00
impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {}
2018-08-17 19:00:13 +00:00
impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {}
impl<'a> TypeDef<'a> {}
2018-08-11 13:20:37 +00:00
2018-08-22 16:02:37 +00:00
// TypeParam
#[derive(Debug, Clone, Copy)]
pub struct TypeParam<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for TypeParam<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
TYPE_PARAM => Some(TypeParam { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
impl<'a> ast::NameOwner<'a> for TypeParam<'a> {}
impl<'a> TypeParam<'a> {}
2018-08-22 13:46:42 +00:00
// TypeParamList
#[derive(Debug, Clone, Copy)]
pub struct TypeParamList<'a> {
syntax: SyntaxNodeRef<'a>,
}
impl<'a> AstNode<'a> for TypeParamList<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
TYPE_PARAM_LIST => Some(TypeParamList { syntax }),
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-08-22 16:02:37 +00:00
impl<'a> TypeParamList<'a> {
pub fn type_params(self) -> impl Iterator<Item = TypeParam<'a>> + 'a {
super::children(self)
}
}
2018-08-22 13:46:42 +00:00
2018-08-14 09:38:20 +00:00
// TypeRef
#[derive(Debug, Clone, Copy)]
2018-08-17 19:00:13 +00:00
pub enum TypeRef<'a> {
ParenType(ParenType<'a>),
TupleType(TupleType<'a>),
NeverType(NeverType<'a>),
PathType(PathType<'a>),
PointerType(PointerType<'a>),
ArrayType(ArrayType<'a>),
SliceType(SliceType<'a>),
ReferenceType(ReferenceType<'a>),
PlaceholderType(PlaceholderType<'a>),
FnPointerType(FnPointerType<'a>),
ForType(ForType<'a>),
ImplTraitType(ImplTraitType<'a>),
DynTraitType(DynTraitType<'a>),
}
impl<'a> AstNode<'a> for TypeRef<'a> {
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
2018-08-14 09:38:20 +00:00
match syntax.kind() {
PAREN_TYPE => Some(TypeRef::ParenType(ParenType { syntax })),
TUPLE_TYPE => Some(TypeRef::TupleType(TupleType { syntax })),
NEVER_TYPE => Some(TypeRef::NeverType(NeverType { syntax })),
PATH_TYPE => Some(TypeRef::PathType(PathType { syntax })),
POINTER_TYPE => Some(TypeRef::PointerType(PointerType { syntax })),
ARRAY_TYPE => Some(TypeRef::ArrayType(ArrayType { syntax })),
SLICE_TYPE => Some(TypeRef::SliceType(SliceType { syntax })),
REFERENCE_TYPE => Some(TypeRef::ReferenceType(ReferenceType { syntax })),
PLACEHOLDER_TYPE => Some(TypeRef::PlaceholderType(PlaceholderType { syntax })),
FN_POINTER_TYPE => Some(TypeRef::FnPointerType(FnPointerType { syntax })),
FOR_TYPE => Some(TypeRef::ForType(ForType { syntax })),
IMPL_TRAIT_TYPE => Some(TypeRef::ImplTraitType(ImplTraitType { syntax })),
DYN_TRAIT_TYPE => Some(TypeRef::DynTraitType(DynTraitType { syntax })),
_ => None,
}
}
2018-08-17 19:00:13 +00:00
fn syntax(self) -> SyntaxNodeRef<'a> {
2018-08-14 09:38:20 +00:00
match self {
TypeRef::ParenType(inner) => inner.syntax(),
TypeRef::TupleType(inner) => inner.syntax(),
TypeRef::NeverType(inner) => inner.syntax(),
TypeRef::PathType(inner) => inner.syntax(),
TypeRef::PointerType(inner) => inner.syntax(),
TypeRef::ArrayType(inner) => inner.syntax(),
TypeRef::SliceType(inner) => inner.syntax(),
TypeRef::ReferenceType(inner) => inner.syntax(),
TypeRef::PlaceholderType(inner) => inner.syntax(),
TypeRef::FnPointerType(inner) => inner.syntax(),
TypeRef::ForType(inner) => inner.syntax(),
TypeRef::ImplTraitType(inner) => inner.syntax(),
TypeRef::DynTraitType(inner) => inner.syntax(),
}
}
}
2018-08-17 19:00:13 +00:00
impl<'a> TypeRef<'a> {}
2018-08-14 09:38:20 +00:00
2018-08-22 13:46:42 +00:00
// WhereClause
2018-08-22 08:56:36 +00:00
#[derive(Debug, Clone, Copy)]
2018-08-22 13:46:42 +00:00
pub struct WhereClause<'a> {
2018-08-22 08:56:36 +00:00
syntax: SyntaxNodeRef<'a>,
}
2018-08-22 13:46:42 +00:00
impl<'a> AstNode<'a> for WhereClause<'a> {
2018-08-22 08:56:36 +00:00
fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
match syntax.kind() {
2018-08-22 13:46:42 +00:00
WHERE_CLAUSE => Some(WhereClause { syntax }),
2018-08-22 08:56:36 +00:00
_ => None,
}
}
fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
}
2018-08-22 13:46:42 +00:00
impl<'a> WhereClause<'a> {}
2018-08-22 08:56:36 +00:00