Skip to content

Commit 62c2a77

Browse files
committed
handle atom args better
1 parent 706c498 commit 62c2a77

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

lib/elixir_sense/core/binding.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,7 +1647,7 @@ defmodule ElixirSense.Core.Binding do
16471647
defp parse_type(_env, _type, _, _include_private, _stack), do: nil
16481648

16491649
defp expand_type(env, mod, type_name, args, include_private, stack) do
1650-
arity = length(args || [])
1650+
arity = if(is_list(args), do: length(args), else: 0)
16511651
type = {mod, type_name, arity}
16521652

16531653
if type in stack do
@@ -1659,7 +1659,7 @@ defmodule ElixirSense.Core.Binding do
16591659
end
16601660

16611661
defp do_expand_type(env, mod, type_name, args, include_private, stack) do
1662-
arity = length(args || [])
1662+
arity = if(is_list(args), do: length(args), else: 0)
16631663

16641664
case expand_type_from_metadata(env, mod, type_name, arity, include_private, stack) do
16651665
nil -> expand_type_from_introspection(env, mod, type_name, arity, include_private, stack)

lib/elixir_sense/core/compiler.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ defmodule ElixirSense.Core.Compiler do
861861
fa =
862862
case list do
863863
[{f, _, a} | _] ->
864-
{f, length(a || [])}
864+
{f, if(is_list(a), do: length(a), else: 0)}
865865

866866
_ ->
867867
{:__unknown__, 0}
@@ -1707,7 +1707,7 @@ defmodule ElixirSense.Core.Compiler do
17071707
fa =
17081708
case list do
17091709
[{f, _, a} | _] ->
1710-
{f, length(a || [])}
1710+
{f, if(is_list(a), do: length(a), else: 0)}
17111711

17121712
_ ->
17131713
{:__unknown__, 0}

lib/elixir_sense/core/compiler/typespec.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ defmodule ElixirSense.Core.Compiler.Typespec do
1313
when is_list(args) do
1414
case args do
1515
[{n, _, a} | _] ->
16-
{n, a || []}
16+
{n, if(is_list(a), do: a, else: [])}
1717

1818
_ ->
1919
# type name replaced by cursor
@@ -28,7 +28,7 @@ defmodule ElixirSense.Core.Compiler.Typespec do
2828
def type_to_signature({:__cursor__, _, args}) when is_list(args) do
2929
case args do
3030
[{n, _, a} | _] ->
31-
{n, a || []}
31+
{n, if(is_list(a), do: a, else: [])}
3232

3333
_ ->
3434
# type name replaced by cursor

lib/elixir_sense/core/introspection.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ defmodule ElixirSense.Core.Introspection do
487487
def to_string_with_parens({name, meta, args}) when is_atom(name) do
488488
if ElixirSense.Core.Normalized.Code.Formatter.local_without_parens?(
489489
name,
490-
length(args || []),
490+
if(is_list(args), do: length(args), else: 0),
491491
ElixirSense.Core.Normalized.Code.Formatter.locals_without_parens()
492492
) do
493493
# Macro.to_string formats some locals without parens
@@ -688,7 +688,7 @@ defmodule ElixirSense.Core.Introspection do
688688
end
689689

690690
def extract_fun_args({{_fun, _}, _line, _kind, args, _doc, _metadata}) do
691-
(args || [])
691+
if(is_list(args), do: args, else: [])
692692
|> Enum.map(&format_doc_arg(&1))
693693
end
694694

@@ -736,7 +736,7 @@ defmodule ElixirSense.Core.Introspection do
736736
spec = Map.get(specs, {f, a})
737737

738738
formatted_args =
739-
(args || [])
739+
if(is_list(args), do: args, else: [])
740740
|> Enum.map(&format_doc_arg(&1))
741741

742742
desc = extract_summary_from_docs(doc)

lib/elixir_sense/core/options.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ defmodule ElixirSense.Core.Options do
346346

347347
def do_expand_type({name, meta, args}, metadata, module, named_args, stack)
348348
when is_atom(name) do
349-
args = (args || []) |> Enum.map(&expand_type(&1, metadata, module, named_args, stack))
349+
args = if(is_list(args), do: args, else: []) |> Enum.map(&expand_type(&1, metadata, module, named_args, stack))
350350
named_arg = Keyword.fetch(named_args, name)
351351

352352
cond do
@@ -410,7 +410,7 @@ defmodule ElixirSense.Core.Options do
410410
def do_expand_type(literal, _metadata, _module, _named_args, _stack), do: literal
411411

412412
defp find_type(module, name, args, metadata) do
413-
args = args || []
413+
args = if(is_list(args), do: args, else: [])
414414

415415
case metadata.types[{module, name, length(args)}] do
416416
nil ->

0 commit comments

Comments
 (0)