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 | 33 |
1 files changed, 18 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 32fd497be..1a2b0b2f6 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, Def}; | 1 | use hir::{Ty, Def, AdtDef}; |
2 | 2 | ||
3 | use crate::completion::{CompletionContext, Completions, CompletionItem, CompletionItemKind}; | 3 | use crate::completion::{CompletionContext, Completions, CompletionItem, CompletionItemKind}; |
4 | use crate::completion::completion_item::CompletionKind; | 4 | use crate::completion::completion_item::CompletionKind; |
@@ -28,21 +28,24 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) | |||
28 | Ty::Adt { | 28 | Ty::Adt { |
29 | def_id, ref substs, .. | 29 | def_id, ref substs, .. |
30 | } => { | 30 | } => { |
31 | match def_id.resolve(ctx.db) { | 31 | match def_id { |
32 | Def::Struct(s) => { | 32 | AdtDef::Struct() => {} |
33 | for field in s.fields(ctx.db) { | 33 | AdtDef::Def(def_id) => match def_id.resolve(ctx.db) { |
34 | CompletionItem::new( | 34 | Def::Struct(s) => { |
35 | CompletionKind::Reference, | 35 | for field in s.fields(ctx.db) { |
36 | ctx.source_range(), | 36 | CompletionItem::new( |
37 | field.name().to_string(), | 37 | CompletionKind::Reference, |
38 | ) | 38 | ctx.source_range(), |
39 | .kind(CompletionItemKind::Field) | 39 | field.name().to_string(), |
40 | .set_detail(field.ty(ctx.db).map(|ty| ty.subst(substs).to_string())) | 40 | ) |
41 | .add_to(acc); | 41 | .kind(CompletionItemKind::Field) |
42 | .set_detail(field.ty(ctx.db).map(|ty| ty.subst(substs).to_string())) | ||
43 | .add_to(acc); | ||
44 | } | ||
42 | } | 45 | } |
43 | } | 46 | // TODO unions |
44 | // TODO unions | 47 | _ => {} |
45 | _ => {} | 48 | }, |
46 | } | 49 | } |
47 | } | 50 | } |
48 | Ty::Tuple(fields) => { | 51 | Ty::Tuple(fields) => { |