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

Rename function/variable #791

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

Conversation

timgent
Copy link

@timgent timgent commented Dec 17, 2022

Note that this uses ElixirSense to get the definition and references under the hood, which limits the rename functionality. There is a PR raised against elixir_sense already to address some of the current issues with the find references functionality - elixir-lsp/elixir_sense#173 - I'm waiting for feedback on that one.

I do suspect that there are other cases where find definition/references doesn't work 100% - for example I know find references doesn't work for a variable in a list comprehension. I've not had time to properly test and identify all of those cases, but know they will impact rename functionality. Still feel like this is a good improvement to merge in, but let me know what you think!

@lukaszsamson
Copy link
Collaborator

Nice work @timgent. The problem with that approach is that it's error prone. We recently had to revert a similar text based code transformation (#775). A better option would be to express the code changes in terms of AST transformations. See #773

@timgent
Copy link
Author

timgent commented Jan 1, 2023

@lukaszsamson thanks for the update. Sounds like it's best for me to stop looking at improvements to support rename functionality in elixir sense and elixir-ls until #773 gets merged and other existing features are ported over?

Sounds like the existing elixir-sense find references functionality will also be replaced so I should close this PR too? elixir-lsp/elixir_sense#173

In the meantime let me know if there's any support that could be helpful to improve elixir-ls. I'm up for contributing but want to make sure what I do is useful!

Tuxified and others added 10 commits January 24, 2023 15:14
LSPs can offer a rename capability to rename a "symbol" across a workspace.
We're not there yet, but this is a starting point. In VS Code it can be used by
right clicking a symbol (currently variable or call to local function) and
selecting "Rename symbol". A dialog should pop up asking for a new name.

Official spec:
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rename
- Make rename_example a `.ex` file so we can later test multi-file
  refactors
- Simplify rename_example to make it easier to follow
- Extract some common patterns out in the tests
@illia-danko
Copy link

@timgent don't wont to push :), but is any plan to finish renaming, or you are blocking by something?

@timgent
Copy link
Author

timgent commented Jun 15, 2023

@illia-danko I've since got a new baby so been struggling to find time. Any more guidance on using the AST as suggested would be helpful though. I've not had the chance to look into that in depth, but if I could get a few pointers that might make it easier :)

@illia-danko
Copy link

@timgent congratulations on the baby born! Sure, take your time, hopefully you'll come back at some point

@lukaszsamson
Copy link
Collaborator

AST based transforms landed in #1057. Would you be interested in reworking the PR using this approach? Possibly also with Code.string_to_quoted_with_comments

@timgent
Copy link
Author

timgent commented May 26, 2024

@lukaszsamson I'm still a bit time-poor to be honest but would love to get this over the line. Will try to get my head back into this and give it a go if I find the time

@hubcio2115
Copy link

How's the work going? I'm willing to take this feature upon myself if you don't have time now.
@timgent

@timgent
Copy link
Author

timgent commented Sep 16, 2024

@hubcio2115 yeah tbh I've struggled to find the time - if you're able to pick it up that would be great. I've been working mostly in Typescript recently which doesn't help! Thank you!

@hubcio2115
Copy link

I'm pretty new to this so it might take a while.

@hubcio2115
Copy link

After trying a couple of times to implement this feature I decided to give up for now. I'm not nearly enough proficient with the language to do this on my own. I'll probably go back to it after some time, if it won't be already implemented.

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.

6 participants