aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/completion')
-rw-r--r--crates/ra_ide_api/src/completion/complete_postfix.rs82
-rw-r--r--crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap64
2 files changed, 71 insertions, 75 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_postfix.rs b/crates/ra_ide_api/src/completion/complete_postfix.rs
index 7042d8bff..a25e517f5 100644
--- a/crates/ra_ide_api/src/completion/complete_postfix.rs
+++ b/crates/ra_ide_api/src/completion/complete_postfix.rs
@@ -51,22 +51,82 @@ pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) {
51 51
52#[cfg(test)] 52#[cfg(test)]
53mod tests { 53mod tests {
54 use crate::completion::{check_completion, CompletionKind}; 54 use crate::completion::{do_completion, CompletionItem, CompletionKind};
55 use insta::assert_debug_snapshot_matches;
55 56
56 fn check_snippet_completion(test_name: &str, code: &str) { 57 fn do_postfix_completion(code: &str) -> Vec<CompletionItem> {
57 check_completion(test_name, code, CompletionKind::Postfix); 58 do_completion(code, CompletionKind::Postfix)
58 } 59 }
59 60
60 #[test] 61 #[test]
61 fn postfix_completion_works_for_trivial_path_expression() { 62 fn postfix_completion_works_for_trivial_path_expression() {
62 check_snippet_completion( 63 assert_debug_snapshot_matches!(
63 "postfix_completion_works_for_trivial_path_expression", 64 do_postfix_completion(
64 r#" 65 r#"
65 fn main() { 66 fn main() {
66 let bar = "a"; 67 let bar = "a";
67 bar.<|> 68 bar.<|>
68 } 69 }
69 "#, 70 "#,
71 ),
72 @r###"[
73 CompletionItem {
74 label: "box",
75 source_range: [88; 88),
76 delete: [84; 88),
77 insert: "Box::new(bar)",
78 detail: "Box::new(expr)",
79 },
80 CompletionItem {
81 label: "dbg",
82 source_range: [88; 88),
83 delete: [84; 88),
84 insert: "dbg!(bar)",
85 detail: "dbg!(expr)",
86 },
87 CompletionItem {
88 label: "if",
89 source_range: [88; 88),
90 delete: [84; 88),
91 insert: "if bar {$0}",
92 detail: "if expr {}",
93 },
94 CompletionItem {
95 label: "match",
96 source_range: [88; 88),
97 delete: [84; 88),
98 insert: "match bar {\n ${1:_} => {$0\\},\n}",
99 detail: "match expr {}",
100 },
101 CompletionItem {
102 label: "not",
103 source_range: [88; 88),
104 delete: [84; 88),
105 insert: "!bar",
106 detail: "!expr",
107 },
108 CompletionItem {
109 label: "ref",
110 source_range: [88; 88),
111 delete: [84; 88),
112 insert: "&bar",
113 detail: "&expr",
114 },
115 CompletionItem {
116 label: "refm",
117 source_range: [88; 88),
118 delete: [84; 88),
119 insert: "&mut bar",
120 detail: "&mut expr",
121 },
122 CompletionItem {
123 label: "while",
124 source_range: [88; 88),
125 delete: [84; 88),
126 insert: "while bar {\n$0\n}",
127 detail: "while expr {}",
128 },
129]"###
70 ); 130 );
71 } 131 }
72} 132}
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap
deleted file mode 100644
index c1a40b7b4..000000000
--- a/crates/ra_ide_api/src/completion/snapshots/completion_item__postfix_completion_works_for_trivial_path_expression.snap
+++ /dev/null
@@ -1,64 +0,0 @@
1---
2created: "2019-06-23T13:01:08.775536006Z"
3creator: [email protected]
4source: crates/ra_ide_api/src/completion/completion_item.rs
5expression: kind_completions
6---
7[
8 CompletionItem {
9 label: "box",
10 source_range: [76; 76),
11 delete: [72; 76),
12 insert: "Box::new(bar)",
13 detail: "Box::new(expr)",
14 },
15 CompletionItem {
16 label: "dbg",
17 source_range: [76; 76),
18 delete: [72; 76),
19 insert: "dbg!(bar)",
20 detail: "dbg!(expr)",
21 },
22 CompletionItem {
23 label: "if",
24 source_range: [76; 76),
25 delete: [72; 76),
26 insert: "if bar {$0}",
27 detail: "if expr {}",
28 },
29 CompletionItem {
30 label: "match",
31 source_range: [76; 76),
32 delete: [72; 76),
33 insert: "match bar {\n ${1:_} => {$0\\},\n}",
34 detail: "match expr {}",
35 },
36 CompletionItem {
37 label: "not",
38 source_range: [76; 76),
39 delete: [72; 76),
40 insert: "!bar",
41 detail: "!expr",
42 },
43 CompletionItem {
44 label: "ref",
45 source_range: [76; 76),
46 delete: [72; 76),
47 insert: "&bar",
48 detail: "&expr",
49 },
50 CompletionItem {
51 label: "refm",
52 source_range: [76; 76),
53 delete: [72; 76),
54 insert: "&mut bar",
55 detail: "&mut expr",
56 },
57 CompletionItem {
58 label: "while",
59 source_range: [76; 76),
60 delete: [72; 76),
61 insert: "while bar {\n$0\n}",
62 detail: "while expr {}",
63 },
64]