Skip to content

Commit 8b1d2a0

Browse files
lukaszsamsonaxelson
andcommitted
clear_cache moved to Mix.State on elixir 1.10 (elixir-editors#91)
* clear_cache moved to Mix.State on elixir 1.10 * Update formatting Co-authored-by: Jason Axelson <[email protected]>
1 parent 7d1dbf1 commit 8b1d2a0

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

apps/elixir_ls_utils/test/support/mix_test.case.ex

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ defmodule ElixirLS.Utils.MixTest.Case do
9595

9696
defp clear_project_stack! do
9797
stack = clear_project_stack!([])
98-
Mix.ProjectStack.clear_cache()
98+
99+
clear_mix_cache()
99100

100101
# Attempt to purge mixfiles for dependencies to avoid module redefinition warnings
101102
mix_exs = System.get_env("MIX_EXS") || "mix.exs"
@@ -110,6 +111,7 @@ defmodule ElixirLS.Utils.MixTest.Case do
110111
end
111112

112113
defp clear_project_stack!(stack) do
114+
# FIXME: Private API
113115
case Mix.Project.pop() do
114116
nil ->
115117
stack
@@ -120,13 +122,26 @@ defmodule ElixirLS.Utils.MixTest.Case do
120122
end
121123

122124
defp restore_project_stack!(stack) do
125+
# FIXME: Private API
123126
Mix.ProjectStack.clear_stack()
124-
Mix.ProjectStack.clear_cache()
127+
clear_mix_cache()
125128

126129
for %{name: module, file: file} <- stack do
127130
:code.purge(module)
128131
:code.delete(module)
129132
Code.require_file(file)
130133
end
131134
end
135+
136+
# FIXME: Private API
137+
defp clear_mix_cache do
138+
module =
139+
if Version.match?(System.version(), ">= 1.10.0-rc.0") do
140+
Mix.State
141+
else
142+
Mix.ProjectStack
143+
end
144+
145+
module.clear_cache()
146+
end
132147
end

0 commit comments

Comments
 (0)