diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-24 22:56:13 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-24 22:56:13 +0000 |
commit | c42db0bbd750fae19a91f0a0354240ea6c3bafce (patch) | |
tree | beb7030248280fd8c67eb2b2c9cc4b19c6074c17 /crates/ra_syntax/src | |
parent | b308375b82a33687f93468d75c7cc628b83a1351 (diff) | |
parent | 31d3a56b1865c33ef54e5d76e606965c87676695 (diff) |
Merge #623
623: WIP: module id is not def id r=matklad a=matklad
This achieves two things:
* makes module_tree & item_map per crate, not per source_root
* begins the refactoring to remove universal `DefId` in favor of having separate ids for each kind of `Def`. Currently, only modules get a differnt ID though.
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 7 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 1 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar.ron | 4 |
3 files changed, 10 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index bcbd4c60c..fd65264b2 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -430,6 +430,13 @@ impl StructDef { | |||
430 | } | 430 | } |
431 | 431 | ||
432 | impl EnumVariant { | 432 | impl EnumVariant { |
433 | pub fn parent_enum(&self) -> &EnumDef { | ||
434 | self.syntax() | ||
435 | .parent() | ||
436 | .and_then(|it| it.parent()) | ||
437 | .and_then(EnumDef::cast) | ||
438 | .expect("EnumVariants are always nested in Enums") | ||
439 | } | ||
433 | pub fn flavor(&self) -> StructFlavor { | 440 | pub fn flavor(&self) -> StructFlavor { |
434 | StructFlavor::from_node(self) | 441 | StructFlavor::from_node(self) |
435 | } | 442 | } |
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index ac6c8a835..a207f8429 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -3229,6 +3229,7 @@ impl ast::VisibilityOwner for TraitDef {} | |||
3229 | impl ast::NameOwner for TraitDef {} | 3229 | impl ast::NameOwner for TraitDef {} |
3230 | impl ast::AttrsOwner for TraitDef {} | 3230 | impl ast::AttrsOwner for TraitDef {} |
3231 | impl ast::DocCommentsOwner for TraitDef {} | 3231 | impl ast::DocCommentsOwner for TraitDef {} |
3232 | impl ast::TypeParamsOwner for TraitDef {} | ||
3232 | impl TraitDef {} | 3233 | impl TraitDef {} |
3233 | 3234 | ||
3234 | // TrueKw | 3235 | // TrueKw |
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index c5297e46d..dedefea59 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron | |||
@@ -280,7 +280,7 @@ Grammar( | |||
280 | ], options: [["variant_list", "EnumVariantList"]] ), | 280 | ], options: [["variant_list", "EnumVariantList"]] ), |
281 | "EnumVariantList": ( collections: [["variants", "EnumVariant"]] ), | 281 | "EnumVariantList": ( collections: [["variants", "EnumVariant"]] ), |
282 | "EnumVariant": ( traits: ["NameOwner", "DocCommentsOwner"], options: ["Expr"] ), | 282 | "EnumVariant": ( traits: ["NameOwner", "DocCommentsOwner"], options: ["Expr"] ), |
283 | "TraitDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner"] ), | 283 | "TraitDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner", "TypeParamsOwner"] ), |
284 | "Module": ( | 284 | "Module": ( |
285 | traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner" ], | 285 | traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner" ], |
286 | options: [ "ItemList" ] | 286 | options: [ "ItemList" ] |
@@ -489,7 +489,7 @@ Grammar( | |||
489 | ), | 489 | ), |
490 | 490 | ||
491 | "RefPat": ( options: [ "Pat" ]), | 491 | "RefPat": ( options: [ "Pat" ]), |
492 | "BindPat": ( | 492 | "BindPat": ( |
493 | options: [ "Pat" ], | 493 | options: [ "Pat" ], |
494 | traits: ["NameOwner"] | 494 | traits: ["NameOwner"] |
495 | ), | 495 | ), |