From 9e4fee8b41b1ff4cf2b36d550c6cdb689b914f15 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 3 May 2019 12:18:35 +0800 Subject: Add default type param in TypeParam Node --- crates/ra_syntax/src/ast/generated.rs | 1 + crates/ra_syntax/src/ast/traits.rs | 6 ++++++ crates/ra_syntax/src/grammar.ron | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index fae371509..19a3362ca 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -4038,6 +4038,7 @@ impl ToOwned for TypeParam { impl ast::NameOwner for TypeParam {} impl ast::AttrsOwner for TypeParam {} impl ast::TypeBoundsOwner for TypeParam {} +impl ast::DefaultTypeParamOwner for TypeParam {} impl TypeParam {} // TypeParamList diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs index aaf07d731..1c90cf148 100644 --- a/crates/ra_syntax/src/ast/traits.rs +++ b/crates/ra_syntax/src/ast/traits.rs @@ -152,3 +152,9 @@ impl<'a> Iterator for CommentIter<'a> { self.iter.by_ref().find_map(|el| el.as_token().and_then(ast::Comment::cast)) } } + +pub trait DefaultTypeParamOwner: AstNode { + fn default_type(&self) -> Option<&ast::PathType> { + child_opt(self) + } +} diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 5bdcf9c84..011ef0616 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -563,7 +563,7 @@ Grammar( ["lifetime_params", "LifetimeParam" ], ] ), - "TypeParam": ( traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner"] ), + "TypeParam": ( traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner", "DefaultTypeParamOwner"] ), "LifetimeParam": ( traits: ["AttrsOwner"], ), -- cgit v1.2.3