From 688a45e00b53412a7a16360c6d678a5d91a95789 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 12 Jan 2019 21:27:35 +0100 Subject: Implement beginnings of generics - add HIR for generic params - resolve generic params in type paths - add substitions for ADTs - insert type variables for substitutions --- crates/ra_ide_api/src/completion/complete_dot.rs | 6 ++++-- crates/ra_ide_api/src/db.rs | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 473edc50e..76c2f8173 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs @@ -24,7 +24,9 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) { fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) { for receiver in receiver.autoderef(ctx.db) { match receiver { - Ty::Adt { def_id, .. } => { + Ty::Adt { + def_id, ref substs, .. + } => { match def_id.resolve(ctx.db) { Def::Struct(s) => { for field in s.fields(ctx.db) { @@ -33,7 +35,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) field.name().to_string(), ) .kind(CompletionItemKind::Field) - .set_detail(field.ty(ctx.db).map(|ty| ty.to_string())) + .set_detail(field.ty(ctx.db).map(|ty| ty.subst(substs).to_string())) .add_to(acc); } } diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index c2978f909..d53919973 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs @@ -129,6 +129,7 @@ salsa::database_storage! { fn body_hir() for hir::db::BodyHirQuery; fn body_syntax_mapping() for hir::db::BodySyntaxMappingQuery; fn fn_signature() for hir::db::FnSignatureQuery; + fn generics() for hir::db::GenericsQuery; } } } -- cgit v1.2.3 From 969f588025ab2c3224757e282ef78a546c4f56c4 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 19 Jan 2019 18:58:04 +0100 Subject: Generics -> GenericParams --- crates/ra_ide_api/src/db.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index d53919973..a1b666899 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs @@ -129,7 +129,7 @@ salsa::database_storage! { fn body_hir() for hir::db::BodyHirQuery; fn body_syntax_mapping() for hir::db::BodySyntaxMappingQuery; fn fn_signature() for hir::db::FnSignatureQuery; - fn generics() for hir::db::GenericsQuery; + fn generic_params() for hir::db::GenericParamsQuery; } } } -- cgit v1.2.3