I'm wondering whether it's possible to rename a symbol in a stack of commits using rust-analyzer
and git-branchless
's git test fix
or a similar tool. What is the best way to do so? Presumably, I'd want to tell rust-analyzer
to rename an identifier from the command line or from a shell script.
I looked at the docs a little, and it seems like I might have to start rust-analyzer and send an LSP request to it. I'm not sure what the request should be exactly, but it seems like it involves calculating the cursor position for the desired symbol.
Is this really the best one can do, or is there a way to (for example) refer to the symbol by name? In any case, are there docs, examples, or other pointers on how to do it?
Thank you!
P.S. Just for completeness, another tool that seemed promising was https://ast-grep.github.io/. It's based on Treesitter, so it could work in many cases, but AFAICT it wouldn't know about anything beyond what a parser can tell, e.g. if symbols of the same name shadow each other or whether symbols of the same name in different files refer to the same thing or not.
Update: Another sort-of-an-option I found is Coccinelle for Rust - Rust for Linux. It is rust-analyzer based but is under-documented and seems to have been abandoned some months ago.