Skip to content

Commit a153d89

Browse files
committed
Remove fallbacks
Fallbacks for situations where there was no debug info on the module were a bit too defensive IMO. They make a huge sacrifice in code readability for a very unlikely win. Removing them to keep the code cleaner.
1 parent 83dfc5b commit a153d89

1 file changed

Lines changed: 5 additions & 37 deletions

File tree

lib/elixir_sense/providers/definition/locator.ex

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -373,43 +373,11 @@ defmodule ElixirSense.Providers.Definition.Locator do
373373
end
374374

375375
defp get_module_source_file(mod) do
376-
try do
377-
compile_info = mod.__info__(:compile)
378-
source = Keyword.get(compile_info, :source)
379-
if source, do: to_string(source)
380-
catch
381-
_, _ ->
382-
case Code.fetch_docs(mod) do
383-
{:docs_v1, _, _, _, _, _, docs} when is_list(docs) ->
384-
docs
385-
|> Enum.find_value(fn
386-
{{_, _, _}, _, _, _, meta} when is_map(meta) ->
387-
Map.get(meta, :source)
388-
389-
_ ->
390-
nil
391-
end)
392-
393-
_ ->
394-
try do
395-
case :code.get_object_code(mod) do
396-
{^mod, bin, _} ->
397-
case :beam_lib.chunks(bin, [:debug_info]) do
398-
{:ok, {_, [{:debug_info, {:debug_info_v1, _, {_, %{file: file}, _}}}]}} ->
399-
to_string(file)
400-
401-
_ ->
402-
nil
403-
end
404-
405-
_ ->
406-
nil
407-
end
408-
catch
409-
_, _ -> nil
410-
end
411-
end
412-
end
376+
compile_info = mod.__info__(:compile)
377+
source = Keyword.get(compile_info, :source)
378+
if source, do: to_string(source)
379+
catch
380+
_, _ -> nil
413381
end
414382

415383
defp find_used_modules_and_search_in_source(source, mod, fun) do

0 commit comments

Comments
 (0)