From 55dcdb7d094f473c73f87ecf997b24f8e35f2a5e Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Sun, 31 Mar 2019 10:56:48 +0300 Subject: Add trait ast::TypeBoundsOwner --- crates/ra_syntax/src/ast.rs | 6 ++++++ crates/ra_syntax/src/ast/generated.rs | 5 +++++ crates/ra_syntax/src/grammar.ron | 15 ++++++++++----- 3 files changed, 21 insertions(+), 5 deletions(-) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index a6fac07c4..4fddc00ea 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs @@ -110,6 +110,12 @@ pub trait TypeParamsOwner: AstNode { } } +pub trait TypeBoundsOwner: AstNode { + fn type_bound_list(&self) -> Option<&TypeBoundList> { + child_opt(self) + } +} + pub trait AttrsOwner: AstNode { fn attrs(&self) -> AstChildren { children(self) diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index faf80bc32..9ea423b40 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -685,6 +685,7 @@ impl ToOwned for DynTraitType { } +impl ast::TypeBoundsOwner for DynTraitType {} impl DynTraitType {} // EnumDef @@ -1581,6 +1582,7 @@ impl ToOwned for ImplTraitType { } +impl ast::TypeBoundsOwner for ImplTraitType {} impl ImplTraitType {} // IndexExpr @@ -4061,6 +4063,7 @@ impl ast::NameOwner for TraitDef {} impl ast::AttrsOwner for TraitDef {} impl ast::DocCommentsOwner for TraitDef {} impl ast::TypeParamsOwner for TraitDef {} +impl ast::TypeBoundsOwner for TraitDef {} impl TraitDef { pub fn item_list(&self) -> Option<&ItemList> { super::child_opt(self) @@ -4291,6 +4294,7 @@ impl ast::NameOwner for TypeAliasDef {} impl ast::TypeParamsOwner for TypeAliasDef {} impl ast::AttrsOwner for TypeAliasDef {} impl ast::DocCommentsOwner for TypeAliasDef {} +impl ast::TypeBoundsOwner for TypeAliasDef {} impl TypeAliasDef { pub fn type_ref(&self) -> Option<&TypeRef> { super::child_opt(self) @@ -4465,6 +4469,7 @@ impl ToOwned for TypeParam { impl ast::NameOwner for TypeParam {} impl ast::AttrsOwner for TypeParam {} +impl ast::TypeBoundsOwner for TypeParam {} impl TypeParam {} // TypeParamList diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 660a2b207..18730a894 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -295,7 +295,7 @@ Grammar( "EnumVariantList": ( collections: [["variants", "EnumVariant"]] ), "EnumVariant": ( traits: ["NameOwner", "DocCommentsOwner", "AttrsOwner"], options: ["Expr"] ), "TraitDef": ( - traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner", "TypeParamsOwner"], + traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner", "TypeParamsOwner", "TypeBoundsOwner"], options: ["ItemList"] ), "Module": ( @@ -332,7 +332,8 @@ Grammar( "NameOwner", "TypeParamsOwner", "AttrsOwner", - "DocCommentsOwner" + "DocCommentsOwner", + "TypeBoundsOwner", ], options: ["TypeRef"] ), @@ -349,8 +350,12 @@ Grammar( "PlaceholderType": (), "FnPointerType": (options: ["ParamList", "RetType"]), "ForType": (options: ["TypeRef"]), - "ImplTraitType": (), - "DynTraitType": (), + "ImplTraitType": ( + traits: ["TypeBoundsOwner"], + ), + "DynTraitType": ( + traits: ["TypeBoundsOwner"], + ), "TypeRef": ( enum: [ "ParenType", @@ -573,7 +578,7 @@ Grammar( ["lifetime_params", "LifetimeParam" ], ] ), - "TypeParam": ( traits: ["NameOwner", "AttrsOwner"] ), + "TypeParam": ( traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner"] ), "LifetimeParam": ( options: [ "Lifetime"], traits: ["AttrsOwner"], -- cgit v1.2.3