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

Deprecate "Go: Extract to variable/function" command (obsolete by gopls's code action) #2862

Closed
benjaminclauss opened this issue Jul 6, 2023 · 6 comments

Comments

@benjaminclauss
Copy link

Is your feature request related to a problem? Please describe.
I would like to be able to extract a value to a const. I can only extract to a variable.

Screenshot 2023-07-06 at 10 55 38 AM

Screenshot 2023-07-06 at 10 55 54 AM

Describe the solution you'd like
Go: Extract to const

Describe alternatives you've considered
N/A

@gopherbot gopherbot added this to the Untriaged milestone Jul 6, 2023
@findleyr
Copy link
Contributor

findleyr commented Jul 6, 2023

Thanks.

Not sure if this belongs in VS Code or gopls issue tracker, but this is a useful feature suggestion (and should be easy to implement, given that we already support extracting to variable).

@findleyr findleyr changed the title Extract to const Add an 'Extract to const' command Jul 6, 2023
@findleyr
Copy link
Contributor

findleyr commented Jul 6, 2023

@hyangah if I'm reading the source correctly this command still uses godoctor? Is that right? We should use gopls instead.

@hyangah
Copy link
Contributor

hyangah commented Jul 7, 2023

Yes, the Extract to variable/function commands still use godoctor.
We need equivalent gopls commands (takes the current cursor position, and new variable/const/function names).

@adonovan adonovan modified the milestones: Untriaged, v0.40.0 Jul 13, 2023
@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/538756 mentions this issue: package.json: remove godoctor-based extract func/var commands

@hyangah
Copy link
Contributor

hyangah commented Oct 31, 2023

@benclauss I filed golang/go#63852 for the followup. In cl/5387566, we are moving the "Go: Extract to variable" and "Go: Extract to function" vscode commands. Equivalent functionalities are currently available through code action. How important is it in your workflow to access them through the vscode command interface?

To access the gopls-based extract features, you can either find the light bulb, or use refactoring context menu or key bindings https://code.visualstudio.com/docs/getstarted/keybindings#_custom-keybindings-for-refactorings. If they are not as convenient, we can consider to add back the "Go: Extract to variable/function" commands interface to minimize disruption.

gopherbot pushed a commit that referenced this issue Nov 1, 2023
This change removes "Go: Extract to function" and "Go: Extract to
variable" commands, which were using godoctor.
Extract function/var features are implemented in gopls, which can
be accessible by
  selecting the range to extract
  trigger code action

If users want access through commands, we can consider to add
commands (as we are doing for "Go: Fill struct" command).

Updates #2862

Change-Id: Id43374513dcd347c06ae8107aa1c25a41e884641
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/538756
Commit-Queue: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
@hyangah hyangah changed the title Add an 'Extract to const' command Deprecate "Go: Extract to variable/function" command (obsolete by gopls's code action) Nov 2, 2023
@hyangah
Copy link
Contributor

hyangah commented Nov 2, 2023

Sorry for using this feature request (extending a legacy feature) for deprecating the legacy feature. I hope we can get to golang/go#63842. Please follow the issue. Thanks!

@hyangah hyangah closed this as completed Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants