[tools] gopls/internal/golang: sync protocol changes from CL 765240

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Jun 5, 2026, 6:49:15 PM (2 days ago) Jun 5
to Hongxiang Jiang, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, golang...@luci-project-accounts.iam.gserviceaccount.com, Alan Donovan, Madeline Kalil, Alex Putman, golang-co...@googlegroups.com

Gopher Robot submitted the change with unreviewed changes

Unreviewed changes

8 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: gopls/doc/design/integrating-interactive-refactoring.md
Insertions: 1, Deletions: 1.

@@ -124,7 +124,7 @@
// Type specifies the data type and validation constraints for the answer.
type: FormFieldType;

- // Required specifies whether an answer is absolutely required for this field.
+ // Required specifies whether an answer is required for this field.
required: boolean;

// Default specifies an optional initial value for the answer.
```
```
The name of the file: gopls/internal/protocol/form.go
Insertions: 1, Deletions: 1.

@@ -188,7 +188,7 @@
// fall back to a string input.
Type any `json:"type"`

- // Required specifies whether an answer is absolutely required for this field.
+ // Required specifies whether an answer is required for this field.
Required bool `json:"required"`

// Default specifies an optional initial value for the answer.
```
```
The name of the file: gopls/internal/golang/resolve.go
Insertions: 7, Deletions: 8.

@@ -289,22 +289,21 @@
//
// It uses a linear scan since the number of answers is small (usually < 5).
func FormAnswer[T any](params *protocol.InteractiveParams, id string) (v T, err error) {
- var found bool
+ matches := 0
for _, ans := range params.FormAnswers {
if ans.ID == id {
- if found {
- return v, fmt.Errorf("duplicate answer for id %q", id)
- }
+ matches++
val, ok := ans.Value.(T)
if !ok {
- return v, fmt.Errorf("invalid type for id %q, want %T: got %T", id, *new(T), ans.Value)
+ return v, fmt.Errorf("form answer %q has unexpected type %T, want %T", id, ans.Value, v)
}
v = val
- found = true
}
}
- if !found {
- return v, fmt.Errorf("answer for %q missing from client", id)
+ if matches == 0 {
+ return v, fmt.Errorf("form lacks answer %q", id)
+ } else if matches > 1 {
+ return v, fmt.Errorf("form contains duplicate answer %q", id)
}
return v, nil
}
```

Change information

Commit message:
gopls/internal/protocol: ID-based answer/question in interactive form

Transition form fields and answers in the interactive refactoring
protocol from positional (index-based) arrays to explicit, ID-based
key-value mappings.

The protocol changes:
- Adds a 'required' field and a unique 'id' field to FormField. The
server should not return duplicate 'id' values for a given form.
- Replaces the raw `[]any` FormAnswers array with a list of `FormAnswer`
structs, each containing 'id' and 'value'. The client must provide
exactly one answer per required 'id', with no duplicate IDs, and must
not supply answers for non-existent field IDs.
- Adds client and server capability structs. The client should specify
supported input types through 'InteractiveResolveClientCapabilities'
under experimental. The server should specify the supported kinds of
interactive resolution through 'InteractiveResolveOptions' under
experimental.
- Adds a 'filters' field to FormFieldTypeFile to support file
extension filtering.

Update the documentation for language client to integrate interactive
refactoring, and update the marker test framework to support testing
the new ID-based answers.

proposal CL 765240

vscode-go CL 784640

For golang/go#76331
Change-Id: I4b51931c85825024a5c7e86dc374c66d2fc53a2c
Reviewed-by: Madeline Kalil <mka...@google.com>
Auto-Submit: Hongxiang Jiang <hxj...@golang.org>
Reviewed-by: Alan Donovan <adon...@google.com>
Files:
  • M gopls/doc/design/integrating-interactive-refactoring.md
  • M gopls/internal/golang/resolve.go
  • M gopls/internal/protocol/form.go
  • M gopls/internal/server/command.go
  • M gopls/internal/server/general.go
  • M gopls/internal/settings/settings.go
  • M gopls/internal/test/marker/codeaction_test.go
  • M gopls/internal/test/marker/doc.go
  • M gopls/internal/test/marker/marker_test.go
  • M gopls/internal/test/marker/testdata/codeaction/dialog_add_tags.txt
  • M gopls/internal/test/marker/testdata/codeaction/dialog_implement_interface.txt
  • M gopls/internal/test/marker/testdata/codeaction/dialog_remove_tags.txt
Change size: L
Delta: 12 files changed, 265 insertions(+), 141 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I4b51931c85825024a5c7e86dc374c66d2fc53a2c
Gerrit-Change-Number: 784882
Gerrit-PatchSet: 11
Gerrit-Owner: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alex Putman <apu...@golang.org>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages