diff options
| author | João Távora | 2023-11-08 08:36:04 -0600 |
|---|---|---|
| committer | João Távora | 2023-12-14 00:55:52 +0000 |
| commit | ea29a48da13d6e6b87a3b017bcf92689bc18ca54 (patch) | |
| tree | 3797d254321ca2e10ad3455cd301dee139211391 /test | |
| parent | 60473c4d90a6cdce3f06e183809f5be440dd8797 (diff) | |
| download | emacs-ea29a48da13d6e6b87a3b017bcf92689bc18ca54.tar.gz emacs-ea29a48da13d6e6b87a3b017bcf92689bc18ca54.zip | |
Jsonrpc: support some JSONesque non-JSONRPC protocols, like DAP
* lisp/jsonrpc.el (jsonrpc-convert-to-endpoint)
(jsonrpc-convert-from-endpoint): New generics.
(jsonrpc-connection-send): Call jsonrpc-convert-to-endpoint.
Rework logging.
(jsonrpc-connection-receive): Call jsonrpc-convert-from-endpoint.
Rework logging. jsonrpc--reply with METHOD.
(jsonrpc--log-event): Take subtype.
(Version): Bump to 1.0.19
* test/lisp/progmodes/eglot-tests.el (eglot--sniffing): Adapt
to new protocol of jsonrpc--log-event.
* doc/lispref/text.texi (JSONRPC Overview): Rework.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/progmodes/eglot-tests.el | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/test/lisp/progmodes/eglot-tests.el b/test/lisp/progmodes/eglot-tests.el index 575a6ac8ef1..996ff276e68 100644 --- a/test/lisp/progmodes/eglot-tests.el +++ b/test/lisp/progmodes/eglot-tests.el | |||
| @@ -209,27 +209,25 @@ directory hierarchy." | |||
| 209 | client-replies)) | 209 | client-replies)) |
| 210 | (advice-add | 210 | (advice-add |
| 211 | #'jsonrpc--log-event :before | 211 | #'jsonrpc--log-event :before |
| 212 | (lambda (_proc message &optional type) | 212 | (lambda (_proc message &optional origin subtype) |
| 213 | (cl-destructuring-bind (&key method id _error &allow-other-keys) | 213 | (let ((req-p (eq subtype 'request)) |
| 214 | message | 214 | (notif-p (eq subtype 'notification)) |
| 215 | (let ((req-p (and method id)) | 215 | (reply-p (eql subtype 'reply))) |
| 216 | (notif-p method) | 216 | (cond |
| 217 | (reply-p id)) | 217 | ((eq origin 'server) |
| 218 | (cond | 218 | (cond (req-p ,(when server-requests |
| 219 | ((eq type 'server) | 219 | `(push message ,server-requests))) |
| 220 | (cond (req-p ,(when server-requests | 220 | (notif-p ,(when server-notifications |
| 221 | `(push message ,server-requests))) | 221 | `(push message ,server-notifications))) |
| 222 | (notif-p ,(when server-notifications | 222 | (reply-p ,(when server-replies |
| 223 | `(push message ,server-notifications))) | 223 | `(push message ,server-replies))))) |
| 224 | (reply-p ,(when server-replies | 224 | ((eq origin 'client) |
| 225 | `(push message ,server-replies))))) | 225 | (cond (req-p ,(when client-requests |
| 226 | ((eq type 'client) | 226 | `(push message ,client-requests))) |
| 227 | (cond (req-p ,(when client-requests | 227 | (notif-p ,(when client-notifications |
| 228 | `(push message ,client-requests))) | 228 | `(push message ,client-notifications))) |
| 229 | (notif-p ,(when client-notifications | 229 | (reply-p ,(when client-replies |
| 230 | `(push message ,client-notifications))) | 230 | `(push message ,client-replies)))))))) |
| 231 | (reply-p ,(when client-replies | ||
| 232 | `(push message ,client-replies))))))))) | ||
| 233 | '((name . ,log-event-ad-sym))) | 231 | '((name . ,log-event-ad-sym))) |
| 234 | ,@body) | 232 | ,@body) |
| 235 | (advice-remove #'jsonrpc--log-event ',log-event-ad-sym)))) | 233 | (advice-remove #'jsonrpc--log-event ',log-event-ad-sym)))) |