Skip to content

Commit

Permalink
Only emit specs related to the current doc entry for erlang functions
Browse files Browse the repository at this point in the history
Avoid loading and parsing typespecs for erlang functions with documentation
Improves doc and spec rendering in documentation and signature providers
Fixes #252
  • Loading branch information
lukaszsamson committed Aug 5, 2023
1 parent 28b1fbf commit 1db6ac0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/elixir_sense/core/introspection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,12 @@ defmodule ElixirSense.Core.Introspection do
[]
end

# erlang docs have signature included in metadata
def get_spec_as_string(_module, _function, _arity, :function, %{signature: signature}) do
[{:attribute, _, :spec, spec}] = signature
spec |> spec_to_string()
end

def get_spec_as_string(_module, function, arity, :macro, %{implementing: behaviour}) do
TypeInfo.get_callback(behaviour, :"MACRO-#{function}", arity + 1) |> spec_to_string()
end
Expand Down Expand Up @@ -1291,6 +1297,11 @@ defmodule ElixirSense.Core.Introspection do
end)
end

def spec_to_string({{_module, name, arity}, specs}) when is_atom(name) and is_integer(arity) do
# spec with module - transform it to moduleless form
spec_to_string({{name, arity}, specs})
end

@spec actual_module(
nil | module,
[{module, module}],
Expand Down

0 comments on commit 1db6ac0

Please sign in to comment.