@@ -36,7 +36,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
36
36
37
37
project_dir = maybe_convert_path_separators ( FixtureHelpers . get_path ( "no_mixfile" ) )
38
38
39
- assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir )
39
+ assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir , false )
40
40
41
41
assert changes == [
42
42
% TextEdit {
@@ -86,7 +86,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
86
86
87
87
project_dir = nil
88
88
89
- assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir )
89
+ assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir , false )
90
90
91
91
assert changes == [
92
92
% TextEdit {
@@ -137,7 +137,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
137
137
138
138
project_dir = maybe_convert_path_separators ( FixtureHelpers . get_path ( "formatter" ) )
139
139
140
- assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir )
140
+ assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir , true )
141
141
142
142
assert changes == [
143
143
% TextEdit {
@@ -190,7 +190,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
190
190
191
191
project_dir = maybe_convert_path_separators ( FixtureHelpers . get_path ( "formatter" ) )
192
192
193
- assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir )
193
+ assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir , true )
194
194
195
195
assert changes == [
196
196
% TextEdit {
@@ -279,7 +279,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
279
279
project_dir = maybe_convert_path_separators ( FixtureHelpers . get_path ( "formatter" ) )
280
280
281
281
assert { :ok , [ ] } =
282
- Formatting . format ( source_file , uri , project_dir )
282
+ Formatting . format ( source_file , uri , project_dir , true )
283
283
end )
284
284
end
285
285
@@ -310,7 +310,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
310
310
311
311
project_dir = maybe_convert_path_separators ( FixtureHelpers . get_path ( "formatter" ) )
312
312
313
- assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir )
313
+ assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir , true )
314
314
315
315
assert changes == [
316
316
% TextEdit {
@@ -365,7 +365,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
365
365
project_dir = maybe_convert_path_separators ( FixtureHelpers . get_path ( "formatter" ) )
366
366
367
367
assert { :ok , [ ] } =
368
- Formatting . format ( source_file , uri , project_dir )
368
+ Formatting . format ( source_file , uri , project_dir , true )
369
369
end )
370
370
end
371
371
@@ -388,7 +388,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
388
388
389
389
project_dir = maybe_convert_path_separators ( "/project" )
390
390
391
- assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir )
391
+ assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir , true )
392
392
393
393
assert changes == [
394
394
% TextEdit {
@@ -428,7 +428,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
428
428
429
429
project_dir = maybe_convert_path_separators ( FixtureHelpers . get_path ( "formatter" ) )
430
430
431
- assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir )
431
+ assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir , true )
432
432
433
433
assert changes == [
434
434
% TextEdit {
@@ -468,7 +468,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
468
468
469
469
project_dir = maybe_convert_path_separators ( FixtureHelpers . get_path ( "formatter" ) )
470
470
471
- assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir )
471
+ assert { :ok , changes } = Formatting . format ( source_file , uri , project_dir , true )
472
472
473
473
assert changes == [
474
474
% TextEdit {
@@ -495,40 +495,41 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
495
495
store_mix_cache ( )
496
496
project_dir = Path . expand ( "." )
497
497
498
- assert_formatted ( "file.ex" , project_dir )
498
+ assert_formatted ( "file.ex" , project_dir , true )
499
499
500
500
# test/.formatter.exs has [inputs: ["*.exs"]]
501
- assert_formatted ( "test/file.exs" , project_dir )
502
- refute_formatted ( "test/file.ex" , project_dir )
501
+ assert_formatted ( "test/file.exs" , project_dir , true )
502
+ refute_formatted ( "test/file.ex" , project_dir , true )
503
503
504
504
unless is_windows ( ) do
505
- assert_formatted ( "symlink/file.exs" , project_dir )
506
- refute_formatted ( "symlink/file.ex" , project_dir )
505
+ assert_formatted ( "symlink/file.exs" , project_dir , true )
506
+ refute_formatted ( "symlink/file.ex" , project_dir , true )
507
507
end
508
508
509
509
File . mkdir! ( "#{ project_dir } /test/foo" )
510
- refute_formatted ( "test/foo/file.ex" , project_dir )
510
+ refute_formatted ( "test/foo/file.ex" , project_dir , true )
511
511
512
512
# apps/foo/bar/.formatter.exs has [inputs: ["foo.ex"]]
513
- assert_formatted ( "apps/foo/foo.ex" , project_dir )
514
- refute_formatted ( "apps/foo/bar.ex" , project_dir )
515
- refute_formatted ( "apps/foo.ex" , project_dir )
513
+ assert_formatted ( "apps/foo/foo.ex" , project_dir , true )
514
+ refute_formatted ( "apps/foo/bar.ex" , project_dir , true )
515
+ refute_formatted ( "apps/foo.ex" , project_dir , true )
516
516
end )
517
517
end
518
518
519
- def assert_formatted ( path , project_dir ) do
519
+ def assert_formatted ( path , project_dir , mix_file? ) do
520
520
assert match? (
521
521
{ :ok , [ % ElixirLS.LanguageServer.Protocol.TextEdit { } | _ ] } ,
522
- format ( path , project_dir )
522
+ format ( path , project_dir , mix_file? )
523
523
) ,
524
524
"expected '#{ path } ' to be formatted"
525
525
end
526
526
527
- def refute_formatted ( path , project_dir ) do
528
- assert match? ( { :ok , [ ] } , format ( path , project_dir ) ) , "expected '#{ path } ' not to be formatted"
527
+ def refute_formatted ( path , project_dir , mix_file? ) do
528
+ assert match? ( { :ok , [ ] } , format ( path , project_dir , mix_file? ) ) ,
529
+ "expected '#{ path } ' not to be formatted"
529
530
end
530
531
531
- defp format ( path , project_dir ) do
532
+ defp format ( path , project_dir , mix_project? ) do
532
533
project_dir =
533
534
maybe_convert_path_separators ( project_dir )
534
535
|> Path . absname ( )
@@ -542,7 +543,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
542
543
}
543
544
544
545
File . write! ( path , " asd = 1" )
545
- Formatting . format ( source_file , SourceFile.Path . to_uri ( path ) , project_dir )
546
+ Formatting . format ( source_file , SourceFile.Path . to_uri ( path ) , project_dir , mix_project? )
546
547
end
547
548
548
549
defp store_mix_cache ( ) do
0 commit comments