aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-24 14:54:18 +0000
committerAleksey Kladov <[email protected]>2019-01-24 14:54:18 +0000
commit60a607d33f1c50acd0a4218da32abe35b2941e38 (patch)
treefa1e5e1785cb04186ed07e04e3e5c1c73bb83c79 /crates/ra_ide_api
parentc57a8579888643e73e12dd0ca23e81f88608c52f (diff)
new struct id
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs33
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 @@
1use hir::{Ty, Def}; 1use hir::{Ty, Def, AdtDef};
2 2
3use crate::completion::{CompletionContext, Completions, CompletionItem, CompletionItemKind}; 3use crate::completion::{CompletionContext, Completions, CompletionItem, CompletionItemKind};
4use crate::completion::completion_item::CompletionKind; 4use 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) => {