Skip to content

Commit 0e2bdbd

Browse files
committed
address todos
fix crash when module cannot be expanded
1 parent 6f124e1 commit 0e2bdbd

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

lib/elixir_sense/core/binding.ex

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,11 +1542,15 @@ defmodule ElixirSense.Core.Binding do
15421542
m
15431543

15441544
{:__aliases__, _, list} ->
1545-
# TODO type may be expanded
15461545
Module.concat(list)
1546+
1547+
_ ->
1548+
nil
15471549
end
15481550

1549-
{:struct, fields, {:atom, module}, nil}
1551+
if module do
1552+
{:struct, fields, {:atom, module}, nil}
1553+
end
15501554
end
15511555

15521556
# map
@@ -1598,24 +1602,23 @@ defmodule ElixirSense.Core.Binding do
15981602
end
15991603

16001604
# remote user type
1601-
defp parse_type(env, {{:., _, [mod, atom]}, _, args}, _mod, _include_private, stack)
1602-
when is_atom(mod) and is_atom(atom) do
1603-
# do not propagate include_private when expanding remote types
1604-
expand_type(env, mod, atom, args, false, stack)
1605-
end
1605+
defp parse_type(env, {{:., _, [remote, type]}, _, args}, _mod, _include_private, stack) do
1606+
module =
1607+
case remote do
1608+
m when is_atom(m) ->
1609+
m
16061610

1607-
# remote user type
1608-
# TODO the alias may be already expanded
1609-
defp parse_type(
1610-
env,
1611-
{{:., _, [{:__aliases__, _, aliases}, atom]}, _, args},
1612-
_mod,
1613-
_include_private,
1614-
stack
1615-
)
1616-
when is_atom(atom) do
1617-
# do not propagate include_private when expanding remote types
1618-
expand_type(env, Module.concat(aliases), atom, args, false, stack)
1611+
{:__aliases__, _, list} ->
1612+
Module.concat(list)
1613+
1614+
_ ->
1615+
nil
1616+
end
1617+
1618+
if remote && is_atom(type) do
1619+
# do not propagate include_private when expanding remote types
1620+
expand_type(env, module, type, args, false, stack)
1621+
end
16191622
end
16201623

16211624
# no_return

0 commit comments

Comments
 (0)