aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-04-10 11:58:21 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-04-10 11:58:21 +0100
commitb28e403c6ca1f87e452955df8d6be976805bd771 (patch)
treeefba4cc07c6d2cd53e42bcfa6fb388246007371f /crates/ra_ide_api/src
parent37eb12f2dd6f36570a27b4e4aaf9048860b5a06b (diff)
parent1b19c1c8f218d0c23e78a14b80845bf7c2cfd32c (diff)
Merge #1130
1130: Use inline snapshots in complete_fn_param r=matklad a=vipentti Relates to #1127 Co-authored-by: Ville Penttinen <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/completion/complete_fn_param.rs85
-rw-r--r--crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_last_param.snap15
-rw-r--r--crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_nth_param.snap15
-rw-r--r--crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_trait_param.snap15
4 files changed, 58 insertions, 72 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_fn_param.rs b/crates/ra_ide_api/src/completion/complete_fn_param.rs
index f87ccdeb9..85ef62f52 100644
--- a/crates/ra_ide_api/src/completion/complete_fn_param.rs
+++ b/crates/ra_ide_api/src/completion/complete_fn_param.rs
@@ -54,48 +54,79 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
54 54
55#[cfg(test)] 55#[cfg(test)]
56mod tests { 56mod tests {
57 use crate::completion::{check_completion, CompletionKind}; 57 use crate::completion::{do_completion, CompletionItem, CompletionKind};
58 use insta::assert_debug_snapshot_matches;
58 59
59 fn check_magic_completion(name: &str, code: &str) { 60 fn do_magic_completion(code: &str) -> Vec<CompletionItem> {
60 check_completion(name, code, CompletionKind::Magic); 61 do_completion(code, CompletionKind::Magic)
61 } 62 }
62 63
63 #[test] 64 #[test]
64 fn test_param_completion_last_param() { 65 fn test_param_completion_last_param() {
65 check_magic_completion( 66 assert_debug_snapshot_matches!(
66 "param_completion_last_param", 67 do_magic_completion(
67 r" 68 r"
68 fn foo(file_id: FileId) {} 69 fn foo(file_id: FileId) {}
69 fn bar(file_id: FileId) {} 70 fn bar(file_id: FileId) {}
70 fn baz(file<|>) {} 71 fn baz(file<|>) {}
71 ", 72 ",
73 ),
74 @r###"[
75 CompletionItem {
76 label: "file_id: FileId",
77 source_range: [110; 114),
78 delete: [110; 114),
79 insert: "file_id: FileId",
80 lookup: "file_id"
81 }
82]"###
72 ); 83 );
73 } 84 }
74 85
75 #[test] 86 #[test]
76 fn test_param_completion_nth_param() { 87 fn test_param_completion_nth_param() {
77 check_magic_completion( 88 assert_debug_snapshot_matches!(
78 "param_completion_nth_param", 89 do_magic_completion(
79 r" 90 r"
80 fn foo(file_id: FileId) {} 91 fn foo(file_id: FileId) {}
81 fn bar(file_id: FileId) {} 92 fn bar(file_id: FileId) {}
82 fn baz(file<|>, x: i32) {} 93 fn baz(file<|>, x: i32) {}
83 ", 94 ",
95 ),
96 @r###"[
97 CompletionItem {
98 label: "file_id: FileId",
99 source_range: [110; 114),
100 delete: [110; 114),
101 insert: "file_id: FileId",
102 lookup: "file_id"
103 }
104]"###
84 ); 105 );
85 } 106 }
86 107
87 #[test] 108 #[test]
88 fn test_param_completion_trait_param() { 109 fn test_param_completion_trait_param() {
89 check_magic_completion( 110 assert_debug_snapshot_matches!(
90 "param_completion_trait_param", 111 do_magic_completion(
91 r" 112 r"
92 pub(crate) trait SourceRoot { 113 pub(crate) trait SourceRoot {
93 pub fn contains(&self, file_id: FileId) -> bool; 114 pub fn contains(&self, file_id: FileId) -> bool;
94 pub fn module_map(&self) -> &ModuleMap; 115 pub fn module_map(&self) -> &ModuleMap;
95 pub fn lines(&self, file_id: FileId) -> &LineIndex; 116 pub fn lines(&self, file_id: FileId) -> &LineIndex;
96 pub fn syntax(&self, file<|>) 117 pub fn syntax(&self, file<|>)
97 } 118 }
98 ", 119 ",
120 ),
121 @r###"[
122 CompletionItem {
123 label: "file_id: FileId",
124 source_range: [289; 293),
125 delete: [289; 293),
126 insert: "file_id: FileId",
127 lookup: "file_id"
128 }
129]"###
99 ); 130 );
100 } 131 }
101} 132}
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_last_param.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_last_param.snap
deleted file mode 100644
index cab77f5a2..000000000
--- a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_last_param.snap
+++ /dev/null
@@ -1,15 +0,0 @@
1---
2created: "2019-02-18T09:22:23.949634602Z"
3creator: [email protected]
4source: crates/ra_ide_api/src/completion/completion_item.rs
5expression: kind_completions
6---
7[
8 CompletionItem {
9 label: "file_id: FileId",
10 source_range: [98; 102),
11 delete: [98; 102),
12 insert: "file_id: FileId",
13 lookup: "file_id"
14 }
15]
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_nth_param.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_nth_param.snap
deleted file mode 100644
index 8fbee160c..000000000
--- a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_nth_param.snap
+++ /dev/null
@@ -1,15 +0,0 @@
1---
2created: "2019-02-18T09:22:23.949634355Z"
3creator: [email protected]
4source: crates/ra_ide_api/src/completion/completion_item.rs
5expression: kind_completions
6---
7[
8 CompletionItem {
9 label: "file_id: FileId",
10 source_range: [98; 102),
11 delete: [98; 102),
12 insert: "file_id: FileId",
13 lookup: "file_id"
14 }
15]
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_trait_param.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_trait_param.snap
deleted file mode 100644
index 76eeadb6d..000000000
--- a/crates/ra_ide_api/src/completion/snapshots/completion_item__param_completion_trait_param.snap
+++ /dev/null
@@ -1,15 +0,0 @@
1---
2created: "2019-02-18T09:22:23.974417169Z"
3creator: [email protected]
4source: crates/ra_ide_api/src/completion/completion_item.rs
5expression: kind_completions
6---
7[
8 CompletionItem {
9 label: "file_id: FileId",
10 source_range: [269; 273),
11 delete: [269; 273),
12 insert: "file_id: FileId",
13 lookup: "file_id"
14 }
15]