@opensumi/ide-debug 2.22.11 → 2.23.1-next-1679481979.0

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 (70) hide show
  1. package/lib/browser/breakpoint/breakpoint-manager.d.ts +2 -0
  2. package/lib/browser/breakpoint/breakpoint-manager.d.ts.map +1 -1
  3. package/lib/browser/breakpoint/breakpoint-manager.js +5 -0
  4. package/lib/browser/breakpoint/breakpoint-manager.js.map +1 -1
  5. package/lib/browser/contextkeys/debug-contextkey.service.d.ts +1 -1
  6. package/lib/browser/contextkeys/debug-contextkey.service.d.ts.map +1 -1
  7. package/lib/browser/contextkeys/debug-contextkey.service.js +1 -1
  8. package/lib/browser/contextkeys/debug-contextkey.service.js.map +1 -1
  9. package/lib/browser/debug-session-manager.d.ts.map +1 -1
  10. package/lib/browser/debug-session-manager.js +1 -5
  11. package/lib/browser/debug-session-manager.js.map +1 -1
  12. package/lib/browser/debug-session.js +3 -3
  13. package/lib/browser/debug-session.js.map +1 -1
  14. package/lib/browser/editor/debug-editor-contribution.d.ts.map +1 -1
  15. package/lib/browser/editor/debug-editor-contribution.js +1 -1
  16. package/lib/browser/editor/debug-editor-contribution.js.map +1 -1
  17. package/lib/browser/editor/debug-model.d.ts +2 -2
  18. package/lib/browser/editor/debug-model.d.ts.map +1 -1
  19. package/lib/browser/editor/debug-model.js +4 -3
  20. package/lib/browser/editor/debug-model.js.map +1 -1
  21. package/lib/browser/model/debug-stack-frame.d.ts +12 -0
  22. package/lib/browser/model/debug-stack-frame.d.ts.map +1 -1
  23. package/lib/browser/model/debug-stack-frame.js +24 -1
  24. package/lib/browser/model/debug-stack-frame.js.map +1 -1
  25. package/lib/browser/view/breakpoints/debug-breakpoints.service.d.ts.map +1 -1
  26. package/lib/browser/view/breakpoints/debug-breakpoints.service.js +5 -4
  27. package/lib/browser/view/breakpoints/debug-breakpoints.service.js.map +1 -1
  28. package/lib/browser/view/breakpoints/debug-breakpoints.view.d.ts.map +1 -1
  29. package/lib/browser/view/breakpoints/debug-breakpoints.view.js.map +1 -1
  30. package/lib/browser/view/configuration/debug-toolbar.view.d.ts.map +1 -1
  31. package/lib/browser/view/configuration/debug-toolbar.view.js +27 -25
  32. package/lib/browser/view/configuration/debug-toolbar.view.js.map +1 -1
  33. package/lib/browser/view/console/debug-console.service.js +2 -2
  34. package/lib/browser/view/console/debug-console.service.js.map +1 -1
  35. package/lib/browser/view/debug-view-model.d.ts.map +1 -1
  36. package/lib/browser/view/debug-view-model.js.map +1 -1
  37. package/lib/browser/view/frames/debug-call-stack-frame.view.d.ts +1 -0
  38. package/lib/browser/view/frames/debug-call-stack-frame.view.d.ts.map +1 -1
  39. package/lib/browser/view/frames/debug-call-stack-frame.view.js +101 -26
  40. package/lib/browser/view/frames/debug-call-stack-frame.view.js.map +1 -1
  41. package/lib/browser/view/frames/debug-call-stack-session.view.d.ts.map +1 -1
  42. package/lib/browser/view/frames/debug-call-stack-session.view.js +4 -4
  43. package/lib/browser/view/frames/debug-call-stack-session.view.js.map +1 -1
  44. package/lib/browser/view/frames/debug-call-stack-thread.view.d.ts +1 -0
  45. package/lib/browser/view/frames/debug-call-stack-thread.view.d.ts.map +1 -1
  46. package/lib/browser/view/frames/debug-call-stack-thread.view.js +3 -3
  47. package/lib/browser/view/frames/debug-call-stack-thread.view.js.map +1 -1
  48. package/lib/common/debug-service.d.ts +1 -6
  49. package/lib/common/debug-service.d.ts.map +1 -1
  50. package/lib/common/debug-service.js +1 -9
  51. package/lib/common/debug-service.js.map +1 -1
  52. package/lib/common/inline-values.d.ts +1 -0
  53. package/lib/common/inline-values.d.ts.map +1 -1
  54. package/package.json +23 -23
  55. package/src/browser/breakpoint/breakpoint-manager.ts +6 -0
  56. package/src/browser/contextkeys/debug-contextkey.service.ts +2 -2
  57. package/src/browser/debug-session-manager.ts +1 -7
  58. package/src/browser/debug-session.ts +3 -3
  59. package/src/browser/editor/debug-editor-contribution.ts +1 -1
  60. package/src/browser/editor/debug-model.ts +4 -3
  61. package/src/browser/model/debug-stack-frame.ts +27 -2
  62. package/src/browser/view/breakpoints/debug-breakpoints.service.ts +4 -4
  63. package/src/browser/view/breakpoints/debug-breakpoints.view.tsx +1 -7
  64. package/src/browser/view/configuration/debug-toolbar.view.tsx +112 -94
  65. package/src/browser/view/console/debug-console.service.ts +2 -2
  66. package/src/browser/view/debug-view-model.ts +6 -2
  67. package/src/browser/view/frames/debug-call-stack-frame.view.tsx +139 -50
  68. package/src/browser/view/frames/debug-call-stack-session.view.tsx +10 -4
  69. package/src/browser/view/frames/debug-call-stack-thread.view.tsx +7 -2
  70. package/src/common/debug-service.ts +1 -15
