elixir-lsp / elixir-ls

A frontend-independent IDE "smartness" server for Elixir. Implements the "Language Server Protocol" standard and provides debugger support via the "Debug Adapter Protocol"
https://elixir-lsp.github.io/elixir-ls/
Apache License 2.0
1.5k stars 196 forks source link

Autocomplete/goto definition does not work for code aliases defined inside a macro #1059

Closed Gigitsu closed 9 months ago

Gigitsu commented 9 months ago

Precheck

[x] Do a quick search and make sure the issue has not yet been reported [x] Do not use the issues tracker for guidance, questions or support (try Elixir Forum, Stack Overflow, Slack, etc. instead) [x] If using a client other than VS Code, please try VSCode's "ElixirLS: Elixir support and debugger" extension. Does it reproduce your failure?

Environment

Current behavior

If I define an alias inside a macro other than __using__ there is no autocomplete of go to definition for that alias. If I define the very same alias inside a __using__ macro, everything works as expected.

I made this repository that reproduce the issue: https://github.com/Gigitsu/macro_alias_issue

Expected behavior

Aliases should be defined in a generic macro should be recognized as well as the alias defined inside a __using__ macro

lukaszsamson commented 9 months ago

I don’t see how that could be done without actually executing client code in language server. If you want to give it a try please look into elixir_sense MetadataBuilder module. This is the code that tries to expand use macro and does AST based inferience

Gigitsu commented 9 months ago

Thank you @lukaszsamson, I'll give it a look!

Gigitsu commented 9 months ago

I think I can close this. Thanks