diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-16 18:28:13 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-16 18:28:13 +0100 |
commit | f38770cd2606148bfe764351849ea7ebea45132c (patch) | |
tree | 4cdfb20392ec5884706f66b754b4a3a84e66498b /crates | |
parent | f6e73d510da3a7b2582fdf629fcfda4dca9c7b06 (diff) | |
parent | a92ed1eef4a5804c474221d1088dafb5d45f1378 (diff) |
Merge #9302
9302: internal: Add builtin derives to attribute completion fixtures r=Veykril a=Veykril
bors R+
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ide_completion/src/completions/attribute/derive.rs | 74 |
1 files changed, 67 insertions, 7 deletions
diff --git a/crates/ide_completion/src/completions/attribute/derive.rs b/crates/ide_completion/src/completions/attribute/derive.rs index 7b3133e53..20bbbba46 100644 --- a/crates/ide_completion/src/completions/attribute/derive.rs +++ b/crates/ide_completion/src/completions/attribute/derive.rs | |||
@@ -31,6 +31,8 @@ pub(super) fn complete_derive( | |||
31 | let lookup = components.join(", "); | 31 | let lookup = components.join(", "); |
32 | let label = components.iter().rev().join(", "); | 32 | let label = components.iter().rev().join(", "); |
33 | (label, Some(lookup)) | 33 | (label, Some(lookup)) |
34 | } else if existing_derives.contains(&derive) { | ||
35 | continue; | ||
34 | } else { | 36 | } else { |
35 | (derive, None) | 37 | (derive, None) |
36 | }; | 38 | }; |
@@ -83,7 +85,31 @@ mod tests { | |||
83 | use crate::{test_utils::completion_list, CompletionKind}; | 85 | use crate::{test_utils::completion_list, CompletionKind}; |
84 | 86 | ||
85 | fn check(ra_fixture: &str, expect: Expect) { | 87 | fn check(ra_fixture: &str, expect: Expect) { |
86 | let actual = completion_list(ra_fixture, CompletionKind::Attribute); | 88 | let builtin_derives = r#" |
89 | #[rustc_builtin_macro] | ||
90 | pub macro Clone {} | ||
91 | #[rustc_builtin_macro] | ||
92 | pub macro Copy {} | ||
93 | #[rustc_builtin_macro] | ||
94 | pub macro Default {} | ||
95 | #[rustc_builtin_macro] | ||
96 | pub macro Debug {} | ||
97 | #[rustc_builtin_macro] | ||
98 | pub macro Hash {} | ||
99 | #[rustc_builtin_macro] | ||
100 | pub macro PartialEq {} | ||
101 | #[rustc_builtin_macro] | ||
102 | pub macro Eq {} | ||
103 | #[rustc_builtin_macro] | ||
104 | pub macro PartialOrd {} | ||
105 | #[rustc_builtin_macro] | ||
106 | pub macro Ord {} | ||
107 | |||
108 | "#; | ||
109 | let actual = completion_list( | ||
110 | &format!("{} {}", builtin_derives, ra_fixture), | ||
111 | CompletionKind::Attribute, | ||
112 | ); | ||
87 | expect.assert_eq(&actual); | 113 | expect.assert_eq(&actual); |
88 | } | 114 | } |
89 | 115 | ||
@@ -94,19 +120,53 @@ mod tests { | |||
94 | 120 | ||
95 | #[test] | 121 | #[test] |
96 | fn empty_derive() { | 122 | fn empty_derive() { |
97 | // FIXME: Add build-in derives to fixture. | 123 | check( |
98 | check(r#"#[derive($0)] struct Test;"#, expect![[r#""#]]); | 124 | r#"#[derive($0)] struct Test;"#, |
125 | expect![[r#" | ||
126 | at PartialEq | ||
127 | at Default | ||
128 | at PartialEq, Eq | ||
129 | at PartialEq, Eq, PartialOrd, Ord | ||
130 | at Clone, Copy | ||
131 | at Debug | ||
132 | at Clone | ||
133 | at Hash | ||
134 | at PartialEq, PartialOrd | ||
135 | "#]], | ||
136 | ); | ||
99 | } | 137 | } |
100 | 138 | ||
101 | #[test] | 139 | #[test] |
102 | fn derive_with_input() { | 140 | fn derive_with_input() { |
103 | // FIXME: Add build-in derives to fixture. | 141 | check( |
104 | check(r#"#[derive(serde::Serialize, PartialEq, $0)] struct Test;"#, expect![[r#""#]]) | 142 | r#"#[derive(serde::Serialize, PartialEq, $0)] struct Test;"#, |
143 | expect![[r#" | ||
144 | at Default | ||
145 | at Eq | ||
146 | at Eq, PartialOrd, Ord | ||
147 | at Clone, Copy | ||
148 | at Debug | ||
149 | at Clone | ||
150 | at Hash | ||
151 | at PartialOrd | ||
152 | "#]], | ||
153 | ) | ||
105 | } | 154 | } |
106 | 155 | ||
107 | #[test] | 156 | #[test] |
108 | fn derive_with_input2() { | 157 | fn derive_with_input2() { |
109 | // FIXME: Add build-in derives to fixture. | 158 | check( |
110 | check(r#"#[derive($0 serde::Serialize, PartialEq)] struct Test;"#, expect![[r#""#]]) | 159 | r#"#[derive($0 serde::Serialize, PartialEq)] struct Test;"#, |
160 | expect![[r#" | ||
161 | at Default | ||
162 | at Eq | ||
163 | at Eq, PartialOrd, Ord | ||
164 | at Clone, Copy | ||
165 | at Debug | ||
166 | at Clone | ||
167 | at Hash | ||
168 | at PartialOrd | ||
169 | "#]], | ||
170 | ) | ||
111 | } | 171 | } |
112 | } | 172 | } |