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

x/tools/gopls: feature: CLI syntax for renaming by identifier, not position (like cmd/gorename) #61627

Open
nabice opened this issue Jul 28, 2023 · 3 comments
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@nabice
Copy link

nabice commented Jul 28, 2023

Such as:

  "encoding/json".Decoder.Decode        method of package-level named type                                                                                                                                                                     
  (*"encoding/json".Decoder).Decode     ditto, alternative syntax                                                                                                                                                                              
  "encoding/json".Decoder.buf           field of package-level named struct type                                                                                                                                                               
  "encoding/json".HTMLEscape            package member (const, func, var, type)                                                                                                                                                                
  "encoding/json".Decoder.Decode::x     local object x within a method                                                                                                                                                                         
  "encoding/json".HTMLEscape::x         local object x within a function                                                                                                                                                                       
  "encoding/json"::x                    object x anywhere within a package                                                                                                                                                                     
  json.go::x                            object x within file json.go  
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jul 28, 2023
@gopherbot gopherbot added this to the Unreleased milestone Jul 28, 2023
@suzmue suzmue modified the milestones: Unreleased, gopls/unplanned Jul 28, 2023
@findleyr
Copy link
Contributor

findleyr commented Aug 3, 2023

Thanks, this would be nice, but we're not aware of a significant number of users depending on gopls' CLI, so this is unlikely to get prioritized any time soon.

@thepudds
Copy link
Contributor

thepudds commented Aug 3, 2023

Hi @nabice, you might be interested in rsc.io/rf, which is a refactoring tool that supports something similar to what you are suggesting, if I understood correctly.

You can see a sample use in this commit. In that example, rf was used to rename identifiers via its mv command (and that commit also includes samples of example-based refactoring, moving packages, and so on).

The documentation has more details, but here is a snippet of the mv command documentation:

item → renamed item

Any named item can be renamed by specifying a destination that is
the same code address with the final element changed. For example:

mv E Euler             # constant
mv F Func              # function
mv F.w F.writer        # argument name
mv F.who F.greetee     # local variable name
mv T MyType            # type
mv T.M T.Method        # method
mv T.M.t T.M.rcvr      # receiver name
mv Point.x Point.X     # struct field
mv V Var               # var
mv V.Value V.IntValue  # var struct field

rf is still WIP as far as I understand, but still usable.

@findleyr
Copy link
Contributor

findleyr commented Aug 3, 2023

Thanks @thepudds (and sorry for my perhaps hasty reply - I was taking notes in our triage meeting).

Yes, we'd rather invest in rf as a tool for implementing command-line refactorings.

@adonovan adonovan changed the title x/tools/gopls: The rename command line may accept identifiers instead of positions, like gorename x/tools/gopls: feature: CLI syntax for renaming by identifier, not position (like cmd/gorename) Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants