Skip to content

Commit 4c22c6e

Browse files
h9jianggopherbot
authored andcommitted
gopls/internal/test/integration: add codeAction/resolve in fake editor
For golang/go#76331 Change-Id: I791caefcaadbee043917196e7e761d8c7c51409f Reviewed-on: https://go-review.googlesource.com/c/tools/+/722245 Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Hongxiang Jiang <hxjiang@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent a6e94eb commit 4c22c6e

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

gopls/internal/test/integration/fake/editor.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,14 @@ func (e *Editor) ChangeWorkspaceFolders(ctx context.Context, folders []string) e
16851685
return e.Server.DidChangeWorkspaceFolders(ctx, &params)
16861686
}
16871687

1688+
// ResolveCodeAction executes a codeAction/resolve request on the server.
1689+
func (e *Editor) ResolveCodeAction(ctx context.Context, action *protocol.CodeAction) (*protocol.CodeAction, error) {
1690+
if e.Server == nil {
1691+
return nil, nil
1692+
}
1693+
return e.Server.ResolveCodeAction(ctx, action)
1694+
}
1695+
16881696
// CodeAction executes a codeAction request on the server.
16891697
// If loc.Range is zero, the whole file is implied.
16901698
// To reduce distraction, the trigger action (unknown, automatic, invoked)

gopls/internal/test/integration/misc/addtest_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ func TestFoo(t *testing.T) {
8080
if err != nil {
8181
t.Fatal(err)
8282
}
83+
action, err = env.Editor.ResolveCodeAction(env.Ctx, action)
84+
if err != nil {
85+
t.Fatal(err)
86+
}
8387

8488
// Execute the command.
8589
// Its side effect should be a single showDocument request.

gopls/internal/test/integration/web/util_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ func codeActionWebPage(t *testing.T, env *integration.Env, kind protocol.CodeAct
8080
if err != nil {
8181
t.Fatal(err)
8282
}
83+
action, err = env.Editor.ResolveCodeAction(env.Ctx, action)
84+
if err != nil {
85+
t.Fatal(err)
86+
}
8387

8488
// Execute the command.
8589
// Its side effect should be a single showDocument request.

0 commit comments

Comments
 (0)