diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-24 13:28:07 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-24 13:28:07 +0000 |
commit | f092bb377e96f7e5b4b0cc428ab8c77d46e04e37 (patch) | |
tree | 497bed64e2838c63ee838e5f0fc440d7ebcfdb2e | |
parent | eaef72937767dbb79f240cc4d08cb05f7f4071ea (diff) | |
parent | 52633b2a071a75bf35ca4f23c4092aaf33959e7b (diff) |
Merge #628
628: Display type when completing tuples r=matklad a=kjeremy
Co-authored-by: Jeremy Kolb <[email protected]>
-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 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 | --- | ||
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 | ] | ||