mirror of
https://github.com/golang/go.git
synced 2025-05-07 16:43:03 +00:00
We were omitting the parens in function completions like "(foo<>)()" because our check thought "foo" was the Fun in the outer CallExpr so it already had parens. Fix by tightening up logic to only omit parens for cases like "foo<>()" and "foo.bar<>()". Change-Id: Ia602b80275f72baa6cdf6d61c22d3f3a6cfc3019 GitHub-Last-Rev: 41fecf92617e0812ee6552d8c43789eae83889bd GitHub-Pull-Request: golang/tools#98 Reviewed-on: https://go-review.googlesource.com/c/tools/+/176944 Reviewed-by: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
33 lines
1.1 KiB
Go
33 lines
1.1 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()", "field")
|
|
|
|
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", "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{B} //@snippet("}", snipFieldBar, "Bar: ${1}", "Bar: ${1:int}")
|
|
Foo{} //@snippet("}", snipFieldBar, "Bar: ${1}", "Bar: ${1:int}")
|
|
|
|
Foo{Foo{}.B} //@snippet("} ", snipFieldBar, "Bar", "Bar")
|
|
}
|