github.com/v2fly/tools@v0.100.0/internal/lsp/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 lsp 6 7 import ( 8 "context" 9 10 "github.com/v2fly/tools/internal/event" 11 "github.com/v2fly/tools/internal/lsp/debug/tag" 12 "github.com/v2fly/tools/internal/lsp/protocol" 13 "github.com/v2fly/tools/internal/lsp/source" 14 ) 15 16 func (s *Server) signatureHelp(ctx context.Context, params *protocol.SignatureHelpParams) (*protocol.SignatureHelp, error) { 17 snapshot, fh, ok, release, err := s.beginFileRequest(ctx, params.TextDocument.URI, source.Go) 18 defer release() 19 if !ok { 20 return nil, err 21 } 22 info, activeParameter, err := source.SignatureHelp(ctx, snapshot, fh, params.Position) 23 if err != nil { 24 event.Error(ctx, "no signature help", err, tag.Position.Of(params.Position)) 25 return nil, nil 26 } 27 return &protocol.SignatureHelp{ 28 Signatures: []protocol.SignatureInformation{*info}, 29 ActiveParameter: uint32(activeParameter), 30 }, nil 31 }