From 4798a89a12f40af17174a160f6d6a2f1c53db8d6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 3 Sep 2018 15:10:06 +0300 Subject: Complete params --- crates/libsyntax2/src/ast/generated.rs | 33 ++++++++++++++++++++++++++------- crates/libsyntax2/src/ast/mod.rs | 6 ++++++ 2 files changed, 32 insertions(+), 7 deletions(-) (limited to 'crates/libsyntax2/src/ast') diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index 11306a835..4a57837df 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs @@ -682,6 +682,28 @@ impl<'a> AstNode<'a> for IndexExpr<'a> { impl<'a> IndexExpr<'a> {} +// ItemList +#[derive(Debug, Clone, Copy)] +pub struct ItemList<'a> { + syntax: SyntaxNodeRef<'a>, +} + +impl<'a> AstNode<'a> for ItemList<'a> { + fn cast(syntax: SyntaxNodeRef<'a>) -> Option { + match syntax.kind() { + ITEM_LIST => Some(ItemList { syntax }), + _ => None, + } + } + fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } +} + +impl<'a> ItemList<'a> { + pub fn items(self) -> impl Iterator> + 'a { + super::children(self) + } +} + // Label #[derive(Debug, Clone, Copy)] pub struct Label<'a> { @@ -956,9 +978,9 @@ impl<'a> AstNode<'a> for Module<'a> { impl<'a> ast::NameOwner<'a> for Module<'a> {} impl<'a> ast::AttrsOwner<'a> for Module<'a> {} -impl<'a> Module<'a> { - pub fn items(self) -> impl Iterator> + 'a { - super::children(self) +impl<'a> ast::FnDefOwner<'a> for Module<'a> {} +impl<'a> Module<'a> {pub fn item_list(self) -> Option> { + super::child_opt(self) } } @@ -1593,15 +1615,12 @@ impl<'a> AstNode<'a> for Root<'a> { fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } +impl<'a> ast::FnDefOwner<'a> for Root<'a> {} impl<'a> Root<'a> { pub fn items(self) -> impl Iterator> + 'a { super::children(self) } - pub fn functions(self) -> impl Iterator> + 'a { - super::children(self) - } - pub fn modules(self) -> impl Iterator> + 'a { super::children(self) } diff --git a/crates/libsyntax2/src/ast/mod.rs b/crates/libsyntax2/src/ast/mod.rs index 274996171..881f380f3 100644 --- a/crates/libsyntax2/src/ast/mod.rs +++ b/crates/libsyntax2/src/ast/mod.rs @@ -32,6 +32,12 @@ pub trait ArgListOwner<'a>: AstNode<'a> { } } +pub trait FnDefOwner<'a>: AstNode<'a> { + fn functions(self) -> Box> + 'a> { + Box::new(children(self)) + } +} + pub trait TypeParamsOwner<'a>: AstNode<'a> { fn type_param_list(self) -> Option> { child_opt(self) -- cgit v1.2.3