@@ -146,7 +146,7 @@ defmodule IEx.Autocomplete do
146146
147147 @ doc false
148148 def exports ( mod ) do
149- if Code . ensure_loaded? ( mod ) and function_exported? ( mod , :__info__ , 1 ) do
149+ if ensure_loaded? ( mod ) and function_exported? ( mod , :__info__ , 1 ) do
150150 mod . __info__ ( :macros ) ++ ( mod . __info__ ( :functions ) -- [ __info__: 1 ] )
151151 else
152152 mod . module_info ( :exports ) -- [ module_info: 0 , module_info: 1 ]
@@ -313,21 +313,23 @@ defmodule IEx.Autocomplete do
313313 for { alias , mod } <- aliases_from_env ( shell ) ,
314314 [ name ] = Module . split ( alias ) ,
315315 String . starts_with? ( name , hint ) ,
316- struct? ( mod ) and not function_exported? ( mod , :exception , 1 ) ,
317- do: % { kind: :struct , name: name }
316+ do: { mod , name }
318317
319318 modules =
320319 for "Elixir." <> name = full_name <- match_modules ( "Elixir." <> hint , true ) ,
321320 String . starts_with? ( name , hint ) ,
322321 mod = String . to_atom ( full_name ) ,
323- struct? ( mod ) and not function_exported? ( mod , :exception , 1 ) ,
324- do: % { kind: :struct , name: name }
322+ do: { mod , name }
325323
326- format_expansion ( aliases ++ modules , hint )
327- end
324+ all = aliases ++ modules
325+ Code . ensure_all_loaded ( Enum . map ( all , & elem ( & 1 , 0 ) ) )
328326
329- defp struct? ( mod ) do
330- Code . ensure_loaded? ( mod ) and function_exported? ( mod , :__struct__ , 1 )
327+ refs =
328+ for { mod , name } <- all ,
329+ function_exported? ( mod , :__struct__ , 1 ) and not function_exported? ( mod , :exception , 1 ) ,
330+ do: % { kind: :struct , name: name }
331+
332+ format_expansion ( refs , hint )
331333 end
332334
333335 defp expand_container_context ( code , context , hint , shell ) do
@@ -420,7 +422,9 @@ defmodule IEx.Autocomplete do
420422 defp container_context_struct ( cursor , pairs , aliases , shell ) do
421423 with { pairs , [ ^ cursor ] } <- Enum . split ( pairs , - 1 ) ,
422424 alias = value_from_alias ( aliases , shell ) ,
423- true <- Keyword . keyword? ( pairs ) and struct? ( alias ) do
425+ true <-
426+ Keyword . keyword? ( pairs ) and ensure_loaded? ( alias ) and
427+ function_exported? ( alias , :__struct__ , 1 ) do
424428 { :struct , alias , pairs }
425429 else
426430 _ -> nil
0 commit comments