diff options
Diffstat (limited to 'internal/lsp/testdata/snippets')
-rw-r--r-- | internal/lsp/testdata/snippets/func_snippets118.go.in | 19 | ||||
-rw-r--r-- | internal/lsp/testdata/snippets/literal.go | 22 | ||||
-rw-r--r-- | internal/lsp/testdata/snippets/literal.go.golden | 6 | ||||
-rw-r--r-- | internal/lsp/testdata/snippets/literal_snippets.go.in | 233 | ||||
-rw-r--r-- | internal/lsp/testdata/snippets/literal_snippets118.go.in | 14 | ||||
-rw-r--r-- | internal/lsp/testdata/snippets/postfix.go | 42 | ||||
-rw-r--r-- | internal/lsp/testdata/snippets/snippets.go.golden | 3 | ||||
-rw-r--r-- | internal/lsp/testdata/snippets/snippets.go.in | 61 |
8 files changed, 0 insertions, 400 deletions
diff --git a/internal/lsp/testdata/snippets/func_snippets118.go.in b/internal/lsp/testdata/snippets/func_snippets118.go.in deleted file mode 100644 index d4933689d..000000000 --- a/internal/lsp/testdata/snippets/func_snippets118.go.in +++ /dev/null @@ -1,19 +0,0 @@ -// +build go1.18 -//go:build go1.18 - -package snippets - -type SyncMap[K comparable, V any] struct{} - -func NewSyncMap[K comparable, V any]() (result *SyncMap[K, V]) { //@item(NewSyncMap, "NewSyncMap", "", "") - return -} - -func Identity[P ~int](p P) P { //@item(Identity, "Identity", "", "") - return p -} - -func _() { - _ = NewSyncM //@snippet(" //", NewSyncMap, "NewSyncMap[${1:}]()", "NewSyncMap[${1:K comparable}, ${2:V any}]()") - _ = Identi //@snippet(" //", Identity, "Identity[${1:}](${2:})", "Identity[${1:P ~int}](${2:p P})") -} diff --git a/internal/lsp/testdata/snippets/literal.go b/internal/lsp/testdata/snippets/literal.go deleted file mode 100644 index 43931d18e..000000000 --- a/internal/lsp/testdata/snippets/literal.go +++ /dev/null @@ -1,22 +0,0 @@ -package snippets - -import ( - "golang.org/x/tools/internal/lsp/signature" - t "golang.org/x/tools/internal/lsp/types" -) - -type structy struct { - x signature.MyType -} - -func X(_ map[signature.Alias]t.CoolAlias) (map[signature.Alias]t.CoolAlias) { - return nil -} - -func _() { - X() //@signature(")", "X(_ map[signature.Alias]t.CoolAlias) map[signature.Alias]t.CoolAlias", 0) - _ = signature.MyType{} //@item(literalMyType, "signature.MyType{}", "", "var") - s := structy{ - x: //@snippet(" //", literalMyType, "signature.MyType{\\}", "signature.MyType{\\}") - } -}
\ No newline at end of file diff --git a/internal/lsp/testdata/snippets/literal.go.golden b/internal/lsp/testdata/snippets/literal.go.golden deleted file mode 100644 index f9725f733..000000000 --- a/internal/lsp/testdata/snippets/literal.go.golden +++ /dev/null @@ -1,6 +0,0 @@ --- X(_ map[signature.Alias]t.CoolAlias) map[signature.Alias]t.CoolAlias-signature -- -X(_ map[signature.Alias]t.CoolAlias) map[signature.Alias]t.CoolAlias - --- X(_ map[signatures.Alias]types.CoolAlias) map[signatures.Alias]types.CoolAlias-signature -- -X(_ map[signatures.Alias]types.CoolAlias) map[signatures.Alias]types.CoolAlias - diff --git a/internal/lsp/testdata/snippets/literal_snippets.go.in b/internal/lsp/testdata/snippets/literal_snippets.go.in deleted file mode 100644 index 4a2a01dfa..000000000 --- a/internal/lsp/testdata/snippets/literal_snippets.go.in +++ /dev/null @@ -1,233 +0,0 @@ -package snippets - -import ( - "bytes" - "context" - "go/ast" - "net/http" - "sort" - - "golang.org/x/tools/internal/lsp/foo" -) - -func _() { - []int{} //@item(litIntSlice, "[]int{}", "", "var") - &[]int{} //@item(litIntSliceAddr, "&[]int{}", "", "var") - make([]int, 0) //@item(makeIntSlice, "make([]int, 0)", "", "func") - - var _ *[]int = in //@snippet(" //", litIntSliceAddr, "&[]int{$0\\}", "&[]int{$0\\}") - var _ **[]int = in //@complete(" //") - - var slice []int - slice = i //@snippet(" //", litIntSlice, "[]int{$0\\}", "[]int{$0\\}") - slice = m //@snippet(" //", makeIntSlice, "make([]int, ${1:})", "make([]int, ${1:0})") -} - -func _() { - type namedInt []int - - namedInt{} //@item(litNamedSlice, "namedInt{}", "", "var") - make(namedInt, 0) //@item(makeNamedSlice, "make(namedInt, 0)", "", "func") - - var namedSlice namedInt - namedSlice = n //@snippet(" //", litNamedSlice, "namedInt{$0\\}", "namedInt{$0\\}") - namedSlice = m //@snippet(" //", makeNamedSlice, "make(namedInt, ${1:})", "make(namedInt, ${1:0})") -} - -func _() { - make(chan int) //@item(makeChan, "make(chan int)", "", "func") - - var ch chan int - ch = m //@snippet(" //", makeChan, "make(chan int)", "make(chan int)") -} - -func _() { - map[string]struct{}{} //@item(litMap, "map[string]struct{}{}", "", "var") - make(map[string]struct{}) //@item(makeMap, "make(map[string]struct{})", "", "func") - - var m map[string]struct{} - m = m //@snippet(" //", litMap, "map[string]struct{\\}{$0\\}", "map[string]struct{\\}{$0\\}") - m = m //@snippet(" //", makeMap, "make(map[string]struct{\\})", "make(map[string]struct{\\})") - - struct{}{} //@item(litEmptyStruct, "struct{}{}", "", "var") - - m["hi"] = s //@snippet(" //", litEmptyStruct, "struct{\\}{\\}", "struct{\\}{\\}") -} - -func _() { - type myStruct struct{ i int } //@item(myStructType, "myStruct", "struct{...}", "struct") - - myStruct{} //@item(litStruct, "myStruct{}", "", "var") - &myStruct{} //@item(litStructPtr, "&myStruct{}", "", "var") - - var ms myStruct - ms = m //@snippet(" //", litStruct, "myStruct{$0\\}", "myStruct{$0\\}") - - var msPtr *myStruct - msPtr = m //@snippet(" //", litStructPtr, "&myStruct{$0\\}", "&myStruct{$0\\}") - - msPtr = &m //@snippet(" //", litStruct, "myStruct{$0\\}", "myStruct{$0\\}") - - type myStructCopy struct { i int } //@item(myStructCopyType, "myStructCopy", "struct{...}", "struct") - - // Don't offer literal completion for convertible structs. - ms = myStruct //@complete(" //", litStruct, myStructType, myStructCopyType) -} - -type myImpl struct{} - -func (myImpl) foo() {} - -func (*myImpl) bar() {} - -type myBasicImpl string - -func (myBasicImpl) foo() {} - -func _() { - type myIntf interface { - foo() - } - - myImpl{} //@item(litImpl, "myImpl{}", "", "var") - - var mi myIntf - mi = m //@snippet(" //", litImpl, "myImpl{\\}", "myImpl{\\}") - - myBasicImpl() //@item(litBasicImpl, "myBasicImpl()", "string", "var") - - mi = m //@snippet(" //", litBasicImpl, "myBasicImpl($0)", "myBasicImpl($0)") - - // only satisfied by pointer to myImpl - type myPtrIntf interface { - bar() - } - - &myImpl{} //@item(litImplPtr, "&myImpl{}", "", "var") - - var mpi myPtrIntf - mpi = m //@snippet(" //", litImplPtr, "&myImpl{\\}", "&myImpl{\\}") -} - -func _() { - var s struct{ i []int } //@item(litSliceField, "i", "[]int", "field") - var foo []int - // no literal completions after selector - foo = s.i //@complete(" //", litSliceField) -} - -func _() { - type myStruct struct{ i int } //@item(litMyStructType, "myStruct", "struct{...}", "struct") - myStruct{} //@item(litMyStruct, "myStruct{}", "", "var") - - foo := func(s string, args ...myStruct) {} - // Don't give literal slice candidate for variadic arg. - // Do give literal candidates for variadic element. - foo("", myStruct) //@complete(")", litMyStruct, litMyStructType) -} - -func _() { - Buffer{} //@item(litBuffer, "Buffer{}", "", "var") - - var b *bytes.Buffer - b = bytes.Bu //@snippet(" //", litBuffer, "Buffer{\\}", "Buffer{\\}") -} - -func _() { - _ = "func(...) {}" //@item(litFunc, "func(...) {}", "", "var") - - sort.Slice(nil, fun) //@complete(")", litFunc),snippet(")", litFunc, "func(i, j int) bool {$0\\}", "func(i, j int) bool {$0\\}") - - http.HandleFunc("", f) //@snippet(")", litFunc, "func(w http.ResponseWriter, r *http.Request) {$0\\}", "func(${1:w} http.ResponseWriter, ${2:r} *http.Request) {$0\\}") - - // no literal "func" completions - http.Handle("", fun) //@complete(")") - - http.HandlerFunc() //@item(handlerFunc, "http.HandlerFunc()", "", "var") - http.Handle("", h) //@snippet(")", handlerFunc, "http.HandlerFunc($0)", "http.HandlerFunc($0)") - http.Handle("", http.HandlerFunc()) //@snippet("))", litFunc, "func(w http.ResponseWriter, r *http.Request) {$0\\}", "func(${1:w} http.ResponseWriter, ${2:r} *http.Request) {$0\\}") - - var namedReturn func(s string) (b bool) - namedReturn = f //@snippet(" //", litFunc, "func(s string) (b bool) {$0\\}", "func(s string) (b bool) {$0\\}") - - var multiReturn func() (bool, int) - multiReturn = f //@snippet(" //", litFunc, "func() (bool, int) {$0\\}", "func() (bool, int) {$0\\}") - - var multiNamedReturn func() (b bool, i int) - multiNamedReturn = f //@snippet(" //", litFunc, "func() (b bool, i int) {$0\\}", "func() (b bool, i int) {$0\\}") - - var duplicateParams func(myImpl, int, myImpl) - duplicateParams = f //@snippet(" //", litFunc, "func(mi1 myImpl, i int, mi2 myImpl) {$0\\}", "func(${1:mi1} myImpl, ${2:i} int, ${3:mi2} myImpl) {$0\\}") - - type aliasImpl = myImpl - var aliasParams func(aliasImpl) aliasImpl - aliasParams = f //@snippet(" //", litFunc, "func(ai aliasImpl) aliasImpl {$0\\}", "func(${1:ai} aliasImpl) aliasImpl {$0\\}") - - const two = 2 - var builtinTypes func([]int, [two]bool, map[string]string, struct{ i int }, interface{ foo() }, <-chan int) - builtinTypes = f //@snippet(" //", litFunc, "func(i1 []int, b [two]bool, m map[string]string, s struct{ i int \\}, i2 interface{ foo() \\}, c <-chan int) {$0\\}", "func(${1:i1} []int, ${2:b} [two]bool, ${3:m} map[string]string, ${4:s} struct{ i int \\}, ${5:i2} interface{ foo() \\}, ${6:c} <-chan int) {$0\\}") - - var _ func(ast.Node) = f //@snippet(" //", litFunc, "func(n ast.Node) {$0\\}", "func(${1:n} ast.Node) {$0\\}") - var _ func(error) = f //@snippet(" //", litFunc, "func(err error) {$0\\}", "func(${1:err} error) {$0\\}") - var _ func(context.Context) = f //@snippet(" //", litFunc, "func(ctx context.Context) {$0\\}", "func(${1:ctx} context.Context) {$0\\}") - - type context struct {} - var _ func(context) = f //@snippet(" //", litFunc, "func(ctx context) {$0\\}", "func(${1:ctx} context) {$0\\}") -} - -func _() { - StructFoo{} //@item(litStructFoo, "StructFoo{}", "struct{...}", "struct") - - var sfp *foo.StructFoo - // Don't insert the "&" before "StructFoo{}". - sfp = foo.Str //@snippet(" //", litStructFoo, "StructFoo{$0\\}", "StructFoo{$0\\}") - - var sf foo.StructFoo - sf = foo.Str //@snippet(" //", litStructFoo, "StructFoo{$0\\}", "StructFoo{$0\\}") - sf = foo. //@snippet(" //", litStructFoo, "StructFoo{$0\\}", "StructFoo{$0\\}") -} - -func _() { - float64() //@item(litFloat64, "float64()", "float64", "var") - - // don't complete to "&float64()" - var _ *float64 = float64 //@complete(" //") - - var f float64 - f = fl //@complete(" //", litFloat64),snippet(" //", litFloat64, "float64($0)", "float64($0)") - - type myInt int - myInt() //@item(litMyInt, "myInt()", "", "var") - - var mi myInt - mi = my //@snippet(" //", litMyInt, "myInt($0)", "myInt($0)") -} - -func _() { - type ptrStruct struct { - p *ptrStruct - } - - ptrStruct{} //@item(litPtrStruct, "ptrStruct{}", "", "var") - - ptrStruct{ - p: &ptrSt, //@rank(",", litPtrStruct) - } - - &ptrStruct{} //@item(litPtrStructPtr, "&ptrStruct{}", "", "var") - - &ptrStruct{ - p: ptrSt, //@rank(",", litPtrStructPtr) - } -} - -func _() { - f := func(...[]int) {} - f() //@snippet(")", litIntSlice, "[]int{$0\\}", "[]int{$0\\}") -} - - -func _() { - // don't complete to "untyped int()" - []int{}[untyped] //@complete("] //") -} diff --git a/internal/lsp/testdata/snippets/literal_snippets118.go.in b/internal/lsp/testdata/snippets/literal_snippets118.go.in deleted file mode 100644 index 8251a6384..000000000 --- a/internal/lsp/testdata/snippets/literal_snippets118.go.in +++ /dev/null @@ -1,14 +0,0 @@ -// +build go1.18 -//go:build go1.18 - -package snippets - -type Tree[T any] struct{} - -func (tree Tree[T]) Do(f func(s T)) {} - -func _() { - _ = "func(...) {}" //@item(litFunc, "func(...) {}", "", "var") - var t Tree[string] - t.Do(fun) //@complete(")", litFunc),snippet(")", litFunc, "func(s string) {$0\\}", "func(s string) {$0\\}") -} diff --git a/internal/lsp/testdata/snippets/postfix.go b/internal/lsp/testdata/snippets/postfix.go deleted file mode 100644 index d29694e83..000000000 --- a/internal/lsp/testdata/snippets/postfix.go +++ /dev/null @@ -1,42 +0,0 @@ -package snippets - -// These tests check that postfix completions do and do not show up in -// certain cases. Tests for the postfix completion contents are under -// regtest. - -func _() { - /* append! */ //@item(postfixAppend, "append!", "append and re-assign slice", "snippet") - 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") - - var foo []int - foo. //@complete(" //", postfixAppend, postfixCopy, postfixLast, postfixPrint, postfixRange, postfixReverse, postfixSort, postfixVar) - - foo = nil -} diff --git a/internal/lsp/testdata/snippets/snippets.go.golden b/internal/lsp/testdata/snippets/snippets.go.golden deleted file mode 100644 index 3f20ba50b..000000000 --- a/internal/lsp/testdata/snippets/snippets.go.golden +++ /dev/null @@ -1,3 +0,0 @@ --- baz(at AliasType, b bool)-signature -- -baz(at AliasType, b bool) - diff --git a/internal/lsp/testdata/snippets/snippets.go.in b/internal/lsp/testdata/snippets/snippets.go.in deleted file mode 100644 index 58150c644..000000000 --- a/internal/lsp/testdata/snippets/snippets.go.in +++ /dev/null @@ -1,61 +0,0 @@ -package snippets - -type AliasType = int //@item(sigAliasType, "AliasType", "AliasType", "type") - -func foo(i int, b bool) {} //@item(snipFoo, "foo", "func(i int, b bool)", "func") -func bar(fn func()) func() {} //@item(snipBar, "bar", "func(fn func())", "func") -func baz(at AliasType, b bool) {} //@item(snipBaz, "baz", "func(at AliasType, b bool)", "func") - -type Foo struct { - Bar int //@item(snipFieldBar, "Bar", "int", "field") - Func func(at AliasType) error //@item(snipFieldFunc, "Func", "func(at AliasType) error", "field") -} - -func (Foo) Baz() func() {} //@item(snipMethodBaz, "Baz", "func() func()", "method") -func (Foo) BazBar() func() {} //@item(snipMethodBazBar, "BazBar", "func() func()", "method") -func (Foo) BazBaz(at AliasType) func() {} //@item(snipMethodBazBaz, "BazBaz", "func(at AliasType) func()", "method") - -func _() { - f //@snippet(" //", snipFoo, "foo(${1:})", "foo(${1:i int}, ${2:b bool})") - - bar //@snippet(" //", snipBar, "bar(${1:})", "bar(${1:fn func()})") - - baz //@snippet(" //", snipBaz, "baz(${1:})", "baz(${1:at AliasType}, ${2:b bool})") - baz() //@signature("(", "baz(at AliasType, b bool)", 0) - - bar(nil) //@snippet("(", snipBar, "bar", "bar") - bar(ba) //@snippet(")", snipBar, "bar(${1:})", "bar(${1:fn func()})") - var f Foo - bar(f.Ba) //@snippet(")", snipMethodBaz, "Baz()", "Baz()") - (bar)(nil) //@snippet(")", snipBar, "bar(${1:})", "bar(${1:fn func()})") - (f.Ba)() //@snippet(")", snipMethodBaz, "Baz()", "Baz()") - - Foo{ - B //@snippet(" //", snipFieldBar, "Bar: ${1:},", "Bar: ${1:int},") - } - - Foo{ - F //@snippet(" //", snipFieldFunc, "Func: ${1:},", "Func: ${1:func(at AliasType) error},") - } - - Foo{B} //@snippet("}", snipFieldBar, "Bar: ${1:}", "Bar: ${1:int}") - Foo{} //@snippet("}", snipFieldBar, "Bar: ${1:}", "Bar: ${1:int}") - - Foo{Foo{}.B} //@snippet("} ", snipFieldBar, "Bar", "Bar") - - var err error - err.Error() //@snippet("E", Error, "Error()", "Error()") - f.Baz() //@snippet("B", snipMethodBaz, "Baz()", "Baz()") - - f.Baz() //@snippet("(", snipMethodBazBar, "BazBar", "BazBar") - - f.Baz() //@snippet("B", snipMethodBazBaz, "BazBaz(${1:})", "BazBaz(${1:at AliasType})") -} - -func _() { - type bar struct { - a int - b float64 //@item(snipBarB, "b", "float64", "field") - } - bar{b} //@snippet("}", snipBarB, "b: ${1:}", "b: ${1:float64}") -} |