From 52633b2a071a75bf35ca4f23c4092aaf33959e7b Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Thu, 24 Jan 2019 08:25:35 -0500 Subject: Display type when completing tuples --- crates/ra_ide_api/src/completion/complete_dot.rs | 16 ++++++++- .../completion_item__tuple_field_completion.snap | 40 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 crates/ra_ide_api/src/completion/snapshots/completion_item__tuple_field_completion.snap (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 32fd497be..07007d03f 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs @@ -46,13 +46,14 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) } } Ty::Tuple(fields) => { - for (i, _ty) in fields.iter().enumerate() { + for (i, ty) in fields.iter().enumerate() { CompletionItem::new( CompletionKind::Reference, ctx.source_range(), i.to_string(), ) .kind(CompletionItemKind::Field) + .detail(ty.to_string()) .add_to(acc); } } @@ -174,4 +175,17 @@ mod tests { ", ); } + + #[test] + fn test_tuple_field_completion() { + check_ref_completion( + "tuple_field_completion", + r" + fn foo() { + let b = (0, 3.14); + b.<|> + } + ", + ); + } } diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__tuple_field_completion.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__tuple_field_completion.snap new file mode 100644 index 000000000..c9764eab3 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__tuple_field_completion.snap @@ -0,0 +1,40 @@ +--- +created: "2019-01-24T13:22:02.107228200+00:00" +creator: insta@0.5.2 +expression: kind_completions +source: crates/ra_ide_api/src/completion/completion_item.rs +--- +[ + CompletionItem { + completion_kind: Reference, + label: "0", + kind: Some( + Field + ), + detail: Some( + "i32" + ), + documentation: None, + lookup: None, + insert_text: None, + insert_text_format: PlainText, + source_range: [75; 75), + text_edit: None + }, + CompletionItem { + completion_kind: Reference, + label: "1", + kind: Some( + Field + ), + detail: Some( + "f64" + ), + documentation: None, + lookup: None, + insert_text: None, + insert_text_format: PlainText, + source_range: [75; 75), + text_edit: None + } +] -- cgit v1.2.3