@opensumi/ide-debug 2.21.11-rc-1671793101.0 → 2.21.11

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 (182) hide show
  1. package/lib/browser/debug-configuration-manager.js +1 -1
  2. package/lib/browser/debug-configuration-manager.js.map +1 -1
  3. package/lib/browser/debug-session-manager.js +1 -1
  4. package/lib/browser/debug-session-manager.js.map +1 -1
  5. package/lib/browser/debug-session.d.ts.map +1 -1
  6. package/lib/browser/debug-session.js +1 -5
  7. package/lib/browser/debug-session.js.map +1 -1
  8. package/lib/browser/index.d.ts.map +1 -1
  9. package/lib/browser/index.js +9 -2
  10. package/lib/browser/index.js.map +1 -1
  11. package/lib/browser/preferences/launch-folder-preference-provider.d.ts +2 -2
  12. package/lib/browser/preferences/launch-folder-preference-provider.d.ts.map +1 -1
  13. package/lib/browser/preferences/launch-folder-preference-provider.js +2 -2
  14. package/lib/browser/preferences/launch-folder-preference-provider.js.map +1 -1
  15. package/lib/browser/view/configuration/debug-configuration.module.less +5 -5
  16. package/lib/browser/view/configuration/debug-configuration.view.d.ts.map +1 -1
  17. package/lib/browser/view/configuration/debug-configuration.view.js +1 -1
  18. package/lib/browser/view/configuration/debug-configuration.view.js.map +1 -1
  19. package/lib/browser/view/configuration/debug-toolbar.view.js +2 -2
  20. package/lib/browser/view/configuration/debug-toolbar.view.js.map +1 -1
  21. package/lib/browser/view/console/debug-console.module.less +1 -2
  22. package/lib/browser/view/console/debug-console.view.js +2 -2
  23. package/lib/browser/view/console/debug-console.view.js.map +1 -1
  24. package/lib/browser/view/frames/debug-call-stack-frame.view.d.ts.map +1 -1
  25. package/lib/browser/view/frames/debug-call-stack-frame.view.js +24 -32
  26. package/lib/browser/view/frames/debug-call-stack-frame.view.js.map +1 -1
  27. package/lib/browser/view/frames/debug-call-stack-session.view.d.ts.map +1 -1
  28. package/lib/browser/view/frames/debug-call-stack-session.view.js +5 -8
  29. package/lib/browser/view/frames/debug-call-stack-session.view.js.map +1 -1
  30. package/lib/browser/view/frames/debug-call-stack-thread.view.d.ts.map +1 -1
  31. package/lib/browser/view/frames/debug-call-stack-thread.view.js +7 -12
  32. package/lib/browser/view/frames/debug-call-stack-thread.view.js.map +1 -1
  33. package/lib/browser/view/variables/debug-variables.module.less +1 -2
  34. package/lib/browser/view/variables/debug-variables.view.js +1 -1
  35. package/lib/browser/view/variables/debug-variables.view.js.map +1 -1
  36. package/lib/browser/view/watch/debug-watch.module.less +1 -2
  37. package/lib/browser/view/watch/debug-watch.view.js +1 -1
  38. package/lib/browser/view/watch/debug-watch.view.js.map +1 -1
  39. package/package.json +24 -25
  40. package/src/browser/assets/breakpoint-conditional-disabled.svg +0 -4
  41. package/src/browser/assets/breakpoint-conditional-unverified.svg +0 -4
  42. package/src/browser/assets/breakpoint-conditional.svg +0 -4
  43. package/src/browser/assets/breakpoint-disabled.svg +0 -4
  44. package/src/browser/assets/breakpoint-hint.svg +0 -4
  45. package/src/browser/assets/breakpoint-log-disabled.svg +0 -4
  46. package/src/browser/assets/breakpoint-log-unverified.svg +0 -4
  47. package/src/browser/assets/breakpoint-log.svg +0 -4
  48. package/src/browser/assets/breakpoint-unsupported.svg +0 -4
  49. package/src/browser/assets/breakpoint-unverified.svg +0 -4
  50. package/src/browser/assets/breakpoint.svg +0 -4
  51. package/src/browser/assets/breakpoints-activate-inverse.svg +0 -4
  52. package/src/browser/assets/breakpoints-activate.svg +0 -4
  53. package/src/browser/assets/configure-inverse.svg +0 -4
  54. package/src/browser/assets/configure.svg +0 -4
  55. package/src/browser/assets/continue-inverse.svg +0 -4
  56. package/src/browser/assets/current-and-breakpoint.svg +0 -4
  57. package/src/browser/assets/current-arrow.svg +0 -4
  58. package/src/browser/assets/remove-all-inverse.svg +0 -4
  59. package/src/browser/assets/remove-all.svg +0 -4
  60. package/src/browser/assets/repl-inverse.svg +0 -4
  61. package/src/browser/assets/repl.svg +0 -4
  62. package/src/browser/assets/restart-inverse.svg +0 -4
  63. package/src/browser/assets/stackframe-and-breakpoint.svg +0 -4
  64. package/src/browser/assets/stackframe-arrow.svg +0 -4
  65. package/src/browser/assets/start-inverse.svg +0 -4
  66. package/src/browser/breakpoint/breakpoint-decoration.ts +0 -57
  67. package/src/browser/breakpoint/breakpoint-manager.ts +0 -348
  68. package/src/browser/breakpoint/breakpoint-marker.ts +0 -70
  69. package/src/browser/breakpoint/index.ts +0 -3
  70. package/src/browser/components/debug-action/index.module.less +0 -73
  71. package/src/browser/components/debug-action/index.tsx +0 -40
  72. package/src/browser/components/debug-exception-widget.less +0 -42
  73. package/src/browser/components/floating-click-widget/index.module.less +0 -5
  74. package/src/browser/components/floating-click-widget/index.tsx +0 -21
  75. package/src/browser/components/index.ts +0 -1
  76. package/src/browser/contextkeys/debug-call-stack-item-type-key.ts +0 -4
  77. package/src/browser/contextkeys/debug-contextkey.service.ts +0 -54
  78. package/src/browser/contextkeys/index.ts +0 -1
  79. package/src/browser/debug-ansi-handle.ts +0 -521
  80. package/src/browser/debug-configuration-manager.ts +0 -513
  81. package/src/browser/debug-configuration-model.ts +0 -66
  82. package/src/browser/debug-contribution.ts +0 -904
  83. package/src/browser/debug-exception-widget.tsx +0 -89
  84. package/src/browser/debug-link-detector.ts +0 -234
  85. package/src/browser/debug-memory.ts +0 -220
  86. package/src/browser/debug-preferences.ts +0 -70
  87. package/src/browser/debug-progress.service.ts +0 -122
  88. package/src/browser/debug-schema-updater.ts +0 -67
  89. package/src/browser/debug-service.ts +0 -42
  90. package/src/browser/debug-session-connection.ts +0 -333
  91. package/src/browser/debug-session-contribution.ts +0 -57
  92. package/src/browser/debug-session-manager.ts +0 -622
  93. package/src/browser/debug-session.ts +0 -1182
  94. package/src/browser/debug-style.less +0 -128
  95. package/src/browser/debugUtils.ts +0 -110
  96. package/src/browser/editor/debug-breakpoint-widget.ts +0 -99
  97. package/src/browser/editor/debug-breakpoint-zone-widget.tsx +0 -262
  98. package/src/browser/editor/debug-breakpoint.module.less +0 -31
  99. package/src/browser/editor/debug-editor-contribution.ts +0 -590
  100. package/src/browser/editor/debug-expression-provider.ts +0 -101
  101. package/src/browser/editor/debug-hover-model.ts +0 -38
  102. package/src/browser/editor/debug-hover-source.ts +0 -107
  103. package/src/browser/editor/debug-hover-tree.model.service.ts +0 -332
  104. package/src/browser/editor/debug-hover-widget.tsx +0 -200
  105. package/src/browser/editor/debug-hover.module.less +0 -29
  106. package/src/browser/editor/debug-hover.view.tsx +0 -147
  107. package/src/browser/editor/debug-model-manager.ts +0 -220
  108. package/src/browser/editor/debug-model.ts +0 -853
  109. package/src/browser/editor/debug-run-to-cursor.service.ts +0 -180
  110. package/src/browser/editor/debug-styles.ts +0 -66
  111. package/src/browser/editor/evaluatable-expression.ts +0 -47
  112. package/src/browser/editor/index.ts +0 -6
  113. package/src/browser/index.ts +0 -121
  114. package/src/browser/markers/index.ts +0 -2
  115. package/src/browser/markers/marker-manager.ts +0 -201
  116. package/src/browser/markers/marker.ts +0 -20
  117. package/src/browser/model/debug-source.ts +0 -144
  118. package/src/browser/model/debug-stack-frame.ts +0 -111
  119. package/src/browser/model/debug-thread.ts +0 -186
  120. package/src/browser/model/debug-watch.ts +0 -130
  121. package/src/browser/model/index.ts +0 -4
  122. package/src/browser/preferences/launch-folder-preference-provider.ts +0 -23
  123. package/src/browser/preferences/launch-preferences-contribution.ts +0 -9
  124. package/src/browser/preferences/launch-preferences.ts +0 -16
  125. package/src/browser/tree/debug-console-tree-node.define.tsx +0 -76
  126. package/src/browser/tree/debug-tree-node.define.ts +0 -768
  127. package/src/browser/tree/index.ts +0 -2
  128. package/src/browser/view/breakpoints/debug-breakpoints.module.less +0 -72
  129. package/src/browser/view/breakpoints/debug-breakpoints.service.ts +0 -217
  130. package/src/browser/view/breakpoints/debug-breakpoints.view.tsx +0 -174
  131. package/src/browser/view/configuration/debug-configuration.module.less +0 -110
  132. package/src/browser/view/configuration/debug-configuration.service.ts +0 -170
  133. package/src/browser/view/configuration/debug-configuration.view.tsx +0 -252
  134. package/src/browser/view/configuration/debug-toolbar.service.ts +0 -167
  135. package/src/browser/view/configuration/debug-toolbar.view.tsx +0 -335
  136. package/src/browser/view/console/debug-console-filter.model.ts +0 -49
  137. package/src/browser/view/console/debug-console-filter.service.ts +0 -81
  138. package/src/browser/view/console/debug-console-filter.view.tsx +0 -78
  139. package/src/browser/view/console/debug-console-model.ts +0 -48
  140. package/src/browser/view/console/debug-console-session.ts +0 -164
  141. package/src/browser/view/console/debug-console-toolbar.view.tsx +0 -28
  142. package/src/browser/view/console/debug-console-tree.model.service.ts +0 -550
  143. package/src/browser/view/console/debug-console.contribution.ts +0 -181
  144. package/src/browser/view/console/debug-console.module.less +0 -373
  145. package/src/browser/view/console/debug-console.service.ts +0 -433
  146. package/src/browser/view/console/debug-console.view.tsx +0 -500
  147. package/src/browser/view/debug-view-model.ts +0 -182
  148. package/src/browser/view/frames/debug-call-stack-frame.view.tsx +0 -238
  149. package/src/browser/view/frames/debug-call-stack-session.view.tsx +0 -253
  150. package/src/browser/view/frames/debug-call-stack-thread.view.tsx +0 -103
  151. package/src/browser/view/frames/debug-call-stack.contribution.ts +0 -88
  152. package/src/browser/view/frames/debug-call-stack.module.less +0 -193
  153. package/src/browser/view/frames/debug-call-stack.operation.tsx +0 -97
  154. package/src/browser/view/frames/debug-call-stack.service.ts +0 -105
  155. package/src/browser/view/frames/debug-call-stack.view.tsx +0 -43
  156. package/src/browser/view/variables/debug-variables-model.ts +0 -38
  157. package/src/browser/view/variables/debug-variables-tree.model.service.ts +0 -467
  158. package/src/browser/view/variables/debug-variables.contribution.ts +0 -244
  159. package/src/browser/view/variables/debug-variables.module.less +0 -149
  160. package/src/browser/view/variables/debug-variables.view.tsx +0 -303
  161. package/src/browser/view/watch/debug-watch-model.ts +0 -38
  162. package/src/browser/view/watch/debug-watch-tree.model.service.ts +0 -567
  163. package/src/browser/view/watch/debug-watch.contribution.ts +0 -167
  164. package/src/browser/view/watch/debug-watch.module.less +0 -189
  165. package/src/browser/view/watch/debug-watch.view.tsx +0 -337
  166. package/src/common/constants.ts +0 -81
  167. package/src/common/debug-breakpoint.ts +0 -43
  168. package/src/common/debug-configuration.ts +0 -68
  169. package/src/common/debug-editor.ts +0 -4
  170. package/src/common/debug-hover.ts +0 -31
  171. package/src/common/debug-model.ts +0 -247
  172. package/src/common/debug-progress.ts +0 -8
  173. package/src/common/debug-schema-updater.ts +0 -1
  174. package/src/common/debug-service.ts +0 -176
  175. package/src/common/debug-session-options.ts +0 -19
  176. package/src/common/debug-session.ts +0 -200
  177. package/src/common/evaluatable-expression.ts +0 -43
  178. package/src/common/index.ts +0 -14
  179. package/src/common/inline-values.ts +0 -77
  180. package/src/common/terminal.ts +0 -163
  181. package/src/common/types.ts +0 -86
  182. package/src/index.ts +0 -1
