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: 'refactor'-only codeAction should return all available 'refactor.*' code action items #44213

Closed
hyangah opened this issue Feb 10, 2021 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Feb 10, 2021

gopls version v0.6.5

When vscode user selects 'Refactor...' context menu entry, vscode requests codeAction with "context": { ... "only": ["refactor"]}. Gopls doesn't return anything even though there are possible refactoring actions applicable to the selected range.

[Trace - 14:38:03.583 PM] Sending request 'textDocument/codeAction - (10)'.
Params: {
  "textDocument":{"uri":"file:///Users/hakim/projects/w/main.go"},
  "range":{"start":{"line":6,"character":0},"end":{"line":8,"character":3}},
  "context":{"diagnostics":[],"only":["refactor"]}}


[Trace - 14:38:03.584 PM] Received response 'textDocument/codeAction - (10)' in 1ms.
Result: null

Compare against the result for the previous codeAction request on the same range:

[Trace - 14:37:57.484 PM] Sending request 'textDocument/codeAction - (8)'.
Params: {
   "textDocument":{"uri":"file:///Users/hakim/projects/w/main.go"},
   "range":{"start":{"line":6,"character":0},"end":{"line":8,"character":3}},
   "context":{"diagnostics":[]}}


[Trace - 14:37:57.485 PM] Received response 'textDocument/codeAction - (8)' in 0ms.
Result: [{
   "title":"Extract to function",
   "kind":"refactor.extract","edit":{},
   "command":{"title":"","command":"gopls.extract_function","arguments":["file:///Users/hakim/projects/w/main.go",{"start":{"line":6,"character":0},"end":{"line":8,"character":3}}]}}]
@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 Feb 10, 2021
@gopherbot gopherbot added this to the Unreleased milestone Feb 10, 2021
@heschi
Copy link
Contributor

heschi commented Feb 10, 2021

https://cs.opensource.google/go/x/tools/+/master:internal/lsp/code_action.go;l=165-178;drc=d4590503678b9a270e7c2a91fe6dccea617322a6 does exact matches on the only attribute. It seems we should return refactor.extract for only=refactor.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v1.0.0 Feb 10, 2021
@stamblerre stamblerre changed the title x/tools/gopls: 'refactor'-only codeAction should return all available 'refactor.*' code action items. x/tools/gopls: 'refactor'-only codeAction should return all available 'refactor.*' code action items Feb 10, 2021
@stamblerre stamblerre added this to To Do in gopls on-deck Feb 28, 2021
@stamblerre stamblerre moved this from To Do to P2 in gopls on-deck Aug 12, 2021
@findleyr
Copy link
Contributor

@suzmue was this fixed by https://go.dev/cl/361834?

@suzmue
Copy link
Contributor

suzmue commented Jan 19, 2022

Yes this is fixed!

@suzmue suzmue closed this as completed Jan 19, 2022
gopls on-deck automation moved this from P2 to Done Jan 19, 2022
@findleyr findleyr modified the milestones: gopls/later, gopls/v0.7.5 Jul 1, 2022
@golang golang locked and limited conversation to collaborators Jul 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
No open projects
Development

No branches or pull requests

6 participants