elixir-ls icon indicating copy to clipboard operation
elixir-ls copied to clipboard

"Go to definition" does not work within the scope of a Phoenix router

Open Sleepful opened this issue 4 years ago • 2 comments

This is in the README.

https://github.com/elixir-lsp/elixir-ls/blob/9becfba6b5cf15676fd78b9b14d47d3611bd85da/README.md?plain=1#L232

Is there a GH issue for this already?

Any clue why it doesn't work?

Sleepful avatar Nov 01 '21 07:11 Sleepful

Go To Definition also does not work for elixir source code. Ref: https://github.com/elixir-lsp/elixir_sense/issues/44

khanakia avatar Nov 07 '21 06:11 khanakia

Any clue why it doesn't work?

@Sleepful Phoenix Router macros mess with modules in scopes. e.g. in

scope "/", Foo.Bar do
    pipe_through :browser

    scope "/some" do
      get "/:id", MyController, :index
    end
end

MyController is transformed to Foo.Bar.MyController. To make it work someone would need to write a phoenix plugin to elixir_sense or add some hacks to ElixirSense.MetadataBuilder to make it understand how those macros work. If you use a full module name (or properly alias it), then go to definition should work (not sure if router would still work though)

lukaszsamson avatar Nov 07 '21 09:11 lukaszsamson

Tracked in https://github.com/elixir-lsp/elixir_sense/pull/281

lukaszsamson avatar Nov 27 '23 20:11 lukaszsamson