From ae9530addc4c5e9bbfd5c0287d3c3adb2de95e40 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 28 Dec 2018 14:34:00 +0100 Subject: Add HIR for impl blocks Since we need to be able to go from def to containing impl block, as well as the other direction, and to find all impls for a certain type, a design similar to the one for modules, where we collect all impls for the whole crate and keep them in an arena, seemed fitting. The ImplBlock type, which provides the public interface, then consists only of an Arc to the arena containing all impls, and the index into it. --- crates/ra_syntax/src/grammar.ron | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crates/ra_syntax/src/grammar.ron') diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 9a4a96fac..688a4af1e 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -284,6 +284,7 @@ Grammar( options: [ "ItemList" ] ), "ItemList": ( + collections: [["impl_items", "ImplItem"]], traits: [ "FnDefOwner", "ModuleItemOwner" ], ), "ConstDef": ( traits: [ @@ -307,7 +308,7 @@ Grammar( "AttrsOwner", "DocCommentsOwner" ] ), - "ImplBlock": (collections: []), + "ImplBlock": (options: ["ItemList"]), "ParenType": (options: ["TypeRef"]), "TupleType": ( collections: [["fields", "TypeRef"]] ), @@ -351,6 +352,9 @@ Grammar( enum: ["StructDef", "EnumDef", "FnDef", "TraitDef", "TypeDef", "ImplBlock", "UseItem", "ExternCrateItem", "ConstDef", "StaticDef", "Module" ] ), + "ImplItem": ( + enum: ["FnDef", "TypeDef", "ConstDef"] + ), "TupleExpr": (), "ArrayExpr": (), -- cgit v1.2.3 From 111126ed3c4f6358e0c833f80226e5192778f749 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 29 Dec 2018 21:32:07 +0100 Subject: Type the self parameter --- crates/ra_syntax/src/grammar.ron | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crates/ra_syntax/src/grammar.ron') diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index 688a4af1e..c55e9e07a 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -534,7 +534,8 @@ Grammar( ["params", "Param"] ] ), - "SelfParam": (), + "SelfParam": (options: ["TypeRef", "SelfKw"]), + "SelfKw": (), "Param": ( options: [ "Pat", "TypeRef" ], ), -- cgit v1.2.3