[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/dart-mode 1ccf8a0 073/192: Better handling and of analysis
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/dart-mode 1ccf8a0 073/192: Better handling and of analysis server messages. |
Date: |
Sun, 29 Aug 2021 11:01:53 -0400 (EDT) |
branch: elpa/dart-mode
commit 1ccf8a01f441d310e6e6357001663de75dc39642
Author: Natalie Weizenbaum <nweiz@google.com>
Commit: Natalie Weizenbaum <nweiz@google.com>
Better handling and of analysis server messages.
This logs messages the same way on send and on receive, and nicely
surfaces errors (especially errors not associated with specific
requests).
---
dart-mode.el | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/dart-mode.el b/dart-mode.el
index 6dc07c8..f408de4 100644
--- a/dart-mode.el
+++ b/dart-mode.el
@@ -792,8 +792,8 @@ The constructed request will call METHOD with optional
PARAMS."
(defun dart--analysis-server-on-error-callback (response)
"If RESPONSE has an error, report it."
- (-when-let (resp-err (assoc 'error response))
- (dart-log (format "Response from server had error: %s" resp-err))))
+ (-when-let (resp-err (assoc-default 'error response))
+ (error "Analysis server error: %s" (assoc-default 'message resp-err))))
(defun dart--analysis-server-enqueue (req-without-id callback)
"Send REQ-WITHOUT-ID to the analysis server, call CALLBACK with the result."
@@ -801,22 +801,17 @@ The constructed request will call METHOD with optional
PARAMS."
(let ((request
(json-encode (push (cons 'id (format "%s"
dart--analysis-server-next-id))
req-without-id))))
- (dart-info (concat "Sent:\n" request))
- (if callback
- (push (cons dart--analysis-server-next-id callback)
- dart--analysis-server-callbacks)
- (push
- (cons dart--analysis-server-next-id
- #'dart--analysis-server-on-error-callback)
- dart--analysis-server-callbacks))
+
+ ;; Enqueue the request so that we can be sure all requests are processed in
+ ;; order.
+ (push (cons dart--analysis-server-next-id
+ (or callback #'dart--analysis-server-on-error-callback))
+ dart--analysis-server-callbacks)
+
+ (dart-info (concat "Sent: " request))
(process-send-string (dart--analysis-server-process dart--analysis-server)
(concat request "\n"))))
-(defun dart--analysis-server-handle-response (callback response)
- "Call CALLBACK with the parsed JSON RESPONSE from the analysis server."
- (dart-info (concat "Received:\n" (format "%s" response)))
- (funcall callback response))
-
(defun dart--analysis-server-process-filter (das string)
"Handle the event or method response from the dart analysis server.
@@ -836,10 +831,13 @@ the callback for that request is given the json decoded
response."
(let ((buf-lines (split-string (buffer-string) "\n")))
(delete-region (point-min) (point-max))
(insert (-last-item buf-lines))
- (let ((json-lines (-map 'json-read-from-string
- (-filter (lambda (s)
- (not (or (null s) (string= ""
s))))
- (-butlast buf-lines)))))
+ (let ((json-lines
+ (-map (lambda (s)
+ (dart-info (concat "Received: " s))
+ (json-read-from-string s))
+ (-filter (lambda (s)
+ (not (or (null s) (string= "" s))))
+ (-butlast buf-lines)))))
(-each json-lines 'dart--analysis-server-handle-msg)))))))
(defun dart--analysis-server-handle-msg (msg)
@@ -849,10 +847,12 @@ the callback for that request is given the json decoded
response."
(id (string-to-number raw-id)))
(-if-let (resp-closure (assoc id dart--analysis-server-callbacks))
(progn
- (dart--analysis-server-handle-response (cdr resp-closure) msg)
(setq dart--analysis-server-callbacks
- (assq-delete-all id dart--analysis-server-callbacks)))
- (dart-info (format "No callback was associated with id %s" raw-id)))))
+ (assq-delete-all id dart--analysis-server-callbacks))
+ (funcall (cdr resp-closure) msg))
+ (-if-let (err (assoc 'error msg))
+ (dart--analysis-server-on-error-callback msg)
+ (dart-info (format "No callback was associated with id %s" raw-id))))))
(defun dart--flycheck-start (checker callback)
"Run the CHECKER and report the errors to the CALLBACK."
- [nongnu] elpa/dart-mode d39043f 032/192: Fix an offset., (continued)
- [nongnu] elpa/dart-mode d39043f 032/192: Fix an offset., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 5e9c9b9 034/192: Add a known bug., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode cb7d85d 033/192: Handle member initializers a little better., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 53155c1 036/192: Fix map literal indentation when cc-mode thinks it's a defun., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 085522f 044/192: Properly indent continued {} lines as well., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1bba413 046/192: Bump version to 0.7., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 592192c 054/192: Bump version to 0.9., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode aba5eed 064/192: 'dart' must be found to find the analysis server snapshot, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1b01681 065/192: Merge pull request #14 from hterkelsen/issue13, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 351db28 072/192: Lexically scope the library., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1ccf8a0 073/192: Better handling and of analysis server messages.,
ELPA Syncer <=
- [nongnu] elpa/dart-mode a4d7a3c 075/192: Declare compatibility with flycheck 0.23., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1b75622 079/192: Only mention marmalade in the README., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode e338148 078/192: Get rid of busted flymake and formatter support., ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 05fbd30 081/192: Merge pull request #24 from phst/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode bd08208 082/192: Switch completely to cl-lib (#33), ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1f65c88 083/192: Add LIMIT argument for looking-back (#34), ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 1c9da5a 087/192: Explicitly load compile.el so that the compilation-error-regexp-* variables are defined (#41), ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode eea1000 093/192: Highlight hover dartdoc, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 907cba5 095/192: Indicate deprecated hovers, ELPA Syncer, 2021/08/29
- [nongnu] elpa/dart-mode 8e09b68 120/192: Exclusively use cl-lib to avoid byte-compilation inconsistencies, ELPA Syncer, 2021/08/29