aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/handlers
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-06-23 22:34:12 +0100
committerGitHub <[email protected]>2020-06-23 22:34:12 +0100
commite2e373e0716cea4ea341c7f381da0d39f484cd30 (patch)
tree0337d53010edd2d5d09ab3ceffb0945b8eb4ae55 /crates/ra_assists/src/handlers
parent846ed08fba1331f1ca8d3512e7536c05784ae4bc (diff)
parentaa69757a01c26cfad12498053c55cbc3d66a4bdb (diff)
Merge #5013
5013: More principled indentation trimming in fixtures r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/handlers')
-rw-r--r--crates/ra_assists/src/handlers/add_function.rs1
-rw-r--r--crates/ra_assists/src/handlers/auto_import.rs92
-rw-r--r--crates/ra_assists/src/handlers/fix_visibility.rs157
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
990pub(crate) fn bar() { 989pub(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 { 493macro_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() { 498fn main() {
499 foo<|> 499 foo<|>
500 }", 500}
501",
501 r"use crate_with_macro::foo; 502 r"use crate_with_macro::foo;
502 503
503fn main() { 504fn 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; 852pub struct Struct;
852 853
853 //- /main.rs crate:main deps:dep 854//- /main.rs crate:main deps:dep
854 fn main() { 855fn main() {
855 Struct<|> 856 Struct<|>
856 }", 857}
858",
857 r"use dep::Struct; 859 r"use dep::Struct;
858 860
859fn main() { 861fn 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 { 875pub mod fmt {
874 pub trait Display {} 876 pub trait Display {}
875 } 877}
876 878
877 pub fn panic_fmt() {} 879pub fn panic_fmt() {}
878 880
879 //- /main.rs crate:main deps:dep 881//- /main.rs crate:main deps:dep
880 struct S; 882struct S;
881 883
882 impl f<|>mt::Display for S {}", 884impl f<|>mt::Display for S {}
885",
883 r"use dep::fmt; 886 r"use dep::fmt;
884 887
885struct S; 888struct S;
889
886impl fmt::Display for S {} 890impl 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 902macro_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 908mac!();
908 909
909 fn main() { 910//- /main.rs crate:main deps:dep
910 Cheese<|>; 911fn main() {
911 }", 912 Cheese<|>;
913}
914",
912 r"use dep::Cheese; 915 r"use dep::Cheese;
913 916
914fn main() { 917fn 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 931pub struct FMT;
929 pub struct FMT; 932pub 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<|>; 935fn main() {
936 }", 936 FMT<|>;
937}
938",
937 r"use dep::FMT; 939 r"use dep::FMT;
938 940
939fn main() { 941fn 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; 259mod foo;
260 fn main() { foo::Foo<|> } 260fn main() { foo::Foo<|> }
261 261
262 //- /foo.rs 262//- /foo.rs
263 struct Foo; 263struct 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: () }; } 283mod foo;
285 //- /foo.rs 284fn main() { foo::Foo { <|>bar: () }; }
286 pub struct Foo { bar: () } 285//- /foo.rs
287 ", 286pub 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: () }; } 300mod foo;
302 //- /foo.rs 301fn main() { foo::Foo { <|>bar: () }; }
303 pub struct Foo { pub bar: () } 302//- /foo.rs
304 ", 303pub 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: () }; } 321mod foo;
322 //- /foo.rs 322fn main() { foo::Foo::Bar { <|>bar: () }; }
323 pub enum Foo { Bar { bar: () } } 323//- /foo.rs
324 ", 324pub 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: () }; } 338mod foo;
339 //- /foo.rs 339fn main() { foo::Foo { <|>bar: () }; }
340 pub struct Foo { pub bar: () } 340//- /foo.rs
341 ", 341pub 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: () }; } 361mod foo;
361 //- /foo.rs 362fn main() { foo::Foo { <|>bar: () }; }
362 pub union Foo { bar: () } 363//- /foo.rs
363 ", 364pub 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: () }; } 378mod foo;
378 //- /foo.rs 379fn main() { foo::Foo { <|>bar: () }; }
379 pub union Foo { pub bar: () } 380//- /foo.rs
380 ", 381pub 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; 464mod foo;
463 fn main() { foo::bar<|>::baz(); } 465fn main() { foo::bar<|>::baz(); }
464 466
465 //- /foo.rs 467//- /foo.rs
466 mod bar { 468mod 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; 491mod foo;
491 fn main() { foo::bar<|>::baz(); } 492fn main() { foo::bar<|>::baz(); }
492 493
493 //- /foo.rs 494//- /foo.rs
494 mod bar; 495mod bar;
495 496//- /foo/bar.rs
496 //- /foo/bar.rs 497pub 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(); } 510mod foo;
511fn main() { foo::bar<|>>::baz(); }
512 512
513 //- /foo.rs 513//- /foo.rs
514 mod bar { 514mod 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 531foo::Bar<|>
531 struct Bar;", 532//- /lib.rs crate:foo
533struct Bar;
534",
532 r"$0pub struct Bar; 535 r"$0pub struct Bar;
533", 536",
534 ) 537 )