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 | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 1a2b0b2f6..d0fa8146c 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, AdtDef}; | 1 | use hir::{Ty, 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; |
@@ -29,23 +29,21 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) | |||
29 | def_id, ref substs, .. | 29 | def_id, ref substs, .. |
30 | } => { | 30 | } => { |
31 | match def_id { | 31 | match def_id { |
32 | AdtDef::Struct() => {} | 32 | AdtDef::Struct(s) => { |
33 | AdtDef::Def(def_id) => match def_id.resolve(ctx.db) { | 33 | for field in s.fields(ctx.db) { |
34 | Def::Struct(s) => { | 34 | CompletionItem::new( |
35 | for field in s.fields(ctx.db) { | 35 | CompletionKind::Reference, |
36 | CompletionItem::new( | 36 | ctx.source_range(), |
37 | CompletionKind::Reference, | 37 | field.name().to_string(), |
38 | ctx.source_range(), | 38 | ) |
39 | field.name().to_string(), | 39 | .kind(CompletionItemKind::Field) |
40 | ) | 40 | .set_detail(field.ty(ctx.db).map(|ty| ty.subst(substs).to_string())) |
41 | .kind(CompletionItemKind::Field) | 41 | .add_to(acc); |
42 | .set_detail(field.ty(ctx.db).map(|ty| ty.subst(substs).to_string())) | ||
43 | .add_to(acc); | ||
44 | } | ||
45 | } | 42 | } |
46 | // TODO unions | 43 | } |
47 | _ => {} | 44 | |
48 | }, | 45 | // TODO unions |
46 | AdtDef::Enum(_) => (), | ||
49 | } | 47 | } |
50 | } | 48 | } |
51 | Ty::Tuple(fields) => { | 49 | Ty::Tuple(fields) => { |