@opensumi/ide-debug 2.21.9-rc-1671440760.0 → 2.21.9

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,122 +0,0 @@
1
- /* ---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
- import { Injectable, Autowired } from '@opensumi/di';
6
- import { Event, IDisposable } from '@opensumi/ide-core-browser';
7
- import { IProgressService } from '@opensumi/ide-core-browser/lib/progress';
8
- import { DisposableCollection, IProgress, IProgressStep } from '@opensumi/ide-core-common';
9
- import { ProgressLocation } from '@opensumi/ide-core-common';
10
- import { DebugProtocol } from '@opensumi/vscode-debugprotocol';
11
-
12
- import { IDebugProgress } from '../common/debug-progress';
13
- import { DebugState, IDebugSessionManager } from '../common/debug-session';
14
-
15
- import { DebugSession } from './debug-session';
16
-
17
- @Injectable()
18
- export class DebugProgressService implements IDebugProgress {
19
- static DEBUG_PANEL_PROGRESS_ID = 'debug';
20
-
21
- @Autowired(IProgressService)
22
- protected readonly progressService: IProgressService;
23
-
24
- private progressResolve: (() => void) | undefined;
25
-
26
- private toDispose: IDisposable[] = [];
27
-
28
- public async onDebugServiceStateChange(state: DebugState) {
29
- if (this.progressResolve) {
30
- this.progressResolve();
31
- this.progressResolve = undefined;
32
- }
33
- if (
34
- state === DebugState.Initializing &&
35
- this.progressService.getIndicator(DebugProgressService.DEBUG_PANEL_PROGRESS_ID)
36
- ) {
37
- this.progressService.withProgress(
38
- { location: DebugProgressService.DEBUG_PANEL_PROGRESS_ID },
39
- (_progress) => new Promise<void>((resolve) => (this.progressResolve = resolve)),
40
- );
41
- }
42
- }
43
-
44
- public run(sessionsManager: IDebugSessionManager): void {
45
- let progressListener: DisposableCollection | undefined;
46
- const listenOnProgress = (session: DebugSession | undefined) => {
47
- progressListener = new DisposableCollection();
48
-
49
- if (session) {
50
- progressListener?.push(session.onDidChangeState((state: DebugState) => this.onDebugServiceStateChange(state)));
51
- progressListener?.push(
52
- session.onDidProgressStart(async (progressStartEvent: DebugProtocol.ProgressStartEvent) => {
53
- const promise = new Promise<void>((r) => {
54
- const listener = Event.any(
55
- Event.filter(session.onDidProgressEnd, (e) => e.body.progressId === progressStartEvent.body.progressId),
56
- session.onDidExitAdapter as Event<any>,
57
- )(() => {
58
- listener.dispose();
59
- r();
60
- });
61
- });
62
-
63
- if (this.progressService.getIndicator(DebugProgressService.DEBUG_PANEL_PROGRESS_ID)) {
64
- this.progressService.withProgress(
65
- { location: DebugProgressService.DEBUG_PANEL_PROGRESS_ID },
66
- () => promise,
67
- );
68
- }
69
-
70
- this.progressService.withProgress(
71
- {
72
- location: ProgressLocation.Notification,
73
- title: progressStartEvent.body.title,
74
- cancellable: progressStartEvent.body.cancellable,
75
- silent: true,
76
- delay: 500,
77
- },
78
- (progressStep: IProgress<IProgressStep>) => {
79
- let total = 0;
80
- const reportProgress = (progress: { message?: string; percentage?: number }) => {
81
- let increment: undefined | number;
82
- if (typeof progress.percentage === 'number') {
83
- increment = progress.percentage - total;
84
- total += increment;
85
- }
86
- progressStep.report({
87
- message: progress.message,
88
- increment,
89
- total: typeof increment === 'number' ? 100 : undefined,
90
- });
91
- };
92
-
93
- if (progressStartEvent.body.message) {
94
- reportProgress(progressStartEvent.body);
95
- }
96
-
97
- const progressUpdateListener = session.onDidProgressUpdate((e) => {
98
- if (e.body.progressId === progressStartEvent.body.progressId) {
99
- reportProgress(e.body);
100
- }
101
- });
102
-
103
- return promise.then(() => progressUpdateListener.dispose());
104
- },
105
- () => session.cancel(progressStartEvent.body.progressId),
106
- );
107
- }),
108
- );
109
- }
110
- };
111
-
112
- this.toDispose.push(
113
- sessionsManager.onDidChangeActiveDebugSession(({ current }) => {
114
- if (progressListener) {
115
- progressListener.dispose();
116
- }
117
- listenOnProgress(current);
118
- }),
119
- );
120
- listenOnProgress(sessionsManager.currentSession);
121
- }
122
- }
@@ -1,67 +0,0 @@
1
- import { Injectable, Autowired } from '@opensumi/di';
2
- import { objects, IJSONSchema, IJSONSchemaRegistry } from '@opensumi/ide-core-browser';
3
-
4
- import { launchSchemaUri } from '../common';
5
- import { DebugServer, IDebugServer } from '../common/debug-service';
6
-
7
- import { DebugConfigurationManager } from './debug-configuration-manager';
8
-
9
- const { deepClone } = objects;
10
-
11
- @Injectable()
12
- export class DebugSchemaUpdater {
13
- @Autowired(IDebugServer)
14
- protected readonly debug: DebugServer;
15
-
16
- @Autowired(IJSONSchemaRegistry)
17
- private schemaRegistry: IJSONSchemaRegistry;
18
-
19
- @Autowired(DebugConfigurationManager)
20
- private config: DebugConfigurationManager;
21
-
22
- async update(): Promise<void> {
23
- const debuggers = this.config.getDebuggers();
24
- const schema = { ...deepClone(launchSchema) };
25
- const items = schema!.properties!.configurations.items as IJSONSchema;
26
- const configurations = debuggers.map((dbg) => ({
27
- attributes: Object.keys(dbg.configurationAttributes || {}).map((request) => {
28
- const attributes: IJSONSchema = dbg.configurationAttributes[request];
29
- return attributes;
30
- }),
31
- configurationSnippets: dbg.configurationSnippets,
32
- }));
33
- for (const { attributes, configurationSnippets } of configurations) {
34
- if (attributes && items.oneOf) {
35
- items.oneOf!.push(...attributes);
36
- }
37
- if (configurationSnippets && items.defaultSnippets) {
38
- items.defaultSnippets.push(...configurationSnippets);
39
- }
40
- }
41
- this.schemaRegistry.registerSchema(`${launchSchemaUri}/extension`, schema, ['launch.json']);
42
- }
43
- }
44
-
45
- export const launchSchema: IJSONSchema = {
46
- $id: launchSchemaUri,
47
- type: 'object',
48
- title: 'Launch',
49
- required: [],
50
- default: { version: '0.2.0', configurations: [] },
51
- properties: {
52
- version: {
53
- type: 'string',
54
- description: 'Version of this file format.',
55
- default: '0.2.0',
56
- },
57
- configurations: {
58
- type: 'array',
59
- description: 'List of configurations. Add new configurations or edit existing ones by using IntelliSense.',
60
- items: {
61
- defaultSnippets: [],
62
- type: 'object',
63
- oneOf: [],
64
- },
65
- },
66
- },
67
- };
@@ -1,42 +0,0 @@
1
- import { Injectable } from '@opensumi/di';
2
- import { IJSONSchema, Event, Emitter } from '@opensumi/ide-core-browser';
3
-
4
- import { IDebugService, IDebugServiceContributionPoint } from '../common';
5
-
6
- @Injectable()
7
- export class DebugService implements IDebugService {
8
- private onDidDebugContributionPointChangeEmitter: Emitter<IDebugServiceContributionPoint> =
9
- new Emitter<IDebugServiceContributionPoint>();
10
-
11
- private debugContributionPointsMap: Map<string, IJSONSchema[]> = new Map();
12
-
13
- registerDebugContributionPoints(path: string, contributions: IJSONSchema[]) {
14
- if (!this.debugContributionPointsMap.has(path)) {
15
- this.debugContributionPointsMap.set(path, contributions);
16
- this.onDidDebugContributionPointChangeEmitter.fire({
17
- path,
18
- contributions,
19
- });
20
- }
21
- }
22
-
23
- unregisterDebugContributionPoints(path: string) {
24
- const contributions = this.debugContributionPointsMap.get(path);
25
- if (contributions) {
26
- this.debugContributionPointsMap.delete(path);
27
- this.onDidDebugContributionPointChangeEmitter.fire({
28
- path,
29
- contributions,
30
- removed: true,
31
- });
32
- }
33
- }
34
-
35
- get debugContributionPoints() {
36
- return this.debugContributionPointsMap;
37
- }
38
-
39
- get onDidDebugContributionPointChange(): Event<IDebugServiceContributionPoint> {
40
- return this.onDidDebugContributionPointChangeEmitter.event;
41
- }
42
- }
@@ -1,333 +0,0 @@
1
- import { DebugConfiguration } from 'vscode';
2
-
3
- import { Injectable, Optional, Autowired } from '@opensumi/di';
4
- import { IWebSocket } from '@opensumi/ide-connection';
5
- import {
6
- Event,
7
- Emitter,
8
- DisposableCollection,
9
- Disposable,
10
- IDisposable,
11
- Deferred,
12
- getDebugLogger,
13
- } from '@opensumi/ide-core-browser';
14
- import { CancellationToken } from '@opensumi/ide-core-common';
15
- import { OutputChannel } from '@opensumi/ide-output/lib/browser/output.channel';
16
- import { DebugProtocol } from '@opensumi/vscode-debugprotocol';
17
-
18
- import {
19
- DebugEventTypes,
20
- DebugExitEvent,
21
- DebugRequestTypes,
22
- DEBUG_REPORT_NAME,
23
- getSequenceId,
24
- IDebugSessionManager,
25
- } from '../common';
26
-
27
-
28
- import { DebugSessionManager } from './debug-session-manager';
29
-
30
- export type DebugRequestHandler = (request: DebugProtocol.Request) => any;
31
-
32
- const standardDebugEvents = new Set<Required<keyof DebugEventTypes>>([
33
- 'breakpoint',
34
- 'capabilities',
35
- 'continued',
36
- 'exited',
37
- 'initialized',
38
- 'loadedSource',
39
- 'module',
40
- 'output',
41
- 'process',
42
- 'stopped',
43
- 'terminated',
44
- 'thread',
45
- 'progressStart',
46
- 'progressUpdate',
47
- 'progressEnd',
48
- 'invalidated',
49
- ]);
50
-
51
- @Injectable({ multiple: true })
52
- export class DebugSessionConnection implements IDisposable {
53
- @Autowired(IDebugSessionManager)
54
- protected readonly manager: DebugSessionManager;
55
-
56
- protected readonly pendingRequests = new Map<number, (response: DebugProtocol.Response) => void>();
57
- protected readonly connection: Promise<IWebSocket>;
58
-
59
- protected readonly requestHandlers = new Map<string, DebugRequestHandler>();
60
-
61
- protected readonly onDidCustomEventEmitter = new Emitter<DebugProtocol.Event>();
62
- readonly onDidCustomEvent: Event<DebugProtocol.Event> = this.onDidCustomEventEmitter.event;
63
-
64
- protected readonly toDispose = new DisposableCollection(
65
- this.onDidCustomEventEmitter,
66
- Disposable.create(() => this.pendingRequests.clear()),
67
- Disposable.create(() => this.emitters.clear()),
68
- );
69
-
70
- constructor(
71
- @Optional() readonly sessionId: string,
72
- @Optional() protected readonly connectionFactory: (sessionId: string) => Promise<IWebSocket>,
73
- @Optional() protected readonly traceOutputChannel: OutputChannel | undefined,
74
- ) {
75
- this.connection = this.createConnection();
76
- }
77
-
78
- get disposed(): boolean {
79
- return this.toDispose.disposed;
80
- }
81
-
82
- dispose(): void {
83
- this.toDispose.dispose();
84
- }
85
-
86
- /**
87
- * 通过 Connection 模块创建可与 Node 进程通信的链接
88
- * @returns IWebSocket
89
- */
90
- protected async createConnection(): Promise<IWebSocket> {
91
- if (this.disposed) {
92
- throw new Error('Connection has been already disposed.');
93
- } else {
94
- const connection = await this.connectionFactory(this.sessionId);
95
- connection.onClose((code, reason) => {
96
- this.fire('exited', { code, reason });
97
- });
98
-
99
- connection.onMessage((data) => this.handleMessage(data));
100
-
101
- this.toDispose.push(
102
- Disposable.create(() => {
103
- connection.close();
104
- }),
105
- );
106
- return connection;
107
- }
108
- }
109
-
110
- protected allThreadsContinued = true;
111
-
112
- protected sessionAdapterID: DebugProtocol.InitializeRequestArguments['adapterID'];
113
-
114
- async sendRequest<K extends keyof DebugRequestTypes>(
115
- command: K,
116
- args: DebugRequestTypes[K][0],
117
- configuration: DebugConfiguration,
118
- token?: CancellationToken,
119
- ): Promise<DebugRequestTypes[K][1]> {
120
- /**
121
- * 在接收到 initialize 请求的时候记录当前的 session 适配器类型
122
- */
123
- if (command === 'initialize') {
124
- this.sessionAdapterID = (args as DebugProtocol.InitializeRequestArguments).adapterID;
125
- }
126
-
127
- const reportDAP = this.manager.reportTime(DEBUG_REPORT_NAME.DEBUG_ADAPTER_PROTOCOL_TIME, {
128
- sessionId: this.sessionId,
129
- threadId: (args && (args as DebugProtocol.ThreadsArguments).threadId) || this.manager.currentThread?.raw.id,
130
- });
131
- const result = await this.doSendRequest(command, args, token);
132
-
133
- /*
134
- * 对 threads 请求增加 数量 统计
135
- */
136
- const reportExtra: any = {
137
- adapterID: this.sessionAdapterID,
138
- request: configuration.request,
139
- };
140
-
141
- if (command === 'threads') {
142
- reportExtra.amount = (result as DebugProtocol.ThreadsResponse).body.threads.length;
143
- }
144
-
145
- reportDAP(command, reportExtra);
146
-
147
- if (
148
- command === 'next' ||
149
- command === 'stepIn' ||
150
- command === 'stepOut' ||
151
- command === 'stepBack' ||
152
- command === 'reverseContinue' ||
153
- command === 'restartFrame'
154
- ) {
155
- this.fireContinuedEvent((args as any).threadId);
156
- }
157
- if (command === 'continue') {
158
- const response = result as DebugProtocol.ContinueResponse;
159
- const allThreadsContinued = response && response.body && response.body.allThreadsContinued;
160
- if (allThreadsContinued !== undefined) {
161
- this.allThreadsContinued = result.body.allThreadsContinued;
162
- }
163
- this.fireContinuedEvent((args as any).threadId, this.allThreadsContinued);
164
- return result;
165
- }
166
- return result;
167
- }
168
-
169
- async sendCustomRequest<T extends DebugProtocol.Response>(command: string, args?: any): Promise<T> {
170
- return (await this.doSendRequest<T>(command, args))?.body;
171
- }
172
-
173
- protected async doSendRequest<K extends DebugProtocol.Response>(
174
- command: string,
175
- args: any = null,
176
- token?: CancellationToken,
177
- ): Promise<K> {
178
- const result = new Deferred<K>();
179
-
180
- const request: DebugProtocol.Request = {
181
- seq: getSequenceId(),
182
- type: 'request',
183
- command,
184
- };
185
-
186
- let cancelationListener: IDisposable;
187
- if (args && Object.keys(args).length > 0) {
188
- request.arguments = args;
189
- }
190
-
191
- this.pendingRequests.set(request.seq, (response: any) => {
192
- if (cancelationListener) {
193
- cancelationListener.dispose();
194
- }
195
- if (!response.success) {
196
- result.reject(response);
197
- } else {
198
- result.resolve(response);
199
- }
200
- });
201
-
202
- if (token) {
203
- cancelationListener = token.onCancellationRequested(async () => {
204
- cancelationListener.dispose();
205
- const session = this.manager.getSession(this.sessionId);
206
- if (session && session.capabilities.supportsCancelRequest) {
207
- session.sendRequest('cancel', {
208
- requestId: request.seq,
209
- });
210
- }
211
- });
212
- }
213
-
214
- await this.send(request);
215
- return result.promise;
216
- }
217
-
218
- protected async send(message: DebugProtocol.ProtocolMessage): Promise<void> {
219
- const connection = await this.connection;
220
- const messageStr = JSON.stringify(message);
221
- if (this.traceOutputChannel) {
222
- this.traceOutputChannel.appendLine(`${this.sessionId.substring(0, 8)} [UI -> adapter]: ${messageStr}`);
223
- }
224
- connection.send(messageStr);
225
- }
226
-
227
- protected handleMessage(data: string) {
228
- if (this.traceOutputChannel) {
229
- this.traceOutputChannel.appendLine(`${this.sessionId.substring(0, 8)} [adapter -> UI ]: ${data}`);
230
- }
231
- const message: DebugProtocol.ProtocolMessage = JSON.parse(data);
232
- if (message.type === 'request') {
233
- this.handleRequest(message as DebugProtocol.Request);
234
- } else if (message.type === 'response') {
235
- this.handleResponse(message as DebugProtocol.Response);
236
- } else if (message.type === 'event') {
237
- this.handleEvent(message as DebugProtocol.Event);
238
- }
239
- }
240
-
241
- protected handleResponse(response: DebugProtocol.Response): void {
242
- const callback = this.pendingRequests.get(response.request_seq);
243
- if (callback) {
244
- this.pendingRequests.delete(response.request_seq);
245
- callback(response);
246
- }
247
- }
248
-
249
- onRequest(command: string, handler: DebugRequestHandler): void {
250
- this.requestHandlers.set(command, handler);
251
- }
252
-
253
- protected async handleRequest(request: DebugProtocol.Request): Promise<void> {
254
- const response: DebugProtocol.Response = {
255
- type: 'response',
256
- seq: getSequenceId(),
257
- command: request.command,
258
- request_seq: request.seq,
259
- success: true,
260
- };
261
- const handler = this.requestHandlers.get(request.command);
262
- if (handler) {
263
- try {
264
- response.body = handler(request);
265
- } catch (error) {
266
- response.success = false;
267
- response.message = error.message;
268
- }
269
- } else {
270
- getDebugLogger().error('Unhandled request', request);
271
- }
272
- await this.send(response);
273
- }
274
-
275
- protected handleEvent(event: DebugProtocol.Event): void {
276
- if ('event' in event) {
277
- if (event.event === 'continued') {
278
- this.allThreadsContinued =
279
- (event as DebugProtocol.ContinuedEvent).body.allThreadsContinued === false ? false : true;
280
- }
281
- if (standardDebugEvents.has(event.event as keyof DebugEventTypes)) {
282
- this.doFire(event.event, event);
283
- } else {
284
- this.onDidCustomEventEmitter.fire(event);
285
- }
286
- } else {
287
- this.fire('exited', event as DebugEventTypes['exited']);
288
- }
289
- }
290
-
291
- protected readonly emitters = new Map<string, Emitter<DebugProtocol.Event | DebugExitEvent>>();
292
- on<K extends keyof DebugEventTypes>(kind: K, listener: (e: DebugEventTypes[K]) => any): IDisposable {
293
- if (this.disposed) {
294
- return Disposable.create(() => {});
295
- }
296
- return this.getEmitter(kind).event(listener);
297
- }
298
-
299
- public fire<K extends keyof DebugEventTypes>(kind: K, e: DebugEventTypes[K]): void {
300
- this.doFire(kind, e);
301
- }
302
-
303
- protected doFire(kind: string, e: DebugProtocol.Event | DebugExitEvent): void {
304
- if (this.disposed) {
305
- return;
306
- }
307
- this.getEmitter(kind).fire(e);
308
- }
309
-
310
- protected getEmitter(kind: string): Emitter<DebugProtocol.Event | DebugExitEvent> {
311
- const emitter = this.emitters.get(kind) || this.newEmitter();
312
- this.emitters.set(kind, emitter);
313
- return emitter;
314
- }
315
-
316
- protected newEmitter(): Emitter<DebugProtocol.Event | DebugExitEvent> {
317
- const emitter = new Emitter<DebugProtocol.Event | DebugExitEvent>();
318
- this.toDispose.push(emitter);
319
- return emitter;
320
- }
321
-
322
- protected fireContinuedEvent(threadId: number, allThreadsContinued = false): void {
323
- this.fire('continued', {
324
- type: 'event',
325
- event: 'continued',
326
- body: {
327
- threadId,
328
- allThreadsContinued,
329
- },
330
- seq: getSequenceId(),
331
- });
332
- }
333
- }
@@ -1,57 +0,0 @@
1
- import { Injectable, Autowired } from '@opensumi/di';
2
- import { ContributionProvider } from '@opensumi/ide-core-browser';
3
-
4
- import { DebugSessionOptions } from '../common';
5
-
6
- import { DebugSession } from './debug-session';
7
-
8
- export const DebugSessionContribution = Symbol('DebugSessionContribution');
9
-
10
- export interface DebugSessionContribution {
11
- /**
12
- * 调试类型,如node2
13
- */
14
- debugType: string;
15
-
16
- /**
17
- * 生成DebugSession的工厂函数.
18
- */
19
- debugSessionFactory(): DebugSessionFactory;
20
- }
21
-
22
- export const DebugSessionContributionRegistry = Symbol('DebugSessionContributionRegistry');
23
-
24
- export interface DebugSessionContributionRegistry {
25
- get(debugType: string): DebugSessionContribution | undefined;
26
- }
27
-
28
- @Injectable()
29
- export class DebugSessionContributionRegistryImpl implements DebugSessionContributionRegistry {
30
- protected readonly contribs = new Map<string, DebugSessionContribution>();
31
-
32
- @Autowired(DebugSessionContribution)
33
- protected readonly contributions: ContributionProvider<DebugSessionContribution>;
34
-
35
- constructor() {
36
- this.init();
37
- }
38
-
39
- protected init(): void {
40
- for (const contrib of this.contributions.getContributions()) {
41
- this.contribs.set(contrib.debugType, contrib);
42
- }
43
- }
44
-
45
- get(debugType: string): DebugSessionContribution | undefined {
46
- return this.contribs.get(debugType);
47
- }
48
- }
49
-
50
- export const DebugSessionFactory = Symbol('DebugSessionFactory');
51
-
52
- /**
53
- * 生成DebugSession的工厂函数.
54
- */
55
- export interface DebugSessionFactory {
56
- get(sessionId: string, options: DebugSessionOptions): DebugSession;
57
- }