diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-03 14:06:55 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-03 14:06:55 +0100 |
commit | b29f442c8b8601feec4dbc49f121801b153d83e1 (patch) | |
tree | 205b8e397a979ec742667f65eb781178e2e68c8c /crates/ra_syntax | |
parent | e593d4ac73497f01d577a88ff1a0d57f63734dbf (diff) | |
parent | 9e4fee8b41b1ff4cf2b36d550c6cdb689b914f15 (diff) |
Merge #1227
1227: Add `default_type` method in `TypeParam` Node r=matklad a=edwin0cheng
This PR add a `default_type` method in `TypeParam` Node which allow future PR to handle #1099 case.
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 1 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/traits.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar.ron | 2 |
3 files changed, 8 insertions, 1 deletions
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 { | |||
4038 | impl ast::NameOwner for TypeParam {} | 4038 | impl ast::NameOwner for TypeParam {} |
4039 | impl ast::AttrsOwner for TypeParam {} | 4039 | impl ast::AttrsOwner for TypeParam {} |
4040 | impl ast::TypeBoundsOwner for TypeParam {} | 4040 | impl ast::TypeBoundsOwner for TypeParam {} |
4041 | impl ast::DefaultTypeParamOwner for TypeParam {} | ||
4041 | impl TypeParam {} | 4042 | impl TypeParam {} |
4042 | 4043 | ||
4043 | // TypeParamList | 4044 | // 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> { | |||
152 | self.iter.by_ref().find_map(|el| el.as_token().and_then(ast::Comment::cast)) | 152 | self.iter.by_ref().find_map(|el| el.as_token().and_then(ast::Comment::cast)) |
153 | } | 153 | } |
154 | } | 154 | } |
155 | |||
156 | pub trait DefaultTypeParamOwner: AstNode { | ||
157 | fn default_type(&self) -> Option<&ast::PathType> { | ||
158 | child_opt(self) | ||
159 | } | ||
160 | } | ||
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( | |||
563 | ["lifetime_params", "LifetimeParam" ], | 563 | ["lifetime_params", "LifetimeParam" ], |
564 | ] | 564 | ] |
565 | ), | 565 | ), |
566 | "TypeParam": ( traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner"] ), | 566 | "TypeParam": ( traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner", "DefaultTypeParamOwner"] ), |
567 | "LifetimeParam": ( | 567 | "LifetimeParam": ( |
568 | traits: ["AttrsOwner"], | 568 | traits: ["AttrsOwner"], |
569 | ), | 569 | ), |