-
-
Notifications
You must be signed in to change notification settings - Fork 787
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
Implement renaming for local variables #4185
base: main
Are you sure you want to change the base?
Conversation
e5c4a68
to
40c40e4
Compare
Not sure why checks are failing... I haven't changed anything to do with deps or cargo deny |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh this is so exciting!! Amazing! I've left one question inline
I have now made it work properly with:
One thing I wasn't totally sure about is the following: let Wibble(wibble:) = todo
// ^ If you put you cursor here and trigger a rename What should happen? Should it treat is as renaming the local variable: |
Just realised that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic!!! I love this!
I found a tiny bug, it's not renaming variables used in bit array literals
pub fn starts_with(bits: BitArray, prefix: BitArray) -> Bool {
let prefix_size = bit_size(prefix)
case bits {
<<pref:bits-size(prefix_size), _:bits>> if pref == prefix -> True
_ -> False
}
}
Try renaming prefix_size
here
Yay, another edge-case. I'll look into it |
Closes #2956
This PR implements renaming of local variables in the Language Server including:
SomeVar
)A few things I did while implementing this:
definition_location
field to theClauseGuard::Var
variant. SinceClauseGuard
is just one type for both typed and untyped versions, this field has to be present in the untyped AST, where it has no meaning (we don't know where the variable is defined yet). That was the most straightforward solution I could find for the time being.