@opensumi/ide-debug 2.21.6-rc-1669620508.0 → 2.21.6

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 (166) hide show
  1. package/lib/browser/index.d.ts.map +1 -1
  2. package/lib/browser/index.js +9 -2
  3. package/lib/browser/index.js.map +1 -1
  4. package/lib/browser/preferences/launch-folder-preference-provider.d.ts +2 -2
  5. package/lib/browser/preferences/launch-folder-preference-provider.d.ts.map +1 -1
  6. package/lib/browser/preferences/launch-folder-preference-provider.js +2 -2
  7. package/lib/browser/preferences/launch-folder-preference-provider.js.map +1 -1
  8. package/lib/browser/view/configuration/debug-configuration.module.less +5 -5
  9. package/lib/browser/view/configuration/debug-configuration.view.d.ts.map +1 -1
  10. package/lib/browser/view/configuration/debug-configuration.view.js +1 -1
  11. package/lib/browser/view/configuration/debug-configuration.view.js.map +1 -1
  12. package/lib/browser/view/configuration/debug-toolbar.view.js +2 -2
  13. package/lib/browser/view/configuration/debug-toolbar.view.js.map +1 -1
  14. package/lib/browser/view/console/debug-console.module.less +1 -2
  15. package/lib/browser/view/console/debug-console.view.js +2 -2
  16. package/lib/browser/view/console/debug-console.view.js.map +1 -1
  17. package/lib/browser/view/variables/debug-variables.module.less +1 -2
  18. package/lib/browser/view/variables/debug-variables.view.js +1 -1
  19. package/lib/browser/view/variables/debug-variables.view.js.map +1 -1
  20. package/lib/browser/view/watch/debug-watch.module.less +1 -2
  21. package/lib/browser/view/watch/debug-watch.view.js +1 -1
  22. package/lib/browser/view/watch/debug-watch.view.js.map +1 -1
  23. package/package.json +24 -25
  24. package/src/browser/assets/breakpoint-conditional-disabled.svg +0 -4
  25. package/src/browser/assets/breakpoint-conditional-unverified.svg +0 -4
  26. package/src/browser/assets/breakpoint-conditional.svg +0 -4
  27. package/src/browser/assets/breakpoint-disabled.svg +0 -4
  28. package/src/browser/assets/breakpoint-hint.svg +0 -4
  29. package/src/browser/assets/breakpoint-log-disabled.svg +0 -4
  30. package/src/browser/assets/breakpoint-log-unverified.svg +0 -4
  31. package/src/browser/assets/breakpoint-log.svg +0 -4
  32. package/src/browser/assets/breakpoint-unsupported.svg +0 -4
  33. package/src/browser/assets/breakpoint-unverified.svg +0 -4
  34. package/src/browser/assets/breakpoint.svg +0 -4
  35. package/src/browser/assets/breakpoints-activate-inverse.svg +0 -4
  36. package/src/browser/assets/breakpoints-activate.svg +0 -4
  37. package/src/browser/assets/configure-inverse.svg +0 -4
  38. package/src/browser/assets/configure.svg +0 -4
  39. package/src/browser/assets/continue-inverse.svg +0 -4
  40. package/src/browser/assets/current-and-breakpoint.svg +0 -4
  41. package/src/browser/assets/current-arrow.svg +0 -4
  42. package/src/browser/assets/remove-all-inverse.svg +0 -4
  43. package/src/browser/assets/remove-all.svg +0 -4
  44. package/src/browser/assets/repl-inverse.svg +0 -4
  45. package/src/browser/assets/repl.svg +0 -4
  46. package/src/browser/assets/restart-inverse.svg +0 -4
  47. package/src/browser/assets/stackframe-and-breakpoint.svg +0 -4
  48. package/src/browser/assets/stackframe-arrow.svg +0 -4
  49. package/src/browser/assets/start-inverse.svg +0 -4
  50. package/src/browser/breakpoint/breakpoint-decoration.ts +0 -57
  51. package/src/browser/breakpoint/breakpoint-manager.ts +0 -348
  52. package/src/browser/breakpoint/breakpoint-marker.ts +0 -70
  53. package/src/browser/breakpoint/index.ts +0 -3
  54. package/src/browser/components/debug-action/index.module.less +0 -73
  55. package/src/browser/components/debug-action/index.tsx +0 -40
  56. package/src/browser/components/debug-exception-widget.less +0 -42
  57. package/src/browser/components/floating-click-widget/index.module.less +0 -5
  58. package/src/browser/components/floating-click-widget/index.tsx +0 -21
  59. package/src/browser/components/index.ts +0 -1
  60. package/src/browser/contextkeys/debug-call-stack-item-type-key.ts +0 -4
  61. package/src/browser/contextkeys/debug-contextkey.service.ts +0 -54
  62. package/src/browser/contextkeys/index.ts +0 -1
  63. package/src/browser/debug-ansi-handle.ts +0 -521
  64. package/src/browser/debug-configuration-manager.ts +0 -513
  65. package/src/browser/debug-configuration-model.ts +0 -66
  66. package/src/browser/debug-contribution.ts +0 -904
  67. package/src/browser/debug-exception-widget.tsx +0 -89
  68. package/src/browser/debug-link-detector.ts +0 -234
  69. package/src/browser/debug-memory.ts +0 -220
  70. package/src/browser/debug-preferences.ts +0 -70
  71. package/src/browser/debug-progress.service.ts +0 -122
  72. package/src/browser/debug-schema-updater.ts +0 -67
  73. package/src/browser/debug-service.ts +0 -42
  74. package/src/browser/debug-session-connection.ts +0 -333
  75. package/src/browser/debug-session-contribution.ts +0 -57
  76. package/src/browser/debug-session-manager.ts +0 -622
  77. package/src/browser/debug-session.ts +0 -1179
  78. package/src/browser/debug-style.less +0 -128
  79. package/src/browser/debugUtils.ts +0 -110
  80. package/src/browser/editor/debug-breakpoint-widget.ts +0 -99
  81. package/src/browser/editor/debug-breakpoint-zone-widget.tsx +0 -262
  82. package/src/browser/editor/debug-breakpoint.module.less +0 -31
  83. package/src/browser/editor/debug-editor-contribution.ts +0 -590
  84. package/src/browser/editor/debug-expression-provider.ts +0 -101
  85. package/src/browser/editor/debug-hover-model.ts +0 -38
  86. package/src/browser/editor/debug-hover-source.ts +0 -107
  87. package/src/browser/editor/debug-hover-tree.model.service.ts +0 -332
  88. package/src/browser/editor/debug-hover-widget.tsx +0 -200
  89. package/src/browser/editor/debug-hover.module.less +0 -29
  90. package/src/browser/editor/debug-hover.view.tsx +0 -147
  91. package/src/browser/editor/debug-model-manager.ts +0 -220
  92. package/src/browser/editor/debug-model.ts +0 -853
  93. package/src/browser/editor/debug-run-to-cursor.service.ts +0 -180
  94. package/src/browser/editor/debug-styles.ts +0 -66
  95. package/src/browser/editor/evaluatable-expression.ts +0 -47
  96. package/src/browser/editor/index.ts +0 -6
  97. package/src/browser/index.ts +0 -121
  98. package/src/browser/markers/index.ts +0 -2
  99. package/src/browser/markers/marker-manager.ts +0 -201
  100. package/src/browser/markers/marker.ts +0 -20
  101. package/src/browser/model/debug-source.ts +0 -144
  102. package/src/browser/model/debug-stack-frame.ts +0 -111
  103. package/src/browser/model/debug-thread.ts +0 -186
  104. package/src/browser/model/debug-watch.ts +0 -130
  105. package/src/browser/model/index.ts +0 -4
  106. package/src/browser/preferences/launch-folder-preference-provider.ts +0 -23
  107. package/src/browser/preferences/launch-preferences-contribution.ts +0 -9
  108. package/src/browser/preferences/launch-preferences.ts +0 -16
  109. package/src/browser/tree/debug-console-tree-node.define.tsx +0 -76
  110. package/src/browser/tree/debug-tree-node.define.ts +0 -768
  111. package/src/browser/tree/index.ts +0 -2
  112. package/src/browser/view/breakpoints/debug-breakpoints.module.less +0 -72
  113. package/src/browser/view/breakpoints/debug-breakpoints.service.ts +0 -217
  114. package/src/browser/view/breakpoints/debug-breakpoints.view.tsx +0 -174
  115. package/src/browser/view/configuration/debug-configuration.module.less +0 -110
  116. package/src/browser/view/configuration/debug-configuration.service.ts +0 -170
  117. package/src/browser/view/configuration/debug-configuration.view.tsx +0 -252
  118. package/src/browser/view/configuration/debug-toolbar.service.ts +0 -167
  119. package/src/browser/view/configuration/debug-toolbar.view.tsx +0 -335
  120. package/src/browser/view/console/debug-console-filter.model.ts +0 -49
  121. package/src/browser/view/console/debug-console-filter.service.ts +0 -81
  122. package/src/browser/view/console/debug-console-filter.view.tsx +0 -78
  123. package/src/browser/view/console/debug-console-model.ts +0 -48
  124. package/src/browser/view/console/debug-console-session.ts +0 -164
  125. package/src/browser/view/console/debug-console-toolbar.view.tsx +0 -28
  126. package/src/browser/view/console/debug-console-tree.model.service.ts +0 -550
  127. package/src/browser/view/console/debug-console.contribution.ts +0 -181
  128. package/src/browser/view/console/debug-console.module.less +0 -373
  129. package/src/browser/view/console/debug-console.service.ts +0 -433
  130. package/src/browser/view/console/debug-console.view.tsx +0 -500
  131. package/src/browser/view/debug-view-model.ts +0 -182
  132. package/src/browser/view/frames/debug-call-stack-frame.view.tsx +0 -224
  133. package/src/browser/view/frames/debug-call-stack-session.view.tsx +0 -237
  134. package/src/browser/view/frames/debug-call-stack-thread.view.tsx +0 -93
  135. package/src/browser/view/frames/debug-call-stack.contribution.ts +0 -88
  136. package/src/browser/view/frames/debug-call-stack.module.less +0 -193
  137. package/src/browser/view/frames/debug-call-stack.operation.tsx +0 -97
  138. package/src/browser/view/frames/debug-call-stack.service.ts +0 -105
  139. package/src/browser/view/frames/debug-call-stack.view.tsx +0 -43
  140. package/src/browser/view/variables/debug-variables-model.ts +0 -38
  141. package/src/browser/view/variables/debug-variables-tree.model.service.ts +0 -467
  142. package/src/browser/view/variables/debug-variables.contribution.ts +0 -244
  143. package/src/browser/view/variables/debug-variables.module.less +0 -149
  144. package/src/browser/view/variables/debug-variables.view.tsx +0 -303
  145. package/src/browser/view/watch/debug-watch-model.ts +0 -38
  146. package/src/browser/view/watch/debug-watch-tree.model.service.ts +0 -567
  147. package/src/browser/view/watch/debug-watch.contribution.ts +0 -167
  148. package/src/browser/view/watch/debug-watch.module.less +0 -189
  149. package/src/browser/view/watch/debug-watch.view.tsx +0 -337
  150. package/src/common/constants.ts +0 -81
  151. package/src/common/debug-breakpoint.ts +0 -43
  152. package/src/common/debug-configuration.ts +0 -68
  153. package/src/common/debug-editor.ts +0 -4
  154. package/src/common/debug-hover.ts +0 -31
  155. package/src/common/debug-model.ts +0 -247
  156. package/src/common/debug-progress.ts +0 -8
  157. package/src/common/debug-schema-updater.ts +0 -1
  158. package/src/common/debug-service.ts +0 -176
  159. package/src/common/debug-session-options.ts +0 -19
  160. package/src/common/debug-session.ts +0 -200
  161. package/src/common/evaluatable-expression.ts +0 -43
  162. package/src/common/index.ts +0 -14
  163. package/src/common/inline-values.ts +0 -77
  164. package/src/common/terminal.ts +0 -163
  165. package/src/common/types.ts +0 -86
  166. package/src/index.ts +0 -1
