@theia/debug 1.34.2 → 1.34.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +62 -62
  3. package/bin/download-adapters.js +76 -76
  4. package/lib/browser/breakpoint/breakpoint-manager.d.ts +69 -69
  5. package/lib/browser/breakpoint/breakpoint-manager.js +311 -311
  6. package/lib/browser/breakpoint/breakpoint-marker.d.ts +40 -40
  7. package/lib/browser/breakpoint/breakpoint-marker.js +73 -73
  8. package/lib/browser/console/debug-console-contribution.d.ts +40 -40
  9. package/lib/browser/console/debug-console-contribution.js +227 -227
  10. package/lib/browser/console/debug-console-items.d.ts +93 -93
  11. package/lib/browser/console/debug-console-items.js +318 -318
  12. package/lib/browser/console/debug-console-session.d.ts +31 -31
  13. package/lib/browser/console/debug-console-session.js +199 -199
  14. package/lib/browser/debug-call-stack-item-type-key.d.ts +3 -3
  15. package/lib/browser/debug-call-stack-item-type-key.js +19 -19
  16. package/lib/browser/debug-configuration-manager.d.ts +101 -101
  17. package/lib/browser/debug-configuration-manager.js +521 -521
  18. package/lib/browser/debug-configuration-model.d.ts +29 -29
  19. package/lib/browser/debug-configuration-model.js +79 -79
  20. package/lib/browser/debug-contribution.d.ts +22 -22
  21. package/lib/browser/debug-contribution.js +19 -19
  22. package/lib/browser/debug-frontend-application-contribution.d.ts +214 -214
  23. package/lib/browser/debug-frontend-application-contribution.js +1351 -1351
  24. package/lib/browser/debug-frontend-module.d.ts +4 -4
  25. package/lib/browser/debug-frontend-module.js +108 -108
  26. package/lib/browser/debug-keybinding-contexts.d.ts +24 -24
  27. package/lib/browser/debug-keybinding-contexts.js +85 -85
  28. package/lib/browser/debug-package.spec.js +18 -18
  29. package/lib/browser/debug-preferences.d.ts +17 -17
  30. package/lib/browser/debug-preferences.js +89 -89
  31. package/lib/browser/debug-prefix-configuration.d.ts +50 -50
  32. package/lib/browser/debug-prefix-configuration.js +204 -204
  33. package/lib/browser/debug-resource.d.ts +14 -14
  34. package/lib/browser/debug-resource.js +65 -65
  35. package/lib/browser/debug-schema-updater.d.ts +15 -15
  36. package/lib/browser/debug-schema-updater.js +168 -168
  37. package/lib/browser/debug-session-connection.d.ts +110 -110
  38. package/lib/browser/debug-session-connection.js +258 -258
  39. package/lib/browser/debug-session-contribution.d.ts +73 -73
  40. package/lib/browser/debug-session-contribution.js +145 -145
  41. package/lib/browser/debug-session-manager.d.ts +137 -137
  42. package/lib/browser/debug-session-manager.js +593 -593
  43. package/lib/browser/debug-session-options.d.ts +48 -48
  44. package/lib/browser/debug-session-options.js +85 -85
  45. package/lib/browser/debug-session.d.ts +178 -178
  46. package/lib/browser/debug-session.js +859 -859
  47. package/lib/browser/debug-tab-bar-decorator.d.ts +16 -16
  48. package/lib/browser/debug-tab-bar-decorator.js +70 -70
  49. package/lib/browser/debug-watch-manager.d.ts +21 -21
  50. package/lib/browser/debug-watch-manager.js +93 -93
  51. package/lib/browser/disassembly-view/disassembly-view-accessibility-provider.d.ts +6 -6
  52. package/lib/browser/disassembly-view/disassembly-view-accessibility-provider.js +38 -38
  53. package/lib/browser/disassembly-view/disassembly-view-breakpoint-renderer.d.ts +19 -19
  54. package/lib/browser/disassembly-view/disassembly-view-breakpoint-renderer.js +110 -110
  55. package/lib/browser/disassembly-view/disassembly-view-contribution.d.ts +24 -24
  56. package/lib/browser/disassembly-view/disassembly-view-contribution.js +131 -131
  57. package/lib/browser/disassembly-view/disassembly-view-instruction-renderer.d.ts +38 -38
  58. package/lib/browser/disassembly-view/disassembly-view-instruction-renderer.js +222 -222
  59. package/lib/browser/disassembly-view/disassembly-view-table-delegate.d.ts +15 -15
  60. package/lib/browser/disassembly-view/disassembly-view-table-delegate.js +38 -38
  61. package/lib/browser/disassembly-view/disassembly-view-utilities.d.ts +37 -37
  62. package/lib/browser/disassembly-view/disassembly-view-utilities.js +17 -17
  63. package/lib/browser/disassembly-view/disassembly-view-widget.d.ts +60 -60
  64. package/lib/browser/disassembly-view/disassembly-view-widget.js +452 -452
  65. package/lib/browser/editor/debug-breakpoint-widget.d.ts +51 -51
  66. package/lib/browser/editor/debug-breakpoint-widget.js +245 -245
  67. package/lib/browser/editor/debug-editor-model.d.ts +91 -91
  68. package/lib/browser/editor/debug-editor-model.js +497 -497
  69. package/lib/browser/editor/debug-editor-service.d.ts +37 -37
  70. package/lib/browser/editor/debug-editor-service.js +214 -214
  71. package/lib/browser/editor/debug-editor.d.ts +3 -3
  72. package/lib/browser/editor/debug-editor.js +19 -19
  73. package/lib/browser/editor/debug-exception-widget.d.ts +28 -28
  74. package/lib/browser/editor/debug-exception-widget.js +111 -111
  75. package/lib/browser/editor/debug-expression-provider.d.ts +11 -11
  76. package/lib/browser/editor/debug-expression-provider.js +81 -81
  77. package/lib/browser/editor/debug-hover-source.d.ts +18 -18
  78. package/lib/browser/editor/debug-hover-source.js +117 -117
  79. package/lib/browser/editor/debug-hover-widget.d.ts +47 -47
  80. package/lib/browser/editor/debug-hover-widget.js +267 -267
  81. package/lib/browser/editor/debug-inline-value-decorator.d.ts +21 -21
  82. package/lib/browser/editor/debug-inline-value-decorator.js +337 -337
  83. package/lib/browser/model/debug-breakpoint.d.ts +47 -47
  84. package/lib/browser/model/debug-breakpoint.js +109 -109
  85. package/lib/browser/model/debug-function-breakpoint.d.ts +18 -18
  86. package/lib/browser/model/debug-function-breakpoint.js +92 -92
  87. package/lib/browser/model/debug-instruction-breakpoint.d.ts +14 -14
  88. package/lib/browser/model/debug-instruction-breakpoint.js +65 -65
  89. package/lib/browser/model/debug-source-breakpoint.d.ts +37 -37
  90. package/lib/browser/model/debug-source-breakpoint.js +211 -211
  91. package/lib/browser/model/debug-source.d.ts +24 -24
  92. package/lib/browser/model/debug-source.js +80 -80
  93. package/lib/browser/model/debug-stack-frame.d.ts +41 -41
  94. package/lib/browser/model/debug-stack-frame.js +146 -146
  95. package/lib/browser/model/debug-thread.d.ts +60 -60
  96. package/lib/browser/model/debug-thread.js +200 -200
  97. package/lib/browser/preferences/launch-preferences.d.ts +4 -4
  98. package/lib/browser/preferences/launch-preferences.js +38 -38
  99. package/lib/browser/view/debug-action.d.ts +16 -16
  100. package/lib/browser/view/debug-action.js +43 -43
  101. package/lib/browser/view/debug-breakpoints-source.d.ts +9 -9
  102. package/lib/browser/view/debug-breakpoints-source.js +70 -70
  103. package/lib/browser/view/debug-breakpoints-widget.d.ts +22 -22
  104. package/lib/browser/view/debug-breakpoints-widget.js +87 -87
  105. package/lib/browser/view/debug-configuration-select.d.ts +61 -61
  106. package/lib/browser/view/debug-configuration-select.js +204 -204
  107. package/lib/browser/view/debug-configuration-widget.d.ts +30 -30
  108. package/lib/browser/view/debug-configuration-widget.js +135 -135
  109. package/lib/browser/view/debug-exception-breakpoint.d.ts +13 -13
  110. package/lib/browser/view/debug-exception-breakpoint.js +34 -34
  111. package/lib/browser/view/debug-session-widget.d.ts +28 -28
  112. package/lib/browser/view/debug-session-widget.js +134 -134
  113. package/lib/browser/view/debug-stack-frames-source.d.ts +17 -17
  114. package/lib/browser/view/debug-stack-frames-source.js +89 -89
  115. package/lib/browser/view/debug-stack-frames-widget.d.ts +24 -24
  116. package/lib/browser/view/debug-stack-frames-widget.js +154 -154
  117. package/lib/browser/view/debug-threads-source.d.ts +8 -8
  118. package/lib/browser/view/debug-threads-source.js +63 -63
  119. package/lib/browser/view/debug-threads-widget.d.ts +26 -26
  120. package/lib/browser/view/debug-threads-widget.js +145 -145
  121. package/lib/browser/view/debug-toolbar-widget.d.ts +34 -34
  122. package/lib/browser/view/debug-toolbar-widget.js +156 -156
  123. package/lib/browser/view/debug-variables-source.d.ts +9 -9
  124. package/lib/browser/view/debug-variables-source.js +60 -60
  125. package/lib/browser/view/debug-variables-widget.d.ts +16 -16
  126. package/lib/browser/view/debug-variables-widget.js +78 -78
  127. package/lib/browser/view/debug-view-model.d.ts +51 -51
  128. package/lib/browser/view/debug-view-model.js +220 -220
  129. package/lib/browser/view/debug-watch-expression.d.ts +30 -30
  130. package/lib/browser/view/debug-watch-expression.js +73 -73
  131. package/lib/browser/view/debug-watch-source.d.ts +9 -9
  132. package/lib/browser/view/debug-watch-source.js +58 -58
  133. package/lib/browser/view/debug-watch-widget.d.ts +16 -16
  134. package/lib/browser/view/debug-watch-widget.js +78 -78
  135. package/lib/browser/view/debug-widget.d.ts +23 -23
  136. package/lib/browser/view/debug-widget.js +108 -108
  137. package/lib/common/debug-adapter-contribution-registry.d.ts +59 -59
  138. package/lib/common/debug-adapter-contribution-registry.js +212 -212
  139. package/lib/common/debug-adapter-session.d.ts +18 -18
  140. package/lib/common/debug-adapter-session.js +78 -78
  141. package/lib/common/debug-common.d.ts +1 -1
  142. package/lib/common/debug-common.js +29 -29
  143. package/lib/common/debug-compound.d.ts +14 -14
  144. package/lib/common/debug-compound.js +27 -27
  145. package/lib/common/debug-configuration.d.ts +58 -58
  146. package/lib/common/debug-configuration.js +31 -31
  147. package/lib/common/debug-model.d.ts +152 -152
  148. package/lib/common/debug-model.js +35 -35
  149. package/lib/common/debug-service.d.ts +123 -123
  150. package/lib/common/debug-service.js +66 -66
  151. package/lib/common/debug-uri-utils.d.ts +23 -23
  152. package/lib/common/debug-uri-utils.js +26 -26
  153. package/lib/common/inline-debug-adapter.d.ts +18 -18
  154. package/lib/common/inline-debug-adapter.js +44 -44
  155. package/lib/node/debug-adapter-factory.d.ts +19 -19
  156. package/lib/node/debug-adapter-factory.js +96 -96
  157. package/lib/node/debug-adapter-session-manager.d.ts +37 -37
  158. package/lib/node/debug-adapter-session-manager.js +111 -111
  159. package/lib/node/debug-backend-module.d.ts +3 -3
  160. package/lib/node/debug-backend-module.js +41 -41
  161. package/lib/node/debug-service-impl.d.ts +30 -30
  162. package/lib/node/debug-service-impl.js +124 -124
  163. package/lib/node/stream-debug-adapter.d.ts +36 -36
  164. package/lib/node/stream-debug-adapter.js +112 -112
  165. package/lib/node/vscode/vscode-debug-adapter-contribution.d.ts +47 -47
  166. package/lib/node/vscode/vscode-debug-adapter-contribution.js +221 -221
  167. package/package.json +15 -15
  168. package/src/browser/breakpoint/breakpoint-manager.ts +351 -351
  169. package/src/browser/breakpoint/breakpoint-marker.ts +102 -102
  170. package/src/browser/console/debug-console-contribution.tsx +239 -239
  171. package/src/browser/console/debug-console-items.tsx +383 -383
  172. package/src/browser/console/debug-console-session.ts +205 -205
  173. package/src/browser/debug-call-stack-item-type-key.ts +20 -20
  174. package/src/browser/debug-configuration-manager.ts +559 -559
  175. package/src/browser/debug-configuration-model.ts +100 -100
  176. package/src/browser/debug-contribution.ts +43 -43
  177. package/src/browser/debug-frontend-application-contribution.ts +1503 -1503
  178. package/src/browser/debug-frontend-module.ts +136 -136
  179. package/src/browser/debug-keybinding-contexts.ts +75 -75
  180. package/src/browser/debug-package.spec.ts +20 -20
  181. package/src/browser/debug-preferences.ts +98 -98
  182. package/src/browser/debug-prefix-configuration.ts +190 -190
  183. package/src/browser/debug-resource.ts +59 -59
  184. package/src/browser/debug-schema-updater.ts +149 -149
  185. package/src/browser/debug-session-connection.ts +357 -357
  186. package/src/browser/debug-session-contribution.ts +150 -150
  187. package/src/browser/debug-session-manager.ts +681 -681
  188. package/src/browser/debug-session-options.ts +114 -114
  189. package/src/browser/debug-session.tsx +936 -936
  190. package/src/browser/debug-tab-bar-decorator.ts +57 -57
  191. package/src/browser/debug-watch-manager.ts +93 -93
  192. package/src/browser/disassembly-view/disassembly-view-accessibility-provider.ts +43 -43
  193. package/src/browser/disassembly-view/disassembly-view-breakpoint-renderer.ts +119 -119
  194. package/src/browser/disassembly-view/disassembly-view-contribution.ts +109 -109
  195. package/src/browser/disassembly-view/disassembly-view-instruction-renderer.ts +245 -245
  196. package/src/browser/disassembly-view/disassembly-view-table-delegate.ts +39 -39
  197. package/src/browser/disassembly-view/disassembly-view-utilities.ts +55 -55
  198. package/src/browser/disassembly-view/disassembly-view-widget.ts +463 -463
  199. package/src/browser/editor/debug-breakpoint-widget.tsx +275 -275
  200. package/src/browser/editor/debug-editor-model.ts +508 -508
  201. package/src/browser/editor/debug-editor-service.ts +206 -206
  202. package/src/browser/editor/debug-editor.ts +20 -20
  203. package/src/browser/editor/debug-exception-widget.tsx +118 -118
  204. package/src/browser/editor/debug-expression-provider.ts +78 -78
  205. package/src/browser/editor/debug-hover-source.tsx +105 -105
  206. package/src/browser/editor/debug-hover-widget.ts +280 -280
  207. package/src/browser/editor/debug-inline-value-decorator.ts +377 -377
  208. package/src/browser/model/debug-breakpoint.tsx +151 -151
  209. package/src/browser/model/debug-function-breakpoint.tsx +101 -101
  210. package/src/browser/model/debug-instruction-breakpoint.tsx +68 -68
  211. package/src/browser/model/debug-source-breakpoint.tsx +237 -237
  212. package/src/browser/model/debug-source.ts +93 -93
  213. package/src/browser/model/debug-stack-frame.tsx +170 -170
  214. package/src/browser/model/debug-thread.tsx +240 -240
  215. package/src/browser/preferences/launch-preferences.ts +38 -38
  216. package/src/browser/style/index.css +445 -445
  217. package/src/browser/view/debug-action.tsx +57 -57
  218. package/src/browser/view/debug-breakpoints-source.tsx +53 -53
  219. package/src/browser/view/debug-breakpoints-widget.ts +71 -71
  220. package/src/browser/view/debug-configuration-select.tsx +256 -256
  221. package/src/browser/view/debug-configuration-widget.tsx +121 -121
  222. package/src/browser/view/debug-exception-breakpoint.tsx +43 -43
  223. package/src/browser/view/debug-session-widget.ts +124 -124
  224. package/src/browser/view/debug-stack-frames-source.tsx +75 -75
  225. package/src/browser/view/debug-stack-frames-widget.ts +135 -135
  226. package/src/browser/view/debug-threads-source.tsx +48 -48
  227. package/src/browser/view/debug-threads-widget.ts +125 -125
  228. package/src/browser/view/debug-toolbar-widget.tsx +145 -145
  229. package/src/browser/view/debug-variables-source.ts +43 -43
  230. package/src/browser/view/debug-variables-widget.ts +61 -61
  231. package/src/browser/view/debug-view-model.ts +230 -230
  232. package/src/browser/view/debug-watch-expression.tsx +88 -88
  233. package/src/browser/view/debug-watch-source.ts +41 -41
  234. package/src/browser/view/debug-watch-widget.ts +61 -61
  235. package/src/browser/view/debug-widget.ts +97 -97
  236. package/src/common/debug-adapter-contribution-registry.ts +206 -206
  237. package/src/common/debug-adapter-session.ts +102 -102
  238. package/src/common/debug-common.ts +19 -19
  239. package/src/common/debug-compound.ts +33 -33
  240. package/src/common/debug-configuration.ts +93 -93
  241. package/src/common/debug-model.ts +200 -200
  242. package/src/common/debug-service.ts +184 -184
  243. package/src/common/debug-uri-utils.ts +24 -24
  244. package/src/common/inline-debug-adapter.ts +47 -47
  245. package/src/node/debug-adapter-factory.ts +107 -107
  246. package/src/node/debug-adapter-session-manager.ts +106 -106
  247. package/src/node/debug-backend-module.ts +57 -57
  248. package/src/node/debug-service-impl.ts +119 -119
  249. package/src/node/stream-debug-adapter.ts +126 -126
  250. package/src/node/vscode/vscode-debug-adapter-contribution.ts +252 -252
