Skip to content

Commit 2563583

Browse files
committed
Migrate remaining hashs to plists
1 parent 7703507 commit 2563583

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

lsp-dart-flutter-daemon.el

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
(require 'ht)
2525
(require 'lsp-mode)
2626

27+
(require 'lsp-dart-protocol)
2728
(require 'lsp-dart-utils)
2829

2930
(defconst lsp-dart-flutter-daemon-buffer-name "*LSP Dart - Flutter daemon*")
@@ -66,10 +67,10 @@
6667
(defun lsp-dart-flutter-daemon--build-command (id method &optional params)
6768
"Build a command from an ID and METHOD.
6869
PARAMS is the optional method params."
69-
(let ((command (ht ("id" id)
70-
("method" method))))
70+
(let ((command (lsp-make-flutter-daemon-command :id id
71+
:method method)))
7172
(when params
72-
(ht-set! command "params" params))
73+
(lsp:set-flutter-daemon-command-params? command params))
7374
(concat "["
7475
(lsp--json-serialize command)
7576
"]\n")))
@@ -86,22 +87,23 @@ PARAMS is the optional method params."
8687

8788
(defun lsp-dart-flutter-daemon--handle-responses (raw-response)
8889
"Handle Flutter daemon response from RAW-RESPONSE."
89-
(-map (-lambda ((&hash "id" "event" "result" "params" (params &as &hash? "level" "message")))
90-
(if event
91-
(pcase event
90+
(-map (-lambda ((&FlutterDaemonResponse :id :event? :result?
91+
:params? (params &as &FlutterDaemonResponseParams? :level? :message?)))
92+
(if event?
93+
(pcase event?
9294
("device.removed" (lsp-dart-flutter-daemon--device-removed params))
9395

9496
("device.added" (lsp-dart-flutter-daemon--device-added params))
9597

96-
("daemon.logMessage" (lsp-dart-flutter-daemon--log level message)))
98+
("daemon.logMessage" (lsp-dart-flutter-daemon--log level? message?)))
9799
(let* ((command (alist-get id lsp-dart-flutter-daemon-commands))
98-
(callback (gethash "callback" command)))
100+
(callback (plist-get command :callback)))
99101
(when command
100102
(setq lsp-dart-flutter-daemon-commands
101103
(lsp-dart-remove-from-alist id lsp-dart-flutter-daemon-commands)))
102104
(when callback
103-
(when result
104-
(funcall callback result))))))
105+
(when result?
106+
(funcall callback result?))))))
105107
(lsp-dart-flutter-daemon--raw->response raw-response)))
106108

107109
(defun lsp-dart-flutter-daemon--send (method &optional params callback)
@@ -112,7 +114,7 @@ of this command."
112114
(lsp-dart-flutter-daemon-start))
113115
(let* ((id (lsp-dart-flutter-daemon--generate-command-id))
114116
(command (lsp-dart-flutter-daemon--build-command id method params)))
115-
(add-to-list 'lsp-dart-flutter-daemon-commands (cons id (ht ("callback" callback))))
117+
(add-to-list 'lsp-dart-flutter-daemon-commands (cons id (list :callback callback)))
116118
(comint-send-string (get-buffer-process lsp-dart-flutter-daemon-buffer-name) command)))
117119

118120
(defun lsp-dart-flutter-daemon--device-removed (device)

lsp-dart-protocol.el

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,10 @@
3838
(FlutterOutline (:range :codeRange :children :kind) (:dartElement :label :className :variableName :attributes))
3939
(FlutterOutlineAttribute (:name :label) nil))
4040

41+
(lsp-interface
42+
(FlutterDaemonCommand (:id :method) (:params))
43+
(FlutterDaemonResponse (:id) (:result :event :params))
44+
(FlutterDaemonResponseParams nil (:level :message)))
45+
4146
(provide 'lsp-dart-protocol)
4247
;;; lsp-dart-protocol.el ends here

lsp-dart.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;;; lsp-dart.el --- Dart support lsp-mode -*- lexical-binding: t; -*-
22

33
;; Version: 1.11.9
4-
;; Package-Requires: ((emacs "25.2") (lsp-treemacs "0.1") (lsp-mode "6.0") (dap-mode "0.4") (ht "2.0") (f "0.20.0") (dash "2.14.1") (pkg-info "0.4") (dart-mode "1.0.5"))
4+
;; Package-Requires: ((emacs "25.2") (lsp-treemacs "0.1") (lsp-mode "6.4") (dap-mode "0.4") (ht "2.0") (f "0.20.0") (dash "2.14.1") (pkg-info "0.4") (dart-mode "1.0.5"))
55
;; Keywords: languages, extensions
66
;; URL: https://emacs-lsp.github.io/lsp-dart
77

test/lsp-dart-test.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@
6464
(ert-deftest lsp-dart--handle-analyzer-status--when-analyzing-test ()
6565
(with-mock
6666
(mock (lsp-dart-workspace-status "Analyzing project..." "workspace"))
67-
(lsp-dart--handle-analyzer-status "workspace" (ht ("isAnalyzing" t)))))
67+
(lsp-dart--handle-analyzer-status "workspace" (lsp-make-analyzer-status-notification :is-analyzing t))))
6868

69-
(ert-deftest lsp-dart--handle-analyzer-status--when-analyzing-test ()
69+
(ert-deftest lsp-dart--handle-analyzer-status--when-not-analyzing-test ()
7070
(with-mock
7171
(mock (lsp-dart-workspace-status nil "workspace"))
72-
(lsp-dart--handle-analyzer-status "workspace" (ht ("isAnalyzing" nil)))))
72+
(lsp-dart--handle-analyzer-status "workspace" (lsp-make-analyzer-status-notification :is-analyzing nil))))
7373

7474
(ert-deftest lsp-dart-version--test ()
7575
(let ((pkg-version (lsp-dart-test-package-version "lsp-dart.el")))

0 commit comments

Comments
 (0)