Skip to content

x/tools/gopls: support type move refactorings #57016

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

Open
donnol opened this issue Dec 1, 2022 · 2 comments
Open

x/tools/gopls: support type move refactorings #57016

donnol opened this issue Dec 1, 2022 · 2 comments
Assignees
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. gopls Issues related to the Go language server, gopls. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@donnol
Copy link

donnol commented Dec 1, 2022

What did you do?

I have code like below:

package a

type M struct {
}

and used by some package:

package main

func main() {
        _ = &a.M{}
}

Can we have a code action on the M sruct named move to other package (like: package b), and then update the reference &a.M{} in main package to &b.M{}

@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 Dec 1, 2022
@gopherbot gopherbot added this to the Unreleased milestone Dec 1, 2022
@findleyr findleyr added the FeatureRequest Issues asking for a new feature that does not need a proposal. label Dec 14, 2022
@findleyr
Copy link
Member

Thank you for the issue, and apologies for our slow response.

We discussed this in our triage meeting, and while it would be a very useful feature it's a bit tricky to implement in the LSP (see microsoft/language-server-protocol#1164).

I think we could have a custom command (via the workspace/executeCommand API, but it would require each LSP client to implement the UI for manually editing the command before sending.

Putting this in our queue to think about: I think it would be great to develop a framework for this type of refactoring.

@firelizzard18
Copy link
Contributor

Can the extension provide code actions? If the action can be initiated from the extension, then the extension could collect the required user inputs and pass those to a gopls command.

@findleyr findleyr added the Refactoring Issues related to refactoring tools label Feb 21, 2025
@findleyr findleyr changed the title x/tools/gopls: How about add a code action to update the reference after move a type to another package? x/tools/gopls: support type move refactorings Feb 24, 2025
@adonovan adonovan modified the milestones: gopls/backlog, gopls/v0.20.0 Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. gopls Issues related to the Go language server, gopls. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

6 participants