diff options
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_dot.rs | 16 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/snapshots/completion_item__tuple_field_completion.snap | 40 |
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 d0fa8146c..6a9358d33 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs | |||
@@ -47,13 +47,14 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) | |||
47 | } | 47 | } |
48 | } | 48 | } |
49 | Ty::Tuple(fields) => { | 49 | Ty::Tuple(fields) => { |
50 | for (i, _ty) in fields.iter().enumerate() { | 50 | for (i, ty) in fields.iter().enumerate() { |
51 | CompletionItem::new( | 51 | CompletionItem::new( |
52 | CompletionKind::Reference, | 52 | CompletionKind::Reference, |
53 | ctx.source_range(), | 53 | ctx.source_range(), |
54 | i.to_string(), | 54 | i.to_string(), |
55 | ) | 55 | ) |
56 | .kind(CompletionItemKind::Field) | 56 | .kind(CompletionItemKind::Field) |
57 | .detail(ty.to_string()) | ||
57 | .add_to(acc); | 58 | .add_to(acc); |
58 | } | 59 | } |
59 | } | 60 | } |
@@ -175,4 +176,17 @@ mod tests { | |||
175 | ", | 176 | ", |
176 | ); | 177 | ); |
177 | } | 178 | } |
179 | |||
180 | #[test] | ||
181 | fn test_tuple_field_completion() { | ||
182 | check_ref_completion( | ||
183 | "tuple_field_completion", | ||
184 | r" | ||
185 | fn foo() { | ||
186 | let b = (0, 3.14); | ||
187 | b.<|> | ||
188 | } | ||
189 | ", | ||
190 | ); | ||
191 | } | ||
178 | } | 192 | } |
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 | --- | ||
2 | created: "2019-01-24T13:22:02.107228200+00:00" | ||
3 | creator: [email protected] | ||
4 | expression: kind_completions | ||
5 | source: 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 | ] | ||