Skip to content

Commit 8d7a47a

Browse files
authored
fix: bring back completions for things defined in test files (#32)
1 parent 69ac8fe commit 8d7a47a

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

apps/expert/lib/expert/code_intelligence/completion.ex

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ defmodule Expert.CodeIntelligence.Completion do
1717

1818
require Logger
1919

20-
@build_env Mix.env()
2120
@expert_deps Enum.map([:expert | Mix.Project.deps_apps()], &Atom.to_string/1)
2221

2322
def trigger_characters do
@@ -239,6 +238,8 @@ defmodule Expert.CodeIntelligence.Completion do
239238

240239
result_app = metadata[:app]
241240

241+
Logger.info("project_module? #{inspect(binding(), pretty: true)}")
242+
242243
cond do
243244
module_app in project_apps ->
244245
true
@@ -259,19 +260,12 @@ defmodule Expert.CodeIntelligence.Completion do
259260
true
260261

261262
true ->
262-
# The following cases happen on test cases, due to the application
263-
# controller not always recognizing project fixture modules as part
264-
# of any application.
265-
test_env?() and is_nil(module_app) and is_nil(project.project_module)
263+
# Results not belonging to an application or the project are most
264+
# likely to be defined in a test or .exs file.
265+
is_nil(module_app) and is_nil(project.project_module)
266266
end
267267
end
268268

269-
# Because the build env is fixed at compile time, dialyzer knows that
270-
# in :dev and :prod environments, this function will always return false,
271-
# so it produces a warning.
272-
@dialyzer {:nowarn_function, test_env?: 0}
273-
defp test_env?, do: @build_env == :test
274-
275269
defp module_string_to_atom(""), do: nil
276270

277271
defp module_string_to_atom(module_string) do

0 commit comments

Comments
 (0)