| 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/mod" |
| 14 |
"golang.org/x/tools/gopls/internal/protocol" |
| 15 |
"golang.org/x/tools/internal/event" |
| 16 |
) |
| 17 |
|
| 18 |
func (s *server) InlayHint(ctx context.Context, params *protocol.InlayHintParams) ([]protocol.InlayHint, error) { |
| 19 |
ctx, done := event.Start(ctx, "server.InlayHint", label.URI.Of(params.TextDocument.URI)) |
| 20 |
defer done() |
| 21 |
|
| 22 |
fh, snapshot, release, err := s.session.FileOf(ctx, params.TextDocument.URI) |
| 23 |
if err != nil { |
| 24 |
return nil, err |
| 25 |
} |
| 26 |
defer release() |
| 27 |
|
| 28 |
switch snapshot.FileKind(fh) { |
| 29 |
case file.Mod: |
| 30 |
return mod.InlayHint(ctx, snapshot, fh, params.Range) |
| 31 |
case file.Go: |
| 32 |
return golang.InlayHint(ctx, snapshot, fh, params.Range) |
| 33 |
} |
| 34 |
return nil, nil |
| 35 |
} |