| 1 | package definition |
|---|---|
| 2 | |
| 3 | // Tests of 'definition' query, -json output. |
| 4 | // See golang.org/x/tools/cmd/guru/guru_test.go for explanation. |
| 5 | // See main.golden for expected query results. |
| 6 | |
| 7 | // TODO(adonovan): test: selection of member of same package defined in another file. |
| 8 | |
| 9 | import ( |
| 10 | "lib" |
| 11 | lib2 "lib" |
| 12 | "nosuchpkg" |
| 13 | ) |
| 14 | |
| 15 | func main() { |
| 16 | var _ int // @definition builtin "int" |
| 17 | |
| 18 | var _ undef // @definition lexical-undef "undef" |
| 19 | var x lib.T // @definition lexical-pkgname "lib" |
| 20 | f() // @definition lexical-func "f" |
| 21 | print(x) // @definition lexical-var "x" |
| 22 | if x := ""; x == "" { // @definition lexical-shadowing "x" |
| 23 | } |
| 24 | |
| 25 | var _ lib.Type // @definition qualified-type "Type" |
| 26 | var _ lib.Func // @definition qualified-func "Func" |
| 27 | var _ lib.Var // @definition qualified-var "Var" |
| 28 | var _ lib.Const // @definition qualified-const "Const" |
| 29 | var _ lib2.Type // @definition qualified-type-renaming "Type" |
| 30 | var _ lib.Nonesuch // @definition qualified-nomember "Nonesuch" |
| 31 | var _ nosuchpkg.T // @definition qualified-nopkg "nosuchpkg" |
| 32 | |
| 33 | var u U |
| 34 | print(u.field) // @definition select-field "field" |
| 35 | u.method() // @definition select-method "method" |
| 36 | } |
| 37 | |
| 38 | func f() |
| 39 | |
| 40 | type T struct{ field int } |
| 41 | |
| 42 | func (T) method() |
| 43 | |
| 44 | type U struct{ T } |
| 45 | |
| 46 | type V1 struct { |
| 47 | W // @definition embedded-other-file "W" |
| 48 | } |
| 49 | |
| 50 | type V2 struct { |
| 51 | *W // @definition embedded-other-file-pointer "W" |
| 52 | } |
| 53 | |
| 54 | type V3 struct { |
| 55 | int // @definition embedded-basic "int" |
| 56 | } |
| 57 | |
| 58 | type V4 struct { |
| 59 | *int // @definition embedded-basic-pointer "int" |
| 60 | } |
| 61 | |
| 62 | type V5 struct { |
| 63 | lib.Type // @definition embedded-other-pkg "Type" |
| 64 | } |
| 65 | |
| 66 | type V6 struct { |
| 67 | T // @definition embedded-same-file "T" |
| 68 | } |
| 69 |