@@ -146,7 +146,7 @@ defmodule IEx.Autocomplete do
146
146
147
147
@ doc false
148
148
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
150
150
mod . __info__ ( :macros ) ++ ( mod . __info__ ( :functions ) -- [ __info__: 1 ] )
151
151
else
152
152
mod . module_info ( :exports ) -- [ module_info: 0 , module_info: 1 ]
@@ -313,21 +313,23 @@ defmodule IEx.Autocomplete do
313
313
for { alias , mod } <- aliases_from_env ( shell ) ,
314
314
[ name ] = Module . split ( alias ) ,
315
315
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 }
318
317
319
318
modules =
320
319
for "Elixir." <> name = full_name <- match_modules ( "Elixir." <> hint , true ) ,
321
320
String . starts_with? ( name , hint ) ,
322
321
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 }
325
323
326
- format_expansion ( aliases ++ modules , hint )
327
- end
324
+ all = aliases ++ modules
325
+ Code . ensure_all_loaded ( Enum . map ( all , & elem ( & 1 , 0 ) ) )
328
326
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 )
331
333
end
332
334
333
335
defp expand_container_context ( code , context , hint , shell ) do
@@ -420,7 +422,9 @@ defmodule IEx.Autocomplete do
420
422
defp container_context_struct ( cursor , pairs , aliases , shell ) do
421
423
with { pairs , [ ^ cursor ] } <- Enum . split ( pairs , - 1 ) ,
422
424
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
424
428
{ :struct , alias , pairs }
425
429
else
426
430
_ -> nil
0 commit comments