aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs16
-rw-r--r--crates/ra_ide_api/src/completion/snapshots/completion_item__tuple_field_completion.snap40
2 files changed, 55 insertions, 1 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..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)
46 } 46 }
47 } 47 }
48 Ty::Tuple(fields) => { 48 Ty::Tuple(fields) => {
49 for (i, _ty) in fields.iter().enumerate() { 49 for (i, ty) in fields.iter().enumerate() {
50 CompletionItem::new( 50 CompletionItem::new(
51 CompletionKind::Reference, 51 CompletionKind::Reference,
52 ctx.source_range(), 52 ctx.source_range(),
53 i.to_string(), 53 i.to_string(),
54 ) 54 )
55 .kind(CompletionItemKind::Field) 55 .kind(CompletionItemKind::Field)
56 .detail(ty.to_string())
56 .add_to(acc); 57 .add_to(acc);
57 } 58 }
58 } 59 }
@@ -174,4 +175,17 @@ mod tests {
174 ", 175 ",
175 ); 176 );
176 } 177 }
178
179 #[test]
180 fn test_tuple_field_completion() {
181 check_ref_completion(
182 "tuple_field_completion",
183 r"
184 fn foo() {
185 let b = (0, 3.14);
186 b.<|>
187 }
188 ",
189 );
190 }
177} 191}
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 @@
1---
2created: "2019-01-24T13:22:02.107228200+00:00"
3creator: [email protected]
4expression: kind_completions
5source: crates/ra_ide_api/src/completion/completion_item.rs
6---
7[
8 CompletionItem {
9 completion_kind: Reference,
10 label: "0",
11 kind: Some(
12 Field
13 ),
14 detail: Some(
15 "i32"
16 ),
17 documentation: None,
18 lookup: None,
19 insert_text: None,
20 insert_text_format: PlainText,
21 source_range: [75; 75),
22 text_edit: None
23 },
24 CompletionItem {
25 completion_kind: Reference,
26 label: "1",
27 kind: Some(
28 Field
29 ),
30 detail: Some(
31 "f64"
32 ),
33 documentation: None,
34 lookup: None,
35 insert_text: None,
36 insert_text_format: PlainText,
37 source_range: [75; 75),
38 text_edit: None
39 }
40]