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

Unable to autocomplete/hover macro in Phoenix Project #1124

Open
u4d3rc0v3r opened this issue Oct 21, 2024 · 4 comments
Open

Unable to autocomplete/hover macro in Phoenix Project #1124

u4d3rc0v3r opened this issue Oct 21, 2024 · 4 comments

Comments

@u4d3rc0v3r
Copy link

u4d3rc0v3r commented Oct 21, 2024

The project is running in VSCode devcontainer

Sample Code

defmodule AppWeb.PageController do
  use AppWeb, :controller

  def home(conn, _params) do
    # The home page is often custom made,
    # so skip the default app layout.
    render(conn, :home, layout: false)
  end
end
defmodule AppWeb do
   @spec controller() :: {:__block__, [], [{:import, [...], [...]} | {:use, [...], [...]}, ...]}
  def controller do
    quote do
      use Phoenix.Controller,
        formats: [:html, :json],
        layouts: [html: AppWeb.Layouts]

      import Plug.Conn
      import AppWeb.Gettext

      unquote(verified_routes())
    end
  end
  • Elixir & Erlang versions (elixir --version):
    elixir 1.17.3/OTP 27
  • Elixir Language Server version:
    ElixirLS v0.24.1
  • Operating system:
    MacOS
  • Editor or IDE name (e.g. Emacs/VSCode):
    VSCode

Elixir-LS Log

[Warn  - 11:40:30 AM] Unable to expand macro AppWeb.__using__/1: ** (FunctionClauseError) no function clause matching in AppWeb.__using__/1
    (app 0.1.0) expanding macro: AppWeb.__using__/1
    nofile:2: AppWeb.PageController (module)

Reproduction steps

  1. install elixir-ls in VSCode
  2. Create fresh project using mix phx.new app
@lukaszsamson
Copy link
Collaborator

Which macros are you trying to hover on? In which files is autocomplete not working?

@u4d3rc0v3r
Copy link
Author

u4d3rc0v3r commented Oct 21, 2024

Which macros are you trying to hover on? In which files is autocomplete not working?

i was trying to hover this :controller which is a function defined in AppWeb i was wondering why it doesn't allow navigation/autocomplete/hover info. This file is under lib/controllers/page_controller.ex in a fresh Phoenix project

@Ridtt
Copy link

Ridtt commented Nov 8, 2024

Unable to expand macro Phoenix.Component.Declarative.pattern!/2: ** (ArgumentError) could not call Module.delete_attribute/2 because the module MyAppWeb.MyViewLive.FormComponent is already compiled
(elixir 1.17.3) lib/module.ex:2365: Module.assert_not_readonly!/2
(elixir 1.17.3) lib/module.ex:1641: Module.delete_attribute/2
(phoenix_live_view 0.20.17) lib/phoenix_component/declarative.ex:1028: Phoenix.Component.Declarative.pop_slots/1
(phoenix_live_view 0.20.17) lib/phoenix_component/declarative.ex:707: Phoenix.Component.Declarative.register_component!/4
(phoenix_live_view 0.20.17) expanding macro: Phoenix.Component.Declarative.pattern!/2

I can't make it working for any macro accessing attributes/compile time properties of module in using and before_compile functions.

Started ElixirLS v0.24.1
ElixirLS built with elixir "1.17.3" on OTP "27"

Using last version of elixir (1.17.3-otp-27) and OTP (27.1.2) installed via asdf.

im trying to work with elixir-ls lsp from zed editor on Mac OS system.

@lukaszsamson
Copy link
Collaborator

Unable to expand macro Phoenix.Component.Declarative.pattern!/2: ** (ArgumentError) could not call Module.delete_attribute/2 because the module MyAppWeb.MyViewLive.FormComponent is already compiled

That's a know limitation

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

3 participants