Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

References provider fails to find function arguments #124

Closed
lukaszsamson opened this issue Mar 14, 2021 · 0 comments
Closed

References provider fails to find function arguments #124

lukaszsamson opened this issue Mar 14, 2021 · 0 comments

Comments

@lukaszsamson
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant