github.com/v2fly/tools@v0.100.0/internal/lsp/testdata/godef/a/h.go (about) 1 package a 2 3 func _() { 4 type s struct { 5 nested struct { 6 // nested number 7 number int64 //@mark(nestedNumber, "number") 8 } 9 nested2 []struct { 10 // nested string 11 str string //@mark(nestedString, "str") 12 } 13 x struct { 14 x struct { 15 x struct { 16 x struct { 17 x struct { 18 // nested map 19 m map[string]float64 //@mark(nestedMap, "m") 20 } 21 } 22 } 23 } 24 } 25 } 26 27 var t s 28 _ = t.nested.number //@hover("number", nestedNumber) 29 _ = t.nested2[0].str //@hover("str", nestedString) 30 _ = t.x.x.x.x.x.m //@hover("m", nestedMap) 31 } 32 33 func _() { 34 var s struct { 35 // a field 36 a int //@mark(structA, "a") 37 // b nested struct 38 b struct { //@mark(structB, "b") 39 // c field of nested struct 40 c int //@mark(structC, "c") 41 } 42 } 43 _ = s.a //@hover("a", structA) 44 _ = s.b //@hover("b", structB) 45 _ = s.b.c //@hover("c", structC) 46 47 var arr []struct { 48 // d field 49 d int //@mark(arrD, "d") 50 // e nested struct 51 e struct { //@mark(arrE, "e") 52 // f field of nested struct 53 f int //@mark(arrF, "f") 54 } 55 } 56 _ = arr[0].d //@hover("d", arrD) 57 _ = arr[0].e //@hover("e", arrE) 58 _ = arr[0].e.f //@hover("f", arrF) 59 60 var complex []struct { 61 c <-chan map[string][]struct { 62 // h field 63 h int //@mark(complexH, "h") 64 // i nested struct 65 i struct { //@mark(complexI, "i") 66 // j field of nested struct 67 j int //@mark(complexJ, "j") 68 } 69 } 70 } 71 _ = (<-complex[0].c)["0"][0].h //@hover("h", complexH) 72 _ = (<-complex[0].c)["0"][0].i //@hover("i", complexI) 73 _ = (<-complex[0].c)["0"][0].i.j //@hover("j", complexJ) 74 75 var mapWithStructKey map[struct { 76 // X key field 77 x []string //@mark(mapStructKeyX, "x") 78 }]int 79 for k := range mapWithStructKey { 80 _ = k.x //@hover("x", mapStructKeyX) 81 } 82 83 var mapWithStructKeyAndValue map[struct { 84 // Y key field 85 y string //@mark(mapStructKeyY, "y") 86 }]struct { 87 // X value field 88 x string //@mark(mapStructValueX, "x") 89 } 90 for k, v := range mapWithStructKeyAndValue { 91 // TODO: we don't show docs for y field because both map key and value 92 // are structs. And in this case, we parse only map value 93 _ = k.y //@hover("y", mapStructKeyY) 94 _ = v.x //@hover("x", mapStructValueX) 95 } 96 97 var i []map[string]interface { 98 // open method comment 99 open() error //@mark(openMethod, "open") 100 } 101 i[0]["1"].open() //@hover("open", openMethod) 102 } 103 104 func _() { 105 test := struct { 106 // test description 107 desc string //@mark(testDescription, "desc") 108 }{} 109 _ = test.desc //@hover("desc", testDescription) 110 111 for _, tt := range []struct { 112 // test input 113 in map[string][]struct { //@mark(testInput, "in") 114 // test key 115 key string //@mark(testInputKey, "key") 116 // test value 117 value interface{} //@mark(testInputValue, "value") 118 } 119 result struct { 120 v <-chan struct { 121 // expected test value 122 value int //@mark(testResultValue, "value") 123 } 124 } 125 }{} { 126 _ = tt.in //@hover("in", testInput) 127 _ = tt.in["0"][0].key //@hover("key", testInputKey) 128 _ = tt.in["0"][0].value //@hover("value", testInputValue) 129 130 _ = (<-tt.result.v).value //@hover("value", testResultValue) 131 } 132 } 133 134 func _() { 135 getPoints := func() []struct { 136 // X coord 137 x int //@mark(returnX, "x") 138 // Y coord 139 y int //@mark(returnY, "y") 140 } { 141 return nil 142 } 143 144 r := getPoints() 145 r[0].x //@hover("x", returnX) 146 r[0].y //@hover("y", returnY) 147 }