internal/lsp/source: fixes completion for slice literals of pointers

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>
This commit is contained in:
A. Jensen 2019-08-28 22:53:48 -05:00 committed by Rebecca Stambler
parent 311ec0312e
commit 2161848f5a
3 changed files with 7 additions and 2 deletions

View File

@ -765,7 +765,7 @@ func enclosingCompositeLiteral(path []ast.Node, pos token.Pos, info *types.Info)
clInfo := compLitInfo{
cl: n,
clType: tv.Type.Underlying(),
clType: deref(tv.Type).Underlying(),
}
var (

View File

@ -16,6 +16,11 @@ func _() {
//@complete("", fieldX)
Y: 1,
}
_ = []*position{
{
//@complete("", fieldX, fieldY, structPosition)
},
}
}
func _() {

View File

@ -29,7 +29,7 @@ import (
// We hardcode the expected number of test cases to ensure that all tests
// are being executed. If a test is added, this number must be changed.
const (
ExpectedCompletionsCount = 154
ExpectedCompletionsCount = 155
ExpectedCompletionSnippetCount = 15
ExpectedDiagnosticsCount = 21
ExpectedFormatCount = 6