lexical-lsp / lexical

Lexical is a next-generation elixir language server
874 stars 80 forks source link

Provide next best definition when no exact match is present. #807

Open Moosieus opened 2 months ago

Moosieus commented 2 months ago

Pursuant to #780

Moosieus commented 2 months ago

I'll check on the test failure :mag_right:

Go-to-definition supports multiple results, so we could just show all arities and let users select one of them, rather than resolving to any specific one. If that's not preferable though, we can resolve to the lowest arity definition.

LMK what you think and I'll amend things accordingly.

Moosieus commented 1 month ago

Found this behavior which applies to main branch as well. Public calls to non-existent arities can jump to privately defined arities. Screencast from 2024-08-03 23-24-56.webm

This comes from both Lexical's existing ("exact") lookup, and elixir_sense. At the moment, I've filtered out private definitions for public calls on Lexical's lookup ("exact" + "nearest arity"), and left elixir_sense as-is.