JakeBecker / elixir-ls

A frontend-independent IDE "smartness" server for Elixir. Implements the JSON-based "Language Server Protocol" standard and provides debugger support via VS Code's debugger protocol.
Apache License 2.0
843 stars 52 forks source link

"Go to definition" not working in cond statement when alias or import is used #171

Closed wanton7 closed 4 years ago

wanton7 commented 5 years ago

Environment

If I go over get_user_by_email and press F12 "Go to Definition" I get no definition found for 'get_user_by_email'

defmodule FooWeb.DevelopmentController do
  use FooWeb, :controller
  import Foo.Account.User

  def login(conn, %{"email" => email}) do
    cond do
      user = email && get_user_by_email(email) ->
        conn
        |> put_session(:user_id, user.id)
        |> put_resp_content_type("application/json")
        |> resp(:ok, "{}")

      true ->
        conn
        |> put_status(:forbidden)
        |> Phoenix.Controller.render(FooWeb.ErrorView, "403.json")
    end
  end
end

If I change code to one below "Go to definition" starts working

defmodule FooWeb.DevelopmentController do
  use FooWeb, :controller

  def login(conn, %{"email" => email}) do
    cond do
      user = email && Foo.Account.User.get_user_by_email(email) ->
        conn
        |> put_session(:user_id, user.id)
        |> put_resp_content_type("application/json")
        |> resp(:ok, "{}")

      true ->
        conn
        |> put_status(:forbidden)
        |> Phoenix.Controller.render(FooWeb.ErrorView, "403.json")
    end
  end
end

Problem also happens if I use alias Foo.Account.User and change Foo.Account.User.get_user_by_email to User.get_user_by_email. Problem seems to be related to cond statement.

lukaszsamson commented 5 years ago

@JakeBecker I managed to reproduce this issue in elixir_sense version used in elixir_ls (c7ed928ad1c0e2ddf94a951fabe93b7af9b6a78a) but it's no longer reproducible on the current master. Update elixir_sense dependancy to resolve

JakeBecker commented 4 years ago

This project has moved!

It's now being maintained by proactive volunteers from the Elixir community over at elixir-lsp/elixir-ls. Updates will continue to be published from that repo to the original VS Code extension, so no need to switch plugins if you're using VS Code.

To avoid inundating the new maintainers with issues, please verify that your issue persists with the latest version of the extension (which is published from the new repo) before re-filing your issue there.

Thanks for using ElixirLS!