diff options
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_dot.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_dot.rs | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 94c66be31..dc5206a64 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use hir::{Ty, AdtDef}; | 1 | use hir::{Ty, AdtDef, TypeName}; |
2 | 2 | ||
3 | use crate::completion::{CompletionContext, Completions}; | 3 | use crate::completion::{CompletionContext, Completions}; |
4 | 4 | ||
@@ -24,23 +24,20 @@ pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) { | |||
24 | fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) { | 24 | fn 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, ref substs, .. } => { | 27 | Ty::Apply(a_ty) => match a_ty.name { |
28 | match def_id { | 28 | TypeName::Adt(AdtDef::Struct(s)) => { |
29 | AdtDef::Struct(s) => { | 29 | for field in s.fields(ctx.db) { |
30 | for field in s.fields(ctx.db) { | 30 | acc.add_field(ctx, field, &a_ty.parameters); |
31 | acc.add_field(ctx, field, substs); | ||
32 | } | ||
33 | } | 31 | } |
34 | |||
35 | // TODO unions | ||
36 | AdtDef::Enum(_) => (), | ||
37 | } | 32 | } |
38 | } | 33 | // TODO unions |
39 | Ty::Tuple(fields) => { | 34 | TypeName::Tuple => { |
40 | for (i, ty) in fields.iter().enumerate() { | 35 | for (i, ty) in a_ty.parameters.iter().enumerate() { |
41 | acc.add_pos_field(ctx, i, ty); | 36 | acc.add_pos_field(ctx, i, ty); |
37 | } | ||
42 | } | 38 | } |
43 | } | 39 | _ => {} |
40 | }, | ||
44 | _ => {} | 41 | _ => {} |
45 | }; | 42 | }; |
46 | } | 43 | } |