Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

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

Open
Moosieus wants to merge 6 commits into
mainfrom
next-best-definition
Open

Provide next best definition when no exact match is present.#807
Moosieus wants to merge 6 commits into
mainfrom
next-best-definition

Conversation

@Moosieus

Copy link
Copy Markdown
Collaborator

Pursuant to #780

@zachallaun zachallaun left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add some tests to ensure that, when multiple arities are available, it goes to the correct one. I.e. |some_call(1, 2) should go to some_call/1 if that's all that's there, but we should test that it still goes to some_call/2 if there's both an arity-1 and arity-2 definition.

Comment thread apps/common/lib/lexical/ast/analysis.ex Outdated
Comment thread apps/common/lib/lexical/ast/analysis/scope.ex Outdated
@Moosieus

Copy link
Copy Markdown
Collaborator Author

I'll check on the test failure 🔎

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.

Comment thread apps/remote_control/lib/lexical/remote_control/code_intelligence/definition.ex Outdated
* Prevent exact_lookup from returning private definitions for public calls.
* Jump to lowest-arity in next best definition function.
@Moosieus

Moosieus commented Aug 4, 2024

Copy link
Copy Markdown
Collaborator Author

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.

@zachallaun
zachallaun removed their request for review August 20, 2025 19:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants