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/internal/lsp/protocol: CodeAction.Edit is always serialized #58687

Closed
briandealwis opened this issue Feb 24, 2023 · 3 comments
Closed
Assignees
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

@briandealwis
Copy link

protocol.CodeAction can't be used to lazily compute workspace edits with codeAction/resolve as protocol.CodeAction.Edit is a struct value, and not a pointer to a struct, and is thus always serialized even when a zero value:

// The workspace edit this code action performs.
Edit WorkspaceEdit `json:"edit,omitempty"`

I see in serialized output:

I0224 09:15:34.328959      63 conn_opt.go:96] jsonrpc2: <-- result #3: textDocument/codeAction: [{"title":"...","kind":"quickfix","diagnostics":[...],"edit":{},"data":{...}},...]

omitempty is not applied by json.Marshal for zero-value structs (see #11939):

The "omitempty" option specifies that the field should be omitted from the encoding if the field has an empty value, defined as false, 0, a nil pointer, a nil interface value, and any empty array, slice, map, or string.

I think the solution is for {"CodeAction", "edit"} to be marked as wantOptStar:

	{"CodeAction", "edit"}:                                       wantOpt,

cc: @hyangah

@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 24, 2023
@gopherbot gopherbot added this to the Unreleased milestone Feb 24, 2023
@hyangah
Copy link
Contributor

hyangah commented Feb 24, 2023

cc @pjweinb

@pjweinb
Copy link

pjweinb commented Feb 24, 2023 via email

@pjweinb
Copy link

pjweinb commented Mar 4, 2023

This was fixed by https://go-review.git.corp.google.com/c/tools/+/472656 .

@pjweinb pjweinb closed this as completed Mar 4, 2023
@golang golang locked and limited conversation to collaborators Mar 3, 2024
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
None yet
Development

No branches or pull requests

5 participants