diff options
author | Aleksey Kladov <[email protected]> | 2018-09-03 13:10:06 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-09-03 13:10:06 +0100 |
commit | 4798a89a12f40af17174a160f6d6a2f1c53db8d6 (patch) | |
tree | 2a97f379f624127739188f35babfa9710b104bf4 /crates/libsyntax2/src/ast | |
parent | 58480b9190d8851abf7f634820188e33efed286d (diff) |
Complete params
Diffstat (limited to 'crates/libsyntax2/src/ast')
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs | 33 | ||||
-rw-r--r-- | crates/libsyntax2/src/ast/mod.rs | 6 |
2 files changed, 32 insertions, 7 deletions
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> { | |||
682 | 682 | ||
683 | impl<'a> IndexExpr<'a> {} | 683 | impl<'a> IndexExpr<'a> {} |
684 | 684 | ||
685 | // ItemList | ||
686 | #[derive(Debug, Clone, Copy)] | ||
687 | pub struct ItemList<'a> { | ||
688 | syntax: SyntaxNodeRef<'a>, | ||
689 | } | ||
690 | |||
691 | impl<'a> AstNode<'a> for ItemList<'a> { | ||
692 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
693 | match syntax.kind() { | ||
694 | ITEM_LIST => Some(ItemList { syntax }), | ||
695 | _ => None, | ||
696 | } | ||
697 | } | ||
698 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
699 | } | ||
700 | |||
701 | impl<'a> ItemList<'a> { | ||
702 | pub fn items(self) -> impl Iterator<Item = ModuleItem<'a>> + 'a { | ||
703 | super::children(self) | ||
704 | } | ||
705 | } | ||
706 | |||
685 | // Label | 707 | // Label |
686 | #[derive(Debug, Clone, Copy)] | 708 | #[derive(Debug, Clone, Copy)] |
687 | pub struct Label<'a> { | 709 | pub struct Label<'a> { |
@@ -956,9 +978,9 @@ impl<'a> AstNode<'a> for Module<'a> { | |||
956 | 978 | ||
957 | impl<'a> ast::NameOwner<'a> for Module<'a> {} | 979 | impl<'a> ast::NameOwner<'a> for Module<'a> {} |
958 | impl<'a> ast::AttrsOwner<'a> for Module<'a> {} | 980 | impl<'a> ast::AttrsOwner<'a> for Module<'a> {} |
959 | impl<'a> Module<'a> { | 981 | impl<'a> ast::FnDefOwner<'a> for Module<'a> {} |
960 | pub fn items(self) -> impl Iterator<Item = ModuleItem<'a>> + 'a { | 982 | impl<'a> Module<'a> {pub fn item_list(self) -> Option<ItemList<'a>> { |
961 | super::children(self) | 983 | super::child_opt(self) |
962 | } | 984 | } |
963 | } | 985 | } |
964 | 986 | ||
@@ -1593,15 +1615,12 @@ impl<'a> AstNode<'a> for Root<'a> { | |||
1593 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1615 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1594 | } | 1616 | } |
1595 | 1617 | ||
1618 | impl<'a> ast::FnDefOwner<'a> for Root<'a> {} | ||
1596 | impl<'a> Root<'a> { | 1619 | impl<'a> Root<'a> { |
1597 | pub fn items(self) -> impl Iterator<Item = ModuleItem<'a>> + 'a { | 1620 | pub fn items(self) -> impl Iterator<Item = ModuleItem<'a>> + 'a { |
1598 | super::children(self) | 1621 | super::children(self) |
1599 | } | 1622 | } |
1600 | 1623 | ||
1601 | pub fn functions(self) -> impl Iterator<Item = FnDef<'a>> + 'a { | ||
1602 | super::children(self) | ||
1603 | } | ||
1604 | |||
1605 | pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a { | 1624 | pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a { |
1606 | super::children(self) | 1625 | super::children(self) |
1607 | } | 1626 | } |
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> { | |||
32 | } | 32 | } |
33 | } | 33 | } |
34 | 34 | ||
35 | pub trait FnDefOwner<'a>: AstNode<'a> { | ||
36 | fn functions(self) -> Box<Iterator<Item=FnDef<'a>> + 'a> { | ||
37 | Box::new(children(self)) | ||
38 | } | ||
39 | } | ||
40 | |||
35 | pub trait TypeParamsOwner<'a>: AstNode<'a> { | 41 | pub trait TypeParamsOwner<'a>: AstNode<'a> { |
36 | fn type_param_list(self) -> Option<TypeParamList<'a>> { | 42 | fn type_param_list(self) -> Option<TypeParamList<'a>> { |
37 | child_opt(self) | 43 | child_opt(self) |