Skip to content

Commit 653f79b

Browse files
committed
Fix debug with latest debugger extension
1 parent 289b655 commit 653f79b

File tree

2 files changed

+57
-24
lines changed

2 files changed

+57
-24
lines changed

lsp-dart-dap.el

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,31 @@
7575
:group 'lsp-dart
7676
:type 'boolean)
7777

78+
(defcustom lsp-dart-dap-evaluate-getters-in-debug-views t
79+
"If non-nil, evaluate getters in debug views."
80+
:group 'lsp-dart
81+
:type 'boolean)
82+
83+
(defcustom lsp-dart-dap-evaluate-tostring-in-debug-views t
84+
"If non-nil, evaluate toString's in debug views."
85+
:group 'lsp-dart
86+
:type 'boolean)
87+
7888
(defcustom lsp-dart-dap-vm-additional-args ""
7989
"Additional args for dart debugging VM."
8090
:group 'lsp-dart
8191
:type 'string)
8292

93+
(defcustom lsp-dart-dap-vm-service-port 0
94+
"Service port for dart debugging VM."
95+
:group 'lsp-dart
96+
:type 'number)
97+
98+
(defcustom lsp-dart-dap-max-log-line-length 2000
99+
"The max log line length during the debug."
100+
:group 'lsp-dart
101+
:type 'number)
102+
83103
(defcustom lsp-dart-dap-flutter-track-widget-creation t
84104
"Whether to pass –track-widget-creation to Flutter apps.
85105
Required to support 'Inspect Widget'."
@@ -129,19 +149,26 @@ Required to support 'Inspect Widget'."
129149

130150
(defun lsp-dart-dap--base-debugger-args (conf)
131151
"Return the base args for debugging merged with CONF."
132-
(-> conf
133-
(dap--put-if-absent :request "launch")
134-
(dap--put-if-absent :dartPath (lsp-dart-dart-command))
135-
(dap--put-if-absent :cwd (lsp-dart-get-project-root))
136-
(dap--put-if-absent :pubPath (lsp-dart-pub-command))
137-
(dap--put-if-absent :pubSnapshotPath (lsp-dart-pub-snapshot-command))
138-
(dap--put-if-absent :vmAdditionalArgs lsp-dart-dap-vm-additional-args)
139-
(dap--put-if-absent :debugExternalLibraries lsp-dart-dap-debug-external-libraries)
140-
(dap--put-if-absent :debugSdkLibraries lsp-dart-dap-debug-sdk-libraries)
141-
(dap--put-if-absent :flutterPath (lsp-dart-flutter-command))
142-
(dap--put-if-absent :flutterTrackWidgetCreation lsp-dart-dap-flutter-track-widget-creation)
143-
(dap--put-if-absent :useFlutterStructuredErrors lsp-dart-dap-flutter-structured-errors)
144-
lsp-dart-dap--capabilities-debugger-args))
152+
(let ((conf conf))
153+
(dap--put-if-absent conf :request "launch")
154+
(dap--put-if-absent conf :dartPath (lsp-dart-dart-command))
155+
(dap--put-if-absent conf :dartVersion (lsp-dart-get-dart-version))
156+
(dap--put-if-absent conf :sendLogsToClient t)
157+
(dap--put-if-absent conf :maxLogLineLength lsp-dart-dap-max-log-line-length)
158+
(dap--put-if-absent conf :cwd (lsp-dart-get-project-root))
159+
(dap--put-if-absent conf :pubPath (lsp-dart-pub-command))
160+
(dap--put-if-absent conf :pubSnapshotPath (lsp-dart-pub-snapshot-command))
161+
(dap--put-if-absent conf :vmAdditionalArgs lsp-dart-dap-vm-additional-args)
162+
(dap--put-if-absent conf :vmServicePort lsp-dart-dap-vm-service-port)
163+
(dap--put-if-absent conf :debugExternalLibraries lsp-dart-dap-debug-external-libraries)
164+
(dap--put-if-absent conf :debugSdkLibraries lsp-dart-dap-debug-sdk-libraries)
165+
(dap--put-if-absent conf :evaluateGettersInDebugViews lsp-dart-dap-evaluate-getters-in-debug-views)
166+
(dap--put-if-absent conf :evaluateToStringInDebugViews lsp-dart-dap-evaluate-tostring-in-debug-views)
167+
(dap--put-if-absent conf :flutterPath (lsp-dart-flutter-command))
168+
(dap--put-if-absent conf :flutterVersion (lsp-dart-get-flutter-version))
169+
(dap--put-if-absent conf :flutterTrackWidgetCreation lsp-dart-dap-flutter-track-widget-creation)
170+
(dap--put-if-absent conf :useFlutterStructuredErrors lsp-dart-dap-flutter-structured-errors)
171+
(lsp-dart-dap--capabilities-debugger-args conf)))
145172

146173
;; Dart
147174

@@ -244,7 +271,7 @@ Call CALLBACK when the device is chosen and started successfully."
244271
(msg (replace-regexp-in-string (regexp-quote "\n") "" message nil 'literal)))
245272
(lsp-dart-dap-log msg))))
246273

247-
(cl-defmethod dap-handle-event ((_event (eql dart.launching)) _session params)
274+
(cl-defmethod dap-handle-event ((_event (eql dart.progressStart)) _session params)
248275
"Handle debugger uris EVENT for SESSION with PARAMS."
249276
(let ((prefix (concat (propertize "[LSP Dart] "
250277
'face 'font-lock-keyword-face)
@@ -255,14 +282,15 @@ Call CALLBACK when the device is chosen and started successfully."
255282
(setq lsp-dart-dap--flutter-progress-reporter-timer
256283
(run-with-timer 0.2 0.2 #'lsp-dart-dap--flutter-tick-progress-update))))
257284

258-
(cl-defmethod dap-handle-event ((_event (eql dart.launched)) _session _params)
285+
(cl-defmethod dap-handle-event ((_event (eql dart.progressEnd)) _session _params)
259286
"Handle debugger uris EVENT for SESSION with PARAMS."
260287
(when lsp-dart-dap--flutter-progress-reporter
261288
(progress-reporter-done lsp-dart-dap--flutter-progress-reporter))
262289
(lsp-dart-dap-log "Loading app..."))
263290

264-
(cl-defmethod dap-handle-event ((_event (eql dart.progress)) _session params)
291+
(cl-defmethod dap-handle-event ((_event (eql dart.progressUpdate)) _session params)
265292
"Handle debugger uris EVENT for SESSION with PARAMS."
293+
(message "update - receive %s" params)
266294
(-let (((&hash "message") params)
267295
(prefix (concat (propertize "[LSP Dart] "
268296
'face 'font-lock-keyword-face)
@@ -276,12 +304,6 @@ Call CALLBACK when the device is chosen and started successfully."
276304
(lsp-dart-dap--cancel-flutter-progress (dap--cur-session))
277305
(lsp-dart-dap-log "App ready!"))
278306

279-
(cl-defmethod dap-handle-event ((_event (eql dart.serviceRegistered)) _session _params)
280-
"Ignore this event.")
281-
(cl-defmethod dap-handle-event ((_event (eql dart.serviceExtensionAdded)) _session _params)
282-
"Ignore this event.")
283-
(cl-defmethod dap-handle-event ((_event (eql dart.flutter.serviceExtensionStateChanged)) _session _params)
284-
"Ignore this event.")
285307
(cl-defmethod dap-handle-event ((_event (eql dart.hotRestartRequest)) _session _params)
286308
"Ignore this event.")
287309
(cl-defmethod dap-handle-event ((_event (eql dart.hotReloadRequest)) _session _params)

lsp-dart-utils.el

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,23 @@ FLUTTER_ROOT environment variable."
189189
(->> (concat (lsp-dart-dart-command) " --version")
190190
shell-command-to-string))
191191

192-
(defun lsp-dart--get-dart-version ()
192+
(defun lsp-dart-get-full-flutter-version ()
193+
"Retrieve the Flutter version from shell command."
194+
(->> (concat (lsp-dart-flutter-command) " --version")
195+
shell-command-to-string))
196+
197+
(defun lsp-dart-get-dart-version ()
193198
"Retrieve the dart version from shell command."
194199
(->> (lsp-dart-get-full-dart-version)
195200
split-string
196201
(nth 3)))
197202

203+
(defun lsp-dart-get-flutter-version ()
204+
"Retrieve the Flutter version from shell command."
205+
(->> (lsp-dart-get-full-flutter-version)
206+
split-string
207+
(nth 1)))
208+
198209
(defun lsp-dart-version->number (version)
199210
"Transform VERSION into a comparable version number."
200211
(--> version
@@ -204,7 +215,7 @@ FLUTTER_ROOT environment variable."
204215

205216
(defun lsp-dart-version-at-least-p (version)
206217
"Return non-nil if Dart SDK version is at least VERSION."
207-
(let ((sdk-version (lsp-dart--get-dart-version)))
218+
(let ((sdk-version (lsp-dart-get-dart-version)))
208219
(version<= (lsp-dart-version->number version)
209220
(lsp-dart-version->number sdk-version))))
210221

0 commit comments

Comments
 (0)