mirror of
https://github.com/golang/go
synced 2024-11-19 05:24:42 -07:00
775b7fe395
Improve expected type determination for the following cases: - search back further through ast path to handle cases where the position's node is more than two nodes from the ancestor node with type information - generate expected type for return statements - wrap and unwrap pointerness from expected type when position is preceded by "*" (dereference) or "&" (reference) operators, respectively - fix some false positive expected types when completing the "Fun" (left) side of a CallExpr Change-Id: I907ee3e405bd8420031a7b03329de5df1c3493b9 GitHub-Last-Rev: 20a0ac9bf2b5350494c6738f5960676cc50fb454 GitHub-Pull-Request: golang/tools#93 Reviewed-on: https://go-review.googlesource.com/c/tools/+/174477 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
56 lines
1.4 KiB
Go
56 lines
1.4 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,
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|
|
|
|
_ = position{X: a} //@complete("}", abVar, aaVar)
|
|
_ = position{a} //@complete("}", abVar, aaVar)
|
|
|
|
_ = []int{a} //@complete("a", abVar, aaVar, structPosition)
|
|
_ = [1]int{a} //@complete("a", abVar, aaVar, structPosition)
|
|
|
|
var s struct {
|
|
AA int //@item(fieldAA, "AA", "int", "field")
|
|
AB string //@item(fieldAB, "AB", "string", "field")
|
|
}
|
|
_ = 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)
|
|
}
|
|
|
|
func _() {
|
|
_ := position{
|
|
X: 1, //@complete("X", fieldX),complete(" 1", structPosition)
|
|
Y: , //@complete(":", fieldY),complete(" ,", structPosition)
|
|
}
|
|
}
|