@@ -1,594 +1,594 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2018 Red Hat, Inc. and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
- return c > 3 && r && Object.defineProperty(target, key, r), r;
22
- };
23
- var __metadata = (this && this.__metadata) || function (k, v) {
24
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.DebugSessionManager = void 0;
28
- const core_1 = require("@theia/core");
29
- const browser_1 = require("@theia/core/lib/browser");
30
- const context_key_service_1 = require("@theia/core/lib/browser/context-key-service");
31
- const uri_1 = require("@theia/core/lib/common/uri");
32
- const browser_2 = require("@theia/editor/lib/browser");
33
- const quick_open_task_1 = require("@theia/task/lib/browser/quick-open-task");
34
- const task_service_1 = require("@theia/task/lib/browser/task-service");
35
- const browser_3 = require("@theia/variable-resolver/lib/browser");
36
- const inversify_1 = require("@theia/core/shared/inversify");
37
- const debug_service_1 = require("../common/debug-service");
38
- const breakpoint_manager_1 = require("./breakpoint/breakpoint-manager");
39
- const debug_configuration_manager_1 = require("./debug-configuration-manager");
40
- const debug_session_1 = require("./debug-session");
41
- const debug_session_contribution_1 = require("./debug-session-contribution");
42
- const debug_session_options_1 = require("./debug-session-options");
43
- const debug_source_breakpoint_1 = require("./model/debug-source-breakpoint");
44
- const debug_function_breakpoint_1 = require("./model/debug-function-breakpoint");
45
- const debug_instruction_breakpoint_1 = require("./model/debug-instruction-breakpoint");
46
- let DebugSessionManager = class DebugSessionManager {
47
- constructor() {
48
- this._sessions = new Map();
49
- this.onWillStartDebugSessionEmitter = new core_1.Emitter();
50
- this.onWillStartDebugSession = this.onWillStartDebugSessionEmitter.event;
51
- this.onWillResolveDebugConfigurationEmitter = new core_1.Emitter();
52
- this.onWillResolveDebugConfiguration = this.onWillResolveDebugConfigurationEmitter.event;
53
- this.onDidCreateDebugSessionEmitter = new core_1.Emitter();
54
- this.onDidCreateDebugSession = this.onDidCreateDebugSessionEmitter.event;
55
- this.onDidStartDebugSessionEmitter = new core_1.Emitter();
56
- this.onDidStartDebugSession = this.onDidStartDebugSessionEmitter.event;
57
- this.onDidStopDebugSessionEmitter = new core_1.Emitter();
58
- this.onDidStopDebugSession = this.onDidStopDebugSessionEmitter.event;
59
- this.onDidChangeActiveDebugSessionEmitter = new core_1.Emitter();
60
- this.onDidChangeActiveDebugSession = this.onDidChangeActiveDebugSessionEmitter.event;
61
- this.onDidDestroyDebugSessionEmitter = new core_1.Emitter();
62
- this.onDidDestroyDebugSession = this.onDidDestroyDebugSessionEmitter.event;
63
- this.onDidReceiveDebugSessionCustomEventEmitter = new core_1.Emitter();
64
- this.onDidReceiveDebugSessionCustomEvent = this.onDidReceiveDebugSessionCustomEventEmitter.event;
65
- this.onDidFocusStackFrameEmitter = new core_1.Emitter();
66
- this.onDidFocusStackFrame = this.onDidFocusStackFrameEmitter.event;
67
- this.onDidChangeBreakpointsEmitter = new core_1.Emitter();
68
- this.onDidChangeBreakpoints = this.onDidChangeBreakpointsEmitter.event;
69
- this.onDidChangeEmitter = new core_1.Emitter();
70
- this.onDidChange = this.onDidChangeEmitter.event;
71
- this.configurationIds = new Map();
72
- this.disposeOnCurrentSessionChanged = new core_1.DisposableCollection();
73
- }
74
- fireDidChangeBreakpoints(event) {
75
- this.onDidChangeBreakpointsEmitter.fire(event);
76
- }
77
- fireDidChange(current) {
78
- this.debugTypeKey.set(current === null || current === void 0 ? void 0 : current.configuration.type);
79
- this.inDebugModeKey.set(this.inDebugMode);
80
- this.debugStateKey.set((0, debug_session_1.debugStateContextValue)(this.state));
81
- this.onDidChangeEmitter.fire(current);
82
- }
83
- init() {
84
- this.debugTypeKey = this.contextKeyService.createKey('debugType', undefined);
85
- this.inDebugModeKey = this.contextKeyService.createKey('inDebugMode', this.inDebugMode);
86
- this.debugStateKey = this.contextKeyService.createKey('debugState', (0, debug_session_1.debugStateContextValue)(this.state));
87
- this.breakpoints.onDidChangeMarkers(uri => this.fireDidChangeBreakpoints({ uri }));
88
- this.labelProvider.onDidChange(event => {
89
- for (const uriString of this.breakpoints.getUris()) {
90
- const uri = new uri_1.default(uriString);
91
- if (event.affects(uri)) {
92
- this.fireDidChangeBreakpoints({ uri });
93
- }
94
- }
95
- });
96
- }
97
- get inDebugMode() {
98
- return this.state > debug_session_1.DebugState.Inactive;
99
- }
100
- isCurrentEditorFrame(uri) {
101
- var _a, _b;
102
- return ((_b = (_a = this.currentFrame) === null || _a === void 0 ? void 0 : _a.source) === null || _b === void 0 ? void 0 : _b.uri.toString()) === (uri instanceof uri_1.default ? uri : new uri_1.default(uri)).toString();
103
- }
104
- async saveAll() {
105
- if (!this.shell.canSaveAll()) {
106
- return true; // Nothing to save.
107
- }
108
- try {
109
- await this.shell.saveAll();
110
- return true;
111
- }
112
- catch (error) {
113
- console.error('saveAll failed:', error);
114
- return false;
115
- }
116
- }
117
- async start(optionsOrName) {
118
- if (typeof optionsOrName === 'string') {
119
- const options = this.debugConfigurationManager.find(optionsOrName);
120
- return !!options && this.start(options);
121
- }
122
- return optionsOrName.configuration ? this.startConfiguration(optionsOrName) : this.startCompound(optionsOrName);
123
- }
124
- async startConfiguration(options) {
125
- return this.progressService.withProgress('Start...', 'debug', async () => {
126
- try {
127
- if (!await this.saveAll()) {
128
- return undefined;
129
- }
130
- await this.fireWillStartDebugSession();
131
- const resolved = await this.resolveConfiguration(options);
132
- if (!resolved || !resolved.configuration) {
133
- // As per vscode API: https://code.visualstudio.com/api/references/vscode-api#DebugConfigurationProvider
134
- // "Returning the value 'undefined' prevents the debug session from starting.
135
- // Returning the value 'null' prevents the debug session from starting and opens the
136
- // underlying debug configuration instead."
137
- // eslint-disable-next-line no-null/no-null
138
- if (resolved === null) {
139
- this.debugConfigurationManager.openConfiguration();
140
- }
141
- return undefined;
142
- }
143
- // preLaunchTask isn't run in case of auto restart as well as postDebugTask
144
- if (!options.configuration.__restart) {
145
- const taskRun = await this.runTask(options.workspaceFolderUri, resolved.configuration.preLaunchTask, true);
146
- if (!taskRun) {
147
- return undefined;
148
- }
149
- }
150
- const sessionId = await this.debug.createDebugSession(resolved.configuration, options.workspaceFolderUri);
151
- return this.doStart(sessionId, resolved);
152
- }
153
- catch (e) {
154
- if (debug_service_1.DebugError.NotFound.is(e)) {
155
- this.messageService.error(`The debug session type "${e.data.type}" is not supported.`);
156
- return undefined;
157
- }
158
- this.messageService.error('There was an error starting the debug session, check the logs for more details.');
159
- console.error('Error starting the debug session', e);
160
- throw e;
161
- }
162
- });
163
- }
164
- async startCompound(options) {
165
- let configurations = [];
166
- const compoundRoot = options.compound.stopAll ? new debug_session_options_1.DebugCompoundRoot() : undefined;
167
- try {
168
- configurations = this.getCompoundConfigurations(options, compoundRoot);
169
- }
170
- catch (error) {
171
- this.messageService.error(error.message);
172
- return;
173
- }
174
- if (options.compound.preLaunchTask) {
175
- const taskRun = await this.runTask(options.workspaceFolderUri, options.compound.preLaunchTask, true);
176
- if (!taskRun) {
177
- return undefined;
178
- }
179
- }
180
- // Compound launch is a success only if each configuration launched successfully
181
- const values = await Promise.all(configurations.map(async (configuration) => {
182
- const newSession = await this.startConfiguration(configuration);
183
- if (newSession) {
184
- compoundRoot === null || compoundRoot === void 0 ? void 0 : compoundRoot.onDidSessionStop(() => newSession.stop(false, () => this.debug.terminateDebugSession(newSession.id)));
185
- }
186
- return newSession;
187
- }));
188
- const result = values.every(success => !!success);
189
- return result;
190
- }
191
- getCompoundConfigurations(options, compoundRoot) {
192
- const compound = options.compound;
193
- if (!compound.configurations) {
194
- throw new Error(core_1.nls.localizeByDefault('Compound must have "configurations" attribute set in order to start multiple configurations.'));
195
- }
196
- const configurations = [];
197
- for (const configData of compound.configurations) {
198
- const name = typeof configData === 'string' ? configData : configData.name;
199
- if (name === compound.name) {
200
- throw new Error(core_1.nls.localize('theia/debug/compound-cycle', "Launch configuration '{0}' contains a cycle with itself", name));
201
- }
202
- const workspaceFolderUri = typeof configData === 'string' ? options.workspaceFolderUri : configData.folder;
203
- const matchingOptions = [...this.debugConfigurationManager.all]
204
- .filter(option => option.name === name && !!option.configuration && option.workspaceFolderUri === workspaceFolderUri);
205
- if (matchingOptions.length === 1) {
206
- const match = matchingOptions[0];
207
- if (debug_session_options_1.DebugSessionOptions.isConfiguration(match)) {
208
- configurations.push(Object.assign(Object.assign({}, match), { compoundRoot, configuration: Object.assign(Object.assign({}, match.configuration), { noDebug: options.noDebug }) }));
209
- }
210
- else {
211
- throw new Error(core_1.nls.localizeByDefault("Could not find launch configuration '{0}' in the workspace.", name));
212
- }
213
- }
214
- else {
215
- throw new Error(matchingOptions.length === 0
216
- ? workspaceFolderUri
217
- ? core_1.nls.localizeByDefault("Can not find folder with name '{0}' for configuration '{1}' in compound '{2}'.", workspaceFolderUri, name, compound.name)
218
- : core_1.nls.localizeByDefault("Could not find launch configuration '{0}' in the workspace.", name)
219
- : core_1.nls.localizeByDefault("There are multiple launch configurations '{0}' in the workspace. Use folder name to qualify the configuration.", name));
220
- }
221
- }
222
- return configurations;
223
- }
224
- async fireWillStartDebugSession() {
225
- await core_1.WaitUntilEvent.fire(this.onWillStartDebugSessionEmitter, {});
226
- }
227
- async resolveConfiguration(options) {
228
- if (debug_session_options_1.InternalDebugSessionOptions.is(options)) {
229
- return options;
230
- }
231
- const { workspaceFolderUri } = options;
232
- let configuration = await this.resolveDebugConfiguration(options.configuration, workspaceFolderUri);
233
- if (configuration) {
234
- // Resolve command variables provided by the debugger
235
- const commandIdVariables = await this.debug.provideDebuggerVariables(configuration.type);
236
- configuration = await this.variableResolver.resolve(configuration, {
237
- context: options.workspaceFolderUri ? new uri_1.default(options.workspaceFolderUri) : undefined,
238
- configurationSection: 'launch',
239
- commandIdVariables,
240
- configuration
241
- });
242
- if (configuration) {
243
- configuration = await this.resolveDebugConfigurationWithSubstitutedVariables(configuration, workspaceFolderUri);
244
- }
245
- }
246
- if (!configuration) {
247
- return configuration;
248
- }
249
- const key = configuration.name + workspaceFolderUri;
250
- const id = this.configurationIds.has(key) ? this.configurationIds.get(key) + 1 : 0;
251
- this.configurationIds.set(key, id);
252
- return Object.assign(Object.assign({ id }, options), { name: configuration.name, configuration });
253
- }
254
- async resolveDebugConfiguration(configuration, workspaceFolderUri) {
255
- await this.fireWillResolveDebugConfiguration(configuration.type);
256
- return this.debug.resolveDebugConfiguration(configuration, workspaceFolderUri);
257
- }
258
- async fireWillResolveDebugConfiguration(debugType) {
259
- await core_1.WaitUntilEvent.fire(this.onWillResolveDebugConfigurationEmitter, { debugType });
260
- }
261
- async resolveDebugConfigurationWithSubstitutedVariables(configuration, workspaceFolderUri) {
262
- return this.debug.resolveDebugConfigurationWithSubstitutedVariables(configuration, workspaceFolderUri);
263
- }
264
- async doStart(sessionId, options) {
265
- const parentSession = options.configuration.parentSessionId ? this._sessions.get(options.configuration.parentSessionId) : undefined;
266
- const contrib = this.sessionContributionRegistry.get(options.configuration.type);
267
- const sessionFactory = contrib ? contrib.debugSessionFactory() : this.debugSessionFactory;
268
- const session = sessionFactory.get(sessionId, options, parentSession);
269
- this._sessions.set(sessionId, session);
270
- this.debugTypeKey.set(session.configuration.type);
271
- this.onDidCreateDebugSessionEmitter.fire(session);
272
- let state = debug_session_1.DebugState.Inactive;
273
- session.onDidChange(() => {
274
- if (state !== session.state) {
275
- state = session.state;
276
- if (state === debug_session_1.DebugState.Stopped) {
277
- this.onDidStopDebugSessionEmitter.fire(session);
278
- }
279
- }
280
- this.updateCurrentSession(session);
281
- });
282
- session.onDidChangeBreakpoints(uri => this.fireDidChangeBreakpoints({ session, uri }));
283
- session.on('terminated', async (event) => {
284
- const restart = event.body && event.body.restart;
285
- if (restart) {
286
- // postDebugTask isn't run in case of auto restart as well as preLaunchTask
287
- this.doRestart(session, !!restart);
288
- }
289
- else {
290
- await session.disconnect(false, () => this.debug.terminateDebugSession(session.id));
291
- await this.runTask(session.options.workspaceFolderUri, session.configuration.postDebugTask);
292
- }
293
- });
294
- session.on('exited', async (event) => {
295
- await session.disconnect(false, () => this.debug.terminateDebugSession(session.id));
296
- });
297
- session.onDispose(() => this.cleanup(session));
298
- session.start().then(() => this.onDidStartDebugSessionEmitter.fire(session)).catch(e => {
299
- session.stop(false, () => {
300
- this.debug.terminateDebugSession(session.id);
301
- });
302
- });
303
- session.onDidCustomEvent(({ event, body }) => this.onDidReceiveDebugSessionCustomEventEmitter.fire({ event, body, session }));
304
- return session;
305
- }
306
- cleanup(session) {
307
- if (this.remove(session.id)) {
308
- this.onDidDestroyDebugSessionEmitter.fire(session);
309
- }
310
- }
311
- async doRestart(session, isRestart) {
312
- if (session.canRestart()) {
313
- await session.restart();
314
- return session;
315
- }
316
- const { options, configuration } = session;
317
- session.stop(isRestart, () => this.debug.terminateDebugSession(session.id));
318
- configuration.__restart = isRestart;
319
- return this.start(options);
320
- }
321
- async terminateSession(session) {
322
- if (!session) {
323
- this.updateCurrentSession(this._currentSession);
324
- session = this._currentSession;
325
- }
326
- if (session) {
327
- if (session.options.compoundRoot) {
328
- session.options.compoundRoot.stopSession();
329
- }
330
- else if (session.parentSession && session.configuration.lifecycleManagedByParent) {
331
- this.terminateSession(session.parentSession);
332
- }
333
- else {
334
- session.stop(false, () => this.debug.terminateDebugSession(session.id));
335
- }
336
- }
337
- }
338
- async restartSession(session) {
339
- if (!session) {
340
- this.updateCurrentSession(this._currentSession);
341
- session = this._currentSession;
342
- }
343
- if (session) {
344
- if (session.parentSession && session.configuration.lifecycleManagedByParent) {
345
- return this.restartSession(session.parentSession);
346
- }
347
- else {
348
- return this.doRestart(session, true);
349
- }
350
- }
351
- }
352
- remove(sessionId) {
353
- const existed = this._sessions.delete(sessionId);
354
- const { currentSession } = this;
355
- if (currentSession && currentSession.id === sessionId) {
356
- this.updateCurrentSession(undefined);
357
- }
358
- return existed;
359
- }
360
- getSession(sessionId) {
361
- return this._sessions.get(sessionId);
362
- }
363
- get sessions() {
364
- return Array.from(this._sessions.values()).filter(session => session.state > debug_session_1.DebugState.Inactive);
365
- }
366
- get currentSession() {
367
- return this._currentSession;
368
- }
369
- set currentSession(current) {
370
- if (this._currentSession === current) {
371
- return;
372
- }
373
- this.disposeOnCurrentSessionChanged.dispose();
374
- const previous = this.currentSession;
375
- this._currentSession = current;
376
- this.onDidChangeActiveDebugSessionEmitter.fire({ previous, current });
377
- if (current) {
378
- this.disposeOnCurrentSessionChanged.push(current.onDidChange(() => {
379
- if (this.currentFrame === this.topFrame) {
380
- this.open();
381
- }
382
- this.fireDidChange(current);
383
- }));
384
- this.disposeOnCurrentSessionChanged.push(current.onDidFocusStackFrame(frame => this.onDidFocusStackFrameEmitter.fire({ session: current, frame })));
385
- }
386
- this.updateBreakpoints(previous, current);
387
- this.open();
388
- this.fireDidChange(current);
389
- }
390
- open() {
391
- const { currentFrame } = this;
392
- if (currentFrame) {
393
- currentFrame.open();
394
- }
395
- }
396
- updateBreakpoints(previous, current) {
397
- const affectedUri = new Set();
398
- for (const session of [previous, current]) {
399
- if (session) {
400
- for (const uriString of session.breakpointUris) {
401
- if (!affectedUri.has(uriString)) {
402
- affectedUri.add(uriString);
403
- this.fireDidChangeBreakpoints({
404
- session: current,
405
- uri: new uri_1.default(uriString)
406
- });
407
- }
408
- }
409
- }
410
- }
411
- }
412
- updateCurrentSession(session) {
413
- this.currentSession = session || this.sessions[0];
414
- }
415
- get currentThread() {
416
- const session = this.currentSession;
417
- return session && session.currentThread;
418
- }
419
- get state() {
420
- const session = this.currentSession;
421
- return session ? session.state : debug_session_1.DebugState.Inactive;
422
- }
423
- get currentFrame() {
424
- const { currentThread } = this;
425
- return currentThread && currentThread.currentFrame;
426
- }
427
- get topFrame() {
428
- const { currentThread } = this;
429
- return currentThread && currentThread.topFrame;
430
- }
431
- getFunctionBreakpoints(session = this.currentSession) {
432
- if (session && session.state > debug_session_1.DebugState.Initializing) {
433
- return session.getFunctionBreakpoints();
434
- }
435
- const { labelProvider, breakpoints, editorManager } = this;
436
- return this.breakpoints.getFunctionBreakpoints().map(origin => new debug_function_breakpoint_1.DebugFunctionBreakpoint(origin, { labelProvider, breakpoints, editorManager }));
437
- }
438
- getInstructionBreakpoints(session = this.currentSession) {
439
- if (session && session.state > debug_session_1.DebugState.Initializing) {
440
- return session.getInstructionBreakpoints();
441
- }
442
- const { labelProvider, breakpoints, editorManager } = this;
443
- return this.breakpoints.getInstructionBreakpoints().map(origin => new debug_instruction_breakpoint_1.DebugInstructionBreakpoint(origin, { labelProvider, breakpoints, editorManager }));
444
- }
445
- getBreakpoints(arg, arg2) {
446
- const uri = arg instanceof uri_1.default ? arg : undefined;
447
- const session = arg instanceof debug_session_1.DebugSession ? arg : arg2 instanceof debug_session_1.DebugSession ? arg2 : this.currentSession;
448
- if (session && session.state > debug_session_1.DebugState.Initializing) {
449
- return session.getSourceBreakpoints(uri);
450
- }
451
- const { labelProvider, breakpoints, editorManager } = this;
452
- return this.breakpoints.findMarkers({ uri }).map(({ data }) => new debug_source_breakpoint_1.DebugSourceBreakpoint(data, { labelProvider, breakpoints, editorManager }));
453
- }
454
- getLineBreakpoints(uri, line) {
455
- const session = this.currentSession;
456
- if (session && session.state > debug_session_1.DebugState.Initializing) {
457
- return session.getSourceBreakpoints(uri).filter(breakpoint => breakpoint.line === line);
458
- }
459
- const { labelProvider, breakpoints, editorManager } = this;
460
- return this.breakpoints.getLineBreakpoints(uri, line).map(origin => new debug_source_breakpoint_1.DebugSourceBreakpoint(origin, { labelProvider, breakpoints, editorManager }));
461
- }
462
- getInlineBreakpoint(uri, line, column) {
463
- const session = this.currentSession;
464
- if (session && session.state > debug_session_1.DebugState.Initializing) {
465
- return session.getSourceBreakpoints(uri).filter(breakpoint => breakpoint.line === line && breakpoint.column === column)[0];
466
- }
467
- const origin = this.breakpoints.getInlineBreakpoint(uri, line, column);
468
- const { labelProvider, breakpoints, editorManager } = this;
469
- return origin && new debug_source_breakpoint_1.DebugSourceBreakpoint(origin, { labelProvider, breakpoints, editorManager });
470
- }
471
- /**
472
- * Runs the given tasks.
473
- * @param taskName the task name to run, see [TaskNameResolver](#TaskNameResolver)
474
- * @return true if it allowed to continue debugging otherwise it returns false
475
- */
476
- async runTask(workspaceFolderUri, taskName, checkErrors) {
477
- if (!taskName) {
478
- return true;
479
- }
480
- const taskInfo = await this.taskService.runWorkspaceTask(this.taskService.startUserAction(), workspaceFolderUri, taskName);
481
- if (!checkErrors) {
482
- return true;
483
- }
484
- if (!taskInfo) {
485
- return this.doPostTaskAction(`Could not run the task '${taskName}'.`);
486
- }
487
- const getExitCodePromise = this.taskService.getExitCode(taskInfo.taskId).then(result => ({ taskEndedType: task_service_1.TaskEndedTypes.TaskExited, value: result }));
488
- const isBackgroundTaskEndedPromise = this.taskService.isBackgroundTaskEnded(taskInfo.taskId).then(result => ({ taskEndedType: task_service_1.TaskEndedTypes.BackgroundTaskEnded, value: result }));
489
- // After start running the task, we wait for the task process to exit and if it is a background task, we also wait for a feedback
490
- // that a background task is active, as soon as one of the promises fulfills, we can continue and analyze the results.
491
- const taskEndedInfo = await Promise.race([getExitCodePromise, isBackgroundTaskEndedPromise]);
492
- if (taskEndedInfo.taskEndedType === task_service_1.TaskEndedTypes.BackgroundTaskEnded && taskEndedInfo.value) {
493
- return true;
494
- }
495
- if (taskEndedInfo.taskEndedType === task_service_1.TaskEndedTypes.TaskExited && taskEndedInfo.value === 0) {
496
- return true;
497
- }
498
- else if (taskEndedInfo.taskEndedType === task_service_1.TaskEndedTypes.TaskExited && taskEndedInfo.value !== undefined) {
499
- return this.doPostTaskAction(`Task '${taskName}' terminated with exit code ${taskEndedInfo.value}.`);
500
- }
501
- else {
502
- const signal = await this.taskService.getTerminateSignal(taskInfo.taskId);
503
- if (signal !== undefined) {
504
- return this.doPostTaskAction(`Task '${taskName}' terminated by signal ${signal}.`);
505
- }
506
- else {
507
- return this.doPostTaskAction(`Task '${taskName}' terminated for unknown reason.`);
508
- }
509
- }
510
- }
511
- async doPostTaskAction(errorMessage) {
512
- const actions = ['Open launch.json', 'Cancel', 'Configure Task', 'Debug Anyway'];
513
- const result = await this.messageService.error(errorMessage, ...actions);
514
- switch (result) {
515
- case actions[0]: // open launch.json
516
- this.debugConfigurationManager.openConfiguration();
517
- return false;
518
- case actions[1]: // cancel
519
- return false;
520
- case actions[2]: // configure tasks
521
- this.quickOpenTask.configure();
522
- return false;
523
- default: // continue debugging
524
- return true;
525
- }
526
- }
527
- };
528
- __decorate([
529
- (0, inversify_1.inject)(debug_session_contribution_1.DebugSessionFactory),
530
- __metadata("design:type", Object)
531
- ], DebugSessionManager.prototype, "debugSessionFactory", void 0);
532
- __decorate([
533
- (0, inversify_1.inject)(debug_service_1.DebugService),
534
- __metadata("design:type", Object)
535
- ], DebugSessionManager.prototype, "debug", void 0);
536
- __decorate([
537
- (0, inversify_1.inject)(browser_1.LabelProvider),
538
- __metadata("design:type", browser_1.LabelProvider)
539
- ], DebugSessionManager.prototype, "labelProvider", void 0);
540
- __decorate([
541
- (0, inversify_1.inject)(browser_2.EditorManager),
542
- __metadata("design:type", browser_2.EditorManager)
543
- ], DebugSessionManager.prototype, "editorManager", void 0);
544
- __decorate([
545
- (0, inversify_1.inject)(breakpoint_manager_1.BreakpointManager),
546
- __metadata("design:type", breakpoint_manager_1.BreakpointManager)
547
- ], DebugSessionManager.prototype, "breakpoints", void 0);
548
- __decorate([
549
- (0, inversify_1.inject)(browser_3.VariableResolverService),
550
- __metadata("design:type", browser_3.VariableResolverService)
551
- ], DebugSessionManager.prototype, "variableResolver", void 0);
552
- __decorate([
553
- (0, inversify_1.inject)(debug_session_contribution_1.DebugSessionContributionRegistry),
554
- __metadata("design:type", Object)
555
- ], DebugSessionManager.prototype, "sessionContributionRegistry", void 0);
556
- __decorate([
557
- (0, inversify_1.inject)(core_1.MessageService),
558
- __metadata("design:type", core_1.MessageService)
559
- ], DebugSessionManager.prototype, "messageService", void 0);
560
- __decorate([
561
- (0, inversify_1.inject)(core_1.ProgressService),
562
- __metadata("design:type", core_1.ProgressService)
563
- ], DebugSessionManager.prototype, "progressService", void 0);
564
- __decorate([
565
- (0, inversify_1.inject)(context_key_service_1.ContextKeyService),
566
- __metadata("design:type", Object)
567
- ], DebugSessionManager.prototype, "contextKeyService", void 0);
568
- __decorate([
569
- (0, inversify_1.inject)(task_service_1.TaskService),
570
- __metadata("design:type", task_service_1.TaskService)
571
- ], DebugSessionManager.prototype, "taskService", void 0);
572
- __decorate([
573
- (0, inversify_1.inject)(debug_configuration_manager_1.DebugConfigurationManager),
574
- __metadata("design:type", debug_configuration_manager_1.DebugConfigurationManager)
575
- ], DebugSessionManager.prototype, "debugConfigurationManager", void 0);
576
- __decorate([
577
- (0, inversify_1.inject)(quick_open_task_1.QuickOpenTask),
578
- __metadata("design:type", quick_open_task_1.QuickOpenTask)
579
- ], DebugSessionManager.prototype, "quickOpenTask", void 0);
580
- __decorate([
581
- (0, inversify_1.inject)(browser_1.ApplicationShell),
582
- __metadata("design:type", browser_1.ApplicationShell)
583
- ], DebugSessionManager.prototype, "shell", void 0);
584
- __decorate([
585
- (0, inversify_1.postConstruct)(),
586
- __metadata("design:type", Function),
587
- __metadata("design:paramtypes", []),
588
- __metadata("design:returntype", void 0)
589
- ], DebugSessionManager.prototype, "init", null);
590
- DebugSessionManager = __decorate([
591
- (0, inversify_1.injectable)()
592
- ], DebugSessionManager);
593
- exports.DebugSessionManager = DebugSessionManager;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2018 Red Hat, Inc. and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.DebugSessionManager = void 0;
28
+ const core_1 = require("@theia/core");
29
+ const browser_1 = require("@theia/core/lib/browser");
30
+ const context_key_service_1 = require("@theia/core/lib/browser/context-key-service");
31
+ const uri_1 = require("@theia/core/lib/common/uri");
32
+ const browser_2 = require("@theia/editor/lib/browser");
33
+ const quick_open_task_1 = require("@theia/task/lib/browser/quick-open-task");
34
+ const task_service_1 = require("@theia/task/lib/browser/task-service");
35
+ const browser_3 = require("@theia/variable-resolver/lib/browser");
36
+ const inversify_1 = require("@theia/core/shared/inversify");
37
+ const debug_service_1 = require("../common/debug-service");
38
+ const breakpoint_manager_1 = require("./breakpoint/breakpoint-manager");
39
+ const debug_configuration_manager_1 = require("./debug-configuration-manager");
40
+ const debug_session_1 = require("./debug-session");
41
+ const debug_session_contribution_1 = require("./debug-session-contribution");
42
+ const debug_session_options_1 = require("./debug-session-options");
43
+ const debug_source_breakpoint_1 = require("./model/debug-source-breakpoint");
44
+ const debug_function_breakpoint_1 = require("./model/debug-function-breakpoint");
45
+ const debug_instruction_breakpoint_1 = require("./model/debug-instruction-breakpoint");
46
+ let DebugSessionManager = class DebugSessionManager {
47
+ constructor() {
48
+ this._sessions = new Map();
49
+ this.onWillStartDebugSessionEmitter = new core_1.Emitter();
50
+ this.onWillStartDebugSession = this.onWillStartDebugSessionEmitter.event;
51
+ this.onWillResolveDebugConfigurationEmitter = new core_1.Emitter();
52
+ this.onWillResolveDebugConfiguration = this.onWillResolveDebugConfigurationEmitter.event;
53
+ this.onDidCreateDebugSessionEmitter = new core_1.Emitter();
54
+ this.onDidCreateDebugSession = this.onDidCreateDebugSessionEmitter.event;
55
+ this.onDidStartDebugSessionEmitter = new core_1.Emitter();
56
+ this.onDidStartDebugSession = this.onDidStartDebugSessionEmitter.event;
57
+ this.onDidStopDebugSessionEmitter = new core_1.Emitter();
58
+ this.onDidStopDebugSession = this.onDidStopDebugSessionEmitter.event;
59
+ this.onDidChangeActiveDebugSessionEmitter = new core_1.Emitter();
60
+ this.onDidChangeActiveDebugSession = this.onDidChangeActiveDebugSessionEmitter.event;
61
+ this.onDidDestroyDebugSessionEmitter = new core_1.Emitter();
62
+ this.onDidDestroyDebugSession = this.onDidDestroyDebugSessionEmitter.event;
63
+ this.onDidReceiveDebugSessionCustomEventEmitter = new core_1.Emitter();
64
+ this.onDidReceiveDebugSessionCustomEvent = this.onDidReceiveDebugSessionCustomEventEmitter.event;
65
+ this.onDidFocusStackFrameEmitter = new core_1.Emitter();
66
+ this.onDidFocusStackFrame = this.onDidFocusStackFrameEmitter.event;
67
+ this.onDidChangeBreakpointsEmitter = new core_1.Emitter();
68
+ this.onDidChangeBreakpoints = this.onDidChangeBreakpointsEmitter.event;
69
+ this.onDidChangeEmitter = new core_1.Emitter();
70
+ this.onDidChange = this.onDidChangeEmitter.event;
71
+ this.configurationIds = new Map();
72
+ this.disposeOnCurrentSessionChanged = new core_1.DisposableCollection();
73
+ }
74
+ fireDidChangeBreakpoints(event) {
75
+ this.onDidChangeBreakpointsEmitter.fire(event);
76
+ }
77
+ fireDidChange(current) {
78
+ this.debugTypeKey.set(current === null || current === void 0 ? void 0 : current.configuration.type);
79
+ this.inDebugModeKey.set(this.inDebugMode);
80
+ this.debugStateKey.set((0, debug_session_1.debugStateContextValue)(this.state));
81
+ this.onDidChangeEmitter.fire(current);
82
+ }
83
+ init() {
84
+ this.debugTypeKey = this.contextKeyService.createKey('debugType', undefined);
85
+ this.inDebugModeKey = this.contextKeyService.createKey('inDebugMode', this.inDebugMode);
86
+ this.debugStateKey = this.contextKeyService.createKey('debugState', (0, debug_session_1.debugStateContextValue)(this.state));
87
+ this.breakpoints.onDidChangeMarkers(uri => this.fireDidChangeBreakpoints({ uri }));
88
+ this.labelProvider.onDidChange(event => {
89
+ for (const uriString of this.breakpoints.getUris()) {
90
+ const uri = new uri_1.default(uriString);
91
+ if (event.affects(uri)) {
92
+ this.fireDidChangeBreakpoints({ uri });
93
+ }
94
+ }
95
+ });
96
+ }
97
+ get inDebugMode() {
98
+ return this.state > debug_session_1.DebugState.Inactive;
99
+ }
100
+ isCurrentEditorFrame(uri) {
101
+ var _a, _b;
102
+ return ((_b = (_a = this.currentFrame) === null || _a === void 0 ? void 0 : _a.source) === null || _b === void 0 ? void 0 : _b.uri.toString()) === (uri instanceof uri_1.default ? uri : new uri_1.default(uri)).toString();
103
+ }
104
+ async saveAll() {
105
+ if (!this.shell.canSaveAll()) {
106
+ return true; // Nothing to save.
107
+ }
108
+ try {
109
+ await this.shell.saveAll();
110
+ return true;
111
+ }
112
+ catch (error) {
113
+ console.error('saveAll failed:', error);
114
+ return false;
115
+ }
116
+ }
117
+ async start(optionsOrName) {
118
+ if (typeof optionsOrName === 'string') {
119
+ const options = this.debugConfigurationManager.find(optionsOrName);
120
+ return !!options && this.start(options);
121
+ }
122
+ return optionsOrName.configuration ? this.startConfiguration(optionsOrName) : this.startCompound(optionsOrName);
123
+ }
124
+ async startConfiguration(options) {
125
+ return this.progressService.withProgress('Start...', 'debug', async () => {
126
+ try {
127
+ if (!await this.saveAll()) {
128
+ return undefined;
129
+ }
130
+ await this.fireWillStartDebugSession();
131
+ const resolved = await this.resolveConfiguration(options);
132
+ if (!resolved || !resolved.configuration) {
133
+ // As per vscode API: https://code.visualstudio.com/api/references/vscode-api#DebugConfigurationProvider
134
+ // "Returning the value 'undefined' prevents the debug session from starting.
135
+ // Returning the value 'null' prevents the debug session from starting and opens the
136
+ // underlying debug configuration instead."
137
+ // eslint-disable-next-line no-null/no-null
138
+ if (resolved === null) {
139
+ this.debugConfigurationManager.openConfiguration();
140
+ }
141
+ return undefined;
142
+ }
143
+ // preLaunchTask isn't run in case of auto restart as well as postDebugTask
144
+ if (!options.configuration.__restart) {
145
+ const taskRun = await this.runTask(options.workspaceFolderUri, resolved.configuration.preLaunchTask, true);
146
+ if (!taskRun) {
147
+ return undefined;
148
+ }
149
+ }
150
+ const sessionId = await this.debug.createDebugSession(resolved.configuration, options.workspaceFolderUri);
151
+ return this.doStart(sessionId, resolved);
152
+ }
153
+ catch (e) {
154
+ if (debug_service_1.DebugError.NotFound.is(e)) {
155
+ this.messageService.error(`The debug session type "${e.data.type}" is not supported.`);
156
+ return undefined;
157
+ }
158
+ this.messageService.error('There was an error starting the debug session, check the logs for more details.');
159
+ console.error('Error starting the debug session', e);
160
+ throw e;
161
+ }
162
+ });
163
+ }
164
+ async startCompound(options) {
165
+ let configurations = [];
166
+ const compoundRoot = options.compound.stopAll ? new debug_session_options_1.DebugCompoundRoot() : undefined;
167
+ try {
168
+ configurations = this.getCompoundConfigurations(options, compoundRoot);
169
+ }
170
+ catch (error) {
171
+ this.messageService.error(error.message);
172
+ return;
173
+ }
174
+ if (options.compound.preLaunchTask) {
175
+ const taskRun = await this.runTask(options.workspaceFolderUri, options.compound.preLaunchTask, true);
176
+ if (!taskRun) {
177
+ return undefined;
178
+ }
179
+ }
180
+ // Compound launch is a success only if each configuration launched successfully
181
+ const values = await Promise.all(configurations.map(async (configuration) => {
182
+ const newSession = await this.startConfiguration(configuration);
183
+ if (newSession) {
184
+ compoundRoot === null || compoundRoot === void 0 ? void 0 : compoundRoot.onDidSessionStop(() => newSession.stop(false, () => this.debug.terminateDebugSession(newSession.id)));
185
+ }
186
+ return newSession;
187
+ }));
188
+ const result = values.every(success => !!success);
189
+ return result;
190
+ }
191
+ getCompoundConfigurations(options, compoundRoot) {
192
+ const compound = options.compound;
193
+ if (!compound.configurations) {
194
+ throw new Error(core_1.nls.localizeByDefault('Compound must have "configurations" attribute set in order to start multiple configurations.'));
195
+ }
196
+ const configurations = [];
197
+ for (const configData of compound.configurations) {
198
+ const name = typeof configData === 'string' ? configData : configData.name;
199
+ if (name === compound.name) {
200
+ throw new Error(core_1.nls.localize('theia/debug/compound-cycle', "Launch configuration '{0}' contains a cycle with itself", name));
201
+ }
202
+ const workspaceFolderUri = typeof configData === 'string' ? options.workspaceFolderUri : configData.folder;
203
+ const matchingOptions = [...this.debugConfigurationManager.all]
204
+ .filter(option => option.name === name && !!option.configuration && option.workspaceFolderUri === workspaceFolderUri);
205
+ if (matchingOptions.length === 1) {
206
+ const match = matchingOptions[0];
207
+ if (debug_session_options_1.DebugSessionOptions.isConfiguration(match)) {
208
+ configurations.push(Object.assign(Object.assign({}, match), { compoundRoot, configuration: Object.assign(Object.assign({}, match.configuration), { noDebug: options.noDebug }) }));
209
+ }
210
+ else {
211
+ throw new Error(core_1.nls.localizeByDefault("Could not find launch configuration '{0}' in the workspace.", name));
212
+ }
213
+ }
214
+ else {
215
+ throw new Error(matchingOptions.length === 0
216
+ ? workspaceFolderUri
217
+ ? core_1.nls.localizeByDefault("Can not find folder with name '{0}' for configuration '{1}' in compound '{2}'.", workspaceFolderUri, name, compound.name)
218
+ : core_1.nls.localizeByDefault("Could not find launch configuration '{0}' in the workspace.", name)
219
+ : core_1.nls.localizeByDefault("There are multiple launch configurations '{0}' in the workspace. Use folder name to qualify the configuration.", name));
220
+ }
221
+ }
222
+ return configurations;
223
+ }
224
+ async fireWillStartDebugSession() {
225
+ await core_1.WaitUntilEvent.fire(this.onWillStartDebugSessionEmitter, {});
226
+ }
227
+ async resolveConfiguration(options) {
228
+ if (debug_session_options_1.InternalDebugSessionOptions.is(options)) {
229
+ return options;
230
+ }
231
+ const { workspaceFolderUri } = options;
232
+ let configuration = await this.resolveDebugConfiguration(options.configuration, workspaceFolderUri);
233
+ if (configuration) {
234
+ // Resolve command variables provided by the debugger
235
+ const commandIdVariables = await this.debug.provideDebuggerVariables(configuration.type);
236
+ configuration = await this.variableResolver.resolve(configuration, {
237
+ context: options.workspaceFolderUri ? new uri_1.default(options.workspaceFolderUri) : undefined,
238
+ configurationSection: 'launch',
239
+ commandIdVariables,
240
+ configuration
241
+ });
242
+ if (configuration) {
243
+ configuration = await this.resolveDebugConfigurationWithSubstitutedVariables(configuration, workspaceFolderUri);
244
+ }
245
+ }
246
+ if (!configuration) {
247
+ return configuration;
248
+ }
249
+ const key = configuration.name + workspaceFolderUri;
250
+ const id = this.configurationIds.has(key) ? this.configurationIds.get(key) + 1 : 0;
251
+ this.configurationIds.set(key, id);
252
+ return Object.assign(Object.assign({ id }, options), { name: configuration.name, configuration });
253
+ }
254
+ async resolveDebugConfiguration(configuration, workspaceFolderUri) {
255
+ await this.fireWillResolveDebugConfiguration(configuration.type);
256
+ return this.debug.resolveDebugConfiguration(configuration, workspaceFolderUri);
257
+ }
258
+ async fireWillResolveDebugConfiguration(debugType) {
259
+ await core_1.WaitUntilEvent.fire(this.onWillResolveDebugConfigurationEmitter, { debugType });
260
+ }
261
+ async resolveDebugConfigurationWithSubstitutedVariables(configuration, workspaceFolderUri) {
262
+ return this.debug.resolveDebugConfigurationWithSubstitutedVariables(configuration, workspaceFolderUri);
263
+ }
264
+ async doStart(sessionId, options) {
265
+ const parentSession = options.configuration.parentSessionId ? this._sessions.get(options.configuration.parentSessionId) : undefined;
266
+ const contrib = this.sessionContributionRegistry.get(options.configuration.type);
267
+ const sessionFactory = contrib ? contrib.debugSessionFactory() : this.debugSessionFactory;
268
+ const session = sessionFactory.get(sessionId, options, parentSession);
269
+ this._sessions.set(sessionId, session);
270
+ this.debugTypeKey.set(session.configuration.type);
271
+ this.onDidCreateDebugSessionEmitter.fire(session);
272
+ let state = debug_session_1.DebugState.Inactive;
273
+ session.onDidChange(() => {
274
+ if (state !== session.state) {
275
+ state = session.state;
276
+ if (state === debug_session_1.DebugState.Stopped) {
277
+ this.onDidStopDebugSessionEmitter.fire(session);
278
+ }
279
+ }
280
+ this.updateCurrentSession(session);
281
+ });
282
+ session.onDidChangeBreakpoints(uri => this.fireDidChangeBreakpoints({ session, uri }));
283
+ session.on('terminated', async (event) => {
284
+ const restart = event.body && event.body.restart;
285
+ if (restart) {
286
+ // postDebugTask isn't run in case of auto restart as well as preLaunchTask
287
+ this.doRestart(session, !!restart);
288
+ }
289
+ else {
290
+ await session.disconnect(false, () => this.debug.terminateDebugSession(session.id));
291
+ await this.runTask(session.options.workspaceFolderUri, session.configuration.postDebugTask);
292
+ }
293
+ });
294
+ session.on('exited', async (event) => {
295
+ await session.disconnect(false, () => this.debug.terminateDebugSession(session.id));
296
+ });
297
+ session.onDispose(() => this.cleanup(session));
298
+ session.start().then(() => this.onDidStartDebugSessionEmitter.fire(session)).catch(e => {
299
+ session.stop(false, () => {
300
+ this.debug.terminateDebugSession(session.id);
301
+ });
302
+ });
303
+ session.onDidCustomEvent(({ event, body }) => this.onDidReceiveDebugSessionCustomEventEmitter.fire({ event, body, session }));
304
+ return session;
305
+ }
306
+ cleanup(session) {
307
+ if (this.remove(session.id)) {
308
+ this.onDidDestroyDebugSessionEmitter.fire(session);
309
+ }
310
+ }
311
+ async doRestart(session, isRestart) {
312
+ if (session.canRestart()) {
313
+ await session.restart();
314
+ return session;
315
+ }
316
+ const { options, configuration } = session;
317
+ session.stop(isRestart, () => this.debug.terminateDebugSession(session.id));
318
+ configuration.__restart = isRestart;
319
+ return this.start(options);
320
+ }
321
+ async terminateSession(session) {
322
+ if (!session) {
323
+ this.updateCurrentSession(this._currentSession);
324
+ session = this._currentSession;
325
+ }
326
+ if (session) {
327
+ if (session.options.compoundRoot) {
328
+ session.options.compoundRoot.stopSession();
329
+ }
330
+ else if (session.parentSession && session.configuration.lifecycleManagedByParent) {
331
+ this.terminateSession(session.parentSession);
332
+ }
333
+ else {
334
+ session.stop(false, () => this.debug.terminateDebugSession(session.id));
335
+ }
336
+ }
337
+ }
338
+ async restartSession(session) {
339
+ if (!session) {
340
+ this.updateCurrentSession(this._currentSession);
341
+ session = this._currentSession;
342
+ }
343
+ if (session) {
344
+ if (session.parentSession && session.configuration.lifecycleManagedByParent) {
345
+ return this.restartSession(session.parentSession);
346
+ }
347
+ else {
348
+ return this.doRestart(session, true);
349
+ }
350
+ }
351
+ }
352
+ remove(sessionId) {
353
+ const existed = this._sessions.delete(sessionId);
354
+ const { currentSession } = this;
355
+ if (currentSession && currentSession.id === sessionId) {
356
+ this.updateCurrentSession(undefined);
357
+ }
358
+ return existed;
359
+ }
360
+ getSession(sessionId) {
361
+ return this._sessions.get(sessionId);
362
+ }
363
+ get sessions() {
364
+ return Array.from(this._sessions.values()).filter(session => session.state > debug_session_1.DebugState.Inactive);
365
+ }
366
+ get currentSession() {
367
+ return this._currentSession;
368
+ }
369
+ set currentSession(current) {
370
+ if (this._currentSession === current) {
371
+ return;
372
+ }
373
+ this.disposeOnCurrentSessionChanged.dispose();
374
+ const previous = this.currentSession;
375
+ this._currentSession = current;
376
+ this.onDidChangeActiveDebugSessionEmitter.fire({ previous, current });
377
+ if (current) {
378
+ this.disposeOnCurrentSessionChanged.push(current.onDidChange(() => {
379
+ if (this.currentFrame === this.topFrame) {
380
+ this.open();
381
+ }
382
+ this.fireDidChange(current);
383
+ }));
384
+ this.disposeOnCurrentSessionChanged.push(current.onDidFocusStackFrame(frame => this.onDidFocusStackFrameEmitter.fire({ session: current, frame })));
385
+ }
386
+ this.updateBreakpoints(previous, current);
387
+ this.open();
388
+ this.fireDidChange(current);
389
+ }
390
+ open() {
391
+ const { currentFrame } = this;
392
+ if (currentFrame) {
393
+ currentFrame.open();
394
+ }
395
+ }
396
+ updateBreakpoints(previous, current) {
397
+ const affectedUri = new Set();
398
+ for (const session of [previous, current]) {
399
+ if (session) {
400
+ for (const uriString of session.breakpointUris) {
401
+ if (!affectedUri.has(uriString)) {
402
+ affectedUri.add(uriString);
403
+ this.fireDidChangeBreakpoints({
404
+ session: current,
405
+ uri: new uri_1.default(uriString)
406
+ });
407
+ }
408
+ }
409
+ }
410
+ }
411
+ }
412
+ updateCurrentSession(session) {
413
+ this.currentSession = session || this.sessions[0];
414
+ }
415
+ get currentThread() {
416
+ const session = this.currentSession;
417
+ return session && session.currentThread;
418
+ }
419
+ get state() {
420
+ const session = this.currentSession;
421
+ return session ? session.state : debug_session_1.DebugState.Inactive;
422
+ }
423
+ get currentFrame() {
424
+ const { currentThread } = this;
425
+ return currentThread && currentThread.currentFrame;
426
+ }
427
+ get topFrame() {
428
+ const { currentThread } = this;
429
+ return currentThread && currentThread.topFrame;
430
+ }
431
+ getFunctionBreakpoints(session = this.currentSession) {
432
+ if (session && session.state > debug_session_1.DebugState.Initializing) {
433
+ return session.getFunctionBreakpoints();
434
+ }
435
+ const { labelProvider, breakpoints, editorManager } = this;
436
+ return this.breakpoints.getFunctionBreakpoints().map(origin => new debug_function_breakpoint_1.DebugFunctionBreakpoint(origin, { labelProvider, breakpoints, editorManager }));
437
+ }
438
+ getInstructionBreakpoints(session = this.currentSession) {
439
+ if (session && session.state > debug_session_1.DebugState.Initializing) {
440
+ return session.getInstructionBreakpoints();
441
+ }
442
+ const { labelProvider, breakpoints, editorManager } = this;
443
+ return this.breakpoints.getInstructionBreakpoints().map(origin => new debug_instruction_breakpoint_1.DebugInstructionBreakpoint(origin, { labelProvider, breakpoints, editorManager }));
444
+ }
445
+ getBreakpoints(arg, arg2) {
446
+ const uri = arg instanceof uri_1.default ? arg : undefined;
447
+ const session = arg instanceof debug_session_1.DebugSession ? arg : arg2 instanceof debug_session_1.DebugSession ? arg2 : this.currentSession;
448
+ if (session && session.state > debug_session_1.DebugState.Initializing) {
449
+ return session.getSourceBreakpoints(uri);
450
+ }
451
+ const { labelProvider, breakpoints, editorManager } = this;
452
+ return this.breakpoints.findMarkers({ uri }).map(({ data }) => new debug_source_breakpoint_1.DebugSourceBreakpoint(data, { labelProvider, breakpoints, editorManager }));
453
+ }
454
+ getLineBreakpoints(uri, line) {
455
+ const session = this.currentSession;
456
+ if (session && session.state > debug_session_1.DebugState.Initializing) {
457
+ return session.getSourceBreakpoints(uri).filter(breakpoint => breakpoint.line === line);
458
+ }
459
+ const { labelProvider, breakpoints, editorManager } = this;
460
+ return this.breakpoints.getLineBreakpoints(uri, line).map(origin => new debug_source_breakpoint_1.DebugSourceBreakpoint(origin, { labelProvider, breakpoints, editorManager }));
461
+ }
462
+ getInlineBreakpoint(uri, line, column) {
463
+ const session = this.currentSession;
464
+ if (session && session.state > debug_session_1.DebugState.Initializing) {
465
+ return session.getSourceBreakpoints(uri).filter(breakpoint => breakpoint.line === line && breakpoint.column === column)[0];
466
+ }
467
+ const origin = this.breakpoints.getInlineBreakpoint(uri, line, column);
468
+ const { labelProvider, breakpoints, editorManager } = this;
469
+ return origin && new debug_source_breakpoint_1.DebugSourceBreakpoint(origin, { labelProvider, breakpoints, editorManager });
470
+ }
471
+ /**
472
+ * Runs the given tasks.
473
+ * @param taskName the task name to run, see [TaskNameResolver](#TaskNameResolver)
474
+ * @return true if it allowed to continue debugging otherwise it returns false
475
+ */
476
+ async runTask(workspaceFolderUri, taskName, checkErrors) {
477
+ if (!taskName) {
478
+ return true;
479
+ }
480
+ const taskInfo = await this.taskService.runWorkspaceTask(this.taskService.startUserAction(), workspaceFolderUri, taskName);
481
+ if (!checkErrors) {
482
+ return true;
483
+ }
484
+ if (!taskInfo) {
485
+ return this.doPostTaskAction(`Could not run the task '${taskName}'.`);
486
+ }
487
+ const getExitCodePromise = this.taskService.getExitCode(taskInfo.taskId).then(result => ({ taskEndedType: task_service_1.TaskEndedTypes.TaskExited, value: result }));
488
+ const isBackgroundTaskEndedPromise = this.taskService.isBackgroundTaskEnded(taskInfo.taskId).then(result => ({ taskEndedType: task_service_1.TaskEndedTypes.BackgroundTaskEnded, value: result }));
489
+ // After start running the task, we wait for the task process to exit and if it is a background task, we also wait for a feedback
490
+ // that a background task is active, as soon as one of the promises fulfills, we can continue and analyze the results.
491
+ const taskEndedInfo = await Promise.race([getExitCodePromise, isBackgroundTaskEndedPromise]);
492
+ if (taskEndedInfo.taskEndedType === task_service_1.TaskEndedTypes.BackgroundTaskEnded && taskEndedInfo.value) {
493
+ return true;
494
+ }
495
+ if (taskEndedInfo.taskEndedType === task_service_1.TaskEndedTypes.TaskExited && taskEndedInfo.value === 0) {
496
+ return true;
497
+ }
498
+ else if (taskEndedInfo.taskEndedType === task_service_1.TaskEndedTypes.TaskExited && taskEndedInfo.value !== undefined) {
499
+ return this.doPostTaskAction(`Task '${taskName}' terminated with exit code ${taskEndedInfo.value}.`);
500
+ }
501
+ else {
502
+ const signal = await this.taskService.getTerminateSignal(taskInfo.taskId);
503
+ if (signal !== undefined) {
504
+ return this.doPostTaskAction(`Task '${taskName}' terminated by signal ${signal}.`);
505
+ }
506
+ else {
507
+ return this.doPostTaskAction(`Task '${taskName}' terminated for unknown reason.`);
508
+ }
509
+ }
510
+ }
511
+ async doPostTaskAction(errorMessage) {
512
+ const actions = ['Open launch.json', 'Cancel', 'Configure Task', 'Debug Anyway'];
513
+ const result = await this.messageService.error(errorMessage, ...actions);
514
+ switch (result) {
515
+ case actions[0]: // open launch.json
516
+ this.debugConfigurationManager.openConfiguration();
517
+ return false;
518
+ case actions[1]: // cancel
519
+ return false;
520
+ case actions[2]: // configure tasks
521
+ this.quickOpenTask.configure();
522
+ return false;
523
+ default: // continue debugging
524
+ return true;
525
+ }
526
+ }
527
+ };
528
+ __decorate([
529
+ (0, inversify_1.inject)(debug_session_contribution_1.DebugSessionFactory),
530
+ __metadata("design:type", Object)
531
+ ], DebugSessionManager.prototype, "debugSessionFactory", void 0);
532
+ __decorate([
533
+ (0, inversify_1.inject)(debug_service_1.DebugService),
534
+ __metadata("design:type", Object)
535
+ ], DebugSessionManager.prototype, "debug", void 0);
536
+ __decorate([
537
+ (0, inversify_1.inject)(browser_1.LabelProvider),
538
+ __metadata("design:type", browser_1.LabelProvider)
539
+ ], DebugSessionManager.prototype, "labelProvider", void 0);
540
+ __decorate([
541
+ (0, inversify_1.inject)(browser_2.EditorManager),
542
+ __metadata("design:type", browser_2.EditorManager)
543
+ ], DebugSessionManager.prototype, "editorManager", void 0);
544
+ __decorate([
545
+ (0, inversify_1.inject)(breakpoint_manager_1.BreakpointManager),
546
+ __metadata("design:type", breakpoint_manager_1.BreakpointManager)
547
+ ], DebugSessionManager.prototype, "breakpoints", void 0);
548
+ __decorate([
549
+ (0, inversify_1.inject)(browser_3.VariableResolverService),
550
+ __metadata("design:type", browser_3.VariableResolverService)
551
+ ], DebugSessionManager.prototype, "variableResolver", void 0);
552
+ __decorate([
553
+ (0, inversify_1.inject)(debug_session_contribution_1.DebugSessionContributionRegistry),
554
+ __metadata("design:type", Object)
555
+ ], DebugSessionManager.prototype, "sessionContributionRegistry", void 0);
556
+ __decorate([
557
+ (0, inversify_1.inject)(core_1.MessageService),
558
+ __metadata("design:type", core_1.MessageService)
559
+ ], DebugSessionManager.prototype, "messageService", void 0);
560
+ __decorate([
561
+ (0, inversify_1.inject)(core_1.ProgressService),
562
+ __metadata("design:type", core_1.ProgressService)
563
+ ], DebugSessionManager.prototype, "progressService", void 0);
564
+ __decorate([
565
+ (0, inversify_1.inject)(context_key_service_1.ContextKeyService),
566
+ __metadata("design:type", Object)
567
+ ], DebugSessionManager.prototype, "contextKeyService", void 0);
568
+ __decorate([
569
+ (0, inversify_1.inject)(task_service_1.TaskService),
570
+ __metadata("design:type", task_service_1.TaskService)
571
+ ], DebugSessionManager.prototype, "taskService", void 0);
572
+ __decorate([
573
+ (0, inversify_1.inject)(debug_configuration_manager_1.DebugConfigurationManager),
574
+ __metadata("design:type", debug_configuration_manager_1.DebugConfigurationManager)
575
+ ], DebugSessionManager.prototype, "debugConfigurationManager", void 0);
576
+ __decorate([
577
+ (0, inversify_1.inject)(quick_open_task_1.QuickOpenTask),
578
+ __metadata("design:type", quick_open_task_1.QuickOpenTask)
579
+ ], DebugSessionManager.prototype, "quickOpenTask", void 0);
580
+ __decorate([
581
+ (0, inversify_1.inject)(browser_1.ApplicationShell),
582
+ __metadata("design:type", browser_1.ApplicationShell)
583
+ ], DebugSessionManager.prototype, "shell", void 0);
584
+ __decorate([
585
+ (0, inversify_1.postConstruct)(),
586
+ __metadata("design:type", Function),
587
+ __metadata("design:paramtypes", []),
588
+ __metadata("design:returntype", void 0)
589
+ ], DebugSessionManager.prototype, "init", null);
590
+ DebugSessionManager = __decorate([
591
+ (0, inversify_1.injectable)()
592
+ ], DebugSessionManager);
593
+ exports.DebugSessionManager = DebugSessionManager;
594
594
  //# sourceMappingURL=debug-session-manager.js.map