Skip to content

Commit b785a3a

Browse files
committed
locals are defined only in defs
1 parent f862785 commit b785a3a

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

lib/elixir_sense/core/introspection.ex

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -998,21 +998,24 @@ defmodule ElixirSense.Core.Introspection do
998998
{nil, fun},
999999
%State.Env{
10001000
module: current_module,
1001+
function: function,
10011002
functions: functions,
10021003
macros: macros
10031004
},
10041005
mods_funs,
10051006
cursor_position
10061007
) do
10071008
found_in_metadata =
1008-
Enum.any?(mods_funs, fn
1009-
{{^current_module, ^fun, _}, info} ->
1010-
State.ModFunInfo.get_category(info) != :macro or
1011-
List.last(info.positions) < cursor_position
1012-
1013-
_ ->
1014-
false
1015-
end)
1009+
if current_module && function do
1010+
Enum.any?(mods_funs, fn
1011+
{{^current_module, ^fun, _}, info} ->
1012+
State.ModFunInfo.get_category(info) != :macro or
1013+
List.last(info.positions) < cursor_position
1014+
1015+
_ ->
1016+
false
1017+
end)
1018+
end
10161019

10171020
if found_in_metadata do
10181021
{current_module, fun}

test/elixir_sense/core/introspection_test.exs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,17 @@ defmodule ElixirSense.Core.IntrospectionTest do
321321
assert {nil, :not_existing, false, nil} =
322322
actual_mod_fun(
323323
{nil, :not_existing},
324-
%Env{module: MyModule},
324+
%Env{module: MyModule, function: {:foo, 1}},
325+
mod_fun,
326+
%{},
327+
{1, 1},
328+
false
329+
)
330+
331+
assert {nil, :info, false, nil} =
332+
actual_mod_fun(
333+
{nil, :info},
334+
%Env{module: MyModule, function: nil},
325335
mod_fun,
326336
%{},
327337
{1, 1},
@@ -331,7 +341,7 @@ defmodule ElixirSense.Core.IntrospectionTest do
331341
assert {MyModule, :info, true, :mod_fun} =
332342
actual_mod_fun(
333343
{nil, :info},
334-
%Env{module: MyModule},
344+
%Env{module: MyModule, function: {:foo, 1}},
335345
mod_fun,
336346
%{},
337347
{1, 1},

0 commit comments

Comments
 (0)