aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-01-12 20:27:35 +0000
committerFlorian Diebold <[email protected]>2019-01-19 15:02:06 +0000
commit688a45e00b53412a7a16360c6d678a5d91a95789 (patch)
treed3f3481bbad9889d22867729e9efcde184e45671 /crates/ra_ide_api
parent415cdc52108807126f0339fbf812856582f01c18 (diff)
Implement beginnings of generics
- add HIR for generic params - resolve generic params in type paths - add substitions for ADTs - insert type variables for substitutions
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs6
-rw-r--r--crates/ra_ide_api/src/db.rs1
2 files changed, 5 insertions, 2 deletions
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) {
24fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) { 24fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) {
25 for receiver in receiver.autoderef(ctx.db) { 25 for receiver in receiver.autoderef(ctx.db) {
26 match receiver { 26 match receiver {
27 Ty::Adt { def_id, .. } => { 27 Ty::Adt {
28 def_id, ref substs, ..
29 } => {
28 match def_id.resolve(ctx.db) { 30 match def_id.resolve(ctx.db) {
29 Def::Struct(s) => { 31 Def::Struct(s) => {
30 for field in s.fields(ctx.db) { 32 for field in s.fields(ctx.db) {
@@ -33,7 +35,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty)
33 field.name().to_string(), 35 field.name().to_string(),
34 ) 36 )
35 .kind(CompletionItemKind::Field) 37 .kind(CompletionItemKind::Field)
36 .set_detail(field.ty(ctx.db).map(|ty| ty.to_string())) 38 .set_detail(field.ty(ctx.db).map(|ty| ty.subst(substs).to_string()))
37 .add_to(acc); 39 .add_to(acc);
38 } 40 }
39 } 41 }
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! {
129 fn body_hir() for hir::db::BodyHirQuery; 129 fn body_hir() for hir::db::BodyHirQuery;
130 fn body_syntax_mapping() for hir::db::BodySyntaxMappingQuery; 130 fn body_syntax_mapping() for hir::db::BodySyntaxMappingQuery;
131 fn fn_signature() for hir::db::FnSignatureQuery; 131 fn fn_signature() for hir::db::FnSignatureQuery;
132 fn generics() for hir::db::GenericsQuery;
132 } 133 }
133 } 134 }
134} 135}