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

Improve create undefined function quick action #1301

Merged
merged 2 commits into from
May 18, 2022

Conversation

plux
Copy link
Contributor

@plux plux commented May 15, 2022

Description

  • Create function right after current function
  • Create function with correct number of arguments
  • Don't leave trailing whitespaces
  • Don't create -spec

Fixes #1280

plux added 2 commits May 15, 2022 23:23
* Create function right after current function
* Create function with correct number of arguments
* Don't leave trailing whitespaces
* Don't create spec
@robertoaloi
Copy link
Member

Nice, thanks. Why not to leave the specs (e.g. as any())?

@plux
Copy link
Contributor Author

plux commented May 16, 2022

None of the codebases I've worked with (except erlang_ls..) enforces -specs on non-exported functions, so adding the -spec is just causing clutter in my opinion.
Adding an incomplete -spec seems pointless to me, and we already have the suggest spec feature which can add a specs
I guess we could add a code action to add missing spec if there is such a diagnostic.

I could add it back if you want to, but my preference is to not add it.

@michalmuskala
Copy link
Contributor

Adding a spec with just any() would be actually worse than no spec at all. AFAIK Dialyzer reports worse errors in cases like that since it interferes with its inference logic.

@robertoaloi
Copy link
Member

Fair enough, let's get this one as-is. Yes, the quick action would actually be amazing.

@robertoaloi robertoaloi merged commit 27a0489 into erlang-ls:main May 18, 2022
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.

The "create function" code action can produce code in the incorrect place.
3 participants