Skip to content

Commit

Permalink
stdlib: cache code:get_docs calls when completing types in the shell
Browse files Browse the repository at this point in the history
  • Loading branch information
frazze-jobb committed Jan 8, 2025
1 parent 53ffb6a commit bf2d5fd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/stdlib/src/edlin_type_suggestion.erl
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,19 @@ simplified_type(file, name_all, 0) -> {type, erlang, string, []};
simplified_type(file, name, 0) -> {type, erlang, string, []};
simplified_type(_Module, _TypeName, _Arity) -> none.

code_get_doc_cache(Mod) ->
case get(Mod) of
undefined ->
Docs = code:get_doc(Mod, #{sources => [debug_info]}),
put(Mod, Docs),
Docs;
Docs -> Docs
end.

lookup_type(Mod, Type, Arity, FT) ->
case simplified_type(Mod, Type, Arity) of
none ->
case code:get_doc(Mod, #{sources => [debug_info]}) of
case code_get_doc_cache(Mod) of
{ok, #docs_v1{ docs = Docs } } ->
FnFunctions =
lists:filter(fun({{type, T, A},_Anno,_Sig,_Doc,_Meta}) ->
Expand Down

0 comments on commit bf2d5fd

Please sign in to comment.