golang.org/x/tools/gopls@v0.15.3/internal/server/signature_help.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package server 6 7 import ( 8 "context" 9 10 "golang.org/x/tools/gopls/internal/file" 11 "golang.org/x/tools/gopls/internal/golang" 12 "golang.org/x/tools/gopls/internal/protocol" 13 "golang.org/x/tools/internal/event" 14 "golang.org/x/tools/internal/event/tag" 15 ) 16 17 func (s *server) SignatureHelp(ctx context.Context, params *protocol.SignatureHelpParams) (*protocol.SignatureHelp, error) { 18 ctx, done := event.Start(ctx, "lsp.Server.signatureHelp", tag.URI.Of(params.TextDocument.URI)) 19 defer done() 20 21 fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI) 22 if err != nil { 23 return nil, err 24 } 25 defer release() 26 27 if snapshot.FileKind(fh) != file.Go { 28 return nil, nil // empty result 29 } 30 31 info, activeParameter, err := golang.SignatureHelp(ctx, snapshot, fh, params.Position) 32 if err != nil { 33 event.Error(ctx, "no signature help", err, tag.Position.Of(params.Position)) 34 return nil, nil // sic? There could be many reasons for failure. 35 } 36 return &protocol.SignatureHelp{ 37 Signatures: []protocol.SignatureInformation{*info}, 38 ActiveParameter: uint32(activeParameter), 39 }, nil 40 }