@theia/debug 1.45.0 → 1.46.0-next.72

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