Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hover bug #674

Merged
merged 3 commits into from
Feb 11, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions apps/language_server/lib/language_server/providers/hover.ex
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,15 @@ defmodule ElixirLS.LanguageServer.Providers.Hover do
end

defp dep_name(root_mod_name, project_dir) do
s = root_mod_name |> source()

cond do
gofenix marked this conversation as resolved.
Show resolved Hide resolved
third_dep?(s, project_dir) -> third_dep_name(s, project_dir)
builtin?(s) -> builtin_dep_name(s)
true -> ""
not elixir_mod_exported?(root_mod_name) -> ""
true ->
s = root_mod_name |> source()
cond do
third_dep?(s, project_dir) -> third_dep_name(s, project_dir)
builtin?(s) -> builtin_dep_name(s)
true -> ""
end
end
end

Expand All @@ -145,8 +148,16 @@ defmodule ElixirLS.LanguageServer.Providers.Hover do
end

defp source(mod_name) do
dep = ("Elixir." <> mod_name) |> String.to_atom()
dep.__info__(:compile) |> Keyword.get(:source) |> List.to_string()
gofenix marked this conversation as resolved.
Show resolved Hide resolved
try do
dep = ("Elixir." <> mod_name) |> String.to_atom()
dep.__info__(:compile) |> Keyword.get(:source) |> List.to_string()
rescue
gofenix marked this conversation as resolved.
Show resolved Hide resolved
e in UndefinedFunctionError -> :error
gofenix marked this conversation as resolved.
Show resolved Hide resolved
end
end

defp elixir_mod_exported?(mod_name) do
("Elixir." <> mod_name) |> String.to_atom() |> function_exported?(:__info__, 1)
end

defp third_dep?(source, project_dir) do
Expand Down