@@ -296,7 +296,7 @@ defmodule ElixirLS.LanguageServer.Build do
296
296
:code . delete ( module )
297
297
end
298
298
299
- defp purge_app ( app ) do
299
+ defp purge_app ( app , purge_modules? \\ true ) do
300
300
Logger . debug ( "Stopping #{ app } " )
301
301
302
302
case Application . stop ( app ) do
@@ -305,15 +305,17 @@ defmodule ElixirLS.LanguageServer.Build do
305
305
{ :error , error } -> Logger . warning ( "Application.stop failed for #{ app } : #{ inspect ( error ) } " )
306
306
end
307
307
308
- modules =
309
- case :application . get_key ( app , :modules ) do
310
- { :ok , modules } -> modules
311
- _ -> [ ]
312
- end
308
+ if purge_modules? do
309
+ modules =
310
+ case :application . get_key ( app , :modules ) do
311
+ { :ok , modules } -> modules
312
+ _ -> [ ]
313
+ end
313
314
314
- if modules != [ ] do
315
- Logger . debug ( "Purging #{ length ( modules ) } modules from #{ app } " )
316
- for module <- modules , do: purge_module ( module )
315
+ if modules != [ ] do
316
+ Logger . debug ( "Purging #{ length ( modules ) } modules from #{ app } " )
317
+ for module <- modules , do: purge_module ( module )
318
+ end
317
319
end
318
320
319
321
Logger . debug ( "Unloading #{ app } " )
@@ -409,20 +411,14 @@ defmodule ElixirLS.LanguageServer.Build do
409
411
[ Mix.Project . config ( ) [ :app ] ]
410
412
end
411
413
412
- mix_project_apps_deps =
413
- current_deps_by_app
414
- |> Map . take ( mix_project_apps )
415
- |> Enum . flat_map ( & elem ( & 1 , 1 ) )
416
- |> Enum . uniq ( )
417
-
418
414
# purge mix project apps
419
415
# elixir compiler loads apps only on initial compilation
420
416
# on subsequent ones it does not update application controller state
421
- # if we don't purge the apps we end up with invalid state
417
+ # if we don't unload the apps we end up with invalid state
422
418
# e.g. :application.get_key(app, :modules) returns outdated module list
423
419
# see https://github.com/elixir-lang/elixir/issues/13001
424
- for dep <- mix_project_apps_deps do
425
- purge_dep ( dep )
420
+ for app <- mix_project_apps do
421
+ purge_app ( app , false )
426
422
end
427
423
end
428
424
0 commit comments