@@ -1,768 +0,0 @@
1
- import { TreeNode, CompositeTreeNode, ITree, ITreeNodeOrCompositeTreeNode } from '@opensumi/ide-components';
2
- import { MessageType, localize } from '@opensumi/ide-core-browser';
3
- import { IRange, isDefined } from '@opensumi/ide-core-common';
4
- import { Range } from '@opensumi/monaco-editor-core/esm/vs/editor/common/core/range';
5
- import { DebugProtocol } from '@opensumi/vscode-debugprotocol/lib/debugProtocol';
6
-
7
- import { DebugSession } from '../debug-session';
8
-
9
- import { AnsiConsoleNode } from './debug-console-tree-node.define';
10
-
11
- const UNDEFINED_VALUE = 'undefined';
12
-
13
- export class ExpressionTreeService {
14
- constructor(private session?: DebugSession, private source?: DebugProtocol.Source, private line?: number | string) {}
15
-
16
- async resolveChildren(
17
- parent?: ExpressionContainer,
18
- ): Promise<(ExpressionContainer | ExpressionNode | DebugVirtualVariable)[]> {
19
- if (DebugVariableRoot.is(parent) && !parent.variablesReference && !parent.presetChildren) {
20
- return (await this.session?.getScopes(parent)) || [];
21
- }
22
- return await this.doResolve(parent);
23
- }
24
-
25
- protected async doResolve(
26
- parent?: ExpressionContainer,
27
- ): Promise<(ExpressionContainer | DebugVirtualVariable | ExpressionNode)[]> {
28
- const result: (ExpressionContainer | DebugVirtualVariable)[] = [];
29
- if (!parent) {
30
- return result;
31
- }
32
- if (Array.isArray(parent.presetChildren)) {
33
- return parent.presetChildren;
34
- }
35
- if (!this.session || this.session.terminated) {
36
- return result;
37
- }
38
- const { variablesReference, startOfVariables, indexedVariables } = parent;
39
- if (parent.namedVariables) {
40
- await this.fetch(result, variablesReference, 'named', parent);
41
- }
42
- if (indexedVariables) {
43
- let chunkSize = ExpressionContainer.BASE_CHUNK_SIZE;
44
- while (indexedVariables > chunkSize * ExpressionContainer.BASE_CHUNK_SIZE) {
45
- chunkSize *= ExpressionContainer.BASE_CHUNK_SIZE;
46
- }
47
- if (indexedVariables > chunkSize) {
48
- const numberOfChunks = Math.ceil(indexedVariables / chunkSize);
49
- for (let i = 0; i < numberOfChunks; i++) {
50
- const start = parent.startOfVariables + i * chunkSize;
51
- const count = Math.min(chunkSize, indexedVariables - i * chunkSize);
52
- result.push(
53
- new DebugVirtualVariable(
54
- {
55
- session: this.session,
56
- variablesReference: parent.variablesReference,
57
- namedVariables: 0,
58
- indexedVariables: count,
59
- startOfVariables: start,
60
- name: `[${start}..${start + count - 1}]`,
61
- },
62
- parent,
63
- ),
64
- );
65
- }
66
- return result;
67
- }
68
- }
69
- await this.fetch(result, variablesReference, 'indexed', parent, startOfVariables, indexedVariables);
70
- return result;
71
- }
72
-
73
- protected fetch(
74
- result: any,
75
- variablesReference: number,
76
- filter: 'named',
77
- parent?: ExpressionContainer,
78
- ): Promise<void>;
79
- protected fetch(
80
- result: any,
81
- variablesReference: number,
82
- filter: 'indexed',
83
- parent: ExpressionContainer,
84
- start: number,
85
- count?: number,
86
- ): Promise<void>;
87
- protected async fetch(
88
- result: any,
89
- variablesReference: number,
90
- filter: 'indexed' | 'named',
91
- parent?: ExpressionContainer,
92
- start?: number,
93
- count?: number,
94
- ): Promise<void> {
95
- try {
96
- const response = await this.session!.sendRequest('variables', { variablesReference, filter, start, count });
97
- const { variables } = response.body;
98
- for (const variable of variables) {
99
- if (variable.variablesReference) {
100
- result.push(new DebugVariableContainer(this.session, variable, parent, this.source, this.line));
101
- } else {
102
- result.push(new DebugVariable((this as any).session, variable, parent));
103
- }
104
- }
105
- } catch (e) {
106
- result.push({
107
- severity: MessageType.Error,
108
- visible: !!e.message,
109
- message: e.message,
110
- });
111
- }
112
- }
113
-
114
- sortComparator(a: ITreeNodeOrCompositeTreeNode, b: ITreeNodeOrCompositeTreeNode) {
115
- // 当存在 variablesReference 属性时,默认按大小进行排序
116
- if (isDefined((a as any).variablesReference) && isDefined((b as any).variablesReference)) {
117
- return (a as any).variablesReference - (b as any).variablesReference;
118
- }
119
- if (a.constructor === b.constructor) {
120
- return a.name > b.name ? 1 : a.name < b.name ? -1 : 0;
121
- }
122
- return CompositeTreeNode.is(a) ? 1 : CompositeTreeNode.is(b) ? -1 : 0;
123
- }
124
- }
125
-
126
- export class DebugConsoleTreeService extends ExpressionTreeService {
127
- // 按照默认次序排序
128
- sortComparator(a: ITreeNodeOrCompositeTreeNode, b: ITreeNodeOrCompositeTreeNode) {
129
- if (!a) {
130
- return 1;
131
- }
132
- if (!b) {
133
- return -1;
134
- }
135
- return 0;
136
- }
137
- }
138
-
139
- export class ExpressionNode extends TreeNode {
140
- public source: DebugProtocol.Source | undefined;
141
- public line: number | string | undefined;
142
- public variablesReference: number;
143
- public namedVariables: number | undefined;
144
- public indexedVariables: number | undefined;
145
- public memoryReference: string | undefined;
146
-
147
- constructor(options: ExpressionNode.Options, parent?: ExpressionContainer) {
148
- super(new ExpressionTreeService(options.session, options.source, options.line) as ITree, parent, undefined, {
149
- name: String(options.session?.id),
150
- });
151
- this.variablesReference = options.variablesReference || 0;
152
- this.namedVariables = options.namedVariables;
153
- this.indexedVariables = options.indexedVariables;
154
- this.memoryReference = options.memoryReference;
155
- this.source = options.source;
156
- this.line = options.line;
157
- }
158
-
159
- get badge() {
160
- return this.source ? `${this.source.name}:${this.line}` : '';
161
- }
162
-
163
- get displayName() {
164
- return this.name;
165
- }
166
- }
167
-
168
- export namespace ExpressionNode {
169
- export interface Options {
170
- session: DebugSession | undefined;
171
- variablesReference: number;
172
- namedVariables?: number;
173
- indexedVariables?: number;
174
- startOfVariables?: number;
175
- memoryReference?: string;
176
- source?: DebugProtocol.Source;
177
- line?: number | string;
178
- }
179
- }
180
-
181
- export class ExpressionContainer extends CompositeTreeNode {
182
- public static readonly BASE_CHUNK_SIZE = 100;
183
-
184
- protected readonly session: DebugSession | undefined;
185
- public variablesReference: number;
186
- public namedVariables: number | undefined;
187
- public indexedVariables: number | undefined;
188
- public startOfVariables: number;
189
- public memoryReference: string | undefined;
190
-
191
- public source: DebugProtocol.Source | undefined;
192
- public line: number | string | undefined;
193
-
194
- public presetChildren: (ExpressionContainer | ExpressionNode)[];
195
-
196
- constructor(options: ExpressionContainer.Options, parent?: ExpressionContainer, tree?: ITree, name?: string) {
197
- super(
198
- tree || (new ExpressionTreeService(options.session, options.source, options.line) as ITree),
199
- parent,
200
- undefined,
201
- { name: name || options.session?.id },
202
- );
203
- this.session = options.session;
204
- this.variablesReference = options.variablesReference || 0;
205
- this.namedVariables = options.namedVariables;
206
- this.indexedVariables = options.indexedVariables;
207
- this.startOfVariables = options.startOfVariables || 0;
208
- this.memoryReference = options.memoryReference;
209
- this.source = options.source;
210
- this.line = options.line;
211
- }
212
-
213
- get badge() {
214
- return this.source ? `${this.source.name}:${this.line}` : '';
215
- }
216
-
217
- get displayName() {
218
- return this.name;
219
- }
220
-
221
- get path(): string {
222
- /**
223
- * 默认实现中,path 是通过 name 进行组装
224
- * 而在调试场景中,为了保证每个节点的唯一性,需要为每个节点指定唯一的 path 值
225
- * 故这里使用 id 作为 path 值
226
- */
227
- return String(this.id);
228
- }
229
- }
230
-
231
- export namespace ExpressionContainer {
232
- export interface Options {
233
- session: DebugSession | undefined;
234
- variablesReference?: number;
235
- namedVariables?: number;
236
- indexedVariables?: number;
237
- startOfVariables?: number;
238
- memoryReference?: string;
239
- source?: DebugProtocol.Source;
240
- line?: number | string;
241
- }
242
- }
243
-
244
- export namespace DebugVirtualVariable {
245
- export interface Options extends ExpressionContainer.Options {
246
- name: string;
247
- }
248
- }
249
-
250
- /**
251
- * 临时的变量节点,如数组节点需要通过该节点插件成[0..100]
252
- */
253
- export class DebugVirtualVariable extends ExpressionContainer {
254
- private _name: string;
255
-
256
- constructor(options: DebugVirtualVariable.Options, parent?: ExpressionContainer) {
257
- super(options, parent, undefined, options.name);
258
- this._name = options.name;
259
- }
260
- }
261
-
262
- export class DebugVariable extends ExpressionNode {
263
- constructor(
264
- public readonly session: DebugSession | undefined,
265
- /**
266
- * https://code.visualstudio.com/updates/v1_49#_contributable-context-menu-for-variables-view
267
- */
268
- public readonly variable: DebugProtocol.Variable & { __vscodeVariableMenuContext?: string },
269
- parent?: ExpressionContainer,
270
- ) {
271
- super(
272
- {
273
- session,
274
- variablesReference: variable.variablesReference,
275
- namedVariables: variable.namedVariables,
276
- indexedVariables: variable.indexedVariables,
277
- memoryReference: variable.memoryReference,
278
- },
279
- parent,
280
- );
281
- }
282
-
283
- get variableMenuContext(): string {
284
- return this.variable.__vscodeVariableMenuContext || '';
285
- }
286
-
287
- toDebugProtocolObject(): DebugProtocol.Variable {
288
- return {
289
- name: this.name,
290
- variablesReference: this.variable.variablesReference || 0,
291
- value: this.value,
292
- evaluateName: this.evaluateName,
293
- memoryReference: this.memoryReference,
294
- };
295
- }
296
-
297
- get name(): string {
298
- if (this.variable) {
299
- if (this.variable.name) {
300
- return this.variable.name;
301
- } else if (this.variable.evaluateName) {
302
- const isSymbolExpression = /\["(.+)"]/.exec(this.variable.evaluateName);
303
- if (isSymbolExpression) {
304
- return isSymbolExpression[1];
305
- } else {
306
- const evaluateProps = this.variable.evaluateName.split('.');
307
- return evaluateProps[evaluateProps.length - 1];
308
- }
309
- }
310
- }
311
- return String(this.id);
312
- }
313
-
314
- get evaluateName(): string {
315
- return this.variable?.evaluateName || '';
316
- }
317
-
318
- get description(): string {
319
- return this.value || UNDEFINED_VALUE;
320
- }
321
-
322
- protected _value: string | undefined;
323
- get value(): string {
324
- return this._value || this.variable.value;
325
- }
326
-
327
- protected _type: string | undefined;
328
- get variableType(): string | undefined {
329
- return this._type || this.variable.type;
330
- }
331
-
332
- get supportSetVariable(): boolean {
333
- return !!this.session && !!this.session.capabilities.supportsSetVariable;
334
- }
335
-
336
- async setValue(value: string): Promise<void> {
337
- if (!this.session || this.session.terminated) {
338
- return;
339
- }
340
- const { name, parent } = this;
341
- const variablesReference = (parent as DebugScope).variablesReference;
342
- try {
343
- const response = await this.session.sendRequest('setVariable', { variablesReference, name, value });
344
- this._value = response.body.value;
345
- this._type = response.body.type;
346
- this.variablesReference = response.body.variablesReference || 0;
347
- this.namedVariables = response.body.namedVariables;
348
- this.indexedVariables = response.body.indexedVariables;
349
- } catch (error) {
350
- throw error;
351
- }
352
- }
353
-
354
- public getRawScope(): DebugProtocol.Scope | undefined {
355
- let parent = this.parent;
356
- while (parent !== undefined && !(parent instanceof DebugScope)) {
357
- parent = parent?.parent;
358
- }
359
- return parent!.getRawScope();
360
- }
361
- }
362
-
363
- export class DebugVariableContainer extends ExpressionContainer {
364
- static BOOLEAN_REGEX = /^true|false$/i;
365
- static STRING_REGEX = /^(['"]).*\1$/;
366
-
367
- constructor(
368
- public readonly session: DebugSession | undefined,
369
- public readonly variable: DebugProtocol.Variable & { __vscodeVariableMenuContext?: string },
370
- parent: ExpressionContainer | undefined,
371
- source?: DebugProtocol.Source,
372
- line?: string | number,
373
- ) {
374
- super(
375
- {
376
- session,
377
- variablesReference: variable.variablesReference,
378
- namedVariables: variable.namedVariables,
379
- indexedVariables: variable.indexedVariables,
380
- memoryReference: variable.memoryReference,
381
- source,
382
- line,
383
- },
384
- parent,
385
- undefined,
386
- variable?.name ||
387
- (variable.evaluateName
388
- ? /\["(.+)"]/.exec(variable.evaluateName)
389
- ? /\["(.+)"]/.exec(variable.evaluateName)![1]
390
- : variable.evaluateName.split('.')[variable.evaluateName.split('.').length - 1]
391
- : ''),
392
- );
393
- }
394
-
395
- get variableMenuContext(): string {
396
- return this.variable.__vscodeVariableMenuContext || '';
397
- }
398
-
399
- toDebugProtocolObject(): DebugProtocol.Variable {
400
- return {
401
- name: this.name,
402
- variablesReference: this.variable.variablesReference || 0,
403
- value: this.value,
404
- evaluateName: this.evaluateName,
405
- memoryReference: this.memoryReference,
406
- };
407
- }
408
-
409
- get name(): string {
410
- if (this.variable) {
411
- if (this.variable.name) {
412
- return this.variable.name;
413
- } else if (this.variable.evaluateName) {
414
- const isSymbolExpression = /\["(.+)"]/.exec(this.variable.evaluateName);
415
- if (isSymbolExpression) {
416
- return isSymbolExpression[1];
417
- } else {
418
- const evaluateProps = this.variable.evaluateName.split('.');
419
- return evaluateProps[evaluateProps.length - 1];
420
- }
421
- }
422
- }
423
- return String(this.id);
424
- }
425
-
426
- get evaluateName(): string {
427
- return this.variable?.evaluateName || '';
428
- }
429
-
430
- get description(): string {
431
- return this._value || this.variable.value || UNDEFINED_VALUE;
432
- }
433
-
434
- get tooltip(): string {
435
- return this.variableType || this.description;
436
- }
437
-
438
- protected _variableType: string | undefined;
439
- get variableType(): string | undefined {
440
- return this._variableType || this.variable.type;
441
- }
442
-
443
- protected _value: string | undefined;
444
- get value(): string {
445
- return this._value || this.variable.value;
446
- }
447
-
448
- get supportSetVariable(): boolean {
449
- return !!this.session && !!this.session.capabilities.supportsSetVariable;
450
- }
451
-
452
- async setValue(value: string): Promise<void> {
453
- if (!this.session || this.session.terminated) {
454
- return;
455
- }
456
- const { name, parent } = this;
457
- if (!parent) {
458
- return;
459
- }
460
- const variablesReference = (parent as DebugScope).variablesReference;
461
- try {
462
- const response = await this.session.sendRequest('setVariable', { variablesReference, name, value });
463
- this._value = response.body.value;
464
- this._variableType = response.body.type;
465
- this.variablesReference = response.body.variablesReference || 0;
466
- this.namedVariables = response.body.namedVariables;
467
- this.indexedVariables = response.body.indexedVariables;
468
- } catch (error) {
469
- throw error;
470
- }
471
- }
472
-
473
- public getRawScope(): DebugProtocol.Scope | undefined {
474
- let parent = this.parent;
475
- while (parent !== undefined && !(parent instanceof DebugScope)) {
476
- parent = parent?.parent;
477
- }
478
- return parent!.getRawScope();
479
- }
480
- }
481
-
482
- export class DebugScope extends ExpressionContainer {
483
- constructor(
484
- protected readonly raw: DebugProtocol.Scope,
485
- protected readonly session: DebugSession,
486
- parent?: ExpressionContainer,
487
- ) {
488
- super(
489
- {
490
- session,
491
- variablesReference: raw.variablesReference,
492
- namedVariables: raw.namedVariables,
493
- indexedVariables: raw.indexedVariables,
494
- },
495
- parent,
496
- undefined,
497
- raw.name,
498
- );
499
- }
500
-
501
- public getRawScope(): DebugProtocol.Scope {
502
- return this.raw;
503
- }
504
-
505
- public range(): IRange | undefined {
506
- const rs = this.getRawScope();
507
- return rs.line && rs.column && rs.endLine && rs.endColumn
508
- ? new Range(rs.line, rs.column, rs.endLine, rs.endColumn)
509
- : undefined;
510
- }
511
- }
512
-
513
- export class DebugWatchNode extends ExpressionContainer {
514
- static notAvailable = localize('debug.watch.notAvailable');
515
-
516
- static is(node?: any): node is DebugWatchNode {
517
- return !!node && !!(node as DebugWatchNode).expression;
518
- }
519
-
520
- private _description: string;
521
- private _available: boolean;
522
- private raw: DebugProtocol.EvaluateResponse['body'];
523
-
524
- constructor(
525
- public readonly session: DebugSession | undefined,
526
- public readonly expression: string,
527
- parent: ExpressionContainer | undefined,
528
- ) {
529
- super(
530
- {
531
- session,
532
- },
533
- parent,
534
- undefined,
535
- expression,
536
- );
537
- }
538
-
539
- get description() {
540
- return this._available ? this._description || UNDEFINED_VALUE : DebugWatchNode.notAvailable;
541
- }
542
-
543
- get available() {
544
- return this._available;
545
- }
546
-
547
- public getRawWatch(): DebugProtocol.EvaluateResponse['body'] {
548
- return this.raw;
549
- }
550
-
551
- async evaluate(context = 'watch'): Promise<void> {
552
- if (this.session) {
553
- try {
554
- this._available = true;
555
- const { expression } = this;
556
- const body = await this.session.evaluate(expression, context);
557
- if (body) {
558
- this.name = this.expression;
559
- this._description = body.result;
560
- this.variablesReference = body.variablesReference;
561
- this.namedVariables = body.namedVariables;
562
- this.indexedVariables = body.indexedVariables;
563
- this.memoryReference = body.memoryReference;
564
- this.raw = body;
565
- }
566
- } catch (err) {
567
- this.name = this.expression;
568
- this._description = err.message;
569
- }
570
- } else {
571
- this.name = this.expression;
572
- this._available = false;
573
- }
574
- }
575
-
576
- async getClipboardValue() {
577
- if (this.session && this.session.capabilities.supportsValueFormattingOptions) {
578
- try {
579
- const { expression } = this;
580
- const body = await this.session.evaluate(expression, 'clipboard');
581
- if (body) {
582
- return body.result;
583
- }
584
- } catch (err) {
585
- return '';
586
- }
587
- } else {
588
- return this._description;
589
- }
590
- }
591
- }
592
-
593
- export class DebugConsoleVariableContainer extends DebugVariableContainer {
594
- static is(node?: any): node is DebugConsoleVariableContainer {
595
- return !!node && (node as DebugConsoleVariableContainer).uniqueID === DebugConsoleVariableContainer.uniqueID;
596
- }
597
-
598
- static uniqueID = 'DebugConsoleVariable';
599
-
600
- get uniqueID() {
601
- return DebugConsoleVariableContainer.uniqueID;
602
- }
603
-
604
- get description() {
605
- if (this.variable) {
606
- return this.variable.value;
607
- }
608
- return UNDEFINED_VALUE;
609
- }
610
-
611
- get tooltip() {
612
- if (this.variable) {
613
- return this.variable.value;
614
- }
615
- return '';
616
- }
617
- }
618
-
619
- export class DebugConsoleNode extends ExpressionContainer {
620
- static is(node?: any): node is DebugConsoleNode {
621
- return !!node && !!(node as DebugConsoleNode).expression;
622
- }
623
-
624
- private _available: boolean;
625
- private _description: string;
626
-
627
- get available() {
628
- return this._available;
629
- }
630
-
631
- constructor(
632
- public readonly session: DebugSession | undefined,
633
- public readonly expression: string,
634
- parent: ExpressionContainer | undefined,
635
- ) {
636
- super(
637
- {
638
- session,
639
- },
640
- parent,
641
- undefined,
642
- expression,
643
- );
644
- }
645
-
646
- get description() {
647
- return this._description || UNDEFINED_VALUE;
648
- }
649
-
650
- async evaluate(context = 'repl'): Promise<void> {
651
- const { expression } = this;
652
- if (this.session) {
653
- try {
654
- if (typeof expression === 'string') {
655
- const body = await this.session.evaluate(expression, context);
656
- if (body) {
657
- this.name = expression;
658
- this._description = body.result;
659
- this.variablesReference = body.variablesReference;
660
- this.namedVariables = body.namedVariables;
661
- this.indexedVariables = body.indexedVariables;
662
- this.memoryReference = body.memoryReference;
663
- this._available = true;
664
- }
665
- }
666
- } catch (err) {
667
- this._available = false;
668
- this.name = expression;
669
- this._description = err.message;
670
- }
671
- } else {
672
- this._available = false;
673
- this.name = expression;
674
- }
675
- }
676
- }
677
-
678
- export class DebugConsoleRoot extends ExpressionContainer {
679
- static is(node?: ExpressionContainer): node is DebugConsoleRoot {
680
- return !!node && !node.parent;
681
- }
682
-
683
- constructor(public readonly session: DebugSession | undefined, presets: DebugConsoleNode[] = []) {
684
- super({ session }, undefined, new DebugConsoleTreeService(session) as ITree);
685
- this.presetChildren = presets;
686
- }
687
-
688
- get expanded() {
689
- return true;
690
- }
691
-
692
- updatePresetChildren(presets: (AnsiConsoleNode | DebugConsoleNode | DebugVariableContainer)[]) {
693
- this.presetChildren = presets as (ExpressionNode | ExpressionContainer)[];
694
- }
695
- }
696
-
697
- export class DebugWatchRoot extends ExpressionContainer {
698
- static is(node?: ExpressionContainer): node is DebugWatchRoot {
699
- return !!node && !node.parent;
700
- }
701
-
702
- constructor(public readonly session: DebugSession | undefined, presets: DebugWatchNode[] = []) {
703
- super({ session }, undefined);
704
- this.presetChildren = presets;
705
- }
706
-
707
- get expanded() {
708
- return true;
709
- }
710
-
711
- updatePresetChildren(presets: DebugWatchNode[]) {
712
- this.presetChildren = presets;
713
- }
714
- }
715
-
716
- export class DebugVariableRoot extends DebugVariableContainer {
717
- static is(node?: ExpressionContainer): node is DebugVariableRoot {
718
- return !!node && !node.parent;
719
- }
720
-
721
- constructor(public readonly session: DebugSession | undefined) {
722
- super(session, {} as any, undefined);
723
- }
724
-
725
- get expanded() {
726
- return true;
727
- }
728
- }
729
-
730
- export class DebugHoverVariableRoot extends ExpressionContainer {
731
- private _value = '';
732
-
733
- constructor(protected readonly expression: string, protected readonly session: DebugSession | undefined) {
734
- super({ session });
735
- }
736
-
737
- get name() {
738
- return this._value;
739
- }
740
-
741
- protected _available = false;
742
- get available(): boolean {
743
- return this._available;
744
- }
745
-
746
- async evaluate(context = 'repl'): Promise<void> {
747
- if (this.session) {
748
- try {
749
- const { expression } = this;
750
- const body = await this.session.evaluate(expression, context);
751
- if (body) {
752
- this._value = body.result;
753
- this._available = true;
754
- this.variablesReference = body.variablesReference;
755
- this.namedVariables = body.namedVariables;
756
- this.indexedVariables = body.indexedVariables;
757
- this.memoryReference = body.memoryReference;
758
- }
759
- } catch (err) {
760
- this._value = err.message;
761
- this._available = false;
762
- }
763
- } else {
764
- this._value = 'Please start a debug session to evaluate';
765
- this._available = false;
766
- }
767
- }
768
- }