golang.org/x/tools/gopls@v0.15.3/internal/server/inlay_hint.go (about) 1 // Copyright 2022 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/mod" 13 "golang.org/x/tools/gopls/internal/protocol" 14 "golang.org/x/tools/internal/event" 15 "golang.org/x/tools/internal/event/tag" 16 ) 17 18 func (s *server) InlayHint(ctx context.Context, params *protocol.InlayHintParams) ([]protocol.InlayHint, error) { 19 ctx, done := event.Start(ctx, "lsp.Server.inlayHint", tag.URI.Of(params.TextDocument.URI)) 20 defer done() 21 22 fh, snapshot, release, err := s.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 // empty result 35 }