diff options
author | Mikhail Rakhmanov <[email protected]> | 2020-06-03 19:43:57 +0100 |
---|---|---|
committer | Mikhail Rakhmanov <[email protected]> | 2020-06-03 19:43:57 +0100 |
commit | a6d3c77bdd998499941a6aceccde85f7a94b804d (patch) | |
tree | 63161fbc9fd1764507a46e6c58c6e67ea562386e /crates/ra_assists/src/handlers | |
parent | eefa10bc6bff3624ddd0bbb6bc89d8beb4bed186 (diff) |
Fixed tests
Diffstat (limited to 'crates/ra_assists/src/handlers')
-rw-r--r-- | crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs index a36587633..2b1951aff 100644 --- a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs | |||
@@ -18,9 +18,9 @@ use ra_db::FileId; | |||
18 | use ra_fmt::leading_indent; | 18 | use ra_fmt::leading_indent; |
19 | use rustc_hash::FxHashSet; | 19 | use rustc_hash::FxHashSet; |
20 | 20 | ||
21 | // Assist extract_struct_from_enum | 21 | // Assist: extract_struct_from_enum_variant |
22 | // | 22 | // |
23 | // Extracts a struct from enum variant | 23 | // Extracts a struct from enum variant. |
24 | // | 24 | // |
25 | // ``` | 25 | // ``` |
26 | // enum A { <|>One(u32, u32) } | 26 | // enum A { <|>One(u32, u32) } |
@@ -29,9 +29,12 @@ use rustc_hash::FxHashSet; | |||
29 | // ``` | 29 | // ``` |
30 | // struct One(pub u32, pub u32); | 30 | // struct One(pub u32, pub u32); |
31 | // | 31 | // |
32 | // enum A { One(One) }" | 32 | // enum A { One(One) } |
33 | // ``` | 33 | // ``` |
34 | pub(crate) fn extract_struct_from_enum(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 34 | pub(crate) fn extract_struct_from_enum_variant( |
35 | acc: &mut Assists, | ||
36 | ctx: &AssistContext, | ||
37 | ) -> Option<()> { | ||
35 | let variant = ctx.find_node_at_offset::<ast::EnumVariant>()?; | 38 | let variant = ctx.find_node_at_offset::<ast::EnumVariant>()?; |
36 | let field_list = match variant.kind() { | 39 | let field_list = match variant.kind() { |
37 | ast::StructKind::Tuple(field_list) => field_list, | 40 | ast::StructKind::Tuple(field_list) => field_list, |
@@ -221,7 +224,7 @@ mod tests { | |||
221 | #[test] | 224 | #[test] |
222 | fn test_extract_struct_several_fields() { | 225 | fn test_extract_struct_several_fields() { |
223 | check_assist( | 226 | check_assist( |
224 | extract_struct_from_enum, | 227 | extract_struct_from_enum_variant, |
225 | "enum A { <|>One(u32, u32) }", | 228 | "enum A { <|>One(u32, u32) }", |
226 | r#"struct One(pub u32, pub u32); | 229 | r#"struct One(pub u32, pub u32); |
227 | 230 | ||
@@ -232,7 +235,7 @@ enum A { One(One) }"#, | |||
232 | #[test] | 235 | #[test] |
233 | fn test_extract_struct_one_field() { | 236 | fn test_extract_struct_one_field() { |
234 | check_assist( | 237 | check_assist( |
235 | extract_struct_from_enum, | 238 | extract_struct_from_enum_variant, |
236 | "enum A { <|>One(u32) }", | 239 | "enum A { <|>One(u32) }", |
237 | r#"struct One(pub u32); | 240 | r#"struct One(pub u32); |
238 | 241 | ||
@@ -243,7 +246,7 @@ enum A { One(One) }"#, | |||
243 | #[test] | 246 | #[test] |
244 | fn test_extract_struct_pub_visibility() { | 247 | fn test_extract_struct_pub_visibility() { |
245 | check_assist( | 248 | check_assist( |
246 | extract_struct_from_enum, | 249 | extract_struct_from_enum_variant, |
247 | "pub enum A { <|>One(u32, u32) }", | 250 | "pub enum A { <|>One(u32, u32) }", |
248 | r#"pub struct One(pub u32, pub u32); | 251 | r#"pub struct One(pub u32, pub u32); |
249 | 252 | ||
@@ -254,7 +257,7 @@ pub enum A { One(One) }"#, | |||
254 | #[test] | 257 | #[test] |
255 | fn test_extract_struct_with_complex_imports() { | 258 | fn test_extract_struct_with_complex_imports() { |
256 | check_assist( | 259 | check_assist( |
257 | extract_struct_from_enum, | 260 | extract_struct_from_enum_variant, |
258 | r#"mod my_mod { | 261 | r#"mod my_mod { |
259 | fn another_fn() { | 262 | fn another_fn() { |
260 | let m = my_other_mod::MyEnum::MyField(1, 1); | 263 | let m = my_other_mod::MyEnum::MyField(1, 1); |
@@ -305,7 +308,7 @@ fn another_fn() { | |||
305 | fn check_not_applicable(ra_fixture: &str) { | 308 | fn check_not_applicable(ra_fixture: &str) { |
306 | let fixture = | 309 | let fixture = |
307 | format!("//- main.rs crate:main deps:core\n{}\n{}", ra_fixture, FamousDefs::FIXTURE); | 310 | format!("//- main.rs crate:main deps:core\n{}\n{}", ra_fixture, FamousDefs::FIXTURE); |
308 | check_assist_not_applicable(extract_struct_from_enum, &fixture) | 311 | check_assist_not_applicable(extract_struct_from_enum_variant, &fixture) |
309 | } | 312 | } |
310 | 313 | ||
311 | #[test] | 314 | #[test] |