2018-11-12 14:53:10 -07:00
|
|
|
// Copyright 2018 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package lsp
|
|
|
|
|
|
|
|
import (
|
2019-04-17 13:37:20 -06:00
|
|
|
"context"
|
|
|
|
|
2020-04-17 07:32:56 -06:00
|
|
|
"golang.org/x/tools/internal/event"
|
2020-03-10 21:25:10 -06:00
|
|
|
"golang.org/x/tools/internal/lsp/debug/tag"
|
2018-11-12 14:53:10 -07:00
|
|
|
"golang.org/x/tools/internal/lsp/protocol"
|
|
|
|
"golang.org/x/tools/internal/lsp/source"
|
|
|
|
)
|
|
|
|
|
2019-09-07 15:01:26 -06:00
|
|
|
func (s *Server) signatureHelp(ctx context.Context, params *protocol.SignatureHelpParams) (*protocol.SignatureHelp, error) {
|
2020-07-02 16:34:10 -06:00
|
|
|
snapshot, fh, ok, release, err := s.beginFileRequest(ctx, params.TextDocument.URI, source.Go)
|
|
|
|
defer release()
|
2020-02-13 11:46:49 -07:00
|
|
|
if !ok {
|
2019-08-16 11:49:17 -06:00
|
|
|
return nil, err
|
|
|
|
}
|
2020-02-04 20:44:33 -07:00
|
|
|
info, activeParameter, err := source.SignatureHelp(ctx, snapshot, fh, params.Position)
|
2019-04-17 13:37:20 -06:00
|
|
|
if err != nil {
|
2020-04-20 19:50:02 -06:00
|
|
|
event.Error(ctx, "no signature help", err, tag.Position.Of(params.Position))
|
2019-06-07 20:07:33 -06:00
|
|
|
return nil, nil
|
2019-04-17 13:37:20 -06:00
|
|
|
}
|
2018-11-12 14:53:10 -07:00
|
|
|
return &protocol.SignatureHelp{
|
2020-02-04 20:44:33 -07:00
|
|
|
Signatures: []protocol.SignatureInformation{*info},
|
|
|
|
ActiveParameter: float64(activeParameter),
|
|
|
|
}, nil
|
2018-11-12 14:53:10 -07:00
|
|
|
}
|