mirror of
https://github.com/golang/go
synced 2024-11-06 19:56:15 -07:00
2161848f5a
The existing implementation did not suggest struct field names when running completion from within a slice literal of pointers. Now, struct field names are suggested in that case. Fixes golang/go#33211 Change-Id: I6028420a9a789846b070fcc6e45ec89dc4d898d4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/192277 Reviewed-by: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
77 lines
1.9 KiB
Go
77 lines
1.9 KiB
Go
package complit
|
|
|
|
type position struct { //@item(structPosition, "position", "struct{...}", "struct")
|
|
X, Y int //@item(fieldX, "X", "int", "field"),item(fieldY, "Y", "int", "field")
|
|
}
|
|
|
|
func _() {
|
|
_ = position{
|
|
//@complete("", fieldX, fieldY, structPosition)
|
|
}
|
|
_ = position{
|
|
X: 1,
|
|
//@complete("", fieldY)
|
|
}
|
|
_ = position{
|
|
//@complete("", fieldX)
|
|
Y: 1,
|
|
}
|
|
_ = []*position{
|
|
{
|
|
//@complete("", fieldX, fieldY, structPosition)
|
|
},
|
|
}
|
|
}
|
|
|
|
func _() {
|
|
var (
|
|
aa string //@item(aaVar, "aa", "string", "var")
|
|
ab int //@item(abVar, "ab", "int", "var")
|
|
)
|
|
|
|
_ = map[int]int{
|
|
a: a, //@complete(":", abVar, aaVar),complete(",", abVar, aaVar)
|
|
}
|
|
|
|
_ = map[int]int{
|
|
//@complete("", abVar, aaVar, structPosition)
|
|
}
|
|
|
|
_ = []string{a: ""} //@complete(":", abVar, aaVar)
|
|
_ = [1]string{a: ""} //@complete(":", abVar, aaVar)
|
|
|
|
_ = position{X: a} //@complete("}", abVar, aaVar)
|
|
_ = position{a} //@complete("}", abVar, aaVar)
|
|
_ = position{a, } //@complete("}", abVar, aaVar, structPosition)
|
|
|
|
_ = []int{a} //@complete("a", abVar, aaVar, structPosition)
|
|
_ = [1]int{a} //@complete("a", abVar, aaVar, structPosition)
|
|
|
|
type myStruct struct {
|
|
AA int //@item(fieldAA, "AA", "int", "field")
|
|
AB string //@item(fieldAB, "AB", "string", "field")
|
|
}
|
|
|
|
_ = myStruct{
|
|
AB: a, //@complete(",", aaVar, abVar)
|
|
}
|
|
|
|
var s myStruct
|
|
|
|
_ = map[int]string{1: "" + s.A} //@complete("}", fieldAB, fieldAA)
|
|
_ = map[int]string{1: (func(i int) string { return "" })(s.A)} //@complete(")}", fieldAA, fieldAB)
|
|
_ = map[int]string{1: func() string { s.A }} //@complete(" }", fieldAA, fieldAB)
|
|
|
|
_ = position{s.A} //@complete("}", fieldAA, fieldAB)
|
|
|
|
var X int //@item(varX, "X", "int", "var")
|
|
_ = position{X} //@complete("}", fieldX, varX)
|
|
}
|
|
|
|
func _() {
|
|
_ := position{
|
|
X: 1, //@complete("X", fieldX),complete(" 1", structPosition)
|
|
Y: , //@complete(":", fieldY),complete(" ,", structPosition)
|
|
}
|
|
}
|