elixir_sense
elixir_sense copied to clipboard
References provider fails to find function arguments
The following test fails
test "find references of variables in arguments" do
buffer = """
defmodule MyModule do
def call(conn) do
if true do
conn
end
end
end
"""
references = ElixirSense.references(buffer, 2, 13)
assert references == [
%{range: %{end: %{column: 16, line: 2}, start: %{column: 12, line: 2}}, uri: nil},
%{range: %{end: %{column: 11, line: 4}, start: %{column: 7, line: 4}}, uri: nil},
]
# returns []
end
The reason is broken variable tracking in MetadataBuilder.State. new_func_vars_scope works differently from new_vars_scope - it does not increment the scope_id counter and thanks to that conn variable is not in the function scope. The second problem is subscope handling. When leaving a subscope in remove_vars_scope all subscope variable positions are lost.