mirror of
https://github.com/golang/go
synced 2024-11-18 15:04:44 -07:00
6224300ba8
We should just use the protocol.SignatureInformation type, as it's essentially the same thing. Refactor tests a bit to make use of the shared type. Change-Id: I169949f6e23757ce0a6f54de36560c4c8e0479ad Reviewed-on: https://go-review.googlesource.com/c/tools/+/217731 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
// 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"
|
|
|
|
"golang.org/x/tools/internal/lsp/protocol"
|
|
"golang.org/x/tools/internal/lsp/source"
|
|
"golang.org/x/tools/internal/span"
|
|
"golang.org/x/tools/internal/telemetry/log"
|
|
"golang.org/x/tools/internal/telemetry/tag"
|
|
)
|
|
|
|
func (s *Server) signatureHelp(ctx context.Context, params *protocol.SignatureHelpParams) (*protocol.SignatureHelp, error) {
|
|
uri := span.NewURI(params.TextDocument.URI)
|
|
view, err := s.session.ViewOf(uri)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
snapshot := view.Snapshot()
|
|
fh, err := snapshot.GetFile(uri)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if fh.Identity().Kind != source.Go {
|
|
return nil, nil
|
|
}
|
|
info, activeParameter, err := source.SignatureHelp(ctx, snapshot, fh, params.Position)
|
|
if err != nil {
|
|
log.Print(ctx, "no signature help", tag.Of("At", params.Position), tag.Of("Failure", err))
|
|
return nil, nil
|
|
}
|
|
return &protocol.SignatureHelp{
|
|
Signatures: []protocol.SignatureInformation{*info},
|
|
ActiveParameter: float64(activeParameter),
|
|
}, nil
|
|
}
|