1
0
mirror of https://github.com/golang/go synced 2024-11-19 03:54:42 -07:00
go/internal/lsp/testdata/godef/a/d.go
Rebecca Stambler 42268a1f04 internal/lsp: fix link anchors for struct fields
This change fixes the link anchors for fields within a struct or
composite literal by getting the enclosing types.Type.

Fixes golang/go#36138

Change-Id: I534a900fad6fa6fa1b1acaa5a63ca264c5d34c39
Reviewed-on: https://go-review.googlesource.com/c/tools/+/211582
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2019-12-17 02:48:38 +00:00

44 lines
738 B
Go

package a
import "fmt"
type Thing struct { //@Thing
Member string //@Member
}
var Other Thing //@Other
func Things(val []string) []Thing { //@Things
return nil
}
func (t Thing) Method(i int) string { //@Method
return t.Member
}
func useThings() {
t := Thing{ //@mark(aStructType, "ing")
Member: "string", //@mark(fMember, "ember")
}
fmt.Print(t.Member) //@mark(aMember, "ember")
fmt.Print(Other) //@mark(aVar, "ther")
Things() //@mark(aFunc, "ings")
t.Method() //@mark(aMethod, "eth")
}
/*@
godef(aStructType, Thing)
godef(aMember, Member)
godef(aVar, Other)
godef(aFunc, Things)
godef(aMethod, Method)
godef(fMember, Member)
godef(Member, Member)
//param
//package name
//const
//anon field
*/