blob: 79eeb25cc1520c495c51c91e0ebd8213aad12030 [file] [log] [blame]
Robert Findleyb15dac22022-08-30 14:40:12 -04001// Copyright 2020 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
5package lsp
6
7import (
8 "context"
9
10 "golang.org/x/tools/gopls/internal/lsp/protocol"
11 "golang.org/x/tools/gopls/internal/lsp/source"
12)
13
14func (s *Server) prepareCallHierarchy(ctx context.Context, params *protocol.CallHierarchyPrepareParams) ([]protocol.CallHierarchyItem, error) {
15 snapshot, fh, ok, release, err := s.beginFileRequest(ctx, params.TextDocument.URI, source.Go)
16 defer release()
17 if !ok {
18 return nil, err
19 }
20
21 return source.PrepareCallHierarchy(ctx, snapshot, fh, params.Position)
22}
23
24func (s *Server) incomingCalls(ctx context.Context, params *protocol.CallHierarchyIncomingCallsParams) ([]protocol.CallHierarchyIncomingCall, error) {
25 snapshot, fh, ok, release, err := s.beginFileRequest(ctx, params.Item.URI, source.Go)
26 defer release()
27 if !ok {
28 return nil, err
29 }
30
31 return source.IncomingCalls(ctx, snapshot, fh, params.Item.Range.Start)
32}
33
34func (s *Server) outgoingCalls(ctx context.Context, params *protocol.CallHierarchyOutgoingCallsParams) ([]protocol.CallHierarchyOutgoingCall, error) {
35 snapshot, fh, ok, release, err := s.beginFileRequest(ctx, params.Item.URI, source.Go)
36 defer release()
37 if !ok {
38 return nil, err
39 }
40
41 return source.OutgoingCalls(ctx, snapshot, fh, params.Item.Range.Start)
42}