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

     1  package snippets
     2  
     3  // These tests check that postfix completions do and do not show up in
     4  // certain cases. Tests for the postfix completion contents are under
     5  // regtest.
     6  
     7  func _() {
     8  	/* append! */ //@item(postfixAppend, "append!", "append and re-assign slice", "snippet")
     9  	var foo []int
    10  	foo.append //@rank(" //", postfixAppend)
    11  
    12  	[]int{}.append //@complete(" //")
    13  
    14  	[]int{}.last //@complete(" //")
    15  
    16  	/* copy! */ //@item(postfixCopy, "copy!", "duplicate slice", "snippet")
    17  
    18  	foo.copy //@rank(" //", postfixCopy)
    19  
    20  	var s struct{ i []int }
    21  	s.i.copy //@rank(" //", postfixCopy)
    22  
    23  	var _ []int = s.i.copy //@complete(" //")
    24  
    25  	var blah func() []int
    26  	blah().append //@complete(" //")
    27  }
    28  
    29  func _() {
    30  	/* append! */ //@item(postfixAppend, "append!", "append and re-assign slice", "snippet")
    31  	/* last! */ //@item(postfixLast, "last!", "s[len(s)-1]", "snippet")
    32  	/* print! */ //@item(postfixPrint, "print!", "print to stdout", "snippet")
    33  	/* range! */ //@item(postfixRange, "range!", "range over slice", "snippet")
    34  	/* reverse! */ //@item(postfixReverse, "reverse!", "reverse slice", "snippet")
    35  	/* sort! */ //@item(postfixSort, "sort!", "sort.Slice()", "snippet")
    36  	/* var! */ //@item(postfixVar, "var!", "assign to variable", "snippet")
    37  
    38  	var foo []int
    39  	foo. //@complete(" //", postfixAppend, postfixCopy, postfixLast, postfixPrint, postfixRange, postfixReverse, postfixSort, postfixVar)
    40  
    41  		foo = nil
    42  }