Skip to content

Commit

Permalink
fix 2 cases when module_info could be called on not loaded module
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Oct 29, 2023
1 parent 002cc0a commit 8cb847e
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions lib/elixir_sense/providers/suggestion/complete.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1078,9 +1078,13 @@ defmodule ElixirSense.Providers.Suggestion.Complete do
)
else
funs =
mod.module_info(:exports)
|> Kernel.--(if include_builtin, do: [], else: @builtin_functions)
|> Kernel.++(BuiltinFunctions.erlang_builtin_functions(mod))
if Code.ensure_loaded?(mod) do
mod.module_info(:exports)
|> Kernel.--(if include_builtin, do: [], else: @builtin_functions)
|> Kernel.++(BuiltinFunctions.erlang_builtin_functions(mod))
else
[]
end

for {f, a} <- funs do
# we don't expect macros here
Expand Down Expand Up @@ -1134,10 +1138,14 @@ defmodule ElixirSense.Providers.Suggestion.Complete do
end

defp special_builtins(mod) do
mod.module_info(:exports)
|> Enum.filter(fn {f, a} ->
{f, a} in [{:behaviour_info, 1}]
end)
if Code.ensure_loaded?(mod) do
mod.module_info(:exports)
|> Enum.filter(fn {f, a} ->
{f, a} in [{:behaviour_info, 1}]
end)
else
[]
end
end

defp find_doc(fun, _docs) when fun in @builtin_functions, do: {:function, nil}
Expand Down

0 comments on commit 8cb847e

Please sign in to comment.