From 8d82d1551ee09faa5d46a58c17c40c2515d3f3b9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 22 Aug 2018 19:02:37 +0300 Subject: Extend add impl --- crates/libsyntax2/src/ast/generated.rs | 25 ++++++++++++++++++++++++- crates/libsyntax2/src/grammar.ron | 3 ++- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'crates/libsyntax2/src') diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index 6df1d2311..5edb9faaa 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs @@ -580,6 +580,25 @@ impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {} impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {} impl<'a> TypeDef<'a> {} +// 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 { + 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> {} + // TypeParamList #[derive(Debug, Clone, Copy)] pub struct TypeParamList<'a> { @@ -596,7 +615,11 @@ impl<'a> AstNode<'a> for TypeParamList<'a> { fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } } -impl<'a> TypeParamList<'a> {} +impl<'a> TypeParamList<'a> { + pub fn type_params(self) -> impl Iterator> + 'a { + super::children(self) + } +} // TypeRef #[derive(Debug, Clone, Copy)] diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron index e56496be1..daf80dde3 100644 --- a/crates/libsyntax2/src/grammar.ron +++ b/crates/libsyntax2/src/grammar.ron @@ -310,7 +310,8 @@ Grammar( "NameRef": (), "Attr": ( options: [ ["value", "TokenTree"] ] ), "TokenTree": (), - "TypeParamList": (), + "TypeParamList": ( collections: [ ["type_params", "TypeParam" ] ]), + "TypeParam": ( traits: ["NameOwner"]), "WhereClause": (), }, ) -- cgit v1.2.3