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: replace refactoring code actions Command with Edits and codeAction/resolve #64510

Open
suzmue opened this issue Dec 1, 2023 · 2 comments
Assignees
Labels
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

@suzmue
Copy link
Contributor

suzmue commented Dec 1, 2023

codeAction/resolve was introduced to LSP in 3.16. This allows code action requests to omit Edits for a code action and compute them when necessary.

Currently, gopls implements this lazy computation by passing a command to the codeAction. However, if the client supports it we can use codeAction/resolve instead. This will enable code action previews in VS Code.

Client support is registered through textDocument.codeAction.resolveSupport:

textDocument.codeAction.resolveSupport = { properties: ['edit'] };

gopls already has ResolveCodeAction

@suzmue suzmue added the gopls Issues related to the Go language server, gopls. label Dec 1, 2023
@suzmue suzmue added this to the gopls/backlog milestone Dec 1, 2023
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Dec 1, 2023
@adonovan adonovan added the Refactoring Issues related to refactoring tools label Dec 5, 2023
@suzmue suzmue self-assigned this Dec 7, 2023
@gopherbot
Copy link

Change https://go.dev/cl/548276 mentions this issue: internal/lsp: convert refactor code actions to use codeAction/resolve

gopherbot pushed a commit to golang/tools that referenced this issue Jan 18, 2024
Allow apply fix and change signature commands to return edits instead
of applying the edits.

Added a marker test for removing parameters using the new resolve logic.
We probably want most refactoring code actions to work both ways. This
also updates the fill struct test to make sure that the capabilities
of the editor are being correctly respected.

For golang/go#64510

Change-Id: If58f7bdff52ec8e1621c007d029c5b9b60bbdd3a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/548276
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
@gopherbot
Copy link

Change https://go.dev/cl/562118 mentions this issue: gopls/internal/golang: add resolve support for inline refactorings

gopherbot pushed a commit to golang/tools that referenced this issue Feb 9, 2024
Resolve edits for inline refactorings when the client supports it.

For golang/go#64510

Change-Id: I67101ab19576054b1d03c46e3d318a4660088a63
Reviewed-on: https://go-review.googlesource.com/c/tools/+/562118
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

3 participants