mirror of https://github.com/golang/go.git
internal/lsp: release resources for call hierarchy file requests
* adds call to release resources for beginFileRequest in lsp/call_hierarchy.go * fixes source_test Change-Id: Id45f61ccd474a2df9f46be89fdb059cfe8584f0c Reviewed-on: https://go-review.googlesource.com/c/tools/+/247497 Run-TryBot: Danish Dua <danishdua@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
a5d4502270
commit
9221131678
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue