github.com/v2fly/tools@v0.100.0/internal/lsp/testdata/complit/complit.go.in (about)

     1  package complit
     2  
     3  // general completions
     4  
     5  type position struct { //@item(structPosition, "position", "struct{...}", "struct")
     6  	X, Y int //@item(fieldX, "X", "int", "field"),item(fieldY, "Y", "int", "field")
     7  }
     8  
     9  func _() {
    10  	_ = position{
    11  		//@complete("", fieldX, fieldY, structPosition)
    12  	}
    13  	_ = position{
    14  		X: 1,
    15  		//@complete("", fieldY)
    16  	}
    17  	_ = position{
    18  		//@complete("", fieldX)
    19  		Y: 1,
    20  	}
    21  	_ = []*position{
    22          {
    23              //@complete("", fieldX, fieldY, structPosition)
    24          },
    25  	}
    26  }
    27  
    28  func _() {
    29  	var (
    30  		aa string //@item(aaVar, "aa", "string", "var")
    31  		ab int    //@item(abVar, "ab", "int", "var")
    32  	)
    33  
    34  	_ = map[int]int{
    35  		a: a, //@complete(":", abVar, aaVar),complete(",", abVar, aaVar)
    36  	}
    37  
    38  	_ = map[int]int{
    39  		//@complete("", abVar, aaVar, structPosition)
    40  	}
    41  
    42  	_ = []string{a: ""} //@complete(":", abVar, aaVar)
    43  	_ = [1]string{a: ""} //@complete(":", abVar, aaVar)
    44  
    45  	_ = position{X: a}   //@complete("}", abVar, aaVar)
    46  	_ = position{a}      //@complete("}", abVar, aaVar)
    47  	_ = position{a, }      //@complete("}", abVar, aaVar, structPosition)
    48  
    49  	_ = []int{a}  //@complete("}", abVar, aaVar)
    50  	_ = [1]int{a} //@complete("}", abVar, aaVar)
    51  
    52  	type myStruct struct {
    53  		AA int    //@item(fieldAA, "AA", "int", "field")
    54  		AB string //@item(fieldAB, "AB", "string", "field")
    55  	}
    56  
    57  	_ = myStruct{
    58  		AB: a, //@complete(",", aaVar, abVar)
    59  	}
    60  
    61  	var s myStruct
    62  
    63  	_ = map[int]string{1: "" + s.A}                                //@complete("}", fieldAB, fieldAA)
    64  	_ = map[int]string{1: (func(i int) string { return "" })(s.A)} //@complete(")}", fieldAA, fieldAB)
    65  	_ = map[int]string{1: func() string { s.A }}                   //@complete(" }", fieldAA, fieldAB)
    66  
    67  	_ = position{s.A} //@complete("}", fieldAA, fieldAB)
    68  
    69  	var X int //@item(varX, "X", "int", "var")
    70  	_ = position{X}      //@complete("}", fieldX, varX)
    71  }
    72  
    73  func _() {
    74  	type foo struct{} //@item(complitFoo, "foo", "struct{...}", "struct")
    75  
    76  	"&foo" //@item(complitAndFoo, "&foo", "struct{...}", "struct")
    77  
    78  	var _ *foo = &fo{} //@rank("{", complitFoo)
    79  	var _ *foo = fo{} //@rank("{", complitAndFoo)
    80  
    81  	struct { a, b *foo }{
    82  		a: &fo{}, //@rank("{", complitFoo)
    83  		b: fo{}, //@rank("{", complitAndFoo)
    84  	}
    85  }
    86  
    87  func _() {
    88  	_ := position{
    89  		X: 1, //@complete("X", fieldX),complete(" 1", structPosition)
    90  		Y: ,  //@complete(":", fieldY),complete(" ,", structPosition)
    91  	}
    92  }