diff options
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_struct_literal.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_struct_literal.rs | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_struct_literal.rs b/crates/ra_ide_api/src/completion/complete_struct_literal.rs index f8dd2baad..afb092f59 100644 --- a/crates/ra_ide_api/src/completion/complete_struct_literal.rs +++ b/crates/ra_ide_api/src/completion/complete_struct_literal.rs | |||
@@ -1,7 +1,6 @@ | |||
1 | use hir::{Ty, AdtDef, Docs}; | 1 | use hir::{Ty, AdtDef}; |
2 | 2 | ||
3 | use crate::completion::{CompletionContext, Completions, CompletionItem, CompletionItemKind}; | 3 | use crate::completion::{CompletionContext, Completions}; |
4 | use crate::completion::completion_item::CompletionKind; | ||
5 | 4 | ||
6 | /// Complete fields in fields literals. | 5 | /// Complete fields in fields literals. |
7 | pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionContext) { | 6 | pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionContext) { |
@@ -23,15 +22,7 @@ pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionCon | |||
23 | match adt { | 22 | match adt { |
24 | AdtDef::Struct(s) => { | 23 | AdtDef::Struct(s) => { |
25 | for field in s.fields(ctx.db) { | 24 | for field in s.fields(ctx.db) { |
26 | CompletionItem::new( | 25 | acc.add_field(ctx, field, substs); |
27 | CompletionKind::Reference, | ||
28 | ctx.source_range(), | ||
29 | field.name(ctx.db).to_string(), | ||
30 | ) | ||
31 | .kind(CompletionItemKind::Field) | ||
32 | .detail(field.ty(ctx.db).subst(substs).to_string()) | ||
33 | .set_documentation(field.docs(ctx.db)) | ||
34 | .add_to(acc); | ||
35 | } | 26 | } |
36 | } | 27 | } |
37 | 28 | ||
@@ -43,10 +34,10 @@ pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionCon | |||
43 | #[cfg(test)] | 34 | #[cfg(test)] |
44 | mod tests { | 35 | mod tests { |
45 | use insta::assert_debug_snapshot_matches; | 36 | use insta::assert_debug_snapshot_matches; |
46 | use crate::completion::{CompletionItem, CompletionKind}; | 37 | use crate::completion::{CompletionItem, CompletionKind, do_completion}; |
47 | 38 | ||
48 | fn complete(code: &str) -> Vec<CompletionItem> { | 39 | fn complete(code: &str) -> Vec<CompletionItem> { |
49 | crate::completion::completion_item::do_completion(code, CompletionKind::Reference) | 40 | do_completion(code, CompletionKind::Reference) |
50 | } | 41 | } |
51 | 42 | ||
52 | #[test] | 43 | #[test] |