| 1 | // Copyright 2018 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 jsonrpc2_testscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/ |
| 6 | |
| 7 | import ( |
| 8 | "contextscip-go gomod github.com/golang/go/src go1.25.0 context/" |
| 9 | "encoding/jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/" |
| 10 | "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/" |
| 11 | "pathscip-go gomod github.com/golang/go/src go1.25.0 path/" |
| 12 | "reflectscip-go gomod github.com/golang/go/src go1.25.0 reflect/" |
| 13 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 14 | |
| 15 | jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ "golang.org/x/tools/internal/jsonrpc2_v2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/" |
| 16 | ) |
| 17 | |
| 18 | var callTestsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/callTests. = []invokerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/invoker#{ |
| 19 | callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#{"no_args", nil, true}, |
| 20 | callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#{"one_string", "fish", "got:fish"}, |
| 21 | callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#{"one_number", 10, "got:10"}, |
| 22 | callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#{"join", []string{"a", "b", "c"}, "a/b/c"}, |
| 23 | sequencescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/sequence#{"notify", []invokerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/invoker#{ |
| 24 | notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#{"set", 3}, |
| 25 | notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#{"add", 5}, |
| 26 | callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#{"get", nil, 8}, |
| 27 | }}, |
| 28 | sequencescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/sequence#{"preempt", []invokerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/invoker#{ |
| 29 | asyncscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#{"a", "wait", "a"}, |
| 30 | notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#{"unblock", "a"}, |
| 31 | collectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#{"a", true, false}, |
| 32 | }}, |
| 33 | sequencescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/sequence#{"basic cancel", []invokerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/invoker#{ |
| 34 | asyncscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#{"b", "wait", "b"}, |
| 35 | cancelscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/cancel#{"b"}, |
| 36 | collectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#{"b", nil, true}, |
| 37 | }}, |
| 38 | sequencescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/sequence#{"queue", []invokerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/invoker#{ |
| 39 | asyncscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#{"a", "wait", "a"}, |
| 40 | notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#{"set", 1}, |
| 41 | notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#{"add", 2}, |
| 42 | notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#{"add", 3}, |
| 43 | notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#{"add", 4}, |
| 44 | callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#{"peek", nil, 0}, // accumulator will not have any adds yet |
| 45 | notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#{"unblock", "a"}, |
| 46 | collectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#{"a", true, false}, |
| 47 | callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#{"get", nil, 10}, // accumulator now has all the adds |
| 48 | }}, |
| 49 | sequencescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/sequence#{"fork", []invokerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/invoker#{ |
| 50 | asyncscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#{"a", "fork", "a"}, |
| 51 | notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#{"set", 1}, |
| 52 | notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#{"add", 2}, |
| 53 | notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#{"add", 3}, |
| 54 | notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#{"add", 4}, |
| 55 | callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#{"get", nil, 10}, // fork will not have blocked the adds |
| 56 | notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#{"unblock", "a"}, |
| 57 | collectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#{"a", true, false}, |
| 58 | }}, |
| 59 | sequencescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/sequence#{"concurrent", []invokerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/invoker#{ |
| 60 | asyncscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#{"a", "fork", "a"}, |
| 61 | notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#{"unblock", "a"}, |
| 62 | asyncscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#{"b", "fork", "b"}, |
| 63 | notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#{"unblock", "b"}, |
| 64 | collectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#{"a", true, false}, |
| 65 | collectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#{"b", true, false}, |
| 66 | }}, |
| 67 | } |
| 68 | |
| 69 | type binderscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/binder# struct { |
| 70 | framerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/binder#framer. jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.Framerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Framer# |
| 71 | runTestscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/binder#runTest. func(*handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#) |
| 72 | } |
| 73 | |
| 74 | type handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler# struct { |
| 75 | connscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#conn. *jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.Connectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Connection# |
| 76 | accumulatorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#accumulator. int |
| 77 | waitersscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#waiters. chan map[string]chan struct{} |
| 78 | callsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#calls. map[string]*jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.AsyncCallscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/AsyncCall# |
| 79 | } |
| 80 | |
| 81 | type invokerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/invoker# interface { |
| 82 | Namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/invoker#Name.() string |
| 83 | Invokescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/invoker#Invoke.(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#, ctx contextscip-go gomod github.com/golang/go/src go1.25.0 context/.Contextscip-go gomod github.com/golang/go/src go1.25.0 context/Context#, h *handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#) |
| 84 | } |
| 85 | |
| 86 | type notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify# struct { |
| 87 | methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#method. string |
| 88 | paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#params. any |
| 89 | } |
| 90 | |
| 91 | type callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call# struct { |
| 92 | methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#method. string |
| 93 | paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#params. any |
| 94 | expectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#expect. any |
| 95 | } |
| 96 | |
| 97 | type asyncscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async# struct { |
| 98 | namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#name. string |
| 99 | methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#method. string |
| 100 | paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#params. any |
| 101 | } |
| 102 | |
| 103 | type collectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect# struct { |
| 104 | namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#name. string |
| 105 | expectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#expect. any |
| 106 | failsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#fails. bool |
| 107 | } |
| 108 | |
| 109 | type cancelscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/cancel# struct { |
| 110 | namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/cancel#name. string |
| 111 | } |
| 112 | |
| 113 | type sequencescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/sequence# struct { |
| 114 | namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/sequence#name. string |
| 115 | testsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/sequence#tests. []invokerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/invoker# |
| 116 | } |
| 117 | |
| 118 | type echoscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/echo# callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call# |
| 119 | |
| 120 | type cancelParamsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/cancelParams# struct{ IDscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/cancelParams#ID. int64 } |
| 121 | |
| 122 | func TestConnectionRawscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/TestConnectionRaw().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 123 | testConnectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/testConnection().(t, jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.RawFramerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/RawFramer().()) |
| 124 | } |
| 125 | |
| 126 | func TestConnectionHeaderscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/TestConnectionHeader().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 127 | testConnectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/testConnection().(t, jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.HeaderFramerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/HeaderFramer().()) |
| 128 | } |
| 129 | |
| 130 | func testConnectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/testConnection().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#, framer jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.Framerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Framer#) { |
| 131 | ctx := contextscip-go gomod github.com/golang/go/src go1.25.0 context/.Backgroundscip-go gomod github.com/golang/go/src go1.25.0 context/Background().() |
| 132 | listener, err := jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.NetPipeListenerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/NetPipeListener().(ctx) |
| 133 | if err != nil { |
| 134 | t.Fatalscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatal().(err) |
| 135 | } |
| 136 | server := jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.NewServerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/NewServer().(ctx, listener, binderscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/binder#{framer, nil}) |
| 137 | defer func() { |
| 138 | listener.Closescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Listener#Close.() |
| 139 | server.Waitscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Server#Wait().() |
| 140 | }() |
| 141 | |
| 142 | for _, test := range callTestsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/callTests. { |
| 143 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(test.Namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/invoker#Name.(), func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 144 | client, err := jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.Dialscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Dial().(ctx, |
| 145 | listener.Dialerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Listener#Dialer.(), binderscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/binder#{framer, func(h *handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#) { |
| 146 | defer h.connscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#conn..Closescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Connection#Close().() |
| 147 | test.Invokescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/invoker#Invoke.(t, ctx, h) |
| 148 | if call, ok := test.(*callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#); ok { |
| 149 | // also run all simple call tests in echo mode |
| 150 | (*echoscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/echo#)(call).Invokescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/echo#Invoke().(t, ctx, h) |
| 151 | } |
| 152 | }}, nil) |
| 153 | if err != nil { |
| 154 | t.Fatalscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatal().(err) |
| 155 | } |
| 156 | client.Waitscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Connection#Wait().() |
| 157 | }) |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | func (test notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#) Namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#Name().() string { return test.methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#method. } |
| 162 | func (test notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#) Invokescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#Invoke().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#, ctx contextscip-go gomod github.com/golang/go/src go1.25.0 context/.Contextscip-go gomod github.com/golang/go/src go1.25.0 context/Context#, h *handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#) { |
| 163 | if err := h.connscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#conn..Notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Connection#Notify().(ctx, test.methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#method., test.paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#params.); err != nil { |
| 164 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("%v:Notify failed: %v", test.methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/notify#method., err) |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | func (test callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#) Namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#Name().() string { return test.methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#method. } |
| 169 | func (test callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#) Invokescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#Invoke().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#, ctx contextscip-go gomod github.com/golang/go/src go1.25.0 context/.Contextscip-go gomod github.com/golang/go/src go1.25.0 context/Context#, h *handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#) { |
| 170 | results := newResultsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/newResults().(test.expectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#expect.) |
| 171 | if err := h.connscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#conn..Callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Connection#Call().(ctx, test.methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#method., test.paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#params.).Awaitscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/AsyncCall#Await().(ctx, results); err != nil { |
| 172 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("%v:Call failed: %v", test.methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#method., err) |
| 173 | } |
| 174 | verifyResultsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/verifyResults().(t, test.methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#method., results, test.expectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#expect.) |
| 175 | } |
| 176 | |
| 177 | func (test echoscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/echo#) Invokescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/echo#Invoke().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#, ctx contextscip-go gomod github.com/golang/go/src go1.25.0 context/.Contextscip-go gomod github.com/golang/go/src go1.25.0 context/Context#, h *handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#) { |
| 178 | results := newResultsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/newResults().(test.expectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#expect.) |
| 179 | if err := h.connscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#conn..Callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Connection#Call().(ctx, "echo", []any{test.methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#method., test.paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#params.}).Awaitscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/AsyncCall#Await().(ctx, results); err != nil { |
| 180 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("%v:Echo failed: %v", test.methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#method., err) |
| 181 | } |
| 182 | verifyResultsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/verifyResults().(t, test.methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#method., results, test.expectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/call#expect.) |
| 183 | } |
| 184 | |
| 185 | func (test asyncscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#) Namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#Name().() string { return test.namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#name. } |
| 186 | func (test asyncscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#) Invokescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#Invoke().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#, ctx contextscip-go gomod github.com/golang/go/src go1.25.0 context/.Contextscip-go gomod github.com/golang/go/src go1.25.0 context/Context#, h *handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#) { |
| 187 | h.callsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#calls.[test.namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#name.] = h.connscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#conn..Callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Connection#Call().(ctx, test.methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#method., test.paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/async#params.) |
| 188 | } |
| 189 | |
| 190 | func (test collectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#) Namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#Name().() string { return test.namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#name. } |
| 191 | func (test collectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#) Invokescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#Invoke().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#, ctx contextscip-go gomod github.com/golang/go/src go1.25.0 context/.Contextscip-go gomod github.com/golang/go/src go1.25.0 context/Context#, h *handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#) { |
| 192 | o := h.callsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#calls.[test.namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#name.] |
| 193 | results := newResultsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/newResults().(test.expectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#expect.) |
| 194 | err := o.Awaitscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/AsyncCall#Await().(ctx, results) |
| 195 | switch { |
| 196 | case test.failsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#fails. && err == nil: |
| 197 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("%v:Collect was supposed to fail", test.namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#name.) |
| 198 | case !test.failsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#fails. && err != nil: |
| 199 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("%v:Collect failed: %v", test.namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#name., err) |
| 200 | } |
| 201 | verifyResultsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/verifyResults().(t, test.namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#name., results, test.expectscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/collect#expect.) |
| 202 | } |
| 203 | |
| 204 | func (test cancelscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/cancel#) Namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/cancel#Name().() string { return test.namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/cancel#name. } |
| 205 | func (test cancelscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/cancel#) Invokescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/cancel#Invoke().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#, ctx contextscip-go gomod github.com/golang/go/src go1.25.0 context/.Contextscip-go gomod github.com/golang/go/src go1.25.0 context/Context#, h *handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#) { |
| 206 | o := h.callsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#calls.[test.namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/cancel#name.] |
| 207 | if err := h.connscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#conn..Notifyscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Connection#Notify().(ctx, "cancel", &cancelParamsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/cancelParams#{o.IDscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/AsyncCall#ID().().Rawscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ID#Raw().().(int64)}); err != nil { |
| 208 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("%v:Collect failed: %v", test.namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/cancel#name., err) |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | func (test sequencescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/sequence#) Namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/sequence#Name().() string { return test.namescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/sequence#name. } |
| 213 | func (test sequencescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/sequence#) Invokescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/sequence#Invoke().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#, ctx contextscip-go gomod github.com/golang/go/src go1.25.0 context/.Contextscip-go gomod github.com/golang/go/src go1.25.0 context/Context#, h *handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#) { |
| 214 | for _, child := range test.testsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/sequence#tests. { |
| 215 | child.Invokescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/invoker#Invoke.(t, ctx, h) |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | // newResults makes a new empty copy of the expected type to put the results into |
| 220 | func newResultsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/newResults().(expect any) any { |
| 221 | switch e := expect.(type) { |
| 222 | case []any: |
| 223 | var r []any |
| 224 | for _, v := range e { |
| 225 | r = append(r, reflectscip-go gomod github.com/golang/go/src go1.25.0 reflect/.Newscip-go gomod github.com/golang/go/src go1.25.0 reflect/New().(reflectscip-go gomod github.com/golang/go/src go1.25.0 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.25.0 reflect/TypeOf().(v)).Interfacescip-go gomod github.com/golang/go/src go1.25.0 reflect/Value#Interface().()) |
| 226 | } |
| 227 | return r |
| 228 | case nil: |
| 229 | return nil |
| 230 | default: |
| 231 | return reflectscip-go gomod github.com/golang/go/src go1.25.0 reflect/.Newscip-go gomod github.com/golang/go/src go1.25.0 reflect/New().(reflectscip-go gomod github.com/golang/go/src go1.25.0 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.25.0 reflect/TypeOf().(expect)).Interfacescip-go gomod github.com/golang/go/src go1.25.0 reflect/Value#Interface().() |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | // verifyResults compares the results to the expected values |
| 236 | func verifyResultsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/verifyResults().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#, method string, results any, expect any) { |
| 237 | if expect == nil { |
| 238 | if results != nil { |
| 239 | t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("%v:Got results %+v where none expected", method, expect) |
| 240 | } |
| 241 | return |
| 242 | } |
| 243 | val := reflectscip-go gomod github.com/golang/go/src go1.25.0 reflect/.Indirectscip-go gomod github.com/golang/go/src go1.25.0 reflect/Indirect().(reflectscip-go gomod github.com/golang/go/src go1.25.0 reflect/.ValueOfscip-go gomod github.com/golang/go/src go1.25.0 reflect/ValueOf().(results)).Interfacescip-go gomod github.com/golang/go/src go1.25.0 reflect/Value#Interface().() |
| 244 | if !reflectscip-go gomod github.com/golang/go/src go1.25.0 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.25.0 reflect/DeepEqual().(val, expect) { |
| 245 | t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("%v:Results are incorrect, got %+v expect %+v", method, val, expect) |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | func (b binderscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/binder#) Bindscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/binder#Bind().(ctx contextscip-go gomod github.com/golang/go/src go1.25.0 context/.Contextscip-go gomod github.com/golang/go/src go1.25.0 context/Context#, conn *jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.Connectionscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Connection#) jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ConnectionOptionsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ConnectionOptions# { |
| 250 | h := &handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#{ |
| 251 | connscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#conn.: conn, |
| 252 | waitersscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#waiters.: make(chan map[string]chan struct{}, 1), |
| 253 | callsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#calls.: make(map[string]*jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.AsyncCallscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/AsyncCall#), |
| 254 | } |
| 255 | h.waitersscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#waiters. <- make(map[string]chan struct{}) |
| 256 | if b.runTestscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/binder#runTest. != nil { |
| 257 | go b.runTestscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/binder#runTest.(h) |
| 258 | } |
| 259 | return jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ConnectionOptionsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ConnectionOptions#{ |
| 260 | Framerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ConnectionOptions#Framer.: b.framerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/binder#framer., |
| 261 | Preempterscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ConnectionOptions#Preempter.: h, |
| 262 | Handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ConnectionOptions#Handler.: h, |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | func (h *handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#) waiterscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#waiter().(name string) chan struct{} { |
| 267 | waiters := <-h.waitersscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#waiters. |
| 268 | defer func() { h.waitersscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#waiters. <- waiters }() |
| 269 | waiter, found := waiters[name] |
| 270 | if !found { |
| 271 | waiter = make(chan struct{}) |
| 272 | waiters[name] = waiter |
| 273 | } |
| 274 | return waiter |
| 275 | } |
| 276 | |
| 277 | func (h *handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#) Preemptscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#Preempt().(ctx contextscip-go gomod github.com/golang/go/src go1.25.0 context/.Contextscip-go gomod github.com/golang/go/src go1.25.0 context/Context#, req *jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.Requestscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#) (any, error) { |
| 278 | switch req.Methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#Method. { |
| 279 | case "unblock": |
| 280 | var name string |
| 281 | if err := jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/Unmarshal().(req.Paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#Params., &name); err != nil { |
| 282 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("%w: %s", jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrParsescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrParse., err) |
| 283 | } |
| 284 | close(h.waiterscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#waiter().(name)) |
| 285 | return nil, nil |
| 286 | case "peek": |
| 287 | if len(req.Paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#Params.) > 0 { |
| 288 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("%w: expected no params", jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrInvalidParamsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrInvalidParams.) |
| 289 | } |
| 290 | return h.accumulatorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#accumulator., nil |
| 291 | case "cancel": |
| 292 | var params cancelParamsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/cancelParams# |
| 293 | if err := jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/Unmarshal().(req.Paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#Params., ¶ms); err != nil { |
| 294 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("%w: %s", jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrParsescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrParse., err) |
| 295 | } |
| 296 | h.connscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#conn..Cancelscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Connection#Cancel().(jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.Int64IDscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Int64ID().(params.IDscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/cancelParams#ID.)) |
| 297 | return nil, nil |
| 298 | default: |
| 299 | return nil, jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrNotHandledscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrNotHandled. |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | func (h *handlerscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#) Handlescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#Handle().(ctx contextscip-go gomod github.com/golang/go/src go1.25.0 context/.Contextscip-go gomod github.com/golang/go/src go1.25.0 context/Context#, req *jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.Requestscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#) (any, error) { |
| 304 | switch req.Methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#Method. { |
| 305 | case "no_args": |
| 306 | if len(req.Paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#Params.) > 0 { |
| 307 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("%w: expected no params", jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrInvalidParamsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrInvalidParams.) |
| 308 | } |
| 309 | return true, nil |
| 310 | case "one_string": |
| 311 | var v string |
| 312 | if err := jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/Unmarshal().(req.Paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#Params., &v); err != nil { |
| 313 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("%w: %s", jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrParsescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrParse., err) |
| 314 | } |
| 315 | return "got:" + v, nil |
| 316 | case "one_number": |
| 317 | var v int |
| 318 | if err := jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/Unmarshal().(req.Paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#Params., &v); err != nil { |
| 319 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("%w: %s", jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrParsescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrParse., err) |
| 320 | } |
| 321 | return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("got:%d", v), nil |
| 322 | case "set": |
| 323 | var v int |
| 324 | if err := jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/Unmarshal().(req.Paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#Params., &v); err != nil { |
| 325 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("%w: %s", jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrParsescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrParse., err) |
| 326 | } |
| 327 | h.accumulatorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#accumulator. = v |
| 328 | return nil, nil |
| 329 | case "add": |
| 330 | var v int |
| 331 | if err := jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/Unmarshal().(req.Paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#Params., &v); err != nil { |
| 332 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("%w: %s", jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrParsescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrParse., err) |
| 333 | } |
| 334 | h.accumulatorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#accumulator. += v |
| 335 | return nil, nil |
| 336 | case "get": |
| 337 | if len(req.Paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#Params.) > 0 { |
| 338 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("%w: expected no params", jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrInvalidParamsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrInvalidParams.) |
| 339 | } |
| 340 | return h.accumulatorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#accumulator., nil |
| 341 | case "join": |
| 342 | var v []string |
| 343 | if err := jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/Unmarshal().(req.Paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#Params., &v); err != nil { |
| 344 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("%w: %s", jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrParsescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrParse., err) |
| 345 | } |
| 346 | return pathscip-go gomod github.com/golang/go/src go1.25.0 path/.Joinscip-go gomod github.com/golang/go/src go1.25.0 path/Join().(v...), nil |
| 347 | case "echo": |
| 348 | var v []any |
| 349 | if err := jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/Unmarshal().(req.Paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#Params., &v); err != nil { |
| 350 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("%w: %s", jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrParsescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrParse., err) |
| 351 | } |
| 352 | var result any |
| 353 | err := h.connscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#conn..Callscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Connection#Call().(ctx, v[0].(string), v[1]).Awaitscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/AsyncCall#Await().(ctx, &result) |
| 354 | return result, err |
| 355 | case "wait": |
| 356 | var name string |
| 357 | if err := jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/Unmarshal().(req.Paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#Params., &name); err != nil { |
| 358 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("%w: %s", jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrParsescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrParse., err) |
| 359 | } |
| 360 | select { |
| 361 | case <-h.waiterscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#waiter().(name): |
| 362 | return true, nil |
| 363 | case <-ctx.Donescip-go gomod github.com/golang/go/src go1.25.0 context/Context#Done().(): |
| 364 | return nil, ctx.Errscip-go gomod github.com/golang/go/src go1.25.0 context/Context#Err().() |
| 365 | } |
| 366 | case "fork": |
| 367 | var name string |
| 368 | if err := jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.Unmarshalscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/Unmarshal().(req.Paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#Params., &name); err != nil { |
| 369 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("%w: %s", jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrParsescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrParse., err) |
| 370 | } |
| 371 | waitFor := h.waiterscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#waiter().(name) |
| 372 | go func() { |
| 373 | select { |
| 374 | case <-waitFor: |
| 375 | h.connscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#conn..Respondscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Connection#Respond().(req.IDscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#ID., true, nil) |
| 376 | case <-ctx.Donescip-go gomod github.com/golang/go/src go1.25.0 context/Context#Done().(): |
| 377 | h.connscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2_test`/handler#conn..Respondscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Connection#Respond().(req.IDscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/Request#ID., nil, ctx.Errscip-go gomod github.com/golang/go/src go1.25.0 context/Context#Err().()) |
| 378 | } |
| 379 | }() |
| 380 | return nil, jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrAsyncResponsescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrAsyncResponse. |
| 381 | default: |
| 382 | return nil, jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/.ErrNotHandledscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrNotHandled. |
| 383 | } |
| 384 | } |