Skip to content

Commit 8fe064f

Browse files
committed
internal/lsp/protocol: actually handle cancellation delivery
CL 215738 didn't work because the canceller was embedded in the serverHandler, which already had a Deliver method. Add it as an actual handler instead. Change-Id: I0c79f1bee67aa3b4da53d92547804de859f1938c Reviewed-on: https://go-review.googlesource.com/c/tools/+/216303 Run-TryBot: Heschi Kreinick <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent bdfa187 commit 8fe064f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

internal/jsonrpc2/jsonrpc2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func (r *Request) Reply(ctx context.Context, result interface{}, err error) erro
233233
return fmt.Errorf("reply invoked more than once")
234234
}
235235
if r.IsNotify() {
236-
return fmt.Errorf("reply not invoked with a valid call")
236+
return fmt.Errorf("reply not invoked with a valid call: %v, %s", r.Method, r.Params)
237237
}
238238
// reply ends the handling phase of a call, so if we are not yet
239239
// parallel we should be now. The go routine is allowed to continue

internal/lsp/protocol/protocol.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ const (
2323
type canceller struct{ jsonrpc2.EmptyHandler }
2424

2525
type clientHandler struct {
26-
canceller
26+
jsonrpc2.EmptyHandler
2727
client Client
2828
}
2929

3030
type serverHandler struct {
31-
canceller
31+
jsonrpc2.EmptyHandler
3232
server Server
3333
}
3434

@@ -73,6 +73,7 @@ func NewClient(ctx context.Context, stream jsonrpc2.Stream, client Client) (cont
7373
ctx = WithClient(ctx, client)
7474
conn := jsonrpc2.NewConn(stream)
7575
conn.AddHandler(&clientHandler{client: client})
76+
conn.AddHandler(&canceller{})
7677
return ctx, conn, &serverDispatcher{Conn: conn}
7778
}
7879

@@ -81,6 +82,7 @@ func NewServer(ctx context.Context, stream jsonrpc2.Stream, server Server) (cont
8182
client := &clientDispatcher{Conn: conn}
8283
ctx = WithClient(ctx, client)
8384
conn.AddHandler(&serverHandler{server: server})
85+
conn.AddHandler(&canceller{})
8486
return ctx, conn, client
8587
}
8688

0 commit comments

Comments
 (0)