@@ -171,44 +171,48 @@ defmodule ElixirLS.LanguageServer.Build do
171
171
defp reload_project ( mixfile , root_path ) do
172
172
if File . exists? ( mixfile ) do
173
173
if module = Mix.Project . get ( ) do
174
- build_path = Mix.Project . config ( ) [ :build_path ]
175
-
176
- deps_paths =
177
- try do
178
- # this call can raise (RuntimeError) cannot retrieve dependencies information because dependencies
179
- # were not loaded. Please invoke one of "deps.loadpaths", "loadpaths", or "compile" Mix task
180
- Mix.Project . deps_paths ( )
181
- catch
182
- kind , payload ->
183
- { payload , stacktrace } = Exception . blame ( kind , payload , __STACKTRACE__ )
184
- message = Exception . format ( kind , payload , stacktrace )
185
- Logger . warning ( "Unable to prune mix project: #{ message } " )
186
- [ ]
187
- end
174
+ if module != ElixirLS.LanguageServer.MixProject do
175
+ build_path = Mix.Project . config ( ) [ :build_path ]
188
176
189
- for { app , path } <- deps_paths do
190
- child_module =
177
+ deps_paths =
191
178
try do
192
- Mix.Project . in_project ( app , path , [ build_path: build_path ] , fn mix_project ->
193
- mix_project
194
- end )
179
+ # this call can raise (RuntimeError) cannot retrieve dependencies information because dependencies
180
+ # were not loaded. Please invoke one of "deps.loadpaths", "loadpaths", or "compile" Mix task
181
+ Mix.Project . deps_paths ( )
195
182
catch
196
183
kind , payload ->
197
184
{ payload , stacktrace } = Exception . blame ( kind , payload , __STACKTRACE__ )
198
185
message = Exception . format ( kind , payload , stacktrace )
199
- Logger . warning ( "Unable to prune mix project module for #{ app } : #{ message } " )
186
+ Logger . warning ( "Unable to prune mix project: #{ message } " )
187
+ [ ]
200
188
end
201
189
202
- if child_module do
203
- purge_module ( child_module )
190
+ for { app , path } <- deps_paths do
191
+ child_module =
192
+ try do
193
+ Mix.Project . in_project ( app , path , [ build_path: build_path ] , fn mix_project ->
194
+ mix_project
195
+ end )
196
+ catch
197
+ kind , payload ->
198
+ { payload , stacktrace } = Exception . blame ( kind , payload , __STACKTRACE__ )
199
+ message = Exception . format ( kind , payload , stacktrace )
200
+ Logger . warning ( "Unable to prune mix project module for #{ app } : #{ message } " )
201
+ end
202
+
203
+ if child_module do
204
+ purge_module ( child_module )
205
+ end
204
206
end
205
- end
206
207
207
- unload_mix_project_apps ( )
208
+ unload_mix_project_apps ( )
208
209
209
- # FIXME: Private API
210
- Mix.Project . pop ( )
211
- purge_module ( module )
210
+ Mix.Project . pop ( )
211
+ purge_module ( module )
212
+ else
213
+ # don't do any pruning in language server tests
214
+ Mix.Project . pop ( )
215
+ end
212
216
end
213
217
214
218
# We need to clear persistent cache, otherwise `deps.loadpaths` task fails with
@@ -244,7 +248,6 @@ defmodule ElixirLS.LanguageServer.Build do
244
248
set_compiler_options ( )
245
249
246
250
# Override build directory to avoid interfering with other dev tools
247
- # FIXME: Private API
248
251
Mix.ProjectStack . post_config ( build_path: ".elixir_ls/build" )
249
252
Mix.ProjectStack . post_config ( prune_code_paths: false )
250
253
@@ -548,7 +551,6 @@ defmodule ElixirLS.LanguageServer.Build do
548
551
end
549
552
550
553
defp fetch_deps ( current_deps ) do
551
- # FIXME: private struct
552
554
missing_deps =
553
555
current_deps
554
556
|> Enum . filter ( fn % Mix.Dep { status: status , scm: scm } ->
@@ -561,7 +563,6 @@ defmodule ElixirLS.LanguageServer.Build do
561
563
_ -> false
562
564
end
563
565
end )
564
- # FIXME: Private struct
565
566
|> Enum . map ( fn % Mix.Dep { app: app , requirement: requirement } -> "#{ app } #{ requirement } " end )
566
567
567
568
if missing_deps != [ ] do
@@ -613,11 +614,10 @@ defmodule ElixirLS.LanguageServer.Build do
613
614
end
614
615
615
616
defp read_cached_deps ( ) do
616
- # FIXME: Private api
617
617
# we cannot use Mix.Dep.cached() here as it tries to load deps
618
618
project = Mix.Project . get ( )
619
619
# in test do not try to load cache from elixir_ls
620
- if project != nil and project != ElixirLS.LanguageServer.Mixfile do
620
+ if project != nil and project != ElixirLS.LanguageServer.MixProject do
621
621
env_target = { Mix . env ( ) , Mix . target ( ) }
622
622
623
623
case Mix.State . read_cache ( { :cached_deps , project } ) do
0 commit comments