@@ -1,622 +0,0 @@
1
- /** ******************************************************************************
2
- * Copyright (C) 2018 Red Hat, Inc. and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
- // Some code copied and modified from https://github.com/eclipse-theia/theia/tree/v1.14.0/packages/debug/src/browser/debug-session-manager.ts
17
-
18
- import { Injectable, Autowired } from '@opensumi/di';
19
- import {
20
- WaitUntilEvent,
21
- Emitter,
22
- Event,
23
- URI,
24
- IContextKey,
25
- DisposableCollection,
26
- IContextKeyService,
27
- formatLocalize,
28
- Uri,
29
- IReporterService,
30
- uuid,
31
- localize,
32
- COMMON_COMMANDS,
33
- CommandService,
34
- } from '@opensumi/ide-core-browser';
35
- import { LabelService } from '@opensumi/ide-core-browser/lib/services';
36
- import { WorkbenchEditorService } from '@opensumi/ide-editor';
37
- import { IMessageService } from '@opensumi/ide-overlay';
38
- import { ITaskService } from '@opensumi/ide-task/lib/common';
39
- import { IVariableResolverService } from '@opensumi/ide-variable';
40
-
41
- import {
42
- DebugConfiguration,
43
- DebugError,
44
- IDebugServer,
45
- DebugServer,
46
- DebugSessionOptions,
47
- IDebugSessionDTO,
48
- DEBUG_REPORT_NAME,
49
- IDebugSessionManager,
50
- DebugSessionExtra,
51
- DebugThreadExtra,
52
- CONTEXT_DEBUG_STOPPED_KEY,
53
- CONTEXT_IN_DEBUG_MODE_KEY,
54
- CONTEXT_DEBUG_TYPE_KEY,
55
- DebugState,
56
- } from '../common';
57
- import { IDebugProgress } from '../common/debug-progress';
58
-
59
- import { BreakpointManager } from './breakpoint/breakpoint-manager';
60
- import { DebugContextKey } from './contextkeys/debug-contextkey.service';
61
- import { DebugSession } from './debug-session';
62
- import { DebugSessionContributionRegistry } from './debug-session-contribution';
63
- import { isRemoteAttach } from './debugUtils';
64
- import { DebugModelManager } from './editor/debug-model-manager';
65
- import { DebugStackFrame } from './model/debug-stack-frame';
66
- import { DebugThread } from './model/debug-thread';
67
-
68
- export type WillStartDebugSession = WaitUntilEvent;
69
-
70
- export interface WillResolveDebugConfiguration extends WaitUntilEvent {
71
- debugType: string;
72
- }
73
-
74
- export interface DidChangeActiveDebugSession {
75
- previous: DebugSession | undefined;
76
- current: DebugSession | undefined;
77
- }
78
-
79
- export interface DebugSessionCustomEvent {
80
- readonly body?: any;
81
- readonly event: string;
82
- readonly session: DebugSession;
83
- }
84
-
85
- @Injectable()
86
- export class DebugSessionManager implements IDebugSessionManager {
87
- protected readonly _uid = uuid();
88
- protected readonly _sessions = new Map<string, DebugSession>();
89
- protected readonly _extraMap = new Map<string, DebugSessionExtra>();
90
- protected _actionIndex = 0;
91
-
92
- protected readonly onWillStartDebugSessionEmitter = new Emitter<WillStartDebugSession>();
93
- readonly onWillStartDebugSession: Event<WillStartDebugSession> = this.onWillStartDebugSessionEmitter.event;
94
-
95
- protected readonly onWillResolveDebugConfigurationEmitter = new Emitter<WillResolveDebugConfiguration>();
96
- readonly onWillResolveDebugConfiguration: Event<WillResolveDebugConfiguration> =
97
- this.onWillResolveDebugConfigurationEmitter.event;
98
-
99
- protected readonly onDidCreateDebugSessionEmitter = new Emitter<DebugSession>();
100
- readonly onDidCreateDebugSession: Event<DebugSession> = this.onDidCreateDebugSessionEmitter.event;
101
-
102
- protected readonly onDidStartDebugSessionEmitter = new Emitter<DebugSession>();
103
- readonly onDidStartDebugSession: Event<DebugSession> = this.onDidStartDebugSessionEmitter.event;
104
-
105
- protected readonly onDidStopDebugSessionEmitter = new Emitter<DebugSession>();
106
- readonly onDidStopDebugSession: Event<DebugSession> = this.onDidStopDebugSessionEmitter.event;
107
-
108
- protected readonly onDidChangeActiveDebugSessionEmitter = new Emitter<DidChangeActiveDebugSession>();
109
- readonly onDidChangeActiveDebugSession: Event<DidChangeActiveDebugSession> =
110
- this.onDidChangeActiveDebugSessionEmitter.event;
111
-
112
- protected readonly onDidDestroyDebugSessionEmitter = new Emitter<DebugSession>();
113
- readonly onDidDestroyDebugSession: Event<DebugSession> = this.onDidDestroyDebugSessionEmitter.event;
114
-
115
- protected readonly onDidReceiveDebugSessionCustomEventEmitter = new Emitter<DebugSessionCustomEvent>();
116
- readonly onDidReceiveDebugSessionCustomEvent: Event<DebugSessionCustomEvent> =
117
- this.onDidReceiveDebugSessionCustomEventEmitter.event;
118
-
119
- protected readonly onDidChangeEmitter = new Emitter<DebugSession | undefined>();
120
- readonly onDidChange: Event<DebugSession | undefined> = this.onDidChangeEmitter.event;
121
- protected fireDidChange(current: DebugSession | undefined): void {
122
- this.inDebugModeKey.set(this.inDebugMode);
123
- this.onDidChangeEmitter.fire(current);
124
- }
125
-
126
- protected debugTypeKey: IContextKey<string>;
127
- protected inDebugModeKey: IContextKey<boolean>;
128
- protected debugStopped: IContextKey<boolean>;
129
-
130
- @Autowired(LabelService)
131
- protected readonly labelProvider: LabelService;
132
-
133
- @Autowired(IContextKeyService)
134
- protected readonly contextKeyService: IContextKeyService;
135
-
136
- @Autowired(DebugSessionContributionRegistry)
137
- protected readonly sessionContributionRegistry: DebugSessionContributionRegistry;
138
-
139
- @Autowired(IDebugServer)
140
- protected readonly debug: DebugServer;
141
-
142
- @Autowired(WorkbenchEditorService)
143
- protected readonly workbenchEditorService: WorkbenchEditorService;
144
-
145
- @Autowired(IMessageService)
146
- protected readonly messageService: IMessageService;
147
-
148
- @Autowired(IVariableResolverService)
149
- protected readonly variableResolver: IVariableResolverService;
150
-
151
- @Autowired(BreakpointManager)
152
- protected readonly breakpoints: BreakpointManager;
153
-
154
- @Autowired(DebugModelManager)
155
- protected readonly modelManager: DebugModelManager;
156
-
157
- @Autowired(ITaskService)
158
- protected readonly taskService: ITaskService;
159
-
160
- @Autowired(IReporterService)
161
- protected readonly reporterService: IReporterService;
162
-
163
- @Autowired(IDebugProgress)
164
- protected readonly debugProgressService: IDebugProgress;
165
-
166
- @Autowired(DebugContextKey)
167
- protected readonly debugContextKey: DebugContextKey;
168
-
169
- @Autowired(CommandService)
170
- protected readonly commandService: CommandService;
171
-
172
- constructor() {
173
- this.init();
174
- }
175
-
176
- protected init(): void {
177
- this.debugTypeKey = this.contextKeyService.createKey<string>(CONTEXT_DEBUG_TYPE_KEY, undefined);
178
- this.inDebugModeKey = this.contextKeyService.createKey<boolean>(CONTEXT_IN_DEBUG_MODE_KEY, this.inDebugMode);
179
- this.debugStopped = this.contextKeyService.createKey<boolean>(CONTEXT_DEBUG_STOPPED_KEY, false);
180
-
181
- this.modelManager.onModelChanged((event) => {
182
- const { newModelUrl } = event;
183
- if (newModelUrl) {
184
- const uri = URI.parse(newModelUrl.toString());
185
- const model = this.modelManager.model;
186
- if (this.currentSession && this.currentThread && model) {
187
- const frame = this.currentThread.frames.find((f) => f.source?.uri.toString() === uri.toString());
188
- if (frame && frame !== this.currentFrame) {
189
- this.currentThread.currentFrame = frame;
190
- setTimeout(() => {
191
- if (this.workbenchEditorService.currentEditor) {
192
- this.workbenchEditorService.currentEditor.monacoEditor.revealLineInCenter(frame.raw.line);
193
- }
194
- }, 0);
195
- }
196
- }
197
- }
198
- });
199
- }
200
-
201
- private _getExtra(
202
- sessionId: string | undefined,
203
- threadId: number | string | undefined,
204
- ): DebugThreadExtra | undefined {
205
- if (sessionId == null) {
206
- return;
207
- }
208
- const data = this._extraMap.get(sessionId);
209
- if (data) {
210
- return {
211
- traceId: data.traceId,
212
- remote: data.remote,
213
- adapterID: data.adapterID,
214
- request: data.request,
215
- ...(threadId && data.threads.get(`${threadId}`)),
216
- };
217
- }
218
- }
219
-
220
- public getExtra(sessionId: string | undefined, threadId: number | string | undefined): DebugThreadExtra | undefined {
221
- return this._getExtra(sessionId, threadId);
222
- }
223
-
224
- private _setExtra(sessionId: string, threadId: string, extra?: DebugThreadExtra) {
225
- const data = this._extraMap.get(sessionId);
226
- if (!data) {
227
- return;
228
- }
229
- if (extra) {
230
- data.threads.set(threadId, extra);
231
- } else {
232
- data.threads.delete(threadId);
233
- }
234
- }
235
-
236
- public setExtra(sessionId: string, threadId: string, extra?: DebugThreadExtra) {
237
- return this._setExtra(sessionId, threadId, extra);
238
- }
239
-
240
- report(name: string, msg: string | undefined, extra?: any) {
241
- extra = {
242
- traceId: this._uid,
243
- ...this._getExtra(extra?.sessionId, extra?.threadId),
244
- ...extra,
245
- };
246
- return this.reporterService.point(name, msg, extra);
247
- }
248
-
249
- reportTime(name: string, defaults?: any) {
250
- const timer = this.reporterService.time(name);
251
- return (msg: string | undefined, extra?: any) => {
252
- extra = {
253
- ...defaults,
254
- ...extra,
255
- };
256
- extra = {
257
- traceId: this._uid,
258
- ...this._getExtra(extra?.sessionId, extra?.threadId),
259
- ...extra,
260
- };
261
- return timer.timeEnd(msg, extra);
262
- };
263
- }
264
-
265
- reportAction(sessionId: string, threadId: number | string | undefined, action: string) {
266
- let extra = this._getExtra(sessionId, threadId);
267
- if (!extra) {
268
- // session 不存在,忽略
269
- return;
270
- }
271
- if (threadId && !extra.threadId) {
272
- extra = {
273
- ...extra,
274
- };
275
- }
276
- this._actionIndex += 1;
277
- extra.action = `${action}-${this._actionIndex}`;
278
-
279
- // 记录被暂停的文件路径和行号
280
- extra.filePath = this.currentFrame?.raw.source?.path;
281
- extra.fileLineNumber = this.currentFrame?.raw.line;
282
- this._setExtra(sessionId, `${threadId ?? ''}`, extra);
283
- }
284
-
285
- async start(options: DebugSessionOptions): Promise<DebugSession | undefined> {
286
- const { configuration } = options;
287
- const extra: DebugSessionExtra = {
288
- adapterID: configuration.type,
289
- request: configuration.request === 'launch' ? 'launch' : 'attach',
290
- traceId: this._uid,
291
- remote: 0,
292
- threads: new Map(),
293
- };
294
- if (isRemoteAttach(configuration)) {
295
- extra.remote = 1;
296
- }
297
- this.report(DEBUG_REPORT_NAME.DEBUG_BREAKPOINT, 'number', {
298
- count: this.breakpoints.getBreakpoints().length,
299
- ...extra,
300
- });
301
- if (!options.configuration.__restart) {
302
- if (this.isExistedDebugSession(options)) {
303
- this.messageService.error(formatLocalize('debug.launch.existed', options.configuration.name));
304
- return;
305
- }
306
- }
307
- try {
308
- const timeStart = this.reportTime(DEBUG_REPORT_NAME.DEBUG_SESSION_START_TIME, extra);
309
- await this.fireWillStartDebugSession();
310
- const resolved = await this.resolveConfiguration(options);
311
- if (!resolved) {
312
- if (options.configuration.type) {
313
- this.messageService.error(formatLocalize('debug.notSupported.type', options.configuration.type));
314
- } else {
315
- this.messageService.error(localize('debug.notSupported.any'));
316
- }
317
- return;
318
- } else if (resolved.configuration.preLaunchTask) {
319
- this.debugProgressService.onDebugServiceStateChange(DebugState.Initializing);
320
- const workspaceFolderUri = Uri.parse(resolved.workspaceFolderUri!);
321
- const task = await this.taskService.getTask(workspaceFolderUri, resolved.configuration.preLaunchTask);
322
- if (task) {
323
- const timeTask = this.reportTime(DEBUG_REPORT_NAME.DEBUG_PRE_LAUNCH_TASK_TIME, extra);
324
- const result = await this.taskService.run(task);
325
- if (result.exitCode !== 0) {
326
- this.messageService.error(
327
- `The preLaunchTask ${resolved.configuration.preLaunchTask} exitCode is ${result.exitCode}`,
328
- );
329
- }
330
- timeTask(workspaceFolderUri.toString(), {
331
- exitCode: result.exitCode,
332
- });
333
- }
334
- this.debugProgressService.onDebugServiceStateChange(DebugState.Running);
335
- }
336
- const sessionId = await this.debug.createDebugSession(resolved);
337
- timeStart(resolved.configuration.type, {
338
- adapterID: resolved.configuration.type,
339
- request: resolved.configuration.request,
340
- sessionId,
341
- });
342
- if (!sessionId) {
343
- this.messageService.error(formatLocalize('debug.launch.typeNotSupported', resolved.configuration.type));
344
- return;
345
- }
346
- return this.doStart(sessionId, resolved, extra);
347
- } catch (e) {
348
- if (DebugError.NotFound.is(e)) {
349
- this.messageService.error(formatLocalize('debug.launch.typeNotSupported', e.data.type));
350
- return;
351
- }
352
-
353
- this.messageService.error(localize('debug.launch.catchError'));
354
- throw e;
355
- }
356
- }
357
-
358
- async fireWillStartDebugSession(): Promise<void> {
359
- await WaitUntilEvent.fire(this.onWillStartDebugSessionEmitter, {});
360
- }
361
-
362
- protected configurationIds = new Map<string, number>();
363
- async resolveConfiguration(options: Readonly<DebugSessionOptions>): Promise<IDebugSessionDTO | undefined> {
364
- if (IDebugSessionDTO.is(options)) {
365
- return options;
366
- }
367
- const { workspaceFolderUri, index, noDebug, parentSession, repl, compact, lifecycleManagedByParent } = options;
368
-
369
- const resolvedConfiguration = await this.resolveDebugConfiguration(options.configuration, workspaceFolderUri);
370
- if (resolvedConfiguration && !('cwd' in resolvedConfiguration)) {
371
- // 当调试配置不存在配置项时,提供默认的 `cwd` 选项
372
- resolvedConfiguration['cwd'] = '${workspaceFolder}';
373
- }
374
- let configuration = await this.variableResolver.resolve(resolvedConfiguration, {});
375
- if (!configuration) {
376
- // 当返回值为 `undefined` 或 `null` 时,中断调试
377
- if (configuration === null) {
378
- // 当返回值为 `null` 时,打开配置文件
379
- this.commandService.executeCommand(COMMON_COMMANDS.OPEN_LAUNCH_CONFIGURATION.id);
380
- }
381
- return;
382
- }
383
- configuration = await this.resolveDebugConfigurationWithSubstitutedVariables(configuration, workspaceFolderUri);
384
- if (!configuration) {
385
- // 当返回值为 `undefined` 或 `null` 时,中断调试
386
- if (configuration === null) {
387
- // 当返回值为 `null` 时,打开配置文件
388
- this.commandService.executeCommand(COMMON_COMMANDS.OPEN_LAUNCH_CONFIGURATION.id);
389
- }
390
- return;
391
- }
392
- const key = configuration.name + workspaceFolderUri;
393
- const id = this.configurationIds.has(key) ? this.configurationIds.get(key)! + 1 : 0;
394
- this.configurationIds.set(key, id);
395
- return {
396
- id,
397
- configuration,
398
- workspaceFolderUri,
399
- index,
400
- noDebug,
401
- parentSession,
402
- repl,
403
- compact,
404
- lifecycleManagedByParent,
405
- };
406
- }
407
-
408
- async resolveDebugConfiguration(
409
- configuration: DebugConfiguration,
410
- workspaceFolderUri: string | undefined,
411
- ): Promise<DebugConfiguration | undefined | null> {
412
- await this.fireWillResolveDebugConfiguration(configuration.type);
413
- return this.debug.resolveDebugConfiguration(configuration, workspaceFolderUri);
414
- }
415
-
416
- protected async resolveDebugConfigurationWithSubstitutedVariables(
417
- configuration: DebugConfiguration,
418
- workspaceFolderUri: string | undefined,
419
- ): Promise<DebugConfiguration | undefined | null> {
420
- return this.debug.resolveDebugConfigurationWithSubstitutedVariables(configuration, workspaceFolderUri);
421
- }
422
-
423
- async fireWillResolveDebugConfiguration(debugType: string): Promise<void> {
424
- await WaitUntilEvent.fire(this.onWillResolveDebugConfigurationEmitter, { debugType });
425
- }
426
-
427
- protected async doStart(
428
- sessionId: string,
429
- options: DebugSessionOptions,
430
- extra: DebugSessionExtra,
431
- ): Promise<DebugSession | undefined> {
432
- const contrib = this.sessionContributionRegistry.get(options.configuration.type);
433
- if (!contrib) {
434
- return;
435
- }
436
- const sessionFactory = contrib.debugSessionFactory();
437
- const session = sessionFactory.get(sessionId, options);
438
- this._sessions.set(sessionId, session);
439
- this._extraMap.set(sessionId, extra);
440
-
441
- this.debugTypeKey.set(session.configuration.type);
442
- this.onDidCreateDebugSessionEmitter.fire(session);
443
-
444
- let state = DebugState.Inactive;
445
- session.onDidChange(() => {
446
- if (state !== session.state) {
447
- state = session.state;
448
- if (state === DebugState.Stopped) {
449
- this.onDidStopDebugSessionEmitter.fire(session);
450
- this.debugStopped.set(true);
451
- } else {
452
- this.debugStopped.set(false);
453
- }
454
- }
455
- this.debugContextKey.contextSetVariableSupported.set(session.capabilities.supportsSetVariable ?? false);
456
- this.debugContextKey.contextRestartFrameSupported.set(session.capabilities.supportsRestartFrame ?? false);
457
- this.debugContextKey.contextDebugState.set(DebugState[session.state] as keyof typeof DebugState);
458
- this.debugContextKey.contextInDdebugMode.set(state !== DebugState.Inactive);
459
- });
460
- session.on('terminated', (event) => {
461
- const restart = event.body && event.body.restart;
462
- if (restart) {
463
- this.doRestart(session, restart);
464
- } else {
465
- this.destroy(session.id);
466
- }
467
- });
468
- session.on('exited', () => this.destroy(session.id));
469
- session.start().then(() => this.onDidStartDebugSessionEmitter.fire(session));
470
- session.onDidCustomEvent(({ event, body }) =>
471
- this.onDidReceiveDebugSessionCustomEventEmitter.fire({ event, body, session }),
472
- );
473
-
474
- this.updateCurrentSession(session);
475
- return session;
476
- }
477
-
478
- protected isExistedDebugSession(options: DebugSessionOptions): boolean {
479
- const { name } = options.configuration;
480
- for (const [, session] of this._sessions) {
481
- if (session.configuration.name === name && !session.terminated) {
482
- return true;
483
- }
484
- }
485
- return false;
486
- }
487
-
488
- restart(): Promise<DebugSession | undefined>;
489
- restart(session: DebugSession): Promise<DebugSession>;
490
- async restart(session: DebugSession | undefined = this.currentSession): Promise<DebugSession | undefined> {
491
- return session && this.doRestart(session);
492
- }
493
- protected async doRestart(session: DebugSession, restart?: any): Promise<DebugSession | undefined> {
494
- if (await session.restart()) {
495
- return session;
496
- }
497
- await session.terminate(true);
498
- const { options, configuration } = session;
499
- configuration.__restart = restart;
500
- return this.start(options);
501
- }
502
- public updateCurrentSession(session: DebugSession | undefined) {
503
- this.currentSession = session || this.sessions[this.sessions.length - 1];
504
- }
505
-
506
- get inDebugMode(): boolean {
507
- return this.state > DebugState.Inactive;
508
- }
509
-
510
- get currentThread(): DebugThread | undefined {
511
- const session = this.currentSession;
512
- return session && session.currentThread;
513
- }
514
-
515
- get state(): DebugState {
516
- const session = this.currentSession;
517
- return session ? session.state : DebugState.Inactive;
518
- }
519
-
520
- get currentFrame(): DebugStackFrame | undefined {
521
- const { currentThread } = this;
522
- return currentThread && currentThread.currentFrame;
523
- }
524
- get topFrame(): DebugStackFrame | undefined {
525
- const { currentThread } = this;
526
- return currentThread && currentThread.topFrame;
527
- }
528
-
529
- getSession(sessionId: string | undefined): DebugSession | undefined {
530
- if (sessionId) {
531
- return this._sessions.get(sessionId);
532
- }
533
- return undefined;
534
- }
535
-
536
- get sessions(): DebugSession[] {
537
- return Array.from(this._sessions.values()).filter((session) => session.state > DebugState.Inactive);
538
- }
539
-
540
- protected _currentSession: DebugSession | undefined;
541
- protected readonly toDisposeOnCurrentSession = new DisposableCollection();
542
- get currentSession(): DebugSession | undefined {
543
- return this._currentSession;
544
- }
545
- set currentSession(current: DebugSession | undefined) {
546
- if (this._currentSession === current) {
547
- return;
548
- }
549
- this.toDisposeOnCurrentSession.dispose();
550
- const previous = this._currentSession;
551
- this._currentSession = current;
552
- this.onDidChangeActiveDebugSessionEmitter.fire({ previous, current });
553
- if (current) {
554
- this.toDisposeOnCurrentSession.push(
555
- current.onDidChange(() => {
556
- if (this.currentFrame === this.topFrame) {
557
- this.open();
558
- }
559
- this.fireDidChange(current);
560
- }),
561
- );
562
- this.toDisposeOnCurrentSession.push(
563
- current.onCurrentThreadChange(() => {
564
- this.fireDidChange(current);
565
- }),
566
- );
567
- }
568
- this.open();
569
- this.fireDidChange(current);
570
- }
571
-
572
- open(): void {
573
- const { currentFrame } = this;
574
- if (currentFrame) {
575
- currentFrame.open();
576
- }
577
- }
578
-
579
- async stopSession(session: DebugSession | undefined, disconnect = false): Promise<any> {
580
- if (session) {
581
- return disconnect ? session.disconnect() : session.terminate();
582
- }
583
-
584
- return Promise.all(this.sessions.map((s) => (disconnect ? s.disconnect() : s.terminate())));
585
- }
586
-
587
- /**
588
- * 根据sessionId销毁进程
589
- * @param sessionId
590
- */
591
- destroy(sessionId?: string): void {
592
- if (sessionId) {
593
- const session = this._sessions.get(sessionId);
594
- if (session) {
595
- this.doDestroy(session);
596
- }
597
- } else {
598
- this._sessions.forEach((session) => this.doDestroy(session));
599
- }
600
- }
601
-
602
- private doDestroy(session: DebugSession): void {
603
- this.debug.terminateDebugSession(session.id);
604
-
605
- this.remove(session.id);
606
- session.dispose();
607
- this.onDidDestroyDebugSessionEmitter.fire(session);
608
- }
609
-
610
- protected remove(sessionId: string): void {
611
- this._sessions.delete(sessionId);
612
- const { currentSession } = this;
613
- if (currentSession && currentSession.id === sessionId) {
614
- this.updateCurrentSession(undefined);
615
- }
616
- // server 有可能会先返回一个 exited 事件,导致 destroy 先触发
617
- // 包一个 setTimeout 等埋点上报后再清理
618
- setTimeout(() => {
619
- this._extraMap.delete(sessionId);
620
- });
621
- }
622
- }