aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-22 17:02:37 +0100
committerAleksey Kladov <[email protected]>2018-08-22 17:06:30 +0100
commit8d82d1551ee09faa5d46a58c17c40c2515d3f3b9 (patch)
treebdff5ca6dc2d4be1ef0aca616ba920d8ff2933e0 /crates/libsyntax2
parent147578f0fe28dee9ba3bfe3ed8805ffe3a525611 (diff)
Extend add impl
Diffstat (limited to 'crates/libsyntax2')
-rw-r--r--crates/libsyntax2/src/ast/generated.rs25
-rw-r--r--crates/libsyntax2/src/grammar.ron3
2 files changed, 26 insertions, 2 deletions
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> {}
580impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {} 580impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {}
581impl<'a> TypeDef<'a> {} 581impl<'a> TypeDef<'a> {}
582 582
583// TypeParam
584#[derive(Debug, Clone, Copy)]
585pub struct TypeParam<'a> {
586 syntax: SyntaxNodeRef<'a>,
587}
588
589impl<'a> AstNode<'a> for TypeParam<'a> {
590 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
591 match syntax.kind() {
592 TYPE_PARAM => Some(TypeParam { syntax }),
593 _ => None,
594 }
595 }
596 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
597}
598
599impl<'a> ast::NameOwner<'a> for TypeParam<'a> {}
600impl<'a> TypeParam<'a> {}
601
583// TypeParamList 602// TypeParamList
584#[derive(Debug, Clone, Copy)] 603#[derive(Debug, Clone, Copy)]
585pub struct TypeParamList<'a> { 604pub struct TypeParamList<'a> {
@@ -596,7 +615,11 @@ impl<'a> AstNode<'a> for TypeParamList<'a> {
596 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } 615 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
597} 616}
598 617
599impl<'a> TypeParamList<'a> {} 618impl<'a> TypeParamList<'a> {
619 pub fn type_params(self) -> impl Iterator<Item = TypeParam<'a>> + 'a {
620 super::children(self)
621 }
622}
600 623
601// TypeRef 624// TypeRef
602#[derive(Debug, Clone, Copy)] 625#[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(
310 "NameRef": (), 310 "NameRef": (),
311 "Attr": ( options: [ ["value", "TokenTree"] ] ), 311 "Attr": ( options: [ ["value", "TokenTree"] ] ),
312 "TokenTree": (), 312 "TokenTree": (),
313 "TypeParamList": (), 313 "TypeParamList": ( collections: [ ["type_params", "TypeParam" ] ]),
314 "TypeParam": ( traits: ["NameOwner"]),
314 "WhereClause": (), 315 "WhereClause": (),
315 }, 316 },
316) 317)