| 1 |
|
| 2 |
|
| 3 |
|
| 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/label" |
| 13 |
"golang.org/x/tools/gopls/internal/protocol" |
| 14 |
"golang.org/x/tools/gopls/internal/telemetry" |
| 15 |
"golang.org/x/tools/internal/event" |
| 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, "server.Implementation", label.URI.Of(params.TextDocument.URI)) |
| 25 |
defer done() |
| 26 |
|
| 27 |
fh, snapshot, release, err := s.session.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 |
| 34 |
} |
| 35 |
return golang.Implementation(ctx, snapshot, fh, params.Range) |
| 36 |
} |