diff --git a/internal/lsp/call_hierarchy.go b/internal/lsp/call_hierarchy.go index f9307d7016..43c4ea8d5b 100644 --- a/internal/lsp/call_hierarchy.go +++ b/internal/lsp/call_hierarchy.go @@ -12,7 +12,8 @@ import ( ) func (s *Server) prepareCallHierarchy(ctx context.Context, params *protocol.CallHierarchyPrepareParams) ([]protocol.CallHierarchyItem, error) { - snapshot, fh, ok, err := s.beginFileRequest(ctx, params.TextDocument.URI, source.Go) + snapshot, fh, ok, release, err := s.beginFileRequest(ctx, params.TextDocument.URI, source.Go) + defer release() if !ok { return nil, err } @@ -21,7 +22,8 @@ func (s *Server) prepareCallHierarchy(ctx context.Context, params *protocol.Call } func (s *Server) incomingCalls(ctx context.Context, params *protocol.CallHierarchyIncomingCallsParams) ([]protocol.CallHierarchyIncomingCall, error) { - snapshot, fh, ok, err := s.beginFileRequest(ctx, params.Item.URI, source.Go) + snapshot, fh, ok, release, err := s.beginFileRequest(ctx, params.Item.URI, source.Go) + defer release() if !ok { return nil, err } @@ -30,7 +32,8 @@ func (s *Server) incomingCalls(ctx context.Context, params *protocol.CallHierarc } func (s *Server) outgoingCalls(ctx context.Context, params *protocol.CallHierarchyOutgoingCallsParams) ([]protocol.CallHierarchyOutgoingCall, error) { - snapshot, fh, ok, err := s.beginFileRequest(ctx, params.Item.URI, source.Go) + snapshot, fh, ok, release, err := s.beginFileRequest(ctx, params.Item.URI, source.Go) + defer release() if !ok { return nil, err } diff --git a/internal/lsp/source/source_test.go b/internal/lsp/source/source_test.go index c8e4d99c18..76fce9bb31 100644 --- a/internal/lsp/source/source_test.go +++ b/internal/lsp/source/source_test.go @@ -105,12 +105,12 @@ func (r *runner) CallHierarchy(t *testing.T, spn span.Span, expectedCalls *tests if err != nil { t.Fatalf("failed for %v: %v", spn, err) } - fh, err := r.view.Snapshot().GetFile(r.ctx, spn.URI()) + fh, err := r.snapshot.GetFile(r.ctx, spn.URI()) if err != nil { t.Fatal(err) } - items, err := source.PrepareCallHierarchy(r.ctx, r.view.Snapshot(), fh, loc.Range.Start) + items, err := source.PrepareCallHierarchy(r.ctx, r.snapshot, fh, loc.Range.Start) if err != nil { t.Fatal(err) } @@ -127,11 +127,11 @@ func (r *runner) CallHierarchy(t *testing.T, spn span.Span, expectedCalls *tests } // TODO: add span comparison tests for expectedCalls once call hierarchy is implemented - incomingCalls, err := source.IncomingCalls(r.ctx, r.view.Snapshot(), fh, loc.Range.Start) + incomingCalls, err := source.IncomingCalls(r.ctx, r.snapshot, fh, loc.Range.Start) if len(incomingCalls) != 0 { t.Errorf("expected no incoming calls but got %d", len(incomingCalls)) } - outgoingCalls, err := source.OutgoingCalls(r.ctx, r.view.Snapshot(), fh, loc.Range.Start) + outgoingCalls, err := source.OutgoingCalls(r.ctx, r.snapshot, fh, loc.Range.Start) if len(outgoingCalls) != 0 { t.Errorf("expected no outgoing calls but got %d", len(outgoingCalls)) }