github.com/powerman/golang-tools@v0.1.11-0.20220410185822-5ad214d8d803/internal/lsp/hover.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 lsp 6 7 import ( 8 "context" 9 10 "github.com/powerman/golang-tools/internal/lsp/mod" 11 "github.com/powerman/golang-tools/internal/lsp/protocol" 12 "github.com/powerman/golang-tools/internal/lsp/source" 13 "github.com/powerman/golang-tools/internal/lsp/template" 14 "github.com/powerman/golang-tools/internal/lsp/work" 15 ) 16 17 func (s *Server) hover(ctx context.Context, params *protocol.HoverParams) (*protocol.Hover, error) { 18 snapshot, fh, ok, release, err := s.beginFileRequest(ctx, params.TextDocument.URI, source.UnknownKind) 19 defer release() 20 if !ok { 21 return nil, err 22 } 23 switch snapshot.View().FileKind(fh) { 24 case source.Mod: 25 return mod.Hover(ctx, snapshot, fh, params.Position) 26 case source.Go: 27 return source.Hover(ctx, snapshot, fh, params.Position) 28 case source.Tmpl: 29 return template.Hover(ctx, snapshot, fh, params.Position) 30 case source.Work: 31 return work.Hover(ctx, snapshot, fh, params.Position) 32 } 33 return nil, nil 34 }