@@ -18,6 +18,9 @@ defmodule IEx.Autocomplete do
1818 % { kind: :variable , name: "utf32" }
1919 ]
2020
21+ @ alias_only_atoms ~w( alias import require) a
22+ @ alias_only_charlists ~w( alias import require) c
23+
2124 @ doc """
2225 Provides one helper function that is injected into connecting
2326 remote nodes to properly handle autocompletion.
@@ -62,7 +65,11 @@ defmodule IEx.Autocomplete do
6265 expand_typespecs ( expansion , shell , & get_module_types / 1 )
6366
6467 { :dot , path , hint } ->
65- expand_dot ( path , List . to_string ( hint ) , false , shell )
68+ if alias = alias_only ( path , hint , code , shell ) do
69+ expand_aliases ( List . to_string ( alias ) , shell )
70+ else
71+ expand_dot ( path , List . to_string ( hint ) , false , shell )
72+ end
6673
6774 { :dot_arity , path , hint } ->
6875 expand_dot ( path , List . to_string ( hint ) , true , shell )
@@ -80,6 +87,9 @@ defmodule IEx.Autocomplete do
8087 { :local_arity , local } ->
8188 expand_local ( List . to_string ( local ) , true , shell )
8289
90+ { :local_call , local } when local in @ alias_only_charlists ->
91+ expand_aliases ( "" , shell )
92+
8393 { :local_call , local } ->
8494 expand_local_call ( List . to_atom ( local ) , shell )
8595
@@ -382,6 +392,9 @@ defmodule IEx.Autocomplete do
382392 [ cursor , pairs , { :| , _ , [ { variable , _ , nil } | _ ] } , { :%{} , _ , _ } | _ ] ->
383393 container_context_map ( cursor , pairs , variable , shell )
384394
395+ [ cursor , { special_form , _ , [ cursor ] } | _ ] when special_form in @ alias_only_atoms ->
396+ :alias_only
397+
385398 [ cursor | tail ] ->
386399 case remove_operators ( tail , cursor ) do
387400 [ { :"::" , _ , [ _ , _ ] } , { :<<>> , _ , [ _ | _ ] } | _ ] -> :bitstring_modifier
@@ -425,6 +438,16 @@ defmodule IEx.Autocomplete do
425438
426439 ## Aliases and modules
427440
441+ defp alias_only ( path , hint , code , shell ) do
442+ with { :alias , alias } <- path ,
443+ [ ] <- hint ,
444+ :alias_only <- container_context ( code , shell ) do
445+ alias ++ [ ?. ]
446+ else
447+ _ -> nil
448+ end
449+ end
450+
428451 defp expand_aliases ( all , shell ) do
429452 case String . split ( all , "." ) do
430453 [ hint ] ->
0 commit comments