Skip to content

Commit 32e4c29

Browse files
committed
Warn if unable to locate elixir and OTP sources
Fixes elixir-lsp/elixir_sense#44
1 parent 52dae7a commit 32e4c29

File tree

1 file changed

+19
-0
lines changed
  • apps/language_server/lib/language_server

1 file changed

+19
-0
lines changed

apps/language_server/lib/language_server/cli.ex

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ defmodule ElixirLS.LanguageServer.CLI do
3939
)
4040

4141
check_otp_doc_chunks()
42+
check_elixir_sources()
43+
check_otp_sources()
4244

4345
Launch.limit_num_schedulers()
4446

@@ -91,4 +93,21 @@ defmodule ElixirLS.LanguageServer.CLI do
9193
Logger.warn("OTP compiled without EEP48 documentation chunks. Language features for erlang modules will run in limited mode. Please reinstall or rebuild OTP with approperiate flags.")
9294
end
9395
end
96+
97+
def check_elixir_sources() do
98+
enum_ex_path = Enum.module_info[:compile][:source]
99+
unless File.exists?(enum_ex_path, [:raw]) do
100+
dir = Path.join(enum_ex_path, "../../../..") |> Path.expand
101+
Logger.notice("Elixir sources not found (checking in #{dir}). Code navigation to Elixir modules disabled.")
102+
end
103+
end
104+
105+
def check_otp_sources() do
106+
{_module, _binary, beam_filename} = :code.get_object_code(:erlang)
107+
erlang_erl_path = beam_filename |> to_string |> String.replace(Regex.recompile!(~r/(.+)\/ebin\/([^\s]+)\.beam$/), "\\1/src/\\2.erl")
108+
unless File.exists?(erlang_erl_path, [:raw]) do
109+
dir = Path.join(erlang_erl_path, "../../../..") |> Path.expand
110+
Logger.notice("OTP sources not found (checking in #{dir}). Code navigation to OTP modules disabled.")
111+
end
112+
end
94113
end

0 commit comments

Comments
 (0)