24
24
(require 'ht )
25
25
(require 'lsp-mode )
26
26
27
+ (require 'lsp-dart-protocol )
27
28
(require 'lsp-dart-utils )
28
29
29
30
(defconst lsp-dart-flutter-daemon-buffer-name " *LSP Dart - Flutter daemon*" )
66
67
(defun lsp-dart-flutter-daemon--build-command (id method &optional params )
67
68
" Build a command from an ID and METHOD.
68
69
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)))
71
72
(when params
72
- (ht- set! command " params" params))
73
+ (lsp: set-flutter-daemon- command- params? command params))
73
74
(concat " ["
74
75
(lsp--json-serialize command)
75
76
" ]\n " )))
@@ -86,22 +87,23 @@ PARAMS is the optional method params."
86
87
87
88
(defun lsp-dart-flutter-daemon--handle-responses (raw-response )
88
89
" 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?
92
94
(" device.removed" (lsp-dart-flutter-daemon--device-removed params))
93
95
94
96
(" device.added" (lsp-dart-flutter-daemon--device-added params))
95
97
96
- (" daemon.logMessage" (lsp-dart-flutter-daemon--log level message)))
98
+ (" daemon.logMessage" (lsp-dart-flutter-daemon--log level? message? ) ))
97
99
(let* ((command (alist-get id lsp-dart-flutter-daemon-commands))
98
- (callback (gethash " callback " command)))
100
+ (callback (plist-get command :callback )))
99
101
(when command
100
102
(setq lsp-dart-flutter-daemon-commands
101
103
(lsp-dart-remove-from-alist id lsp-dart-flutter-daemon-commands)))
102
104
(when callback
103
- (when result
104
- (funcall callback result))))))
105
+ (when result?
106
+ (funcall callback result? ) )))))
105
107
(lsp-dart-flutter-daemon--raw->response raw-response)))
106
108
107
109
(defun lsp-dart-flutter-daemon--send (method &optional params callback )
@@ -112,7 +114,7 @@ of this command."
112
114
(lsp-dart-flutter-daemon-start))
113
115
(let* ((id (lsp-dart-flutter-daemon--generate-command-id))
114
116
(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)))
116
118
(comint-send-string (get-buffer-process lsp-dart-flutter-daemon-buffer-name) command)))
117
119
118
120
(defun lsp-dart-flutter-daemon--device-removed (device )
0 commit comments