5050 :group 'lsp-dart
5151 :type '(repeat string))
5252
53+ (defcustom lsp-dart-dap-dart-test-debugger-program
54+ `(" node" ,(f-join lsp-dart-dap-debugger-path " extension/out/src/debug/dart_test_debug_entry.js" ))
55+ " The path to the dart test debugger."
56+ :group 'lsp-dart
57+ :type '(repeat string))
58+
5359(defcustom lsp-dart-dap-flutter-debugger-program
5460 `(" node" ,(f-join lsp-dart-dap-debugger-path " extension/out/src/debug/flutter_debug_entry.js" ))
5561 " The path to the Flutter debugger."
5662 :group 'lsp-dart
5763 :type '(repeat string))
5864
65+ (defcustom lsp-dart-dap-flutter-test-debugger-program
66+ `(" node" ,(f-join lsp-dart-dap-debugger-path " extension/out/src/debug/flutter_test_debug_entry.js" ))
67+ " The path to the dart test debugger."
68+ :group 'lsp-dart
69+ :type '(repeat string))
70+
5971(defcustom lsp-dart-dap-debug-external-libraries nil
6072 " If non-nil, enable the debug on external libraries."
6173 :group 'lsp-dart
6678 :group 'lsp-dart
6779 :type 'boolean )
6880
81+ (defcustom lsp-dart-dap-vm-additional-args " "
82+ " Additional args for dart debugging VM."
83+ :group 'lsp-dart
84+ :type 'string )
85+
6986(defcustom lsp-dart-dap-flutter-track-widget-creation t
7087 " Whether to pass –track-widget-creation to Flutter apps.
7188Required to support 'Inspect Widget'."
@@ -103,6 +120,8 @@ Required to support 'Inspect Widget'."
103120 " npm" " install" " --prefix" (f-join lsp-dart-dap-debugger-path " extension" )
104121 " --no-package-lock" " --silent" " --no-save" ))
105122
123+ ; ; Dart
124+
106125(dap-utils-github-extension-setup-function
107126 " dap-dart"
108127 " Dart-Code"
@@ -121,13 +140,35 @@ Required to support 'Inspect Widget'."
121140 (dap--put-if-absent :cwd (lsp-dart-project-get-root))
122141 (dap--put-if-absent :program (buffer-file-name ))
123142 (dap--put-if-absent :dartPath (lsp-dart-project-dart-command))
143+ (dap--put-if-absent :pubPath (lsp-dart-project-get-pub-command))
144+ (dap--put-if-absent :pubSnapshotPath (lsp-dart-project-pub-snapshot-command))
145+ (dap--put-if-absent :vmAdditionalArgs lsp-dart-dap-vm-additional-args)
124146 (dap--put-if-absent :debugExternalLibraries lsp-dart-dap-debug-external-libraries)
125147 (dap--put-if-absent :debugSdkLibraries lsp-dart-dap-debug-sdk-libraries)))
126148
127149(dap-register-debug-provider " dart" 'lsp-dart-dap--populate-dart-start-file-args )
128150(dap-register-debug-template " Dart :: Debug"
129151 (list :type " dart" ))
130152
153+ (defun lsp-dart-dap-debug-dart-test (path args )
154+ " Start dart test debugging from PATH with ARGS."
155+ (-> (list :name " Tests"
156+ :type " dart"
157+ :request " launch"
158+ :dap-server-path lsp-dart-dap-dart-test-debugger-program
159+ :noDebug nil
160+ :shouldConnectDebugger t
161+ :cwd (lsp-dart-project-get-root)
162+ :dartPath (lsp-dart-project-dart-command)
163+ :pubPath (lsp-dart-project-get-pub-command)
164+ :pubSnapshotPath (lsp-dart-project-pub-snapshot-command)
165+ :vmAdditionalArgs lsp-dart-dap-vm-additional-args
166+ :debugExternalLibraries lsp-dart-dap-debug-external-libraries
167+ :debugSdkLibraries lsp-dart-dap-debug-sdk-libraries
168+ :program path
169+ :args args)
170+ dap-start-debugging))
171+
131172; ; Flutter
132173
133174(declare-function all-the-icons-faicon " ext:all-the-icons" )
@@ -179,6 +220,7 @@ Call CALLBACK when the device is chosen and started successfully."
179220 (-> pre-conf
180221 (dap--put-if-absent :deviceId device-id)
181222 (dap--put-if-absent :deviceName device-name)
223+ (dap--put-if-absent :vmAdditionalArgs lsp-dart-dap-vm-additional-args)
182224 (dap--put-if-absent :flutterPlatform " default" )
183225 (dap--put-if-absent :name (concat " Flutter (" device-name " )" )))))))))
184226
@@ -257,6 +299,30 @@ Call CALLBACK when the device is chosen and started successfully."
257299(cl-defmethod dap-handle-event ((_event (eql dart.navigate)) _session _params)
258300 " Ignore this event." )
259301
302+ (cl-defmethod dap-handle-event ((_event (eql dart.testRunNotification)) _session _params)
303+ " Ignore this event." )
304+
305+ (defun lsp-dart-dap-debug-flutter-test (path args )
306+ " Start dart test debugging from PATH with ARGS."
307+ (-> (list :name " Tests"
308+ :type " flutter"
309+ :request " launch"
310+ :dap-server-path lsp-dart-dap-flutter-test-debugger-program
311+ :noDebug nil
312+ :shouldConnectDebugger t
313+ :cwd (lsp-dart-project-get-root)
314+ :dartPath (lsp-dart-project-dart-command)
315+ :pubPath (lsp-dart-project-get-pub-command)
316+ :pubSnapshotPath (lsp-dart-project-pub-snapshot-command)
317+ :flutterPath (lsp-dart-project-get-flutter-path)
318+ :flutterMode " debug"
319+ :vmAdditionalArgs lsp-dart-dap-vm-additional-args
320+ :debugExternalLibraries lsp-dart-dap-debug-external-libraries
321+ :debugSdkLibraries lsp-dart-dap-debug-sdk-libraries
322+ :program path
323+ :args args)
324+ dap-start-debugging))
325+
260326;;;### autoload
261327(defun lsp-dart-dap-flutter-hot-restart ()
262328 " Hot restart current Flutter debug session."
0 commit comments