diff options
Diffstat (limited to 'crates/ide_completion/src/completions/attribute/derive.rs')
-rw-r--r-- | crates/ide_completion/src/completions/attribute/derive.rs | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/crates/ide_completion/src/completions/attribute/derive.rs b/crates/ide_completion/src/completions/attribute/derive.rs index 7b0a778a2..634c0cb00 100644 --- a/crates/ide_completion/src/completions/attribute/derive.rs +++ b/crates/ide_completion/src/completions/attribute/derive.rs | |||
@@ -45,6 +45,7 @@ pub(super) fn complete_derive( | |||
45 | } | 45 | } |
46 | } | 46 | } |
47 | } | 47 | } |
48 | |||
48 | fn get_derive_names_in_scope(ctx: &CompletionContext) -> FxHashSet<String> { | 49 | fn get_derive_names_in_scope(ctx: &CompletionContext) -> FxHashSet<String> { |
49 | let mut result = FxHashSet::default(); | 50 | let mut result = FxHashSet::default(); |
50 | ctx.scope.process_all_names(&mut |name, scope_def| { | 51 | ctx.scope.process_all_names(&mut |name, scope_def| { |
@@ -89,12 +90,14 @@ mod tests { | |||
89 | } | 90 | } |
90 | 91 | ||
91 | #[test] | 92 | #[test] |
92 | fn empty_derive_completion() { | 93 | fn no_completion_for_incorrect_derive() { |
94 | check(r#"#[derive{$0)] struct Test;"#, expect![[]]) | ||
95 | } | ||
96 | |||
97 | #[test] | ||
98 | fn empty_derive() { | ||
93 | check( | 99 | check( |
94 | r#" | 100 | r#"#[derive($0)] struct Test;"#, |
95 | #[derive($0)] | ||
96 | struct Test {} | ||
97 | "#, | ||
98 | expect![[r#" | 101 | expect![[r#" |
99 | at Clone | 102 | at Clone |
100 | at Clone, Copy | 103 | at Clone, Copy |
@@ -110,23 +113,26 @@ struct Test {} | |||
110 | } | 113 | } |
111 | 114 | ||
112 | #[test] | 115 | #[test] |
113 | fn no_completion_for_incorrect_derive() { | 116 | fn derive_with_input() { |
114 | check( | 117 | check( |
115 | r#" | 118 | r#"#[derive(serde::Serialize, PartialEq, $0)] struct Test;"#, |
116 | #[derive{$0)] | 119 | expect![[r#" |
117 | struct Test {} | 120 | at Clone |
118 | "#, | 121 | at Clone, Copy |
119 | expect![[r#""#]], | 122 | at Debug |
123 | at Default | ||
124 | at Hash | ||
125 | at Eq | ||
126 | at PartialOrd | ||
127 | at Eq, PartialOrd, Ord | ||
128 | "#]], | ||
120 | ) | 129 | ) |
121 | } | 130 | } |
122 | 131 | ||
123 | #[test] | 132 | #[test] |
124 | fn derive_with_input_completion() { | 133 | fn derive_with_input2() { |
125 | check( | 134 | check( |
126 | r#" | 135 | r#"#[derive($0 serde::Serialize, PartialEq)] struct Test;"#, |
127 | #[derive(serde::Serialize, PartialEq, $0)] | ||
128 | struct Test {} | ||
129 | "#, | ||
130 | expect![[r#" | 136 | expect![[r#" |
131 | at Clone | 137 | at Clone |
132 | at Clone, Copy | 138 | at Clone, Copy |