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

Add support for renaming modules #1196

Merged
merged 1 commit into from
Feb 14, 2022
Merged

Conversation

plux
Copy link
Contributor

@plux plux commented Feb 11, 2022

Description

Add support for renaming modules.
Put cursor at modname in -module(modname), and trigger the rename command.
This will rename the .erl file (in the same directory), updated the -module attribute
and update references to the module such as:

  • Function applications
  • Type applications
  • Implicit functions
  • Imports
  • -behaviour attributes

This PR also improves the "find references" functionality for modules, previously it only displayed function references.

There's a small race condition with Emacs erlang-mode as it wants to be helpful and suggest that the old filename doesn't match the new module name, you need to answer no when it asks if it should fix the module name.
Personally I have now disabled that check:
(setq erlang-check-module-name nil)
This feature could be handled by erlang_ls with a code action instead as
we already have a diagnostic to check the module name.
Could be a good beginner task 👍

@robertoaloi
Copy link
Member

Personally I have now disabled that check:
(setq erlang-check-module-name nil)

Good point, we can include that in the provided Emacs config sample:

https://github.com/erlang-ls/erlang_ls/blob/main/misc/dotemacs

@robertoaloi
Copy link
Member

This feature could be handled by erlang_ls with a code action instead as
we already have a diagnostic to check the module name.
Could be a good beginner task 👍

Yes! I hinted at that in the release notes, so let's craft an issue with that, pointing to the tutorial and let's leave it for new contributors.

@robertoaloi
Copy link
Member

Nice one, thanks!

@robertoaloi robertoaloi merged commit e0939ff into erlang-ls:main Feb 14, 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.

2 participants