diff options
Diffstat (limited to 'gopls/internal/lsp/testdata/godef')
-rw-r--r-- | gopls/internal/lsp/testdata/godef/a/a_x_test.go | 9 | ||||
-rw-r--r-- | gopls/internal/lsp/testdata/godef/a/a_x_test.go.golden | 26 | ||||
-rw-r--r-- | gopls/internal/lsp/testdata/godef/a/d.go | 69 | ||||
-rw-r--r-- | gopls/internal/lsp/testdata/godef/a/d.go.golden | 191 | ||||
-rw-r--r-- | gopls/internal/lsp/testdata/godef/a/f.go | 16 | ||||
-rw-r--r-- | gopls/internal/lsp/testdata/godef/a/f.go.golden | 34 | ||||
-rw-r--r-- | gopls/internal/lsp/testdata/godef/a/g.go | 6 | ||||
-rw-r--r-- | gopls/internal/lsp/testdata/godef/a/g.go.golden | 7 | ||||
-rw-r--r-- | gopls/internal/lsp/testdata/godef/a/h.go | 147 | ||||
-rw-r--r-- | gopls/internal/lsp/testdata/godef/a/h.go.golden | 161 | ||||
-rw-r--r-- | gopls/internal/lsp/testdata/godef/b/e.go | 31 | ||||
-rw-r--r-- | gopls/internal/lsp/testdata/godef/b/e.go.golden | 156 | ||||
-rw-r--r-- | gopls/internal/lsp/testdata/godef/broken/unclosedIf.go.golden | 31 | ||||
-rw-r--r-- | gopls/internal/lsp/testdata/godef/broken/unclosedIf.go.in | 9 |
14 files changed, 893 insertions, 0 deletions
diff --git a/gopls/internal/lsp/testdata/godef/a/a_x_test.go b/gopls/internal/lsp/testdata/godef/a/a_x_test.go new file mode 100644 index 000000000..f166f0550 --- /dev/null +++ b/gopls/internal/lsp/testdata/godef/a/a_x_test.go @@ -0,0 +1,9 @@ +package a_test + +import ( + "testing" +) + +func TestA2(t *testing.T) { //@TestA2,godef(TestA2, TestA2) + Nonexistant() //@diag("Nonexistant", "compiler", "(undeclared name|undefined): Nonexistant", "error") +} diff --git a/gopls/internal/lsp/testdata/godef/a/a_x_test.go.golden b/gopls/internal/lsp/testdata/godef/a/a_x_test.go.golden new file mode 100644 index 000000000..2e3064794 --- /dev/null +++ b/gopls/internal/lsp/testdata/godef/a/a_x_test.go.golden @@ -0,0 +1,26 @@ +-- TestA2-definition -- +godef/a/a_x_test.go:7:6-12: defined here as ```go +func TestA2(t *testing.T) +``` +-- TestA2-definition-json -- +{ + "span": { + "uri": "file://godef/a/a_x_test.go", + "start": { + "line": 7, + "column": 6, + "offset": 44 + }, + "end": { + "line": 7, + "column": 12, + "offset": 50 + } + }, + "description": "```go\nfunc TestA2(t *testing.T)\n```" +} + +-- TestA2-hoverdef -- +```go +func TestA2(t *testing.T) +``` diff --git a/gopls/internal/lsp/testdata/godef/a/d.go b/gopls/internal/lsp/testdata/godef/a/d.go new file mode 100644 index 000000000..a1d17ad0d --- /dev/null +++ b/gopls/internal/lsp/testdata/godef/a/d.go @@ -0,0 +1,69 @@ +package a //@mark(a, "a "),hoverdef("a ", a) + +import "fmt" + +type Thing struct { //@Thing + Member string //@Member +} + +var Other Thing //@Other + +func Things(val []string) []Thing { //@Things + return nil +} + +func (t Thing) Method(i int) string { //@Method + return t.Member +} + +func (t Thing) Method3() { +} + +func (t *Thing) Method2(i int, j int) (error, string) { + return nil, t.Member +} + +func (t *Thing) private() { +} + +func useThings() { + t := Thing{ //@mark(aStructType, "ing") + Member: "string", //@mark(fMember, "ember") + } + fmt.Print(t.Member) //@mark(aMember, "ember") + fmt.Print(Other) //@mark(aVar, "ther") + Things() //@mark(aFunc, "ings") + t.Method() //@mark(aMethod, "eth") +} + +type NextThing struct { //@NextThing + Thing + Value int +} + +func (n NextThing) another() string { + return n.Member +} + +// Shadows Thing.Method3 +func (n *NextThing) Method3() int { + return n.Value +} + +var nextThing NextThing //@hoverdef("NextThing", NextThing) + +/*@ +godef(aStructType, Thing) +godef(aMember, Member) +godef(aVar, Other) +godef(aFunc, Things) +godef(aMethod, Method) +godef(fMember, Member) +godef(Member, Member) + +//param +//package name +//const +//anon field + +*/ diff --git a/gopls/internal/lsp/testdata/godef/a/d.go.golden b/gopls/internal/lsp/testdata/godef/a/d.go.golden new file mode 100644 index 000000000..ee687750c --- /dev/null +++ b/gopls/internal/lsp/testdata/godef/a/d.go.golden @@ -0,0 +1,191 @@ +-- Member-definition -- +godef/a/d.go:6:2-8: defined here as ```go +field Member string +``` + +@Member + + +[`(a.Thing).Member` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing.Member) +-- Member-definition-json -- +{ + "span": { + "uri": "file://godef/a/d.go", + "start": { + "line": 6, + "column": 2, + "offset": 90 + }, + "end": { + "line": 6, + "column": 8, + "offset": 96 + } + }, + "description": "```go\nfield Member string\n```\n\n@Member\n\n\n[`(a.Thing).Member` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing.Member)" +} + +-- Member-hoverdef -- +```go +field Member string +``` + +@Member + + +[`(a.Thing).Member` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing.Member) +-- Method-definition -- +godef/a/d.go:15:16-22: defined here as ```go +func (Thing).Method(i int) string +``` + +[`(a.Thing).Method` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing.Method) +-- Method-definition-json -- +{ + "span": { + "uri": "file://godef/a/d.go", + "start": { + "line": 15, + "column": 16, + "offset": 219 + }, + "end": { + "line": 15, + "column": 22, + "offset": 225 + } + }, + "description": "```go\nfunc (Thing).Method(i int) string\n```\n\n[`(a.Thing).Method` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing.Method)" +} + +-- Method-hoverdef -- +```go +func (Thing).Method(i int) string +``` + +[`(a.Thing).Method` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing.Method) +-- NextThing-hoverdef -- +```go +type NextThing struct { + Thing + Value int +} + +func (*NextThing).Method3() int +func (NextThing).another() string +``` + +[`a.NextThing` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#NextThing) +-- Other-definition -- +godef/a/d.go:9:5-10: defined here as ```go +var Other Thing +``` + +@Other + + +[`a.Other` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Other) +-- Other-definition-json -- +{ + "span": { + "uri": "file://godef/a/d.go", + "start": { + "line": 9, + "column": 5, + "offset": 121 + }, + "end": { + "line": 9, + "column": 10, + "offset": 126 + } + }, + "description": "```go\nvar Other Thing\n```\n\n@Other\n\n\n[`a.Other` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Other)" +} + +-- Other-hoverdef -- +```go +var Other Thing +``` + +@Other + + +[`a.Other` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Other) +-- Thing-definition -- +godef/a/d.go:5:6-11: defined here as ```go +type Thing struct { + Member string //@Member +} + +func (Thing).Method(i int) string +func (*Thing).Method2(i int, j int) (error, string) +func (Thing).Method3() +func (*Thing).private() +``` + +[`a.Thing` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing) +-- Thing-definition-json -- +{ + "span": { + "uri": "file://godef/a/d.go", + "start": { + "line": 5, + "column": 6, + "offset": 65 + }, + "end": { + "line": 5, + "column": 11, + "offset": 70 + } + }, + "description": "```go\ntype Thing struct {\n\tMember string //@Member\n}\n\nfunc (Thing).Method(i int) string\nfunc (*Thing).Method2(i int, j int) (error, string)\nfunc (Thing).Method3()\nfunc (*Thing).private()\n```\n\n[`a.Thing` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing)" +} + +-- Thing-hoverdef -- +```go +type Thing struct { + Member string //@Member +} + +func (Thing).Method(i int) string +func (*Thing).Method2(i int, j int) (error, string) +func (Thing).Method3() +func (*Thing).private() +``` + +[`a.Thing` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing) +-- Things-definition -- +godef/a/d.go:11:6-12: defined here as ```go +func Things(val []string) []Thing +``` + +[`a.Things` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Things) +-- Things-definition-json -- +{ + "span": { + "uri": "file://godef/a/d.go", + "start": { + "line": 11, + "column": 6, + "offset": 148 + }, + "end": { + "line": 11, + "column": 12, + "offset": 154 + } + }, + "description": "```go\nfunc Things(val []string) []Thing\n```\n\n[`a.Things` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Things)" +} + +-- Things-hoverdef -- +```go +func Things(val []string) []Thing +``` + +[`a.Things` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Things) +-- a-hoverdef -- +Package a is a package for testing go to definition. + diff --git a/gopls/internal/lsp/testdata/godef/a/f.go b/gopls/internal/lsp/testdata/godef/a/f.go new file mode 100644 index 000000000..10f88262a --- /dev/null +++ b/gopls/internal/lsp/testdata/godef/a/f.go @@ -0,0 +1,16 @@ +// Package a is a package for testing go to definition. +package a + +import "fmt" + +func TypeStuff() { //@Stuff + var x string + + switch y := interface{}(x).(type) { //@mark(switchY, "y"),godef("y", switchY) + case int: //@mark(intY, "int") + fmt.Printf("%v", y) //@hoverdef("y", intY) + case string: //@mark(stringY, "string") + fmt.Printf("%v", y) //@hoverdef("y", stringY) + } + +} diff --git a/gopls/internal/lsp/testdata/godef/a/f.go.golden b/gopls/internal/lsp/testdata/godef/a/f.go.golden new file mode 100644 index 000000000..a084356c0 --- /dev/null +++ b/gopls/internal/lsp/testdata/godef/a/f.go.golden @@ -0,0 +1,34 @@ +-- intY-hoverdef -- +```go +var y int +``` +-- stringY-hoverdef -- +```go +var y string +``` +-- switchY-definition -- +godef/a/f.go:8:9-10: defined here as ```go +var y interface{} +``` +-- switchY-definition-json -- +{ + "span": { + "uri": "file://godef/a/f.go", + "start": { + "line": 8, + "column": 9, + "offset": 76 + }, + "end": { + "line": 8, + "column": 10, + "offset": 77 + } + }, + "description": "```go\nvar y interface{}\n```" +} + +-- switchY-hoverdef -- +```go +var y interface{} +``` diff --git a/gopls/internal/lsp/testdata/godef/a/g.go b/gopls/internal/lsp/testdata/godef/a/g.go new file mode 100644 index 000000000..dfef2fb80 --- /dev/null +++ b/gopls/internal/lsp/testdata/godef/a/g.go @@ -0,0 +1,6 @@ +package a + +import "time" + +// dur is a constant of type time.Duration. +const dur = 15*time.Minute + 10*time.Second + 350*time.Millisecond //@dur,hoverdef("dur", dur) diff --git a/gopls/internal/lsp/testdata/godef/a/g.go.golden b/gopls/internal/lsp/testdata/godef/a/g.go.golden new file mode 100644 index 000000000..f7a2e1b07 --- /dev/null +++ b/gopls/internal/lsp/testdata/godef/a/g.go.golden @@ -0,0 +1,7 @@ +-- dur-hoverdef -- +```go +const dur time.Duration = 910350000000 // 15m10.35s +``` + +dur is a constant of type time.Duration. + diff --git a/gopls/internal/lsp/testdata/godef/a/h.go b/gopls/internal/lsp/testdata/godef/a/h.go new file mode 100644 index 000000000..5a5dcc678 --- /dev/null +++ b/gopls/internal/lsp/testdata/godef/a/h.go @@ -0,0 +1,147 @@ +package a + +func _() { + type s struct { + nested struct { + // nested number + number int64 //@mark(nestedNumber, "number") + } + nested2 []struct { + // nested string + str string //@mark(nestedString, "str") + } + x struct { + x struct { + x struct { + x struct { + x struct { + // nested map + m map[string]float64 //@mark(nestedMap, "m") + } + } + } + } + } + } + + var t s + _ = t.nested.number //@hoverdef("number", nestedNumber) + _ = t.nested2[0].str //@hoverdef("str", nestedString) + _ = t.x.x.x.x.x.m //@hoverdef("m", nestedMap) +} + +func _() { + var s struct { + // a field + a int //@mark(structA, "a") + // b nested struct + b struct { //@mark(structB, "b") + // c field of nested struct + c int //@mark(structC, "c") + } + } + _ = s.a //@hoverdef("a", structA) + _ = s.b //@hoverdef("b", structB) + _ = s.b.c //@hoverdef("c", structC) + + var arr []struct { + // d field + d int //@mark(arrD, "d") + // e nested struct + e struct { //@mark(arrE, "e") + // f field of nested struct + f int //@mark(arrF, "f") + } + } + _ = arr[0].d //@hoverdef("d", arrD) + _ = arr[0].e //@hoverdef("e", arrE) + _ = arr[0].e.f //@hoverdef("f", arrF) + + var complex []struct { + c <-chan map[string][]struct { + // h field + h int //@mark(complexH, "h") + // i nested struct + i struct { //@mark(complexI, "i") + // j field of nested struct + j int //@mark(complexJ, "j") + } + } + } + _ = (<-complex[0].c)["0"][0].h //@hoverdef("h", complexH) + _ = (<-complex[0].c)["0"][0].i //@hoverdef("i", complexI) + _ = (<-complex[0].c)["0"][0].i.j //@hoverdef("j", complexJ) + + var mapWithStructKey map[struct { + // X key field + x []string //@mark(mapStructKeyX, "x") + }]int + for k := range mapWithStructKey { + _ = k.x //@hoverdef("x", mapStructKeyX) + } + + var mapWithStructKeyAndValue map[struct { + // Y key field + y string //@mark(mapStructKeyY, "y") + }]struct { + // X value field + x string //@mark(mapStructValueX, "x") + } + for k, v := range mapWithStructKeyAndValue { + // TODO: we don't show docs for y field because both map key and value + // are structs. And in this case, we parse only map value + _ = k.y //@hoverdef("y", mapStructKeyY) + _ = v.x //@hoverdef("x", mapStructValueX) + } + + var i []map[string]interface { + // open method comment + open() error //@mark(openMethod, "open") + } + i[0]["1"].open() //@hoverdef("open", openMethod) +} + +func _() { + test := struct { + // test description + desc string //@mark(testDescription, "desc") + }{} + _ = test.desc //@hoverdef("desc", testDescription) + + for _, tt := range []struct { + // test input + in map[string][]struct { //@mark(testInput, "in") + // test key + key string //@mark(testInputKey, "key") + // test value + value interface{} //@mark(testInputValue, "value") + } + result struct { + v <-chan struct { + // expected test value + value int //@mark(testResultValue, "value") + } + } + }{} { + _ = tt.in //@hoverdef("in", testInput) + _ = tt.in["0"][0].key //@hoverdef("key", testInputKey) + _ = tt.in["0"][0].value //@hoverdef("value", testInputValue) + + _ = (<-tt.result.v).value //@hoverdef("value", testResultValue) + } +} + +func _() { + getPoints := func() []struct { + // X coord + x int //@mark(returnX, "x") + // Y coord + y int //@mark(returnY, "y") + } { + return nil + } + + r := getPoints() + r[0].x //@hoverdef("x", returnX) + r[0].y //@hoverdef("y", returnY) +} diff --git a/gopls/internal/lsp/testdata/godef/a/h.go.golden b/gopls/internal/lsp/testdata/godef/a/h.go.golden new file mode 100644 index 000000000..7cef9ee96 --- /dev/null +++ b/gopls/internal/lsp/testdata/godef/a/h.go.golden @@ -0,0 +1,161 @@ +-- arrD-hoverdef -- +```go +field d int +``` + +d field + +-- arrE-hoverdef -- +```go +field e struct{f int} +``` + +e nested struct + +-- arrF-hoverdef -- +```go +field f int +``` + +f field of nested struct + +-- complexH-hoverdef -- +```go +field h int +``` + +h field + +-- complexI-hoverdef -- +```go +field i struct{j int} +``` + +i nested struct + +-- complexJ-hoverdef -- +```go +field j int +``` + +j field of nested struct + +-- mapStructKeyX-hoverdef -- +```go +field x []string +``` + +X key field + +-- mapStructKeyY-hoverdef -- +```go +field y string +``` + +Y key field + +-- mapStructValueX-hoverdef -- +```go +field x string +``` + +X value field + +-- nestedMap-hoverdef -- +```go +field m map[string]float64 +``` + +nested map + +-- nestedNumber-hoverdef -- +```go +field number int64 +``` + +nested number + +-- nestedString-hoverdef -- +```go +field str string +``` + +nested string + +-- openMethod-hoverdef -- +```go +func (interface).open() error +``` + +open method comment + +-- returnX-hoverdef -- +```go +field x int +``` + +X coord + +-- returnY-hoverdef -- +```go +field y int +``` + +Y coord + +-- structA-hoverdef -- +```go +field a int +``` + +a field + +-- structB-hoverdef -- +```go +field b struct{c int} +``` + +b nested struct + +-- structC-hoverdef -- +```go +field c int +``` + +c field of nested struct + +-- testDescription-hoverdef -- +```go +field desc string +``` + +test description + +-- testInput-hoverdef -- +```go +field in map[string][]struct{key string; value interface{}} +``` + +test input + +-- testInputKey-hoverdef -- +```go +field key string +``` + +test key + +-- testInputValue-hoverdef -- +```go +field value interface{} +``` + +test value + +-- testResultValue-hoverdef -- +```go +field value int +``` + +expected test value + diff --git a/gopls/internal/lsp/testdata/godef/b/e.go b/gopls/internal/lsp/testdata/godef/b/e.go new file mode 100644 index 000000000..9c81cad31 --- /dev/null +++ b/gopls/internal/lsp/testdata/godef/b/e.go @@ -0,0 +1,31 @@ +package b + +import ( + "fmt" + + "golang.org/lsptests/godef/a" +) + +func useThings() { + t := a.Thing{} //@mark(bStructType, "ing") + fmt.Print(t.Member) //@mark(bMember, "ember") + fmt.Print(a.Other) //@mark(bVar, "ther") + a.Things() //@mark(bFunc, "ings") +} + +/*@ +godef(bStructType, Thing) +godef(bMember, Member) +godef(bVar, Other) +godef(bFunc, Things) +*/ + +func _() { + var x interface{} //@mark(eInterface, "interface{}") + switch x := x.(type) { //@hoverdef("x", eInterface) + case string: //@mark(eString, "string") + fmt.Println(x) //@hoverdef("x", eString) + case int: //@mark(eInt, "int") + fmt.Println(x) //@hoverdef("x", eInt) + } +} diff --git a/gopls/internal/lsp/testdata/godef/b/e.go.golden b/gopls/internal/lsp/testdata/godef/b/e.go.golden new file mode 100644 index 000000000..3d7d89797 --- /dev/null +++ b/gopls/internal/lsp/testdata/godef/b/e.go.golden @@ -0,0 +1,156 @@ +-- Member-definition -- +godef/a/d.go:6:2-8: defined here as ```go +field Member string +``` + +@Member + + +[`(a.Thing).Member` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing.Member) +-- Member-definition-json -- +{ + "span": { + "uri": "file://godef/a/d.go", + "start": { + "line": 6, + "column": 2, + "offset": 90 + }, + "end": { + "line": 6, + "column": 8, + "offset": 96 + } + }, + "description": "```go\nfield Member string\n```\n\n@Member\n\n\n[`(a.Thing).Member` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing.Member)" +} + +-- Member-hoverdef -- +```go +field Member string +``` + +@Member + + +[`(a.Thing).Member` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing.Member) +-- Other-definition -- +godef/a/d.go:9:5-10: defined here as ```go +var a.Other a.Thing +``` + +@Other + + +[`a.Other` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Other) +-- Other-definition-json -- +{ + "span": { + "uri": "file://godef/a/d.go", + "start": { + "line": 9, + "column": 5, + "offset": 121 + }, + "end": { + "line": 9, + "column": 10, + "offset": 126 + } + }, + "description": "```go\nvar a.Other a.Thing\n```\n\n@Other\n\n\n[`a.Other` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Other)" +} + +-- Other-hoverdef -- +```go +var a.Other a.Thing +``` + +@Other + + +[`a.Other` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Other) +-- Thing-definition -- +godef/a/d.go:5:6-11: defined here as ```go +type Thing struct { + Member string //@Member +} + +func (a.Thing).Method(i int) string +func (*a.Thing).Method2(i int, j int) (error, string) +func (a.Thing).Method3() +``` + +[`a.Thing` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing) +-- Thing-definition-json -- +{ + "span": { + "uri": "file://godef/a/d.go", + "start": { + "line": 5, + "column": 6, + "offset": 65 + }, + "end": { + "line": 5, + "column": 11, + "offset": 70 + } + }, + "description": "```go\ntype Thing struct {\n\tMember string //@Member\n}\n\nfunc (a.Thing).Method(i int) string\nfunc (*a.Thing).Method2(i int, j int) (error, string)\nfunc (a.Thing).Method3()\n```\n\n[`a.Thing` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing)" +} + +-- Thing-hoverdef -- +```go +type Thing struct { + Member string //@Member +} + +func (a.Thing).Method(i int) string +func (*a.Thing).Method2(i int, j int) (error, string) +func (a.Thing).Method3() +``` + +[`a.Thing` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Thing) +-- Things-definition -- +godef/a/d.go:11:6-12: defined here as ```go +func a.Things(val []string) []a.Thing +``` + +[`a.Things` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Things) +-- Things-definition-json -- +{ + "span": { + "uri": "file://godef/a/d.go", + "start": { + "line": 11, + "column": 6, + "offset": 148 + }, + "end": { + "line": 11, + "column": 12, + "offset": 154 + } + }, + "description": "```go\nfunc a.Things(val []string) []a.Thing\n```\n\n[`a.Things` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Things)" +} + +-- Things-hoverdef -- +```go +func a.Things(val []string) []a.Thing +``` + +[`a.Things` on pkg.go.dev](https://pkg.go.dev/golang.org/lsptests/godef/a#Things) +-- eInt-hoverdef -- +```go +var x int +``` +-- eInterface-hoverdef -- +```go +var x interface{} +``` +-- eString-hoverdef -- +```go +var x string +``` diff --git a/gopls/internal/lsp/testdata/godef/broken/unclosedIf.go.golden b/gopls/internal/lsp/testdata/godef/broken/unclosedIf.go.golden new file mode 100644 index 000000000..9ce869848 --- /dev/null +++ b/gopls/internal/lsp/testdata/godef/broken/unclosedIf.go.golden @@ -0,0 +1,31 @@ +-- myUnclosedIf-definition -- +godef/broken/unclosedIf.go:7:7-19: defined here as ```go +var myUnclosedIf string +``` + +@myUnclosedIf +-- myUnclosedIf-definition-json -- +{ + "span": { + "uri": "file://godef/broken/unclosedIf.go", + "start": { + "line": 7, + "column": 7, + "offset": 68 + }, + "end": { + "line": 7, + "column": 19, + "offset": 80 + } + }, + "description": "```go\nvar myUnclosedIf string\n```\n\n@myUnclosedIf" +} + +-- myUnclosedIf-hoverdef -- +```go +var myUnclosedIf string +``` + +@myUnclosedIf + diff --git a/gopls/internal/lsp/testdata/godef/broken/unclosedIf.go.in b/gopls/internal/lsp/testdata/godef/broken/unclosedIf.go.in new file mode 100644 index 000000000..0f2cf1b1e --- /dev/null +++ b/gopls/internal/lsp/testdata/godef/broken/unclosedIf.go.in @@ -0,0 +1,9 @@ +package broken + +import "fmt" + +func unclosedIf() { + if false { + var myUnclosedIf string //@myUnclosedIf + fmt.Printf("s = %v\n", myUnclosedIf) //@godef("my", myUnclosedIf) +} |