-// Generated file, do not edit by hand, see `crate/ra_tools/src/codegen`
+//! Generated file, do not edit by hand, see `crate/ra_tools/src/codegen`
use crate::{
ast::{self, AstChildren, AstNode},
}
}
impl Attr {
- pub fn value(&self) -> Option<TokenTree> {
+ pub fn path(&self) -> Option<Path> {
+ AstChildren::new(&self.syntax).next()
+ }
+ pub fn input(&self) -> Option<AttrInput> {
AstChildren::new(&self.syntax).next()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub enum AttrInput {
+ Literal(Literal),
+ TokenTree(TokenTree),
+}
+impl From<Literal> for AttrInput {
+ fn from(node: Literal) -> AttrInput {
+ AttrInput::Literal(node)
+ }
+}
+impl From<TokenTree> for AttrInput {
+ fn from(node: TokenTree) -> AttrInput {
+ AttrInput::TokenTree(node)
+ }
+}
+impl AstNode for AttrInput {
+ fn can_cast(kind: SyntaxKind) -> bool {
+ match kind {
+ LITERAL | TOKEN_TREE => true,
+ _ => false,
+ }
+ }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ let res = match syntax.kind() {
+ LITERAL => AttrInput::Literal(Literal { syntax }),
+ TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }),
+ _ => return None,
+ };
+ Some(res)
+ }
+ fn syntax(&self) -> &SyntaxNode {
+ match self {
+ AttrInput::Literal(it) => &it.syntax,
+ AttrInput::TokenTree(it) => &it.syntax,
+ }
+ }
+}
+impl AttrInput {}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AwaitExpr {
pub(crate) syntax: SyntaxNode,
}
}
}
impl ast::AttrsOwner for Block {}
+impl ast::ModuleItemOwner for Block {}
impl Block {
pub fn statements(&self) -> AstChildren<Stmt> {
AstChildren::new(&self.syntax)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct BoxExpr {
+ pub(crate) syntax: SyntaxNode,
+}
+impl AstNode for BoxExpr {
+ fn can_cast(kind: SyntaxKind) -> bool {
+ match kind {
+ BOX_EXPR => true,
+ _ => false,
+ }
+ }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ if Self::can_cast(syntax.kind()) {
+ Some(Self { syntax })
+ } else {
+ None
+ }
+ }
+ fn syntax(&self) -> &SyntaxNode {
+ &self.syntax
+ }
+}
+impl BoxExpr {
+ pub fn expr(&self) -> Option<Expr> {
+ AstChildren::new(&self.syntax).next()
+ }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct BoxPat {
pub(crate) syntax: SyntaxNode,
}
}
impl ContinueExpr {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct DotDotPat {
+ pub(crate) syntax: SyntaxNode,
+}
+impl AstNode for DotDotPat {
+ fn can_cast(kind: SyntaxKind) -> bool {
+ match kind {
+ DOT_DOT_PAT => true,
+ _ => false,
+ }
+ }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ if Self::can_cast(syntax.kind()) {
+ Some(Self { syntax })
+ } else {
+ None
+ }
+ }
+ fn syntax(&self) -> &SyntaxNode {
+ &self.syntax
+ }
+}
+impl DotDotPat {}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DynTraitType {
pub(crate) syntax: SyntaxNode,
}
BinExpr(BinExpr),
Literal(Literal),
MacroCall(MacroCall),
+ BoxExpr(BoxExpr),
}
impl From<TupleExpr> for Expr {
fn from(node: TupleExpr) -> Expr {
Expr::MacroCall(node)
}
}
+impl From<BoxExpr> for Expr {
+ fn from(node: BoxExpr) -> Expr {
+ Expr::BoxExpr(node)
+ }
+}
impl AstNode for Expr {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
| LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL
| BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR
| METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR
- | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL => {
- true
- }
+ | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL
+ | BOX_EXPR => true,
_ => false,
}
}
BIN_EXPR => Expr::BinExpr(BinExpr { syntax }),
LITERAL => Expr::Literal(Literal { syntax }),
MACRO_CALL => Expr::MacroCall(MacroCall { syntax }),
+ BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }),
_ => return None,
};
Some(res)
Expr::BinExpr(it) => &it.syntax,
Expr::Literal(it) => &it.syntax,
Expr::MacroCall(it) => &it.syntax,
+ Expr::BoxExpr(it) => &it.syntax,
}
}
}
&self.syntax
}
}
+impl ast::AttrsOwner for ExternCrateItem {}
impl ExternCrateItem {
pub fn name_ref(&self) -> Option<NameRef> {
AstChildren::new(&self.syntax).next()
pub fn param_list(&self) -> Option<ParamList> {
AstChildren::new(&self.syntax).next()
}
- pub fn body(&self) -> Option<Block> {
+ pub fn body(&self) -> Option<BlockExpr> {
AstChildren::new(&self.syntax).next()
}
pub fn ret_type(&self) -> Option<RetType> {
}
}
}
+impl ast::AttrsOwner for ImplItem {}
impl ImplItem {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ImplTraitType {
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ModuleItem {
StructDef(StructDef),
+ UnionDef(UnionDef),
EnumDef(EnumDef),
FnDef(FnDef),
TraitDef(TraitDef),
ModuleItem::StructDef(node)
}
}
+impl From<UnionDef> for ModuleItem {
+ fn from(node: UnionDef) -> ModuleItem {
+ ModuleItem::UnionDef(node)
+ }
+}
impl From<EnumDef> for ModuleItem {
fn from(node: EnumDef) -> ModuleItem {
ModuleItem::EnumDef(node)
impl AstNode for ModuleItem {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- STRUCT_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_BLOCK | USE_ITEM
- | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true,
+ STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF
+ | IMPL_BLOCK | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true,
_ => false,
}
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }),
+ UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }),
ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }),
FN_DEF => ModuleItem::FnDef(FnDef { syntax }),
TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }),
fn syntax(&self) -> &SyntaxNode {
match self {
ModuleItem::StructDef(it) => &it.syntax,
+ ModuleItem::UnionDef(it) => &it.syntax,
ModuleItem::EnumDef(it) => &it.syntax,
ModuleItem::FnDef(it) => &it.syntax,
ModuleItem::TraitDef(it) => &it.syntax,
}
}
}
+impl ast::AttrsOwner for ModuleItem {}
impl ModuleItem {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Name {
pub enum NominalDef {
StructDef(StructDef),
EnumDef(EnumDef),
+ UnionDef(UnionDef),
}
impl From<StructDef> for NominalDef {
fn from(node: StructDef) -> NominalDef {
NominalDef::EnumDef(node)
}
}
+impl From<UnionDef> for NominalDef {
+ fn from(node: UnionDef) -> NominalDef {
+ NominalDef::UnionDef(node)
+ }
+}
impl AstNode for NominalDef {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- STRUCT_DEF | ENUM_DEF => true,
+ STRUCT_DEF | ENUM_DEF | UNION_DEF => true,
_ => false,
}
}
let res = match syntax.kind() {
STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }),
ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }),
+ UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }),
_ => return None,
};
Some(res)
match self {
NominalDef::StructDef(it) => &it.syntax,
NominalDef::EnumDef(it) => &it.syntax,
+ NominalDef::UnionDef(it) => &it.syntax,
}
}
}
BoxPat(BoxPat),
BindPat(BindPat),
PlaceholderPat(PlaceholderPat),
+ DotDotPat(DotDotPat),
PathPat(PathPat),
RecordPat(RecordPat),
TupleStructPat(TupleStructPat),
Pat::PlaceholderPat(node)
}
}
+impl From<DotDotPat> for Pat {
+ fn from(node: DotDotPat) -> Pat {
+ Pat::DotDotPat(node)
+ }
+}
impl From<PathPat> for Pat {
fn from(node: PathPat) -> Pat {
Pat::PathPat(node)
impl AstNode for Pat {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
- REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | RECORD_PAT
- | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true,
+ REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | PATH_PAT
+ | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => {
+ true
+ }
_ => false,
}
}
BOX_PAT => Pat::BoxPat(BoxPat { syntax }),
BIND_PAT => Pat::BindPat(BindPat { syntax }),
PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }),
+ DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }),
PATH_PAT => Pat::PathPat(PathPat { syntax }),
RECORD_PAT => Pat::RecordPat(RecordPat { syntax }),
TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }),
Pat::BoxPat(it) => &it.syntax,
Pat::BindPat(it) => &it.syntax,
Pat::PlaceholderPat(it) => &it.syntax,
+ Pat::DotDotPat(it) => &it.syntax,
Pat::PathPat(it) => &it.syntax,
Pat::RecordPat(it) => &it.syntax,
Pat::TupleStructPat(it) => &it.syntax,
pub fn type_arg_list(&self) -> Option<TypeArgList> {
AstChildren::new(&self.syntax).next()
}
+ pub fn param_list(&self) -> Option<ParamList> {
+ AstChildren::new(&self.syntax).next()
+ }
+ pub fn ret_type(&self) -> Option<RetType> {
+ AstChildren::new(&self.syntax).next()
+ }
+ pub fn path_type(&self) -> Option<PathType> {
+ AstChildren::new(&self.syntax).next()
+ }
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PathType {
&self.syntax
}
}
-impl ast::TryBlockBodyOwner for TryBlockExpr {}
-impl TryBlockExpr {}
+impl TryBlockExpr {
+ pub fn body(&self) -> Option<BlockExpr> {
+ AstChildren::new(&self.syntax).next()
+ }
+}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TryExpr {
pub(crate) syntax: SyntaxNode,
impl ast::NameOwner for TypeParam {}
impl ast::AttrsOwner for TypeParam {}
impl ast::TypeBoundsOwner for TypeParam {}
-impl ast::DefaultTypeParamOwner for TypeParam {}
-impl TypeParam {}
+impl TypeParam {
+ pub fn default_type(&self) -> Option<TypeRef> {
+ AstChildren::new(&self.syntax).next()
+ }
+}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TypeParamList {
pub(crate) syntax: SyntaxNode,
}
impl TypeRef {}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct UnionDef {
+ pub(crate) syntax: SyntaxNode,
+}
+impl AstNode for UnionDef {
+ fn can_cast(kind: SyntaxKind) -> bool {
+ match kind {
+ UNION_DEF => true,
+ _ => false,
+ }
+ }
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ if Self::can_cast(syntax.kind()) {
+ Some(Self { syntax })
+ } else {
+ None
+ }
+ }
+ fn syntax(&self) -> &SyntaxNode {
+ &self.syntax
+ }
+}
+impl ast::VisibilityOwner for UnionDef {}
+impl ast::NameOwner for UnionDef {}
+impl ast::TypeParamsOwner for UnionDef {}
+impl ast::AttrsOwner for UnionDef {}
+impl ast::DocCommentsOwner for UnionDef {}
+impl UnionDef {
+ pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
+ AstChildren::new(&self.syntax).next()
+ }
+}
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct UseItem {
pub(crate) syntax: SyntaxNode,
}