internal/lsp: include padding in inlay hint marker tests

The marker tests are updated to include padding values
when mapping inlay hints to text edits.

Change-Id: Ieb421088238c65b07abdad12763816d3d1e757c8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/411654
Run-TryBot: Jamal Carvalho <jamal@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
This commit is contained in:
Jamal Carvalho 2022-06-10 13:48:16 +00:00
parent 5e48d261e2
commit c41ddceaa4
5 changed files with 38 additions and 31 deletions

View File

@ -949,9 +949,16 @@ func (r *runner) InlayHints(t *testing.T, spn span.Span) {
// Map inlay hints to text edits.
edits := make([]protocol.TextEdit, len(hints))
for i, hint := range hints {
var paddingLeft, paddingRight string
if hint.PaddingLeft {
paddingLeft = " "
}
if hint.PaddingRight {
paddingRight = " "
}
edits[i] = protocol.TextEdit{
Range: protocol.Range{Start: *hint.Position, End: *hint.Position},
NewText: fmt.Sprintf("<%s>", hint.Label[0].Value),
NewText: fmt.Sprintf("<%s%s%s>", paddingLeft, hint.Label[0].Value, paddingRight),
}
}

View File

@ -4,14 +4,14 @@ package inlayHint //@inlayHint("package")
import "fmt"
func fieldNames() {
for _<int>, c<struct{in string; want strin...> := range []struct {
for _< int>, c< struct{in string; want strin...> := range []struct {
in, want string
}{
{<in:>"Hello, world", <want:>"dlrow ,olleH"},
{<in:>"Hello, 世界", <want:>"界世 ,olleH"},
{<in:>"", <want:>""},
{<in: >"Hello, world", <want: >"dlrow ,olleH"},
{<in: >"Hello, 世界", <want: >"界世 ,olleH"},
{<in: >"", <want: >""},
} {
fmt.Println(<a...:>c.in == c.want)
fmt.Println(<a...: >c.in == c.want)
}
}

View File

@ -6,24 +6,24 @@ const True = true
type Kind int
const (
KindNone Kind = iota<= 0>
KindPrint<= 1>
KindPrintf<= 2>
KindErrorf<= 3>
KindNone Kind = iota< = 0>
KindPrint< = 1>
KindPrintf< = 2>
KindErrorf< = 3>
)
const (
u = iota * 4<= 0>
v float64 = iota * 42<= 42>
w = iota * 42<= 84>
u = iota * 4< = 0>
v float64 = iota * 42< = 42>
w = iota * 42< = 84>
)
const (
a, b = 1, 2
c, d<= 1, 2>
e, f = 5 * 5, "hello" + "world"<= 25, "helloworld">
g, h<= 25, "helloworld">
i, j = true, f<= true, "helloworld">
c, d< = 1, 2>
e, f = 5 * 5, "hello" + "world"< = 25, "helloworld">
g, h< = 25, "helloworld">
i, j = true, f< = true, "helloworld">
)
// No hint

View File

@ -8,7 +8,7 @@ func hello(name string) string {
}
func helloWorld() string {
return hello(<name:>"World")
return hello(<name: >"World")
}
type foo struct{}
@ -21,27 +21,27 @@ func (*foo) bar(baz string, qux int) int {
}
func kase(foo int, bar bool, baz ...string) {
fmt.Println(<a...:>foo, bar, baz)
fmt.Println(<a...: >foo, bar, baz)
}
func kipp(foo string, bar, baz string) {
fmt.Println(<a...:>foo, bar, baz)
fmt.Println(<a...: >foo, bar, baz)
}
func plex(foo, bar string, baz string) {
fmt.Println(<a...:>foo, bar, baz)
fmt.Println(<a...: >foo, bar, baz)
}
func tars(foo string, bar, baz string) {
fmt.Println(<a...:>foo, bar, baz)
fmt.Println(<a...: >foo, bar, baz)
}
func foobar() {
var x foo
x.bar(<baz:>"", <qux:>1)
kase(<foo:>0, <bar:>true, <baz...:>"c", "d", "e")
kipp(<foo:>"a", <bar:>"b", <baz:>"c")
plex(<foo:>"a", <bar:>"b", <baz:>"c")
tars(<foo:>"a", <bar:>"b", <baz:>"c")
x.bar(<baz: >"", <qux: >1)
kase(<foo: >0, <bar: >true, <baz...: >"c", "d", "e")
kipp(<foo: >"a", <bar: >"b", <baz: >"c")
plex(<foo: >"a", <bar: >"b", <baz: >"c")
tars(<foo: >"a", <bar: >"b", <baz: >"c")
}

View File

@ -2,21 +2,21 @@
package inlayHint //@inlayHint("package")
func assignTypes() {
i<int>, j<int> := 0, len([]string{})-1
i< int>, j< int> := 0, len([]string{})-1
println(i, j)
}
func rangeTypes() {
for k<int>, v<string> := range []string{} {
for k< int>, v< string> := range []string{} {
println(k, v)
}
}
func funcLitType() {
myFunc<func(a string) string> := func(a string) string { return "" }
myFunc< func(a string) string> := func(a string) string { return "" }
}
func compositeLitType() {
foo<map[string]interface{}> := map[string]interface{}{"": ""}
foo< map[string]interface{}> := map[string]interface{}{"": ""}
}