diff options
author | Aleksey Kladov <[email protected]> | 2020-06-23 21:27:24 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-06-23 22:33:41 +0100 |
commit | aa69757a01c26cfad12498053c55cbc3d66a4bdb (patch) | |
tree | 0337d53010edd2d5d09ab3ceffb0945b8eb4ae55 /crates/ra_assists/src | |
parent | f2f69e75c84014a6173798e95af0baa48df2607e (diff) |
More principled indentation trimming in fixtures
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r-- | crates/ra_assists/src/handlers/add_function.rs | 1 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/auto_import.rs | 92 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/fix_visibility.rs | 157 |
3 files changed, 127 insertions, 123 deletions
diff --git a/crates/ra_assists/src/handlers/add_function.rs b/crates/ra_assists/src/handlers/add_function.rs index 1cfbd75aa..19ce81d99 100644 --- a/crates/ra_assists/src/handlers/add_function.rs +++ b/crates/ra_assists/src/handlers/add_function.rs | |||
@@ -986,7 +986,6 @@ fn main() { | |||
986 | ", | 986 | ", |
987 | r" | 987 | r" |
988 | 988 | ||
989 | |||
990 | pub(crate) fn bar() { | 989 | pub(crate) fn bar() { |
991 | ${0:todo!()} | 990 | ${0:todo!()} |
992 | }", | 991 | }", |
diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/ra_assists/src/handlers/auto_import.rs index 5092bf336..d1cafa7d9 100644 --- a/crates/ra_assists/src/handlers/auto_import.rs +++ b/crates/ra_assists/src/handlers/auto_import.rs | |||
@@ -488,16 +488,17 @@ mod tests { | |||
488 | check_assist( | 488 | check_assist( |
489 | auto_import, | 489 | auto_import, |
490 | r" | 490 | r" |
491 | //- /lib.rs crate:crate_with_macro | 491 | //- /lib.rs crate:crate_with_macro |
492 | #[macro_export] | 492 | #[macro_export] |
493 | macro_rules! foo { | 493 | macro_rules! foo { |
494 | () => () | 494 | () => () |
495 | } | 495 | } |
496 | 496 | ||
497 | //- /main.rs crate:main deps:crate_with_macro | 497 | //- /main.rs crate:main deps:crate_with_macro |
498 | fn main() { | 498 | fn main() { |
499 | foo<|> | 499 | foo<|> |
500 | }", | 500 | } |
501 | ", | ||
501 | r"use crate_with_macro::foo; | 502 | r"use crate_with_macro::foo; |
502 | 503 | ||
503 | fn main() { | 504 | fn main() { |
@@ -847,13 +848,14 @@ fn main() { | |||
847 | check_assist( | 848 | check_assist( |
848 | auto_import, | 849 | auto_import, |
849 | r" | 850 | r" |
850 | //- /lib.rs crate:dep | 851 | //- /lib.rs crate:dep |
851 | pub struct Struct; | 852 | pub struct Struct; |
852 | 853 | ||
853 | //- /main.rs crate:main deps:dep | 854 | //- /main.rs crate:main deps:dep |
854 | fn main() { | 855 | fn main() { |
855 | Struct<|> | 856 | Struct<|> |
856 | }", | 857 | } |
858 | ", | ||
857 | r"use dep::Struct; | 859 | r"use dep::Struct; |
858 | 860 | ||
859 | fn main() { | 861 | fn main() { |
@@ -869,20 +871,22 @@ fn main() { | |||
869 | check_assist( | 871 | check_assist( |
870 | auto_import, | 872 | auto_import, |
871 | r" | 873 | r" |
872 | //- /lib.rs crate:dep | 874 | //- /lib.rs crate:dep |
873 | pub mod fmt { | 875 | pub mod fmt { |
874 | pub trait Display {} | 876 | pub trait Display {} |
875 | } | 877 | } |
876 | 878 | ||
877 | pub fn panic_fmt() {} | 879 | pub fn panic_fmt() {} |
878 | 880 | ||
879 | //- /main.rs crate:main deps:dep | 881 | //- /main.rs crate:main deps:dep |
880 | struct S; | 882 | struct S; |
881 | 883 | ||
882 | impl f<|>mt::Display for S {}", | 884 | impl f<|>mt::Display for S {} |
885 | ", | ||
883 | r"use dep::fmt; | 886 | r"use dep::fmt; |
884 | 887 | ||
885 | struct S; | 888 | struct S; |
889 | |||
886 | impl fmt::Display for S {} | 890 | impl fmt::Display for S {} |
887 | ", | 891 | ", |
888 | ); | 892 | ); |
@@ -894,21 +898,20 @@ impl fmt::Display for S {} | |||
894 | check_assist( | 898 | check_assist( |
895 | auto_import, | 899 | auto_import, |
896 | r" | 900 | r" |
897 | //- /lib.rs crate:dep | 901 | //- /lib.rs crate:dep |
898 | 902 | macro_rules! mac { | |
899 | macro_rules! mac { | 903 | () => { |
900 | () => { | 904 | pub struct Cheese; |
901 | pub struct Cheese; | 905 | }; |
902 | }; | 906 | } |
903 | } | ||
904 | |||
905 | mac!(); | ||
906 | 907 | ||
907 | //- /main.rs crate:main deps:dep | 908 | mac!(); |
908 | 909 | ||
909 | fn main() { | 910 | //- /main.rs crate:main deps:dep |
910 | Cheese<|>; | 911 | fn main() { |
911 | }", | 912 | Cheese<|>; |
913 | } | ||
914 | ", | ||
912 | r"use dep::Cheese; | 915 | r"use dep::Cheese; |
913 | 916 | ||
914 | fn main() { | 917 | fn main() { |
@@ -924,16 +927,15 @@ fn main() { | |||
924 | check_assist( | 927 | check_assist( |
925 | auto_import, | 928 | auto_import, |
926 | r" | 929 | r" |
927 | //- /lib.rs crate:dep | 930 | //- /lib.rs crate:dep |
928 | 931 | pub struct FMT; | |
929 | pub struct FMT; | 932 | pub struct fmt; |
930 | pub struct fmt; | ||
931 | |||
932 | //- /main.rs crate:main deps:dep | ||
933 | 933 | ||
934 | fn main() { | 934 | //- /main.rs crate:main deps:dep |
935 | FMT<|>; | 935 | fn main() { |
936 | }", | 936 | FMT<|>; |
937 | } | ||
938 | ", | ||
937 | r"use dep::FMT; | 939 | r"use dep::FMT; |
938 | 940 | ||
939 | fn main() { | 941 | fn main() { |
diff --git a/crates/ra_assists/src/handlers/fix_visibility.rs b/crates/ra_assists/src/handlers/fix_visibility.rs index 531b3560f..54601d1f3 100644 --- a/crates/ra_assists/src/handlers/fix_visibility.rs +++ b/crates/ra_assists/src/handlers/fix_visibility.rs | |||
@@ -255,15 +255,14 @@ mod tests { | |||
255 | check_assist( | 255 | check_assist( |
256 | fix_visibility, | 256 | fix_visibility, |
257 | r" | 257 | r" |
258 | //- /main.rs | 258 | //- /main.rs |
259 | mod foo; | 259 | mod foo; |
260 | fn main() { foo::Foo<|> } | 260 | fn main() { foo::Foo<|> } |
261 | 261 | ||
262 | //- /foo.rs | 262 | //- /foo.rs |
263 | struct Foo; | 263 | struct Foo; |
264 | ", | 264 | ", |
265 | r"$0pub(crate) struct Foo; | 265 | r"$0pub(crate) struct Foo; |
266 | |||
267 | ", | 266 | ", |
268 | ); | 267 | ); |
269 | } | 268 | } |
@@ -279,14 +278,14 @@ mod tests { | |||
279 | ); | 278 | ); |
280 | check_assist( | 279 | check_assist( |
281 | fix_visibility, | 280 | fix_visibility, |
282 | r"//- /lib.rs | 281 | r" |
283 | mod foo; | 282 | //- /lib.rs |
284 | fn main() { foo::Foo { <|>bar: () }; } | 283 | mod foo; |
285 | //- /foo.rs | 284 | fn main() { foo::Foo { <|>bar: () }; } |
286 | pub struct Foo { bar: () } | 285 | //- /foo.rs |
287 | ", | 286 | pub struct Foo { bar: () } |
287 | ", | ||
288 | r"pub struct Foo { $0pub(crate) bar: () } | 288 | r"pub struct Foo { $0pub(crate) bar: () } |
289 | |||
290 | ", | 289 | ", |
291 | ); | 290 | ); |
292 | check_assist_not_applicable( | 291 | check_assist_not_applicable( |
@@ -296,12 +295,13 @@ mod tests { | |||
296 | ); | 295 | ); |
297 | check_assist_not_applicable( | 296 | check_assist_not_applicable( |
298 | fix_visibility, | 297 | fix_visibility, |
299 | r"//- /lib.rs | 298 | r" |
300 | mod foo; | 299 | //- /lib.rs |
301 | fn main() { foo::Foo { <|>bar: () }; } | 300 | mod foo; |
302 | //- /foo.rs | 301 | fn main() { foo::Foo { <|>bar: () }; } |
303 | pub struct Foo { pub bar: () } | 302 | //- /foo.rs |
304 | ", | 303 | pub struct Foo { pub bar: () } |
304 | ", | ||
305 | ); | 305 | ); |
306 | } | 306 | } |
307 | 307 | ||
@@ -316,14 +316,14 @@ mod tests { | |||
316 | ); | 316 | ); |
317 | check_assist( | 317 | check_assist( |
318 | fix_visibility, | 318 | fix_visibility, |
319 | r"//- /lib.rs | 319 | r" |
320 | mod foo; | 320 | //- /lib.rs |
321 | fn main() { foo::Foo::Bar { <|>bar: () }; } | 321 | mod foo; |
322 | //- /foo.rs | 322 | fn main() { foo::Foo::Bar { <|>bar: () }; } |
323 | pub enum Foo { Bar { bar: () } } | 323 | //- /foo.rs |
324 | ", | 324 | pub enum Foo { Bar { bar: () } } |
325 | ", | ||
325 | r"pub enum Foo { Bar { $0pub(crate) bar: () } } | 326 | r"pub enum Foo { Bar { $0pub(crate) bar: () } } |
326 | |||
327 | ", | 327 | ", |
328 | ); | 328 | ); |
329 | check_assist_not_applicable( | 329 | check_assist_not_applicable( |
@@ -333,12 +333,13 @@ mod tests { | |||
333 | ); | 333 | ); |
334 | check_assist_not_applicable( | 334 | check_assist_not_applicable( |
335 | fix_visibility, | 335 | fix_visibility, |
336 | r"//- /lib.rs | 336 | r" |
337 | mod foo; | 337 | //- /lib.rs |
338 | fn main() { foo::Foo { <|>bar: () }; } | 338 | mod foo; |
339 | //- /foo.rs | 339 | fn main() { foo::Foo { <|>bar: () }; } |
340 | pub struct Foo { pub bar: () } | 340 | //- /foo.rs |
341 | ", | 341 | pub struct Foo { pub bar: () } |
342 | ", | ||
342 | ); | 343 | ); |
343 | } | 344 | } |
344 | 345 | ||
@@ -355,14 +356,14 @@ mod tests { | |||
355 | ); | 356 | ); |
356 | check_assist( | 357 | check_assist( |
357 | fix_visibility, | 358 | fix_visibility, |
358 | r"//- /lib.rs | 359 | r" |
359 | mod foo; | 360 | //- /lib.rs |
360 | fn main() { foo::Foo { <|>bar: () }; } | 361 | mod foo; |
361 | //- /foo.rs | 362 | fn main() { foo::Foo { <|>bar: () }; } |
362 | pub union Foo { bar: () } | 363 | //- /foo.rs |
363 | ", | 364 | pub union Foo { bar: () } |
365 | ", | ||
364 | r"pub union Foo { $0pub(crate) bar: () } | 366 | r"pub union Foo { $0pub(crate) bar: () } |
365 | |||
366 | ", | 367 | ", |
367 | ); | 368 | ); |
368 | check_assist_not_applicable( | 369 | check_assist_not_applicable( |
@@ -372,12 +373,13 @@ mod tests { | |||
372 | ); | 373 | ); |
373 | check_assist_not_applicable( | 374 | check_assist_not_applicable( |
374 | fix_visibility, | 375 | fix_visibility, |
375 | r"//- /lib.rs | 376 | r" |
376 | mod foo; | 377 | //- /lib.rs |
377 | fn main() { foo::Foo { <|>bar: () }; } | 378 | mod foo; |
378 | //- /foo.rs | 379 | fn main() { foo::Foo { <|>bar: () }; } |
379 | pub union Foo { pub bar: () } | 380 | //- /foo.rs |
380 | ", | 381 | pub union Foo { pub bar: () } |
382 | ", | ||
381 | ); | 383 | ); |
382 | } | 384 | } |
383 | 385 | ||
@@ -458,19 +460,18 @@ mod tests { | |||
458 | check_assist( | 460 | check_assist( |
459 | fix_visibility, | 461 | fix_visibility, |
460 | r" | 462 | r" |
461 | //- /main.rs | 463 | //- /main.rs |
462 | mod foo; | 464 | mod foo; |
463 | fn main() { foo::bar<|>::baz(); } | 465 | fn main() { foo::bar<|>::baz(); } |
464 | 466 | ||
465 | //- /foo.rs | 467 | //- /foo.rs |
466 | mod bar { | 468 | mod bar { |
467 | pub fn baz() {} | 469 | pub fn baz() {} |
468 | } | 470 | } |
469 | ", | 471 | ", |
470 | r"$0pub(crate) mod bar { | 472 | r"$0pub(crate) mod bar { |
471 | pub fn baz() {} | 473 | pub fn baz() {} |
472 | } | 474 | } |
473 | |||
474 | ", | 475 | ", |
475 | ); | 476 | ); |
476 | 477 | ||
@@ -486,17 +487,15 @@ mod tests { | |||
486 | check_assist( | 487 | check_assist( |
487 | fix_visibility, | 488 | fix_visibility, |
488 | r" | 489 | r" |
489 | //- /main.rs | 490 | //- /main.rs |
490 | mod foo; | 491 | mod foo; |
491 | fn main() { foo::bar<|>::baz(); } | 492 | fn main() { foo::bar<|>::baz(); } |
492 | 493 | ||
493 | //- /foo.rs | 494 | //- /foo.rs |
494 | mod bar; | 495 | mod bar; |
495 | 496 | //- /foo/bar.rs | |
496 | //- /foo/bar.rs | 497 | pub fn baz() {} |
497 | pub fn baz() {} | 498 | ", |
498 | } | ||
499 | ", | ||
500 | r"$0pub(crate) mod bar; | 499 | r"$0pub(crate) mod bar; |
501 | ", | 500 | ", |
502 | ); | 501 | ); |
@@ -506,14 +505,16 @@ mod tests { | |||
506 | fn fix_visibility_of_module_declaration_in_other_file() { | 505 | fn fix_visibility_of_module_declaration_in_other_file() { |
507 | check_assist( | 506 | check_assist( |
508 | fix_visibility, | 507 | fix_visibility, |
509 | r"//- /main.rs | 508 | r" |
510 | mod foo; | 509 | //- /main.rs |
511 | fn main() { foo::bar<|>>::baz(); } | 510 | mod foo; |
511 | fn main() { foo::bar<|>>::baz(); } | ||
512 | 512 | ||
513 | //- /foo.rs | 513 | //- /foo.rs |
514 | mod bar { | 514 | mod bar { |
515 | pub fn baz() {} | 515 | pub fn baz() {} |
516 | }", | 516 | } |
517 | ", | ||
517 | r"$0pub(crate) mod bar { | 518 | r"$0pub(crate) mod bar { |
518 | pub fn baz() {} | 519 | pub fn baz() {} |
519 | } | 520 | } |
@@ -525,10 +526,12 @@ mod tests { | |||
525 | fn adds_pub_when_target_is_in_another_crate() { | 526 | fn adds_pub_when_target_is_in_another_crate() { |
526 | check_assist( | 527 | check_assist( |
527 | fix_visibility, | 528 | fix_visibility, |
528 | r"//- /main.rs crate:a deps:foo | 529 | r" |
529 | foo::Bar<|> | 530 | //- /main.rs crate:a deps:foo |
530 | //- /lib.rs crate:foo | 531 | foo::Bar<|> |
531 | struct Bar;", | 532 | //- /lib.rs crate:foo |
533 | struct Bar; | ||
534 | ", | ||
532 | r"$0pub struct Bar; | 535 | r"$0pub struct Bar; |
533 | ", | 536 | ", |
534 | ) | 537 | ) |