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

BUG - imports through use are not available as completion candidates #664

Closed
victorolinasc opened this issue Jan 26, 2022 · 3 comments
Closed
Labels
duplicate This issue or pull request already exists

Comments

@victorolinasc
Copy link
Contributor

Environment

  • Elixir & Erlang versions (elixir --version): Elixir 1.13.2 OTP 24.2
  • Elixir Language Server version: master commit #1e7a52ca242bf06942c405aab043a612fcd2a211
  • Operating system: Linux
  • Editor or IDE name (e.g. Emacs/VSCode): Emacs
  • Editor Plugin/LSP Client name and version: lsp-mode

Current behavior

I have a module that does something like this:

defmodule MySchema do
      defmacro __using__(_opts) do
        quote do
          use Ecto.Schema
          import Ecto.Changeset          
        end
      end
end

Then another with:

defmodule SomeSchema do
  use MySchema

  def any_function(changeset) do
    changeset
    |> validate_<<pointer here>>
  end
end

It does not show the functions from Ecto.Changeset that are imported. The server does not log any error. The build went smoothly and prints this at the end:

Compile took 1457 milliseconds
[ElixirLS Dialyzer] Checking for stale beam files
[ElixirLS WorkspaceSymbols] Updating index...
[ElixirLS WorkspaceSymbols] 1 modules need reindexing
[ElixirLS WorkspaceSymbols] 0 callbacks added to index
[ElixirLS WorkspaceSymbols] 1 modules added to index
[ElixirLS WorkspaceSymbols] 1 types added to index
[ElixirLS WorkspaceSymbols] 10 functions added to index
[ElixirLS Dialyzer] Found 1 changed files in 66 milliseconds
[ElixirLS Dialyzer] Analyzing 1 modules: [xxxxxxxxxxxxxxx (I've hidden the module name just in case here)]
[ElixirLS Dialyzer] Analysis finished in 417 milliseconds
Dialyzer analysis is up to date
[ElixirLS Dialyzer] Writing manifest...
[ElixirLS Dialyzer] Done writing manifest in 3032 milliseconds.

Expected behavior

Some versions ago it was suggesting imported functions just as well. I'll completely rebuild everything from ground zero another time just to be double sure but I think this is a regression.

@victorolinasc
Copy link
Contributor Author

In my case there is also a wrapping if on MySchema module like this:

if Code.ensure_loaded?(Ecto.Schema) do
  defmodule MySchema do
      defmacro __using__(_opts) do
        quote do
          use Ecto.Schema
          import Ecto.Changeset          
        end
      end
  end
end

Though I am sure the dep is present and compiled. Either way I forced recompilation (by deleting the dependency and updating the project), the server said it was replacing the definition of the module in question. Not sure if this would break anything. It didn't before.

Also, the commit of elixir-sense here is: d344003762e4049d7cf423a1f1ff184996bd4fbe

@lukaszsamson lukaszsamson added the duplicate This issue or pull request already exists label Jan 27, 2022
@lukaszsamson
Copy link
Collaborator

Works fine on latest master (built and executed on the exact same version of elixir and OTP).
Screenshot 2022-01-27 at 09 18 41

@victorolinasc unless you can reproduce it as a test case in this repo or elixir_sense, I'm going to close it as a duplicate of #193

@victorolinasc
Copy link
Contributor Author

I've set up a new project with the structured I mentioned. https://github.com/victorolinasc/use_dep_issue

Not re-opening this because maybe I am doing something wrong here but will leave a screenshot of completions here:

image

Everything compiled just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants