mirror of
https://github.com/golang/go
synced 2024-11-19 06:44:41 -07:00
473d3dc1d7
This change handles the case when a function that has already been written out is being completed. Change-Id: I0c4e9ec9bb5a8428526f00a4e62e020bcc30f0bf Reviewed-on: https://go-review.googlesource.com/c/tools/+/176923 Run-TryBot: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
41 lines
1.4 KiB
Go
41 lines
1.4 KiB
Go
package snippets
|
|
|
|
func foo(i int, b bool) {} //@item(snipFoo, "foo(i int, b bool)", "", "func")
|
|
func bar(fn func()) func() {} //@item(snipBar, "bar(fn func())", "", "func")
|
|
|
|
type Foo struct {
|
|
Bar int //@item(snipFieldBar, "Bar", "int", "field")
|
|
}
|
|
|
|
func (Foo) Baz() func() {} //@item(snipMethodBaz, "Baz()", "func()", "method")
|
|
func (Foo) BazBar() func() {} //@item(snipMethodBazBar, "BazBar()", "func()", "method")
|
|
|
|
func _() {
|
|
f //@snippet(" //", snipFoo, "foo(${1})", "foo(${1:i int}, ${2:b bool})")
|
|
|
|
bar //@snippet(" //", snipBar, "bar(${1})", "bar(${1:fn func()})")
|
|
|
|
bar(nil) //@snippet("(", snipBar, "", "")
|
|
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{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, "", "")
|
|
f.Baz() //@snippet("B", snipMethodBaz, "", "")
|
|
|
|
// TODO(rstambler): Handle this case correctly.
|
|
f.Baz() //@fails("(", snipMethodBazBar, "Bar", "Bar")
|
|
}
|