1
0
mirror of https://github.com/golang/go synced 2024-10-01 09:28:37 -06:00
go/internal/lsp/testdata/godef/b/b.go
Muir Manders aa740d4807 internal/lsp: handle embedded struct pointer definitions
When jumping to definition of an embedded struct pointer, be sure to
unwrap the pointer type so you properly jump to the pointee type.

Also, fix jumping to definition of an embedded struct inside an
anonymous struct inside a struct. The embedded struct detection was
continuing too far and thinking it wasn't an embedded struct when it
saw the anonymous struct.

Fixes golang/go#31451

Change-Id: I96017764270712a2ae02a85306605495075d12e7
GitHub-Last-Rev: 9997f60855ebe37bcca2fecc1ba2a7b871f393d4
GitHub-Pull-Request: golang/tools#83
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172583
Run-TryBot: Paul Jolly <paul@myitcv.org.uk>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2019-04-20 18:18:00 +00:00

31 lines
590 B
Go

package b
import "golang.org/x/tools/internal/lsp/godef/a"
type S1 struct { //@S1
F1 int //@mark(S1F1, "F1")
S2 //@godef("S2", S2), mark(S1S2, "S2")
a.A //@godef("A", A)
}
type S2 struct { //@S2
F1 string //@mark(S2F1, "F1")
F2 int //@mark(S2F2, "F2")
*a.A //@godef("A", A)
}
type S3 struct {
F1 struct {
a.A //@godef("A", A)
}
}
func Bar() {
a.Stuff() //@godef("Stuff", Stuff)
var x S1 //@godef("S1", S1)
_ = x.S2 //@godef("S2", S1S2)
_ = x.F1 //@godef("F1", S1F1)
_ = x.F2 //@godef("F2", S2F2)
_ = x.S2.F1 //@godef("F1", S2F1)
}