internal/regtest: fix regtests for the dev.typeparams Go branch
TestFillStruct had an unnecessary dependency on the go/types.Info API.
Break the dependency.
Change-Id: I7cacd045487e3a7d2ba92a6f76f6b37e0ea33bfb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/293929
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
(cherry picked from commit 1f00549ac7cab538a8c3f56ed8b1666243f810a2)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/294912
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/gopls/internal/regtest/misc/fix_test.go b/gopls/internal/regtest/misc/fix_test.go
index a256609..4f97c01 100644
--- a/gopls/internal/regtest/misc/fix_test.go
+++ b/gopls/internal/regtest/misc/fix_test.go
@@ -23,39 +23,35 @@
-- main.go --
package main
-import "go/types"
+type Info struct {
+ WordCounts map[string]int
+ Words []string
+}
func Foo() {
- _ = types.Info{}
+ _ = Info{}
}
`
Run(t, basic, func(t *testing.T, env *Env) {
env.OpenFile("main.go")
+ pos := env.RegexpSearch("main.go", "Info{}").ToProtocolPosition()
if err := env.Editor.RefactorRewrite(env.Ctx, "main.go", &protocol.Range{
- Start: protocol.Position{
- Line: 5,
- Character: 16,
- },
- End: protocol.Position{
- Line: 5,
- Character: 16,
- },
+ Start: pos,
+ End: pos,
}); err != nil {
t.Fatal(err)
}
want := `package main
-import "go/types"
+type Info struct {
+ WordCounts map[string]int
+ Words []string
+}
func Foo() {
- _ = types.Info{
- Types: map[ast.Expr]types.TypeAndValue{},
- Defs: map[*ast.Ident]types.Object{},
- Uses: map[*ast.Ident]types.Object{},
- Implicits: map[ast.Node]types.Object{},
- Selections: map[*ast.SelectorExpr]*types.Selection{},
- Scopes: map[ast.Node]*types.Scope{},
- InitOrder: []*types.Initializer{},
+ _ = Info{
+ WordCounts: map[string]int{},
+ Words: []string{},
}
}
`