@@ -262,8 +262,8 @@ export class DebugModel implements IDebugModel {
262
262
  this.renderFrames();
263
263
  }
264
264
 
265
- render(): void {
266
- this.renderBreakpoints();
265
+ async render() {
266
+ await this.renderBreakpoints();
267
267
  this.renderFrames();
268
268
  }
269
269
 
@@ -271,7 +271,8 @@ export class DebugModel implements IDebugModel {
271
271
  * 渲染断点信息装饰器
272
272
  * @memberof DebugModel
273
273
  */
274
- renderBreakpoints(): void {
274
+ async renderBreakpoints() {
275
+ await this.breakpointManager.whenReady;
275
276
  this.renderNormalBreakpoints();
276
277
  this.renderCurrentBreakpoints();
277
278
  }
@@ -1,4 +1,4 @@
1
- import { IRange } from '@opensumi/ide-core-browser';
1
+ import { formatLocalize, IRange } from '@opensumi/ide-core-browser';
2
2
  import { IResourceOpenOptions } from '@opensumi/ide-editor';
3
3
  import { Range } from '@opensumi/monaco-editor-core/esm/vs/editor/common/core/range';
4
4
  import { DebugProtocol } from '@opensumi/vscode-debugprotocol/lib/debugProtocol';
@@ -9,12 +9,15 @@ import { DebugScope, ExpressionContainer } from '../tree/debug-tree-node.define'
9
9
  import { DebugSource } from './debug-source';
10
10
  import { DebugThread } from './debug-thread';
11
11
 
12
-
13
12
  export class DebugStackFrameData {
14
13
  readonly raw: DebugProtocol.StackFrame;
15
14
  }
16
15
 
17
16
  export class DebugStackFrame extends DebugStackFrameData {
17
+ public static is(frame: any): frame is DebugStackFrame {
18
+ return !!frame && 'raw' in frame;
19
+ }
20
+
18
21
  constructor(readonly thread: DebugThread, readonly session: DebugSession) {
19
22
  super();
20
23
  }
@@ -109,3 +112,25 @@ export class DebugStackFrame extends DebugStackFrameData {
109
112
  return scopesContainingRange.length ? scopesContainingRange : nonExpensiveScopes;
110
113
  }
111
114
  }
115
+
116
+ export class ShowMoreDebugStackFrame {
117
+ constructor(
118
+ public readonly startIndex: number,
119
+ public readonly frames: DebugStackFrame[],
120
+ readonly session: DebugSession,
121
+ readonly origin: string,
122
+ readonly _open: (showMoreFrame: ShowMoreDebugStackFrame) => void,
123
+ ) {}
124
+
125
+ get name() {
126
+ return formatLocalize('debug.stack.showMoreAndOrigin', this.frames.length, this.origin);
127
+ }
128
+
129
+ get id(): string {
130
+ return `${this.session.id}:showMore:${this.startIndex}`;
131
+ }
132
+
133
+ open = () => {
134
+ this._open(this);
135
+ };
136
+ }
@@ -11,7 +11,6 @@ import { WorkspaceEditDidRenameFileEvent, WorkspaceEditDidDeleteFileEvent } from
11
11
  import { DEBUG_REPORT_NAME, CONTEXT_IN_DEBUG_MODE_KEY, IDebugBreakpoint } from '../../../common';
12
12
  import { IDebugSessionManager } from '../../../common/debug-session';
13
13
  import {
14
- DebugBreakpoint,
15
14
  DebugExceptionBreakpoint,
16
15
  isDebugBreakpoint,
17
16
  isDebugExceptionBreakpoint,
@@ -76,9 +75,9 @@ export class DebugBreakpointsService extends WithEventBus {
76
75
 
77
76
  async init() {
78
77
  await this.updateRoots();
79
- this.updateBreakpoints();
78
+ await this.updateBreakpoints();
80
79
  this.workspaceService.onWorkspaceChanged(async () => {
81
- await this.updateRoots();
80
+ this.updateRoots();
82
81
  this.updateBreakpoints();
83
82
  });
84
83
  this.breakpoints.onDidChangeBreakpoints(() => {
@@ -166,7 +165,8 @@ export class DebugBreakpointsService extends WithEventBus {
166
165
  }
167
166
 
168
167
  @action
169
- private updateBreakpoints() {
168
+ private async updateBreakpoints() {
169
+ await this.breakpoints.whenReady;
170
170
  this.nodes = this.extractNodes([
171
171
  ...this.breakpoints.getExceptionBreakpoints(),
172
172
  ...this.breakpoints.getBreakpoints(),
@@ -8,13 +8,7 @@ import { useInjectable, ViewState, CommandService, EDITOR_COMMANDS, URI, getIcon
8
8
  import { DebugProtocol } from '@opensumi/vscode-debugprotocol/lib/debugProtocol';
9
9
 
10
10
  import { IDebugBreakpoint, IDebugSessionManager, ISourceBreakpoint } from '../../../common';
11
- import {
12
- DebugBreakpoint,
13
- DebugExceptionBreakpoint,
14
- isDebugBreakpoint,
15
- isRuntimeBreakpoint,
16
- getStatus,
17
- } from '../../breakpoint';
11
+ import { DebugExceptionBreakpoint, isDebugBreakpoint, isRuntimeBreakpoint, getStatus } from '../../breakpoint';
18
12
  import { DebugSessionManager } from '../../debug-session-manager';
19
13
 
20
14
  import styles from './debug-breakpoints.module.less';
@@ -1,7 +1,7 @@
1
1
  import cls from 'classnames';
2
2
  import { action, observable } from 'mobx';
3
3
  import { observer } from 'mobx-react-lite';
4
- import React, { useEffect, useState } from 'react';
4
+ import React, { useCallback, useEffect, useState } from 'react';
5
5
 
6
6
  import { Injectable } from '@opensumi/di';
7
7
  import { Option, Select } from '@opensumi/ide-components';
@@ -104,63 +104,80 @@ export const DebugToolbarView = observer((props: DebugToolbarViewProps) => {
104
104
 
105
105
  const currentSessionId = currentSession && currentSession.id;
106
106
 
107
- const renderToolBar = (session: DebugSession | undefined): React.ReactNode => {
108
- if (session && session.id && toolBarMenuMap.has(session.id)) {
109
- return <InlineMenuBar menus={toolBarMenuMap.get(session.id)!} />;
110
- }
111
- return null;
112
- };
113
- const renderStop = (state: DebugState): React.ReactNode => {
114
- if (isAttach) {
107
+ const renderToolBar = useCallback(
108
+ (session: DebugSession | undefined): React.ReactNode => {
109
+ if (session && session.id) {
110
+ const menus = toolBarMenuMap.get(session.id);
111
+ if (menus) {
112
+ return <InlineMenuBar menus={menus} />;
113
+ }
114
+ }
115
+ return null;
116
+ },
117
+ [toolBarMenuMap],
118
+ );
119
+
120
+ const renderStop = useCallback(
121
+ (state: DebugState): React.ReactNode => {
122
+ if (isAttach) {
123
+ return (
124
+ <DebugAction
125
+ run={doStop}
126
+ enabled={typeof state === 'number' && state !== DebugState.Inactive}
127
+ icon={'disconnect'}
128
+ label={localize('debug.action.disattach')}
129
+ />
130
+ );
131
+ }
115
132
  return (
116
133
  <DebugAction
117
134
  run={doStop}
118
135
  enabled={typeof state === 'number' && state !== DebugState.Inactive}
119
- icon={'disconnect'}
120
- label={localize('debug.action.disattach')}
136
+ icon={'stop'}
137
+ label={localize('debug.action.stop')}
121
138
  />
122
139
  );
123
- }
124
- return (
125
- <DebugAction
126
- run={doStop}
127
- enabled={typeof state === 'number' && state !== DebugState.Inactive}
128
- icon={'stop'}
129
- label={localize('debug.action.stop')}
130
- />
131
- );
132
- };
133
- const renderContinue = (state: DebugState): React.ReactNode => {
134
- if (state === DebugState.Stopped) {
135
- return <DebugAction run={doContinue} icon={'continue'} label={localize('debug.action.continue')} />;
136
- }
137
- return (
138
- <DebugAction
139
- run={doPause}
140
- enabled={typeof state === 'number' && state === DebugState.Running}
141
- icon={'pause'}
142
- label={localize('debug.action.pause')}
143
- />
144
- );
145
- };
140
+ },
141
+ [doStop],
142
+ );
146
143
 
147
- const renderSessionOptions = (sessions: DebugSession[]) =>
148
- sessions.map((session: DebugSession) => {
149
- if (isElectronRenderer) {
150
- return (
151
- <option key={session.id} value={session.id}>
152
- {session.label}
153
- </option>
154
- );
144
+ const renderContinue = useCallback(
145
+ (state: DebugState): React.ReactNode => {
146
+ if (state === DebugState.Stopped) {
147
+ return <DebugAction run={doContinue} icon={'continue'} label={localize('debug.action.continue')} />;
155
148
  }
156
149
  return (
157
- <Option key={session.id} label={session.label} value={session.id}>
158
- {session.label}
159
- </Option>
150
+ <DebugAction
151
+ run={doPause}
152
+ enabled={typeof state === 'number' && state === DebugState.Running}
153
+ icon={'pause'}
154
+ label={localize('debug.action.pause')}
155
+ />
160
156
  );
161
- });
157
+ },
158
+ [doPause, doContinue],
159
+ );
160
+
161
+ const renderSessionOptions = useCallback(
162
+ (sessions: DebugSession[]) =>
163
+ sessions.map((session: DebugSession) => {
164
+ if (isElectronRenderer) {
165
+ return (
166
+ <option key={session.id} value={session.id}>
167
+ {session.label}
168
+ </option>
169
+ );
170
+ }
171
+ return (
172
+ <Option key={session.id} label={session.label} value={session.id}>
173
+ {session.label}
174
+ </Option>
175
+ );
176
+ }),
177
+ [],
178
+ );
162
179
 
163
- const renderSelections = (sessions: DebugSession[]) => {
180
+ const renderSelections = useCallback((sessions: DebugSession[]) => {
164
181
  if (sessions.length > 1) {
165
182
  return (
166
183
  <div className={cls(styles.debug_selection)}>
@@ -182,59 +199,60 @@ export const DebugToolbarView = observer((props: DebugToolbarViewProps) => {
182
199
  </div>
183
200
  );
184
201
  }
185
- };
202
+ }, []);
186
203
 
187
- const setCurrentSession = (event: React.ChangeEvent<HTMLSelectElement> | string | number) => {
188
- let value = event;
189
- if (isElectronRenderer) {
190
- value = (event as React.ChangeEvent<HTMLSelectElement>).target.value;
191
- }
204
+ const setCurrentSession = useCallback(
205
+ (event: React.ChangeEvent<HTMLSelectElement> | string | number) => {
206
+ let value = event;
207
+ if (isElectronRenderer) {
208
+ value = (event as React.ChangeEvent<HTMLSelectElement>).target.value;
209
+ }
192
210
 
193
- if (!sessions) {
194
- return;
195
- }
196
- for (const session of sessions) {
197
- if (session.id === value) {
198
- updateCurrentSession(session);
211
+ if (!sessions) {
212
+ return;
199
213
  }
200
- }
201
- };
214
+ for (const session of sessions) {
215
+ if (session.id === value) {
216
+ updateCurrentSession(session);
217
+ }
218
+ }
219
+ },
220
+ [updateCurrentSession],
221
+ );
202
222
 
203
223
  return (
204
- <React.Fragment>
205
- <div className={styles.debug_action_bar}>
206
- {renderSelections(sessions.filter((s: DebugSession) => !s.parentSession))}
207
- <div className={styles.debug_actions}>
208
- {renderContinue(state)}
209
- <DebugAction
210
- run={doStepOver}
211
- enabled={typeof state === 'number' && state === DebugState.Stopped}
212
- icon={'step'}
213
- label={localize('debug.action.step-over')}
214
- />
215
- <DebugAction
216
- run={doStepIn}
217
- enabled={typeof state === 'number' && state === DebugState.Stopped}
218
- icon={'step-in'}
219
- label={localize('debug.action.step-into')}
220
- />
221
- <DebugAction
222
- run={doStepOut}
223
- enabled={typeof state === 'number' && state === DebugState.Stopped}
224
- icon={'step-out'}
225
- label={localize('debug.action.step-out')}
226
- />
227
- <DebugAction
228
- run={doRestart}
229
- enabled={typeof state === 'number' && state !== DebugState.Inactive}
230
- icon={'reload'}
231
- label={localize('debug.action.restart')}
232
- />
233
- {renderStop(state)}
234
- {renderToolBar(currentSession)}
235
- </div>
224
+ <div className={styles.debug_action_bar}>
225
+ {renderSelections(sessions.filter((s: DebugSession) => !s.parentSession))}
226
+ <div className={styles.debug_actions}>
227
+ {renderContinue(state)}
228
+ <DebugAction
229
+ run={doStepOver}
230
+ enabled={typeof state === 'number' && state === DebugState.Stopped}
231
+ icon={'step'}
232
+ label={localize('debug.action.step-over')}
233
+ />
234
+ <DebugAction
235
+ run={doStepIn}
236
+ enabled={typeof state === 'number' && state === DebugState.Stopped}
237
+ icon={'step-in'}
238
+ label={localize('debug.action.step-into')}
239
+ />
240
+ <DebugAction
241
+ run={doStepOut}
242
+ enabled={typeof state === 'number' && state === DebugState.Stopped}
243
+ icon={'step-out'}
244
+ label={localize('debug.action.step-out')}
245
+ />
246
+ <DebugAction
247
+ run={doRestart}
248
+ enabled={typeof state === 'number' && state !== DebugState.Inactive}
249
+ icon={'reload'}
250
+ label={localize('debug.action.restart')}
251
+ />
252
+ {renderStop(state)}
253
+ {renderToolBar(currentSession)}
236
254
  </div>
237
- </React.Fragment>
255
+ </div>
238
256
  );
239
257
  });
240
258
 
@@ -156,11 +156,11 @@ export class DebugConsoleService implements IHistoryNavigationWidget {
156
156
  if (inDebugMode) {
157
157
  this.updateReadOnly(false);
158
158
  this.updateInputDecoration();
159
- this.debugContextKey.contextInDdebugMode.set(true);
159
+ this.debugContextKey.contextInDebugMode.set(true);
160
160
  } else {
161
161
  this.updateReadOnly(true);
162
162
  if (this.debugContextKey) {
163
- this.debugContextKey.contextInDdebugMode.set(false);
163
+ this.debugContextKey.contextInDebugMode.set(false);
164
164
  }
165
165
  }
166
166
  }
@@ -24,7 +24,6 @@ import { DebugSessionManager } from '../debug-session-manager';
24
24
  import { DebugStackFrame } from '../model/debug-stack-frame';
25
25
  import { DebugThread } from '../model/debug-thread';
26
26
 
27
-
28
27
  @Injectable()
29
28
  export class DebugViewModel implements IDisposable {
30
29
  @Autowired(IDebugSessionManager)
@@ -43,7 +42,6 @@ export class DebugViewModel implements IDisposable {
43
42
  }
44
43
 
45
44
  protected readonly toDispose = new DisposableCollection(this.onDidChangeEmitter, this.onDidChangeBreakpointsEmitter);
46
-
47
45
  protected readonly _sessions = new Set<DebugSession>();
48
46
 
49
47
  get sessions(): IterableIterator<DebugSession> {
@@ -77,9 +75,11 @@ export class DebugViewModel implements IDisposable {
77
75
  get id(): string {
78
76
  return (this.session && this.session.id) || '-1';
79
77
  }
78
+
80
79
  get label(): string {
81
80
  return (this.session && this.session.label) || 'Unknown Session';
82
81
  }
82
+
83
83
  has(session: DebugSession | undefined): session is DebugSession {
84
84
  return !!session && this._sessions.has(session);
85
85
  }
@@ -120,10 +120,12 @@ export class DebugViewModel implements IDisposable {
120
120
  return this.manager.currentSession.getThreads(() => true);
121
121
  }
122
122
  }
123
+
123
124
  get currentSession(): DebugSession | undefined {
124
125
  const { currentSession } = this.manager;
125
126
  return (this.has(currentSession) && currentSession) || this.session;
126
127
  }
128
+
127
129
  set currentSession(currentSession: DebugSession | undefined) {
128
130
  this.manager.updateCurrentSession(currentSession);
129
131
  }
@@ -132,10 +134,12 @@ export class DebugViewModel implements IDisposable {
132
134
  const { currentSession } = this;
133
135
  return (currentSession && currentSession.state) || DebugState.Inactive;
134
136
  }
137
+
135
138
  get currentThread(): DebugThread | undefined {
136
139
  const { currentSession } = this;
137
140
  return currentSession && currentSession.currentThread;
138
141
  }
142
+
139
143
  get currentFrame(): DebugStackFrame | undefined {
140
144
  const { currentThread } = this;
141
145
  return currentThread && currentThread.currentFrame;