golang.org/x/tools/gopls@v0.15.3/internal/test/marker/testdata/completion/complit.txt (about) 1 This test checks completion related to composite literals. 2 3 -- flags -- 4 -ignore_extra_diags 5 6 -- settings.json -- 7 { 8 "completeUnimported": false 9 } 10 11 -- complit.go -- 12 package complit 13 14 // Literal completion results. 15 /* int() */ //@item(int, "int()", "int", "var") 16 17 // general completions 18 19 type position struct { //@item(structPosition, "position", "struct{...}", "struct") 20 X, Y int //@item(fieldX, "X", "int", "field"),item(fieldY, "Y", "int", "field") 21 } 22 23 func _() { 24 _ = position{ 25 //@complete("", fieldX, fieldY, int, structPosition) 26 } 27 _ = position{ 28 X: 1, 29 //@complete("", fieldY) 30 } 31 _ = position{ 32 //@complete("", fieldX) 33 Y: 1, 34 } 35 _ = []*position{ 36 { 37 //@complete("", fieldX, fieldY, int, structPosition) 38 }, 39 } 40 } 41 42 func _() { 43 var ( 44 aa string //@item(aaVar, "aa", "string", "var") 45 ab int //@item(abVar, "ab", "int", "var") 46 ) 47 48 _ = map[int]int{ 49 a: a, //@complete(":", abVar, aaVar),complete(",", abVar, aaVar) 50 } 51 52 _ = map[int]int{ 53 //@complete("", abVar, int, aaVar, structPosition) 54 } 55 56 _ = []string{a: ""} //@complete(":", abVar, aaVar) 57 _ = [1]string{a: ""} //@complete(":", abVar, aaVar) 58 59 _ = position{X: a} //@complete("}", abVar, aaVar) 60 _ = position{a} //@complete("}", abVar, aaVar) 61 _ = position{a, } //@complete("}", abVar, int, aaVar, structPosition) 62 63 _ = []int{a} //@complete("}", abVar, aaVar) 64 _ = [1]int{a} //@complete("}", abVar, aaVar) 65 66 type myStruct struct { 67 AA int //@item(fieldAA, "AA", "int", "field") 68 AB string //@item(fieldAB, "AB", "string", "field") 69 } 70 71 _ = myStruct{ 72 AB: a, //@complete(",", aaVar, abVar) 73 } 74 75 var s myStruct 76 77 _ = map[int]string{1: "" + s.A} //@complete("}", fieldAB, fieldAA) 78 _ = map[int]string{1: (func(i int) string { return "" })(s.A)} //@complete(")}", fieldAA, fieldAB) 79 _ = map[int]string{1: func() string { s.A }} //@complete(" }", fieldAA, fieldAB) 80 81 _ = position{s.A} //@complete("}", fieldAA, fieldAB) 82 83 var X int //@item(varX, "X", "int", "var") 84 _ = position{X} //@complete("}", fieldX, varX) 85 } 86 87 func _() { 88 type foo struct{} //@item(complitFoo, "foo", "struct{...}", "struct") 89 90 var _ *foo = &fo{} //@snippet("{", complitFoo, "foo") 91 var _ *foo = fo{} //@snippet("{", complitFoo, "&foo") 92 93 struct { a, b *foo }{ 94 a: &fo{}, //@rank("{", complitFoo) 95 b: fo{}, //@snippet("{", complitFoo, "&foo") 96 } 97 } 98 99 func _() { 100 _ := position{ 101 X: 1, //@complete("X", fieldX),complete(" 1", int, structPosition) 102 Y: , //@complete(":", fieldY),complete(" ,", int, structPosition) 103 } 104 }