Skip to content

Use gopls rather than godoctor for extract refactorings #518

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

Closed
sorenisanerd opened this issue Aug 13, 2020 · 8 comments
Closed

Use gopls rather than godoctor for extract refactorings #518

sorenisanerd opened this issue Aug 13, 2020 · 8 comments
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.

Comments

@sorenisanerd
Copy link

Is your feature request related to a problem? Please describe.
If a project uses go.mod mode, the extract refactorings don't work as it depends on godoctor which does not yet support modules.

Describe the solution you'd like
gopls now supports these extract refactorings. The vscode plugin should use that instead of godoctor.

Describe alternatives you've considered
There's work in progress to make godoctor support modules, but a) it has stalled and b) since gopls provides the functionality it makes sense to use that instead.

Additional context
The most recent releases(s?) of gopls has this functionality, so we should be able to safely rely on it.

@hyangah
Copy link
Contributor

hyangah commented Aug 13, 2020

@sorenh thanks! Yes, that's the directory we are heading. I was told both extract function and extract variable features are available since gopls v0.4.4.

Some prerequisite decision making necessary before transitioning to gopls

I am leaning towards dropping the commands and waiting for the LSP improvement.

/cc @joshbaum @stamblerre

@hyangah hyangah added this to the Backlog milestone Aug 13, 2020
@hyangah hyangah added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Aug 13, 2020
@sorenisanerd
Copy link
Author

If I invoke the "Source Action" command, I'm told "No source actions available". What am I doing wrong? "gopls version" tells me I'm running version 0.4.4.

@stamblerre
Copy link
Contributor

@sorenh: If you highlight a range of text, you should see a lightbulb appear with a suggestion to "Extract to function". Does that work?

@sorenisanerd
Copy link
Author

sorenisanerd commented Aug 14, 2020

@stamblerre Nope. It does for e.g. Typescript (check with the vscode source).

@sorenisanerd
Copy link
Author

@stamblerre Er... Now it does. I have absolutely no clue what I changed. I opened the "Typescript" output as well as the "gopls" and "gopls (server)" outputs to see if that might give me some clues. When I looked at my own source code, the light bulb was there.

@sorenisanerd
Copy link
Author

@stamblerre I just tried with code-insiders. Didn't do anything at all and now it works. I'm so confused.

@stamblerre
Copy link
Contributor

Hm..not sure what was going on there, but glad it works now!
@hyangah: Do we want to keep this issue open to track deprecating the existing commands or is this good to close?

@hyangah
Copy link
Contributor

hyangah commented Sep 2, 2020

I will close this bug now and track the command migration separately.

@hyangah hyangah closed this as completed Sep 2, 2020
@golang golang locked and limited conversation to collaborators Sep 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

4 participants