gopls/internal/test/marker: change range selection to position
diff --git a/gopls/internal/test/integration/fake/editor.go b/gopls/internal/test/integration/fake/editor.go
index 3c1fa33..73474eb 100644
--- a/gopls/internal/test/integration/fake/editor.go
+++ b/gopls/internal/test/integration/fake/editor.go
@@ -10,6 +10,7 @@
"encoding/json"
"errors"
"fmt"
+ "log"
"maps"
"math/rand/v2"
"os"
@@ -1284,6 +1285,7 @@
}
completions, err := e.Server.Completion(ctx, params)
if err != nil {
+ log.Printf("params = %v", params)
return nil, err
}
return completions, nil
diff --git a/gopls/internal/test/marker/testdata/completion/address.txt b/gopls/internal/test/marker/testdata/completion/address.txt
index 676b9ad..09eb839 100644
--- a/gopls/internal/test/marker/testdata/completion/address.txt
+++ b/gopls/internal/test/marker/testdata/completion/address.txt
@@ -27,39 +27,39 @@
b int //@item(addrB, "b", "int", "var")
)
- wantsPtr() //@rank(")", addrB, addrA),snippet(")", addrB, "&b")
- wantsPtr(&b) //@snippet(")", addrB, "b")
+ wantsPtr() //@rank(re"()\\)", addrB, addrA),snippet(re"()\\)", addrB, "&b")
+ wantsPtr(&b) //@snippet(re"()\\)", addrB, "b")
- wantsVariadicPtr() //@rank(")", addrB, addrA),snippet(")", addrB, "&b")
+ wantsVariadicPtr() //@rank(re"()\\)", addrB, addrA),snippet(re"()\\)", addrB, "&b")
var s foo
s.c //@item(addrDeepC, "s.c", "int", "field")
- wantsPtr() //@snippet(")", addrDeepC, "&s.c")
- wantsPtr(s) //@snippet(")", addrDeepC, "&s.c")
- wantsPtr(&s) //@snippet(")", addrDeepC, "s.c")
+ wantsPtr() //@snippet(re"()\\)", addrDeepC, "&s.c")
+ wantsPtr(s) //@snippet(re"()\\)", addrDeepC, "&s.c")
+ wantsPtr(&s) //@snippet(re"()\\)", addrDeepC, "s.c")
// don't add "&" in item (it gets added as an additional edit)
- wantsPtr(&s.c) //@snippet(")", addrFieldC, "c")
+ wantsPtr(&s.c) //@snippet(re"()\\)", addrFieldC, "c")
// check dereferencing as well
var c *int //@item(addrCPtr, "c", "*int", "var")
- var _ int = _ //@rank("_ //", addrCPtr, addrA),snippet("_ //", addrCPtr, "*c")
+ var _ int = _ //@rank(re"= ()", addrCPtr, addrA),snippet(re"= ()", addrCPtr, "*c")
- wantsVariadic() //@rank(")", addrCPtr, addrA),snippet(")", addrCPtr, "*c")
+ wantsVariadic() //@rank(re"()\\)", addrCPtr, addrA),snippet(re"()\\)", addrCPtr, "*c")
var d **int //@item(addrDPtr, "d", "**int", "var")
- var _ int = _ //@rank("_ //", addrDPtr, addrA),snippet("_ //", addrDPtr, "**d")
+ var _ int = _ //@rank(re"= ()", addrDPtr, addrA),snippet(re"= ()", addrDPtr, "**d")
type namedPtr *int
var np namedPtr //@item(addrNamedPtr, "np", "namedPtr", "var")
- var _ int = _ //@rank("_ //", addrNamedPtr, addrA)
+ var _ int = _ //@rank(re"= ()", addrNamedPtr, addrA)
// don't get tripped up by recursive pointer type
type dontMessUp *dontMessUp //@item(dontMessUp, "dontMessUp", "*dontMessUp", "type")
- var dmu *dontMessUp //@item(addrDMU, "dmu", "*dontMessUp", "var")
+ var dmu *dontMessUp //@item(addrDMU, re"()dmu", "*dontMessUp", "var")
- var _ int = dmu //@complete(" //", addrDMU, dontMessUp)
+ var _ int = dmu //@complete(re"dmu()", addrDMU, dontMessUp)
}
func (f foo) ptr() *foo { return &f }
@@ -68,13 +68,13 @@
getFoo := func() foo { return foo{} }
// not addressable
- getFoo().c //@item(addrGetFooC, "getFoo().c", "int", "field")
+ getFoo().c //@item(addrGetFooC, re"()getFoo", "int", "field")
// addressable
- getFoo().ptr().c //@item(addrGetFooPtrC, "getFoo().ptr().c", "int", "field")
+ getFoo().ptr().c //@item(addrGetFooPtrC, re"()getFoo", "int", "field")
- wantsPtr() //@snippet(")", addrGetFooPtrC, "&getFoo().ptr().c")
- wantsPtr(&g) //@snippet(")", addrGetFooPtrC, "getFoo().ptr().c")
+ wantsPtr() //@snippet(re"()\\)", addrGetFooPtrC, "&getFoo().ptr().c")
+ wantsPtr(&g) //@snippet(re"()\\)", addrGetFooPtrC, "getFoo().ptr().c")
}
type nested struct {
@@ -84,9 +84,9 @@
func _() {
getNested := func() nested { return nested{} }
- getNested().f.c //@item(addrNestedC, "getNested().f.c", "int", "field")
- getNested().f.ptr().c //@item(addrNestedPtrC, "getNested().f.ptr().c", "int", "field")
+ getNested().f.c //@item(addrNestedC, re"getNested()", "int", "field")
+ getNested().f.ptr().c //@item(addrNestedPtrC, re"()getNested", "int", "field")
// addrNestedC is not addressable, so rank lower
- wantsPtr(getNestedfc) //@complete(")", addrNestedPtrC, addrNestedC)
+ wantsPtr(getNestedfc) //@complete(re"()\\)", addrNestedPtrC, addrNestedC)
}
diff --git a/gopls/internal/test/marker/testdata/configuration/static.txt b/gopls/internal/test/marker/testdata/configuration/static.txt
index c84b55d..1109c54 100644
--- a/gopls/internal/test/marker/testdata/configuration/static.txt
+++ b/gopls/internal/test/marker/testdata/configuration/static.txt
@@ -30,7 +30,7 @@
func _() {
_ = b.B{2}
- _ = Identi //@snippet(" //", Identity, "Identity(${1:p P})"), diag("Ident", re"(undefined|undeclared)")
+ _ = Identi //@snippet(re"ti()", Identity, "Identity(${1:p P})"), diag("Ident", re"(undefined|undeclared)")
}
-- b/b.go --
diff --git a/gopls/internal/test/marker/testdata/definition/cgo.txt b/gopls/internal/test/marker/testdata/definition/cgo.txt
index 0664a7d..aaaf1a0 100644
--- a/gopls/internal/test/marker/testdata/definition/cgo.txt
+++ b/gopls/internal/test/marker/testdata/definition/cgo.txt
@@ -35,7 +35,7 @@
}
func _() {
- Example() //@hover("ample", "Example", hoverExample), def("ample", cgoexample), complete("ample", cgoexampleItem)
+ Example() //@hover("ample", "Example", hoverExample), def("ample", cgoexample), complete(re"()ample", cgoexampleItem)
}
-- @hoverExample --
@@ -54,7 +54,7 @@
)
func _() {
- cgo.Example() //@hover("ample", "Example", hoverImportedExample), def("ample", cgoexample), complete("ample", cgoexampleItem)
+ cgo.Example() //@hover("ample", "Example", hoverImportedExample), def("ample", cgoexample), complete(re"()ample", cgoexampleItem)
}
-- @hoverImportedExample --
```go
diff --git a/gopls/internal/test/marker/testdata/fixedbugs/issue71044.txt b/gopls/internal/test/marker/testdata/fixedbugs/issue71044.txt
index 4b0f204..f114c50 100644
--- a/gopls/internal/test/marker/testdata/fixedbugs/issue71044.txt
+++ b/gopls/internal/test/marker/testdata/fixedbugs/issue71044.txt
@@ -15,4 +15,4 @@
import "unsafe"
-func (unsafe.Pointer) _() {} //@ rank("unsafe")
+func (unsafe.Pointer) _() {} //@ rank(re"()unsafe")
diff --git a/gopls/internal/test/marker/testdata/references/crosspackage.txt b/gopls/internal/test/marker/testdata/references/crosspackage.txt
index bac330b..ef186bc 100644
--- a/gopls/internal/test/marker/testdata/references/crosspackage.txt
+++ b/gopls/internal/test/marker/testdata/references/crosspackage.txt
@@ -32,6 +32,13 @@
func _() {
xes := b.GetXes()
for _, x := range xes { //@loc(defX, "x")
- _ = x.Y //@loc(useX, "x"), loc(anotherXY, "Y"), refs("Y", typeXY, anotherXY, GetXesY), refs(".", defX, useX), refs("x", defX, useX)
+ _ = x.Y //@loc(useX, "x"), loc(anotherXY, "Y"), loc(beforeX, re"()x"), loc(afterX, re"()x"), loc(beforeY, re"()Y"), loc(afterY, re"Y()")
+ //@refs(beforeY, typeXY, anotherXY, GetXesY)
+ //@refs(afterY, typeXY, anotherXY, GetXesY)
+ //@refs(anotherXY, typeXY, anotherXY, GetXesY)
+
+ //@refs(beforeX, defX, useX)
+ //@refs(afterX, defX, useX)
+ //@refs(useX, defX, useX)
}
}
diff --git a/gopls/internal/test/marker/testdata/rename/issue42301.txt b/gopls/internal/test/marker/testdata/rename/issue42301.txt
index 9f26fb9..bb07532 100644
--- a/gopls/internal/test/marker/testdata/rename/issue42301.txt
+++ b/gopls/internal/test/marker/testdata/rename/issue42301.txt
@@ -8,7 +8,7 @@
-- a/a.go --
package a
-// Foo doesn't do anything, Foo is just an empty function. //@rename("Foo", "Bar", fooToBar), renameerr("anything", "Bar", "no identifier found")
+// Foo doesn't do anything, Foo is just an empty function. //@rename(re"()Foo", "Bar", fooToBar), renameerr(re"()anything", "Bar", "no identifier found")
func Foo() {}
func _() {
@@ -27,32 +27,32 @@
-- c/c.go --
package c
-// A is an empty struct. //@rename("A", "B", aToB)
+// A is an empty struct. //@rename(re"()A", "B", aToB)
type A struct {}
-- d/d.go --
package d
-// Bar doesn't do anything, Bar is just an empty function. //@loc(Bar, re`^.*?\bBar\b.*?\b(Bar)\b.*`), rename(Bar, "Foo", barToFoo)
+// Bar doesn't do anything, Bar is just an empty function. //@rename(re", ()Bar", "Foo", barToFoo)
func Bar() {}
-- @aToB/c/c.go --
@@ -3,2 +3,2 @@
--// A is an empty struct. //@rename("A", "B", aToB)
+-// A is an empty struct. //@rename(re"()A", "B", aToB)
-type A struct {}
-+// B is an empty struct. //@rename("B", "B", aToB)
++// B is an empty struct. //@rename(re"()B", "B", aToB)
+type B struct {}
-- @barToFoo/d/d.go --
@@ -3,2 +3,2 @@
--// Bar doesn't do anything, Bar is just an empty function. //@loc(Bar, re`^.*?\bBar\b.*?\b(Bar)\b.*`), rename(Bar, "Foo", barToFoo)
+-// Bar doesn't do anything, Bar is just an empty function. //@rename(re", ()Bar", "Foo", barToFoo)
-func Bar() {}
-+// Foo doesn't do anything, Foo is just an empty function. //@loc(Foo, re`^.*?\bBar\b.*?\b(Foo)\b.*`), rename(Foo, "Foo", barToFoo)
++// Foo doesn't do anything, Foo is just an empty function. //@rename(re", ()Foo", "Foo", barToFoo)
+func Foo() {}
-- @fooToBar/a/a.go --
@@ -3,2 +3,2 @@
--// Foo doesn't do anything, Foo is just an empty function. //@rename("Foo", "Bar", fooToBar), renameerr("anything", "Bar", "no identifier found")
+-// Foo doesn't do anything, Foo is just an empty function. //@rename(re"()Foo", "Bar", fooToBar), renameerr(re"()anything", "Bar", "no identifier found")
-func Foo() {}
-+// Bar doesn't do anything, Bar is just an empty function. //@rename("Bar", "Bar", fooToBar), renameerr("anything", "Bar", "no identifier found")
++// Bar doesn't do anything, Bar is just an empty function. //@rename(re"()Bar", "Bar", fooToBar), renameerr(re"()anything", "Bar", "no identifier found")
+func Bar() {}
@@ -7 +7 @@
- Foo()
diff --git a/gopls/internal/test/marker/testdata/rename/prepare.txt b/gopls/internal/test/marker/testdata/rename/prepare.txt
index 2542648..080be77 100644
--- a/gopls/internal/test/marker/testdata/rename/prepare.txt
+++ b/gopls/internal/test/marker/testdata/rename/prepare.txt
@@ -58,7 +58,7 @@
func random2(y int) int { //@item(good_random2, "random2", "func(y int) int", "func"),item(good_y_param, "y", "int", "var")
//@complete("", good_y_param, types_import, good_random, good_random2, good_stuff)
var b types.Bob = &types.X{} //@preparerename("ypes","types", span="types")
- if _, ok := b.(*types.X); ok { //@complete("X", X_struct, Y_struct, Bob_interface, CoolAlias)
+ if _, ok := b.(*types.X); ok { //@complete(re"()X", X_struct, Y_struct, Bob_interface, CoolAlias)
_ = 0 // suppress "empty branch" diagnostic
}
diff --git a/gopls/internal/test/marker/testdata/signature/signature.txt b/gopls/internal/test/marker/testdata/signature/signature.txt
index 857fd7c..73913c3 100644
--- a/gopls/internal/test/marker/testdata/signature/signature.txt
+++ b/gopls/internal/test/marker/testdata/signature/signature.txt
@@ -56,87 +56,87 @@
func OtherAliasMap(a, b map[Alias]OtherAlias) map[Alias]OtherAlias { return nil }
func Qux() {
- Foo("foo", 123) //@signature("(", "Foo(a string, b int) (c bool)", -1)
- Foo("foo", 123) //@signature("123", "Foo(a string, b int) (c bool)", 1)
- Foo("foo", 123) //@signature(",", "Foo(a string, b int) (c bool)", 0)
- Foo("foo", 123) //@signature(" 1", "Foo(a string, b int) (c bool)", 1)
- Foo("foo", 123) //@signature(")", "Foo(a string, b int) (c bool)", 1)
- Foo("foo", 123) //@signature("o", "Foo(a string, b int) (c bool)", -1)
- _ = Foo //@signature("o", "Foo(a string, b int) (c bool)", -1)
- Foo //@signature("o", "Foo(a string, b int) (c bool)", -1)
- Foo() //@signature("(", "Foo(a string, b int) (c bool)", -1)
+ Foo("foo", 123) //@signature(re"()\\(", "Foo(a string, b int) (c bool)", -1)
+ Foo("foo", 123) //@signature(re"()123", "Foo(a string, b int) (c bool)", 1)
+ Foo("foo", 123) //@signature(re"(),", "Foo(a string, b int) (c bool)", 0)
+ Foo("foo", 123) //@signature(re"() 1", "Foo(a string, b int) (c bool)", 1)
+ Foo("foo", 123) //@signature(re"()\\)", "Foo(a string, b int) (c bool)", 1)
+ Foo("foo", 123) //@signature(re"()o", "Foo(a string, b int) (c bool)", -1)
+ _ = Foo //@signature(re"()o", "Foo(a string, b int) (c bool)", -1)
+ Foo //@signature(re"()o", "Foo(a string, b int) (c bool)", -1)
+ Foo() //@signature(re"()\\(", "Foo(a string, b int) (c bool)", -1)
- Bar(13.37, 0x13) //@signature("13.37", "Bar(float64, ...byte)", 0)
- Bar(13.37, 0x37) //@signature("0x37", "Bar(float64, ...byte)", 1)
- Bar(13.37, 1, 2, 3, 4) //@signature("4", "Bar(float64, ...byte)", 1)
+ Bar(13.37, 0x13) //@signature(re"()13.37", "Bar(float64, ...byte)", 0)
+ Bar(13.37, 0x37) //@signature(re"()0x37", "Bar(float64, ...byte)", 1)
+ Bar(13.37, 1, 2, 3, 4) //@signature(re"()4", "Bar(float64, ...byte)", 1)
- NoArgs() //@signature("(", "NoArgs()", -1)
- NoArgs //@signature("s", "NoArgs()", -1)
+ NoArgs() //@signature(re"()\\(", "NoArgs()", -1)
+ NoArgs //@signature(re"()s", "NoArgs()", -1)
fn := func(hi, there string) func(i int) rune {
return func(int) rune { return 0 }
}
- fn("hi", "there") //@signature("hi", "", 0)
- fn("hi", "there") //@signature(",", "fn(hi string, there string) func(i int) rune", 0)
- fn("hi", "there")(1) //@signature("1", "func(i int) rune", 0)
+ fn("hi", "there") //@signature(re"()hi", "", 0)
+ fn("hi", "there") //@signature(re"(),", "fn(hi string, there string) func(i int) rune", 0)
+ fn("hi", "there")(1) //@signature(re"()1", "func(i int) rune", 0)
fnPtr := &fn
- (*fnPtr)("hi", "there") //@signature(",", "func(hi string, there string) func(i int) rune", 0)
+ (*fnPtr)("hi", "there") //@signature(re"(),", "func(hi string, there string) func(i int) rune", 0)
var fnIntf any = Foo
- fnIntf.(func(string, int) bool)("hi", 123) //@signature("123", "func(string, int) bool", 1)
+ fnIntf.(func(string, int) bool)("hi", 123) //@signature(re"()123", "func(string, int) bool", 1)
- (&bytes.Buffer{}).Next(2) //@signature("2", "Next(n int) []byte", 0)
+ (&bytes.Buffer{}).Next(2) //@signature(re"()2", "Next(n int) []byte", 0)
myFunc := MyFunc(func(n int) string { return "" })
- myFunc(123) //@signature("123", "myFunc(foo int) string", 0)
+ myFunc(123) //@signature(re"()123", "myFunc(foo int) string", 0)
var ms myStruct
- ms.foo(nil) //@signature("nil", "foo(e *json.Decoder) (*big.Int, error)", 0)
+ ms.foo(nil) //@signature(re"()nil", "foo(e *json.Decoder) (*big.Int, error)", 0)
- _ = make([]int, 1, 2) //@signature("2", "make(t Type, size ...int) Type", 1)
+ _ = make([]int, 1, 2) //@signature(re"()2", "make(t Type, size ...int) Type", 1)
- Foo(myFunc(123), 456) //@signature("o(", "Foo(a string, b int) (c bool)", -1)
- Foo(myFunc(123), 456) //@signature("(m", "Foo(a string, b int) (c bool)", -1)
- Foo( myFunc(123), 456) //@signature(" m", "Foo(a string, b int) (c bool)", 0)
- Foo(myFunc(123), 456) //@signature(", ", "Foo(a string, b int) (c bool)", 0)
- Foo(myFunc(123), 456) //@signature("456", "Foo(a string, b int) (c bool)", 1)
- Foo(myFunc) //@signature(")", "Foo(a string, b int) (c bool)", 0)
- Foo(myFunc(123), 456) //@signature("(1", "myFunc(foo int) string", -1)
- Foo(myFunc(123), 456) //@signature("123", "myFunc(foo int) string", 0)
+ Foo(myFunc(123), 456) //@signature(re"()o\\(", "Foo(a string, b int) (c bool)", -1)
+ Foo(myFunc(123), 456) //@signature(re"()\\(m", "Foo(a string, b int) (c bool)", -1)
+ Foo( myFunc(123), 456) //@signature(re"() m", "Foo(a string, b int) (c bool)", 0)
+ Foo(myFunc(123), 456) //@signature(re"(), ", "Foo(a string, b int) (c bool)", 0)
+ Foo(myFunc(123), 456) //@signature(re"()456", "Foo(a string, b int) (c bool)", 1)
+ Foo(myFunc) //@signature(re"()\\)", "Foo(a string, b int) (c bool)", 0)
+ Foo(myFunc(123), 456) //@signature(re"()\\(1", "myFunc(foo int) string", -1)
+ Foo(myFunc(123), 456) //@signature(re"()123", "myFunc(foo int) string", 0)
- fmt.Println //@signature("ln", "Println(a ...any) (n int, err error)", -1)
- fmt.Println(myFunc) //@signature("ln", "Println(a ...any) (n int, err error)", -1)
- fmt.Println(myFunc) //@signature("Func", "myFunc(foo int) string", -1)
+ fmt.Println //@signature(re"()ln", "Println(a ...any) (n int, err error)", -1)
+ fmt.Println(myFunc) //@signature(re"()ln", "Println(a ...any) (n int, err error)", -1)
+ fmt.Println(myFunc) //@signature(re"()Func", "myFunc(foo int) string", -1)
var hi string = "hello"
var wl string = " world: %s"
- fmt.Println(fmt.Sprintf(wl, myFunc)) //@signature("Func", "myFunc(foo int) string", -1)
- fmt.Println(fmt.Sprintf(wl, myFunc)) //@signature("wl", "Sprintf(format string, a ...any) string", 0)
- fmt.Println(fmt.Sprintf(wl, myFunc)) //@signature(" m", "Sprintf(format string, a ...any) string", 1)
- fmt.Println(hi, fmt.Sprintf(wl, myFunc)) //@signature("Sprint", "Sprintf(format string, a ...any) string", -1)
- fmt.Println(hi, fmt.Sprintf(wl, myFunc)) //@signature(" fmt", "Println(a ...any) (n int, err error)", 0)
- fmt.Println(hi, fmt.Sprintf(wl, myFunc)) //@signature("hi", "Println(a ...any) (n int, err error)", 0)
+ fmt.Println(fmt.Sprintf(wl, myFunc)) //@signature(re"()Func", "myFunc(foo int) string", -1)
+ fmt.Println(fmt.Sprintf(wl, myFunc)) //@signature(re"()wl", "Sprintf(format string, a ...any) string", 0)
+ fmt.Println(fmt.Sprintf(wl, myFunc)) //@signature(re"() m", "Sprintf(format string, a ...any) string", 1)
+ fmt.Println(hi, fmt.Sprintf(wl, myFunc)) //@signature(re"()Sprint", "Sprintf(format string, a ...any) string", -1)
+ fmt.Println(hi, fmt.Sprintf(wl, myFunc)) //@signature(re"() fmt", "Println(a ...any) (n int, err error)", 0)
+ fmt.Println(hi, fmt.Sprintf(wl, myFunc)) //@signature(re"()hi", "Println(a ...any) (n int, err error)", 0)
- panic("oops!") //@signature(")", "panic(v any)", 0)
- println("hello", "world") //@signature(",", "println(args ...Type)", 0)
+ panic("oops!") //@signature(re"()\\)", "panic(v any)", 0)
+ println("hello", "world") //@signature(re"(),", "println(args ...Type)", 0)
Hello(func() {
- //@signature("//", "", 0)
+ //@signature(re"()\\/\\/", "", 0)
})
- AliasSlice() //@signature(")", "AliasSlice(a []*Alias) (b Alias)", 0)
- AliasMap() //@signature(")", "AliasMap(a map[*Alias]StringAlias) (b map[*Alias]StringAlias, c map[*Alias]StringAlias)", 0)
- OtherAliasMap() //@signature(")", "OtherAliasMap(a map[Alias]OtherAlias, b map[Alias]OtherAlias) map[Alias]OtherAlias", 0)
+ AliasSlice() //@signature(re"()\\)", "AliasSlice(a []*Alias) (b Alias)", 0)
+ AliasMap() //@signature(re"()\\)", "AliasMap(a map[*Alias]StringAlias) (b map[*Alias]StringAlias, c map[*Alias]StringAlias)", 0)
+ OtherAliasMap() //@signature(re"()\\)", "OtherAliasMap(a map[Alias]OtherAlias, b map[Alias]OtherAlias) map[Alias]OtherAlias", 0)
var l []Foo
- l = append(l, Foo{ //@signature(",", "append(slice []Type, elems ...Type) []Type", 0)
- A: "hello", //@signature(",", "", 0)
- B: "world", //@signature(",", "", 0)
+ l = append(l, Foo{ //@signature(re"(),", "append(slice []Type, elems ...Type) []Type", 0)
+ A: "hello", //@signature(re"(),", "", 0)
+ B: "world", //@signature(re"(),", "", 0)
})
- FooArr([]int{1, 2, 3, 4, 5}) //@signature("1", "", 0)
+ FooArr([]int{1, 2, 3, 4, 5}) //@signature(re"()1", "", 0)
}
func Hello(func()) {}
@@ -145,22 +145,22 @@
package signature
func _() {
- Foo(//@signature("//", "Foo(a string, b int) (c bool)", 0)
- Foo.//@signature("//", "Foo(a string, b int) (c bool)", 0)
- Foo.//@signature("oo", "Foo(a string, b int) (c bool)", 0)
+ Foo(//@signature(re"()\\/\\/", "Foo(a string, b int) (c bool)", 0)
+ Foo.//@signature(re"()\\/\\/", "Foo(a string, b int) (c bool)", 0)
+ Foo.//@signature(re"()oo", "Foo(a string, b int) (c bool)", 0)
}
-- signature/signature3.go --
package signature
func _() {
- Foo("hello",//@signature("//", "Foo(a string, b int) (c bool)", 1)
+ Foo("hello",//@signature(re"()\\/\\/", "Foo(a string, b int) (c bool)", 1)
}
-- signature/nonsignature.go --
package signature
-var x = (1) //@signature("1)", "", 0)
+var x = (1) //@signature(re"()1\\)", "", 0)
-- signature/signature_test.go --
package signature_test
@@ -172,9 +172,9 @@
)
func TestSignature(t *testing.T) {
- sig.AliasSlice() //@signature(")", "AliasSlice(a []*sig.Alias) (b sig.Alias)", 0)
- sig.AliasMap() //@signature(")", "AliasMap(a map[*sig.Alias]sig.StringAlias) (b map[*sig.Alias]sig.StringAlias, c map[*sig.Alias]sig.StringAlias)", 0)
- sig.OtherAliasMap() //@signature(")", "OtherAliasMap(a map[sig.Alias]sig.OtherAlias, b map[sig.Alias]sig.OtherAlias) map[sig.Alias]sig.OtherAlias", 0)
+ sig.AliasSlice() //@signature(re"()\\)", "AliasSlice(a []*sig.Alias) (b sig.Alias)", 0)
+ sig.AliasMap() //@signature(re"()\\)", "AliasMap(a map[*sig.Alias]sig.StringAlias) (b map[*sig.Alias]sig.StringAlias, c map[*sig.Alias]sig.StringAlias)", 0)
+ sig.OtherAliasMap() //@signature(re"()\\)", "OtherAliasMap(a map[sig.Alias]sig.OtherAlias, b map[sig.Alias]sig.OtherAlias) map[sig.Alias]sig.OtherAlias", 0)
}
-- snippets/snippets.go --
@@ -195,10 +195,10 @@
}
func _() {
- X() //@signature(")", "X(_ map[signature.Alias]CoolAlias) map[signature.Alias]CoolAlias", 0)
+ X() //@signature(re"()\\)", "X(_ map[signature.Alias]CoolAlias) map[signature.Alias]CoolAlias", 0)
_ = signature.MyType{} //@item(literalMyType, "signature.MyType{}", "", "var")
s := structy{
- x: //@snippet(" //", literalMyType, "signature.MyType{\\}")
+ x: //@snippet(re"() \\/\\/", literalMyType, "signature.MyType{\\}")
}
}
@@ -210,21 +210,21 @@
// "golang.org/lsptests/foo"
// import completions (separate blocks to avoid comment alignment)
- "crypto/elli" //@complete("\" //", cryptoImport)
+ "crypto/elli" //@complete(re"i()\"", cryptoImport)
- "fm" //@complete("\" //", fmtImport)
+ "fm" //@complete(re"m()\"", fmtImport)
- "go/pars" //@complete("\" //", parserImport)
+ "go/pars" //@complete(re"s()\"", parserImport)
- namedParser "go/pars" //@complete("\" //", parserImport)
+ namedParser "go/pars" //@complete(re"s()\"", parserImport)
- "golang.org/lspte" //@complete("\" //", lsptestsImport)
+ "golang.org/lspte" //@complete(re"e()\"", lsptestsImport)
- "golang.org/lsptests/sign" //@complete("\" //", signatureImport)
+ "golang.org/lsptests/sign" //@complete(re"n()\"", signatureImport)
- "golang.org/lsptests/sign" //@complete("ests", lsptestsImport)
+ "golang.org/lsptests/sign" //@complete(re"()ests", lsptestsImport)
- "golang.org/lsptests/signa" //@complete("na\" //", signatureImport)
+ "golang.org/lsptests/signa" //@complete(re"()na", signatureImport)
)
func _() {
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
This change updates these tests to use explicit point selectionsThanks, I agree that this CL preserves the behavior of the test suite before the recent change to the range semantics. I wonder: is it necessary? I would expect that in most cases the results for the range "foo" and for the position "()foo" should be identical. Can we characterize when and why they differ? Are those differences bugs, or at least problems that need further thinking? Do we need more tests to cover those differences?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
This change updates these tests to use explicit point selectionsThanks, I agree that this CL preserves the behavior of the test suite before the recent change to the range semantics. I wonder: is it necessary? I would expect that in most cases the results for the range "foo" and for the position "()foo" should be identical. Can we characterize when and why they differ? Are those differences bugs, or at least problems that need further thinking? Do we need more tests to cover those differences?
I think the case I raised is pretty straightforward `re"()foo"` and `"foo"`. I agree it make sense to keep it there as "range" and "pos" should yield the same results.
But a lot of test cases in marker uses
```
func _ () {
foo() //@loc(f, " //")
}
```
The test want to get position of `foo()|`, maybe the test is testing against what completion item is available at this position, but the range does not make any sense ` //`.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
This change updates these tests to use explicit point selectionsHongxiang JiangThanks, I agree that this CL preserves the behavior of the test suite before the recent change to the range semantics. I wonder: is it necessary? I would expect that in most cases the results for the range "foo" and for the position "()foo" should be identical. Can we characterize when and why they differ? Are those differences bugs, or at least problems that need further thinking? Do we need more tests to cover those differences?
I think the case I raised is pretty straightforward `re"()foo"` and `"foo"`. I agree it make sense to keep it there as "range" and "pos" should yield the same results.
But a lot of test cases in marker uses
```
func _ () {
foo() //@loc(f, " //")
}
```The test want to get position of `foo()|`, maybe the test is testing against what completion item is available at this position, but the range does not make any sense ` //`.
I did not mean to say straightforward. I mean `re"()foo"` and `"foo"` is a happy case that the test author want to move the cursor to the start of the "foo", and the range being selected make sense.
This change updates these tests to use explicit point selectionsHongxiang JiangThanks, I agree that this CL preserves the behavior of the test suite before the recent change to the range semantics. I wonder: is it necessary? I would expect that in most cases the results for the range "foo" and for the position "()foo" should be identical. Can we characterize when and why they differ? Are those differences bugs, or at least problems that need further thinking? Do we need more tests to cover those differences?
Hongxiang JiangI think the case I raised is pretty straightforward `re"()foo"` and `"foo"`. I agree it make sense to keep it there as "range" and "pos" should yield the same results.
But a lot of test cases in marker uses
```
func _ () {
foo() //@loc(f, " //")
}
```The test want to get position of `foo()|`, maybe the test is testing against what completion item is available at this position, but the range does not make any sense ` //`.
I did not mean to say straightforward. I mean `re"()foo"` and `"foo"` is a happy case that the test author want to move the cursor to the start of the "foo", and the range being selected make sense.
Also, while I'm working on the last CL 728881, I think "range" does not make sense for Completion items because the completion is based on the cursor not the selection.
The gopls implementation can use range internally but the test should try to mimic what a real language client will do: "send only a position". That is also why almost all "Completion" marker have been migrated from a string matcher "foo" to regex matcher re"()foo".
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |