Skip to content

Commit b453e9a

Browse files
authored
Do not suggest 0 arity functions after pipe (#486)
bump elixir_sense - fix invalid argument list returned for Kernel.SpecialForms macros Fixes #479
1 parent dccd34d commit b453e9a

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

apps/language_server/lib/language_server/providers/completion.ex

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,17 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
468468
}
469469
end
470470

471+
defp from_completion_item(
472+
%{
473+
arity: 0
474+
},
475+
%{
476+
pipe_before?: true
477+
},
478+
_options
479+
),
480+
do: nil
481+
471482
defp from_completion_item(
472483
%{name: name, origin: origin} = item,
473484
%{def_before: nil} = context,

apps/language_server/test/providers/completion_test.exs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,4 +919,25 @@ defmodule ElixirLS.LanguageServer.Providers.CompletionTest do
919919
Completion.function_snippet("do_sth", ["My.record(x: x0, y: y0)"], 1, opts)
920920
end
921921
end
922+
923+
describe "do not suggest 0 arity functions after pipe" do
924+
test "moduledoc completion" do
925+
text = """
926+
defmodule MyModule do
927+
def hello do
928+
Date.today() |>
929+
# ^
930+
end
931+
end
932+
"""
933+
934+
{line, char} = {2, 20}
935+
936+
TestUtils.assert_has_cursor_char(text, line, char)
937+
938+
assert {:ok, %{"items" => items}} = Completion.completion(text, line, char, @supports)
939+
940+
refute Enum.any?(items, fn i -> i["label"] == "make_ref/0" end)
941+
end
942+
end
922943
end

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%{
22
"dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"},
33
"docsh": {:hex, :docsh, "0.7.2", "f893d5317a0e14269dd7fe79cf95fb6b9ba23513da0480ec6e77c73221cae4f2", [:rebar3], [{:providers, "1.8.1", [hex: :providers, repo: "hexpm", optional: false]}], "hexpm", "4e7db461bb07540d2bc3d366b8513f0197712d0495bb85744f367d3815076134"},
4-
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "ec5fd93dbef433dca0710e92dd0819dd325cdb99", []},
4+
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "28f8467a349c6ed004aac66a2e8d7020cdde2e0d", []},
55
"erl2ex": {:git, "https://github.com/dazuma/erl2ex.git", "244c2d9ed5805ef4855a491d8616b8842fef7ca4", []},
66
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
77
"forms": {:hex, :forms, "0.0.1", "45f3b10b6f859f95f2c2c1a1de244d63855296d55ed8e93eb0dd116b3e86c4a6", [:rebar3], [], "hexpm", "530f63ed8ed5a171f744fc75bd69cb2e36496899d19dbef48101b4636b795868"},

0 commit comments

Comments
 (0)