Skip to content

Commit 3730a44

Browse files
committed
fix tests
1 parent 753df4c commit 3730a44

File tree

1 file changed

+32
-32
lines changed
  • apps/language_server/lib/language_server

1 file changed

+32
-32
lines changed

apps/language_server/lib/language_server/build.ex

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -171,44 +171,48 @@ defmodule ElixirLS.LanguageServer.Build do
171171
defp reload_project(mixfile, root_path) do
172172
if File.exists?(mixfile) do
173173
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]
188176

189-
for {app, path} <- deps_paths do
190-
child_module =
177+
deps_paths =
191178
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()
195182
catch
196183
kind, payload ->
197184
{payload, stacktrace} = Exception.blame(kind, payload, __STACKTRACE__)
198185
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+
[]
200188
end
201189

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
204206
end
205-
end
206207

207-
unload_mix_project_apps()
208+
unload_mix_project_apps()
208209

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
212216
end
213217

214218
# We need to clear persistent cache, otherwise `deps.loadpaths` task fails with
@@ -244,7 +248,6 @@ defmodule ElixirLS.LanguageServer.Build do
244248
set_compiler_options()
245249

246250
# Override build directory to avoid interfering with other dev tools
247-
# FIXME: Private API
248251
Mix.ProjectStack.post_config(build_path: ".elixir_ls/build")
249252
Mix.ProjectStack.post_config(prune_code_paths: false)
250253

@@ -548,7 +551,6 @@ defmodule ElixirLS.LanguageServer.Build do
548551
end
549552

550553
defp fetch_deps(current_deps) do
551-
# FIXME: private struct
552554
missing_deps =
553555
current_deps
554556
|> Enum.filter(fn %Mix.Dep{status: status, scm: scm} ->
@@ -561,7 +563,6 @@ defmodule ElixirLS.LanguageServer.Build do
561563
_ -> false
562564
end
563565
end)
564-
# FIXME: Private struct
565566
|> Enum.map(fn %Mix.Dep{app: app, requirement: requirement} -> "#{app} #{requirement}" end)
566567

567568
if missing_deps != [] do
@@ -613,11 +614,10 @@ defmodule ElixirLS.LanguageServer.Build do
613614
end
614615

615616
defp read_cached_deps() do
616-
# FIXME: Private api
617617
# we cannot use Mix.Dep.cached() here as it tries to load deps
618618
project = Mix.Project.get()
619619
# 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
621621
env_target = {Mix.env(), Mix.target()}
622622

623623
case Mix.State.read_cache({:cached_deps, project}) do

0 commit comments

Comments
 (0)