Skip to content

Commit 3e531b9

Browse files
gofenixzhuzhenfeng.code
andauthored
Fix hover bug (#674)
* #673 fix hover bug for * use function_exported to check module be loaded Change-Id: I8e3c3cde067a7d3313422c0a94f4c4a464bd37de * remove rescue and use if instead of nested cond Change-Id: Ia85056971d7333df5d6a7cf6d3a6bd21c87635eb Co-authored-by: zhuzhenfeng.code <zhuzhenfeng.code@bytedance.com>
1 parent 8e92bdc commit 3e531b9

File tree

1 file changed

+13
-6
lines changed
  • apps/language_server/lib/language_server/providers

1 file changed

+13
-6
lines changed

apps/language_server/lib/language_server/providers/hover.ex

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,15 @@ defmodule ElixirLS.LanguageServer.Providers.Hover do
131131
end
132132

133133
defp dep_name(root_mod_name, project_dir) do
134-
s = root_mod_name |> source()
135-
136-
cond do
137-
third_dep?(s, project_dir) -> third_dep_name(s, project_dir)
138-
builtin?(s) -> builtin_dep_name(s)
139-
true -> ""
134+
if not elixir_mod_exported?(root_mod_name) do
135+
""
136+
else
137+
s = root_mod_name |> source()
138+
cond do
139+
third_dep?(s, project_dir) -> third_dep_name(s, project_dir)
140+
builtin?(s) -> builtin_dep_name(s)
141+
true -> ""
142+
end
140143
end
141144
end
142145

@@ -149,6 +152,10 @@ defmodule ElixirLS.LanguageServer.Providers.Hover do
149152
dep.__info__(:compile) |> Keyword.get(:source) |> List.to_string()
150153
end
151154

155+
defp elixir_mod_exported?(mod_name) do
156+
("Elixir." <> mod_name) |> String.to_atom() |> function_exported?(:__info__, 1)
157+
end
158+
152159
defp third_dep?(source, project_dir) do
153160
prefix = project_dir <> "/deps"
154161
String.starts_with?(source, prefix)

0 commit comments

Comments
 (0)