Skip to content

Commit

Permalink
Don't show signatures on module attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Oct 25, 2021
1 parent 14a4ca8 commit 2a07798
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/livebook/intellisense/signature_matcher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ defmodule Livebook.Intellisense.SignatureMatcher do
find_cursor_call(right, {nil, :pipe})
end

defp find_cursor_call({:@, _, [{attr, _, [arg]}]}, _acc) when is_atom(attr) do
find_cursor_call(arg, {nil, :none})
end

defp find_cursor_call({left, _, right} = node, {_, pipe_info} = acc) when is_list(right) do
if is_atom(left) and
(Macro.operator?(left, length(right)) or
Expand Down
29 changes: 29 additions & 0 deletions test/livebook/intellisense_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1464,5 +1464,34 @@ defmodule Livebook.IntellisenseTest do
]
} = Intellisense.get_signature_items("Enum.concat([1, 2], ", binding, env)
end

test "does not return any signatures for module attributes" do
{binding, env} = eval(do: nil)

assert nil == Intellisense.get_signature_items("@length(", binding, env)
end

test "does not returns signatures for calls in attribute value" do
{binding, env} = eval(do: nil)

assert %{
active_argument: 0,
signature_items: [
%{
arguments: ["list"],
documentation: """
Returns the length of `list`.
---
```
@spec length(list()) :: non_neg_integer()
```\
""",
signature: "length(list)"
}
]
} = Intellisense.get_signature_items("@attr length(", binding, env)
end
end
end

0 comments on commit 2a07798

Please sign in to comment.