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

Replace unknown local function #861

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sheldak
Copy link
Contributor

@sheldak sheldak commented Apr 12, 2023

I propose extending code actions by adding suggestions for calling or referencing unknown local functions. For example, the following code:

defmodule Example do
  def main do
    fo()
  end

  def foo do
    42
  end
end

calls non-existing function fo/0. But since there is a similar existing function foo, we can introduce a code action that replaces the above code with:

defmodule Example do
  def main do
    foo() # <-- changed here
  end

  def foo do
    42
  end
end

I used String.jaro_distance/2 with a threshold of 0.77 to create at most 5 suggestions (similar to did you mean functionality).

@sheldak sheldak force-pushed the replace-unknown-local-function branch from bf9a99e to 1608bc3 Compare April 27, 2023 15:19
@sheldak
Copy link
Contributor Author

sheldak commented May 10, 2023

@lukaszsamson The feature is finished but I get some CI errors that don't seem to be connected with it. Could you help me with it and/or give some feedback regarding this new code action?

@lukaszsamson
Copy link
Collaborator

@sheldak I'll review it shortly

@sheldak
Copy link
Contributor Author

sheldak commented Jul 10, 2023

@lukaszsamson After merging the new master it passes all the tests

@lukaszsamson
Copy link
Collaborator

@sheldak #1057 is merged now, would you consider to rework this PR on top of the current master?

@sheldak
Copy link
Contributor Author

sheldak commented Mar 12, 2024

@sheldak #1057 is merged now, would you consider to rework this PR on top of the current master?

Sure, I will definitely go back to that at some point. However, currently, I have other priorities so it may take some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants