elixir-tools / next-ls

The language server for Elixir that just works. Ready for early adopters!
https://www.elixir-tools.dev/next-ls
MIT License
698 stars 40 forks source link

code actions: add alias for undefined function #425

Open mhanberg opened 6 months ago

mhanberg commented 6 months ago

Description

Basically how I envision this working is if the compiler returns a "Undefined function baz/3" warning, the LSP can provide code actions for "import module Foo.Bar" or replace with remote callFoo.Bar.baz`.

This could be possible when the client request code actions, to search all loaded modules and all their functions and suggest any that have the name and arity that are found in the diagnostic.

This could potentially be slow on larger projects, but can be potentially cached

mhanberg commented 6 months ago

@srcrip does this sound like the problem you were describing and if yes, a desirable solution?

srcrip commented 6 months ago

Yes this is perfect, this is the general gist of what I was looking for.

Might I suggest exposing a configuration option to search only under the main module of the current application too? Or instance if you're currently in Foo.Bar search only Foo and its children? I think that could potentially speed up a lot in big projects. But you'd definitely want to be able to configure that.

mhanberg commented 6 months ago

can definitely scope it to just your application code, rather than all modules. probably better, as we can query for them in the database.