diff options
author | Marcus Klaas de Vries <[email protected]> | 2019-01-08 15:01:19 +0000 |
---|---|---|
committer | Marcus Klaas de Vries <[email protected]> | 2019-01-10 13:32:56 +0000 |
commit | 978de5cf8bfd2ff82696fc8d5369b41e147431c3 (patch) | |
tree | 27a25a5f2fb20a4afffed97cbb5b678b251d254b /crates/ra_ide_api/src | |
parent | aca14c591fea40b2f803bbf5f02c1571732348fb (diff) |
Implement type inference for enum variants
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_path.rs | 22 | ||||
-rw-r--r-- | crates/ra_ide_api/src/db.rs | 1 |
2 files changed, 15 insertions, 8 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 4723a65a6..6a55670d1 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs | |||
@@ -21,14 +21,20 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) -> C | |||
21 | .add_to(acc) | 21 | .add_to(acc) |
22 | }); | 22 | }); |
23 | } | 23 | } |
24 | hir::Def::Enum(e) => e | 24 | hir::Def::Enum(e) => { |
25 | .variants(ctx.db)? | 25 | e.variants(ctx.db)? |
26 | .into_iter() | 26 | .unwrap_or(vec![]) |
27 | .for_each(|(name, _variant)| { | 27 | .into_iter() |
28 | CompletionItem::new(CompletionKind::Reference, name.to_string()) | 28 | .for_each(|variant| { |
29 | .kind(CompletionItemKind::EnumVariant) | 29 | let variant_name = variant.name(ctx.db); |
30 | .add_to(acc) | 30 | |
31 | }), | 31 | if let Ok(Some(name)) = variant_name { |
32 | CompletionItem::new(CompletionKind::Reference, name.to_string()) | ||
33 | .kind(CompletionItemKind::EnumVariant) | ||
34 | .add_to(acc) | ||
35 | } | ||
36 | }) | ||
37 | } | ||
32 | _ => return Ok(()), | 38 | _ => return Ok(()), |
33 | }; | 39 | }; |
34 | Ok(()) | 40 | Ok(()) |
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index a2e06f5db..efdf261be 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs | |||
@@ -122,6 +122,7 @@ salsa::database_storage! { | |||
122 | fn type_for_field() for hir::db::TypeForFieldQuery; | 122 | fn type_for_field() for hir::db::TypeForFieldQuery; |
123 | fn struct_data() for hir::db::StructDataQuery; | 123 | fn struct_data() for hir::db::StructDataQuery; |
124 | fn enum_data() for hir::db::EnumDataQuery; | 124 | fn enum_data() for hir::db::EnumDataQuery; |
125 | fn enum_variant_data() for hir::db::EnumVariantDataQuery; | ||
125 | fn impls_in_module() for hir::db::ImplsInModuleQuery; | 126 | fn impls_in_module() for hir::db::ImplsInModuleQuery; |
126 | fn body_hir() for hir::db::BodyHirQuery; | 127 | fn body_hir() for hir::db::BodyHirQuery; |
127 | fn body_syntax_mapping() for hir::db::BodySyntaxMappingQuery; | 128 | fn body_syntax_mapping() for hir::db::BodySyntaxMappingQuery; |