@@ -18,6 +18,9 @@ defmodule IEx.Autocomplete do
18
18
% { kind: :variable , name: "utf32" }
19
19
]
20
20
21
+ @ alias_only_atoms ~w( alias import require) a
22
+ @ alias_only_charlists ~w( alias import require) c
23
+
21
24
@ doc """
22
25
Provides one helper function that is injected into connecting
23
26
remote nodes to properly handle autocompletion.
@@ -62,7 +65,11 @@ defmodule IEx.Autocomplete do
62
65
expand_typespecs ( expansion , shell , & get_module_types / 1 )
63
66
64
67
{ :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
66
73
67
74
{ :dot_arity , path , hint } ->
68
75
expand_dot ( path , List . to_string ( hint ) , true , shell )
@@ -80,6 +87,9 @@ defmodule IEx.Autocomplete do
80
87
{ :local_arity , local } ->
81
88
expand_local ( List . to_string ( local ) , true , shell )
82
89
90
+ { :local_call , local } when local in @ alias_only_charlists ->
91
+ expand_aliases ( "" , shell )
92
+
83
93
{ :local_call , local } ->
84
94
expand_local_call ( List . to_atom ( local ) , shell )
85
95
@@ -382,6 +392,9 @@ defmodule IEx.Autocomplete do
382
392
[ cursor , pairs , { :| , _ , [ { variable , _ , nil } | _ ] } , { :%{} , _ , _ } | _ ] ->
383
393
container_context_map ( cursor , pairs , variable , shell )
384
394
395
+ [ cursor , { special_form , _ , [ cursor ] } | _ ] when special_form in @ alias_only_atoms ->
396
+ :alias_only
397
+
385
398
[ cursor | tail ] ->
386
399
case remove_operators ( tail , cursor ) do
387
400
[ { :"::" , _ , [ _ , _ ] } , { :<<>> , _ , [ _ | _ ] } | _ ] -> :bitstring_modifier
@@ -425,6 +438,16 @@ defmodule IEx.Autocomplete do
425
438
426
439
## Aliases and modules
427
440
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
+
428
451
defp expand_aliases ( all , shell ) do
429
452
case String . split ( all , "." ) do
430
453
[ hint ] ->
0 commit comments