Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/lsp/source/signature_help.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ FindCall:
// which may be the parameter to the *ast.CallExpr.
// Don't show signature help in this case.
return nil, 0, errors.Errorf("no signature help within a function declaration")
case *ast.BasicLit:
if node.Kind == token.STRING {
return nil, 0, errors.Errorf("no signature help within a string literal")
}
}

}
if callExpr == nil || callExpr.Fun == nil {
return nil, 0, errors.Errorf("cannot find an enclosing function")
Expand Down
9 changes: 5 additions & 4 deletions internal/lsp/testdata/signature/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ func Qux() {
return func(int) rune { return 0 }
}

fn("hi", "there") //@signature("hi", "fn(hi string, there string) func(i int) rune", 0)
fn("hi", "there") //@signature("hi", "", 0)
fn("hi", "there") //@signature(",", "fn(hi string, there string) func(i int) rune", 0)
fn("hi", "there")(1) //@signature("1", "func(i int) rune", 0)

fnPtr := &fn
(*fnPtr)("hi", "there") //@signature("hi", "func(hi string, there string) func(i int) rune", 0)
(*fnPtr)("hi", "there") //@signature(",", "func(hi string, there string) func(i int) rune", 0)

var fnIntf interface{} = Foo
fnIntf.(func(string, int) bool)("hi", 123) //@signature("123", "func(string, int) bool", 1)
Expand All @@ -69,8 +70,8 @@ func Qux() {
Foo(myFunc(123), 456) //@signature("myFunc", "Foo(a string, b int) (c bool)", 0)
Foo(myFunc(123), 456) //@signature("123", "myFunc(foo int) string", 0)

panic("oops!") //@signature("oops", "panic(v interface{})", 0)
println("hello", "world") //@signature("world", "println(args ...Type)", 0)
panic("oops!") //@signature(")", "panic(v interface{})", 0)
println("hello", "world") //@signature(",", "println(args ...Type)", 0)

Hello(func() {
//@signature("//", "", 0)
Expand Down
2 changes: 1 addition & 1 deletion internal/lsp/testdata/summary.txt.golden
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RenamesCount = 33
PrepareRenamesCount = 7
SymbolsCount = 5
WorkspaceSymbolsCount = 20
SignaturesCount = 32
SignaturesCount = 33
LinksCount = 7
ImplementationsCount = 14