| These tests check that postfix completions do and do not show up in certain |
| cases. Tests for the postfix completion contents are implemented as ad-hoc |
| regtests. |
| |
| -- flags -- |
| -ignore_extra_diags |
| |
| -- go.mod -- |
| module golang.org/lsptests/snippets |
| |
| go 1.18 |
| |
| -- postfix.go -- |
| package snippets |
| |
| func _() { |
| var foo []int |
| foo.append //@rank(" //", postfixAppend) |
| |
| []int{}.append //@complete(" //") |
| |
| []int{}.last //@complete(" //") |
| |
| /* copy! */ //@item(postfixCopy, "copy!", "duplicate slice", "snippet") |
| |
| foo.copy //@rank(" //", postfixCopy) |
| |
| var s struct{ i []int } |
| s.i.copy //@rank(" //", postfixCopy) |
| |
| var _ []int = s.i.copy //@complete(" //") |
| |
| var blah func() []int |
| blah().append //@complete(" //") |
| } |
| |
| func _() { |
| /* append! */ //@item(postfixAppend, "append!", "append and re-assign slice", "snippet") |
| /* last! */ //@item(postfixLast, "last!", "s[len(s)-1]", "snippet") |
| /* print! */ //@item(postfixPrint, "print!", "print to stdout", "snippet") |
| /* range! */ //@item(postfixRange, "range!", "range over slice", "snippet") |
| /* reverse! */ //@item(postfixReverse, "reverse!", "reverse slice", "snippet") |
| /* sort! */ //@item(postfixSort, "sort!", "sort.Slice()", "snippet") |
| /* var! */ //@item(postfixVar, "var!", "assign to variable", "snippet") |
| /* ifnotnil! */ //@item(postfixIfNotNil, "ifnotnil!", "if expr != nil", "snippet") |
| |
| var foo []int |
| foo. //@complete(" //", postfixAppend, postfixCopy, postfixIfNotNil, postfixLast, postfixPrint, postfixRange, postfixReverse, postfixSort, postfixVar) |
| |
| foo = nil |
| } |