Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/elixir_ls_utils/lib/completion_engine.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ defmodule ElixirLS.Utils.CompletionEngine do
needed_requires =
for func_kind <- func_kinds do
if func_kind in [:macro, :defmacro, :defguard] and mod not in env.requires and
mod != Kernel.SpecialForms do
mod != Kernel.SpecialForms and mod != env.module do
mod
end
end
Expand Down
26 changes: 26 additions & 0 deletions apps/elixir_ls_utils/test/complete_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2208,6 +2208,32 @@ defmodule ElixirLS.Utils.CompletionEngineTest do
] = expand(~c"unquote", %Env{requires: []})
end


test "macros from the same module should not add needed_require" do
macro_info = %ElixirSense.Core.State.ModFunInfo{
type: :defmacro,
params: [[:_]]
}

metadata = %Metadata{
mods_funs_to_positions: %{
{MyModule, nil, nil} => %ElixirSense.Core.State.ModFunInfo{},
{MyModule, :info, 1} => macro_info
}
}

assert [
%{
name: "info",
arity: 1,
type: :macro,
origin: "MyModule",
needed_require: nil,
visibility: :public
}
] = expand(~c"inf", %Env{requires: [], module: MyModule}, metadata)
end

if Version.match?(System.version(), ">= 1.14.0") do
test "Application.compile_env classified as macro" do
assert [
Expand Down
Loading