golang.org/x/tools/gopls@v0.15.3/internal/server/implementation.go (about) 1 // Copyright 2019 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/gopls/internal/telemetry" 14 "golang.org/x/tools/internal/event" 15 "golang.org/x/tools/internal/event/tag" 16 ) 17 18 func (s *server) Implementation(ctx context.Context, params *protocol.ImplementationParams) (_ []protocol.Location, rerr error) { 19 recordLatency := telemetry.StartLatencyTimer("implementation") 20 defer func() { 21 recordLatency(ctx, rerr) 22 }() 23 24 ctx, done := event.Start(ctx, "lsp.Server.implementation", tag.URI.Of(params.TextDocument.URI)) 25 defer done() 26 27 fh, snapshot, release, err := s.fileOf(ctx, params.TextDocument.URI) 28 if err != nil { 29 return nil, err 30 } 31 defer release() 32 if snapshot.FileKind(fh) != file.Go { 33 return nil, nil // empty result 34 } 35 return golang.Implementation(ctx, snapshot, fh, params.Position) 36 }