mirror of
https://github.com/golang/go
synced 2024-11-06 19:46:20 -07:00
de15caf068
Fix the following issues: - We were trying to complete struct literal field names for selector expressions (e.g. "Foo{a.B<>}"). Now we only complete field names in this case if the expression is an *ast.Ident. - We weren't including lexical completions in cases where you might be completing a field name or a variable name (e.g. "Foo{A<>}"). I refactored composite literal logic to live mostly in one place. Now enclosingCompositeLiteral computes all the bits of information related to composite literals. The expected type, completion, and snippet code make use of those precalculated facts instead of redoing the work. Change-Id: I29fc808544382c3c77f0bba1843520e04f38e79b GitHub-Last-Rev: 3489062be342ab0f00325d3b3ae9ce681df7cf2e GitHub-Pull-Request: golang/tools#96 Reviewed-on: https://go-review.googlesource.com/c/tools/+/176601 Reviewed-by: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
27 lines
560 B
Go
27 lines
560 B
Go
package importedcomplit
|
|
|
|
import (
|
|
"golang.org/x/tools/internal/lsp/foo"
|
|
)
|
|
|
|
func _() {
|
|
var V int //@item(icVVar, "V", "int", "var")
|
|
_ = foo.StructFoo{V} //@complete("}", Value, icVVar)
|
|
}
|
|
|
|
func _() {
|
|
var (
|
|
aa string //@item(icAAVar, "aa", "string", "var")
|
|
ab int //@item(icABVar, "ab", "int", "var")
|
|
)
|
|
|
|
_ = foo.StructFoo{a} //@complete("}", abVar, aaVar)
|
|
|
|
var s struct {
|
|
AA string //@item(icFieldAA, "AA", "string", "field")
|
|
AB int //@item(icFieldAB, "AB", "int", "field")
|
|
}
|
|
|
|
_ = foo.StructFoo{s.} //@complete("}", icFieldAB, icFieldAA)
|
|
}
|