1
0
mirror of https://github.com/golang/go synced 2024-11-06 19:36:30 -07:00
go/internal/lsp/testdata/index/index.go
Muir Manders e5f21acdc3 internal/lsp: handle more expected type cases
Calculate expected type in the following cases:

- switch case statements
- index expressions (e.g. []int{}[<>] or map[string]int{}[<>])
- slice expressions (e.g. []int{}[1:<>])
- channel send statements
- channel receive expression

We now also prefer type names in type switch clauses and type asserts.

Change-Id: Iff8c317a9116868b36701d931c802d9147f962d8
GitHub-Last-Rev: e039a45aebe1c6aa9b2011cad67ddaa5e4ed4d77
GitHub-Pull-Request: golang/tools#97
Reviewed-on: https://go-review.googlesource.com/c/tools/+/176941
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-05-16 16:26:11 +00:00

22 lines
488 B
Go

package index
func _() {
var (
aa = "123" //@item(indexAA, "aa", "string", "var")
ab = 123 //@item(indexAB, "ab", "int", "var")
)
var foo [1]int
foo[a] //@complete("]", indexAB, indexAA)
foo[:a] //@complete("]", indexAB, indexAA)
a[:a] //@complete("[", indexAA, indexAB)
a[a] //@complete("[", indexAA, indexAB)
var bar map[string]int
bar[a] //@complete("]", indexAA, indexAB)
type myMap map[string]int
var baz myMap
baz[a] //@complete("]", indexAA, indexAB)
}