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