@theia/debug 1.53.0-next.5 → 1.53.0-next.55

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 (88) hide show
  1. package/README.md +62 -62
  2. package/lib/browser/debug-configuration-manager.js +6 -6
  3. package/lib/browser/debug-frontend-application-contribution.d.ts.map +1 -1
  4. package/lib/browser/debug-frontend-application-contribution.js.map +1 -1
  5. package/lib/common/inline-debug-adapter.d.ts +1 -0
  6. package/lib/common/inline-debug-adapter.d.ts.map +1 -1
  7. package/package.json +16 -16
  8. package/src/browser/breakpoint/breakpoint-manager.ts +369 -369
  9. package/src/browser/breakpoint/breakpoint-marker.ts +104 -104
  10. package/src/browser/console/debug-console-contribution.tsx +240 -240
  11. package/src/browser/console/debug-console-items.tsx +384 -384
  12. package/src/browser/console/debug-console-session.ts +205 -205
  13. package/src/browser/debug-call-stack-item-type-key.ts +20 -20
  14. package/src/browser/debug-configuration-manager.ts +591 -591
  15. package/src/browser/debug-configuration-model.ts +100 -100
  16. package/src/browser/debug-contribution.ts +43 -43
  17. package/src/browser/debug-frontend-application-contribution.ts +1551 -1551
  18. package/src/browser/debug-frontend-module.ts +133 -133
  19. package/src/browser/debug-package.spec.ts +20 -20
  20. package/src/browser/debug-preferences.ts +98 -98
  21. package/src/browser/debug-prefix-configuration.ts +195 -195
  22. package/src/browser/debug-resource.ts +59 -59
  23. package/src/browser/debug-schema-updater.ts +149 -149
  24. package/src/browser/debug-session-connection.ts +357 -357
  25. package/src/browser/debug-session-contribution.ts +157 -157
  26. package/src/browser/debug-session-manager.ts +683 -683
  27. package/src/browser/debug-session-options.ts +120 -120
  28. package/src/browser/debug-session.tsx +974 -974
  29. package/src/browser/debug-tab-bar-decorator.ts +57 -57
  30. package/src/browser/debug-watch-manager.ts +93 -93
  31. package/src/browser/disassembly-view/disassembly-view-accessibility-provider.ts +43 -43
  32. package/src/browser/disassembly-view/disassembly-view-breakpoint-renderer.ts +119 -119
  33. package/src/browser/disassembly-view/disassembly-view-contribution.ts +109 -109
  34. package/src/browser/disassembly-view/disassembly-view-instruction-renderer.ts +245 -245
  35. package/src/browser/disassembly-view/disassembly-view-table-delegate.ts +39 -39
  36. package/src/browser/disassembly-view/disassembly-view-utilities.ts +55 -55
  37. package/src/browser/disassembly-view/disassembly-view-widget.ts +463 -463
  38. package/src/browser/editor/debug-breakpoint-widget.tsx +293 -293
  39. package/src/browser/editor/debug-editor-model.ts +529 -529
  40. package/src/browser/editor/debug-editor-service.ts +192 -192
  41. package/src/browser/editor/debug-editor.ts +20 -20
  42. package/src/browser/editor/debug-exception-widget.tsx +122 -122
  43. package/src/browser/editor/debug-expression-provider.ts +78 -78
  44. package/src/browser/editor/debug-hover-source.tsx +105 -105
  45. package/src/browser/editor/debug-hover-widget.ts +298 -298
  46. package/src/browser/editor/debug-inline-value-decorator.ts +373 -373
  47. package/src/browser/model/debug-breakpoint.tsx +151 -151
  48. package/src/browser/model/debug-function-breakpoint.tsx +101 -101
  49. package/src/browser/model/debug-instruction-breakpoint.tsx +68 -68
  50. package/src/browser/model/debug-source-breakpoint.tsx +237 -237
  51. package/src/browser/model/debug-source.ts +93 -93
  52. package/src/browser/model/debug-stack-frame.tsx +177 -177
  53. package/src/browser/model/debug-thread.tsx +292 -292
  54. package/src/browser/preferences/launch-preferences.ts +38 -38
  55. package/src/browser/style/index.css +453 -453
  56. package/src/browser/view/debug-action.tsx +57 -57
  57. package/src/browser/view/debug-breakpoints-source.tsx +53 -53
  58. package/src/browser/view/debug-breakpoints-widget.ts +71 -71
  59. package/src/browser/view/debug-configuration-select.tsx +269 -269
  60. package/src/browser/view/debug-configuration-widget.tsx +121 -121
  61. package/src/browser/view/debug-exception-breakpoint.tsx +68 -68
  62. package/src/browser/view/debug-session-widget.ts +124 -124
  63. package/src/browser/view/debug-stack-frames-source.tsx +75 -75
  64. package/src/browser/view/debug-stack-frames-widget.ts +135 -135
  65. package/src/browser/view/debug-threads-source.tsx +48 -48
  66. package/src/browser/view/debug-threads-widget.ts +126 -126
  67. package/src/browser/view/debug-toolbar-widget.tsx +145 -145
  68. package/src/browser/view/debug-variables-source.ts +43 -43
  69. package/src/browser/view/debug-variables-widget.ts +61 -61
  70. package/src/browser/view/debug-view-model.ts +230 -230
  71. package/src/browser/view/debug-watch-expression.tsx +88 -88
  72. package/src/browser/view/debug-watch-source.ts +41 -41
  73. package/src/browser/view/debug-watch-widget.ts +61 -61
  74. package/src/browser/view/debug-widget.ts +97 -97
  75. package/src/common/debug-adapter-contribution-registry.ts +206 -206
  76. package/src/common/debug-adapter-session.ts +102 -102
  77. package/src/common/debug-common.ts +19 -19
  78. package/src/common/debug-compound.ts +33 -33
  79. package/src/common/debug-configuration.ts +112 -112
  80. package/src/common/debug-model.ts +200 -200
  81. package/src/common/debug-service.ts +184 -184
  82. package/src/common/debug-uri-utils.ts +24 -24
  83. package/src/common/inline-debug-adapter.ts +47 -47
  84. package/src/node/debug-adapter-factory.ts +107 -107
  85. package/src/node/debug-adapter-session-manager.ts +106 -106
  86. package/src/node/debug-backend-module.ts +57 -57
  87. package/src/node/debug-service-impl.ts +119 -119
  88. package/src/node/stream-debug-adapter.ts +126 -126
@@ -1,1551 +1,1551 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 TypeFox 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-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import {
18
- AbstractViewContribution, KeybindingRegistry, Widget, CompositeTreeNode, LabelProvider, codicon, OnWillStopAction, FrontendApplicationContribution, ConfirmDialog, Dialog
19
- } from '@theia/core/lib/browser';
20
- import { injectable, inject } from '@theia/core/shared/inversify';
21
- import * as monaco from '@theia/monaco-editor-core';
22
- import { MenuModelRegistry, CommandRegistry, MAIN_MENU_BAR, Command, Emitter, Mutable, CompoundMenuNodeRole } from '@theia/core/lib/common';
23
- import { EDITOR_LINENUMBER_CONTEXT_MENU, EditorManager } from '@theia/editor/lib/browser';
24
- import { DebugSessionManager } from './debug-session-manager';
25
- import { DebugWidget } from './view/debug-widget';
26
- import { FunctionBreakpoint } from './breakpoint/breakpoint-marker';
27
- import { BreakpointManager } from './breakpoint/breakpoint-manager';
28
- import { DebugConfigurationManager } from './debug-configuration-manager';
29
- import { DebugState, DebugSession } from './debug-session';
30
- import { DebugBreakpointsWidget } from './view/debug-breakpoints-widget';
31
- import { DebugSourceBreakpoint } from './model/debug-source-breakpoint';
32
- import { DebugThreadsWidget } from './view/debug-threads-widget';
33
- import { DebugThread } from './model/debug-thread';
34
- import { DebugStackFramesWidget } from './view/debug-stack-frames-widget';
35
- import { DebugStackFrame } from './model/debug-stack-frame';
36
- import { DebugVariablesWidget } from './view/debug-variables-widget';
37
- import { DebugVariable } from './console/debug-console-items';
38
- import { DebugSessionWidget } from './view/debug-session-widget';
39
- import { DebugEditorModel } from './editor/debug-editor-model';
40
- import { DebugEditorService } from './editor/debug-editor-service';
41
- import { DebugConsoleContribution } from './console/debug-console-contribution';
42
- import { DebugService } from '../common/debug-service';
43
- import { DebugSchemaUpdater } from './debug-schema-updater';
44
- import { DebugPreferences } from './debug-preferences';
45
- import { TabBarToolbarContribution, TabBarToolbarRegistry, TabBarToolbarItem } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
46
- import { DebugWatchWidget } from './view/debug-watch-widget';
47
- import { DebugWatchExpression } from './view/debug-watch-expression';
48
- import { DebugWatchManager } from './debug-watch-manager';
49
- import { DebugSessionOptions } from './debug-session-options';
50
- import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
51
- import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
52
- import { DebugFunctionBreakpoint } from './model/debug-function-breakpoint';
53
- import { DebugBreakpoint } from './model/debug-breakpoint';
54
- import { nls } from '@theia/core/lib/common/nls';
55
- import { DebugInstructionBreakpoint } from './model/debug-instruction-breakpoint';
56
- import { DebugConfiguration } from '../common/debug-configuration';
57
- import { DebugExceptionBreakpoint } from './view/debug-exception-breakpoint';
58
-
59
- export namespace DebugMenus {
60
- export const DEBUG = [...MAIN_MENU_BAR, '6_debug'];
61
- export const DEBUG_CONTROLS = [...DEBUG, 'a_controls'];
62
- export const DEBUG_CONFIGURATION = [...DEBUG, 'b_configuration'];
63
- export const DEBUG_THREADS = [...DEBUG, 'c_threads'];
64
- export const DEBUG_SESSIONS = [...DEBUG, 'd_sessions'];
65
- export const DEBUG_BREAKPOINT = [...DEBUG, 'e_breakpoint'];
66
- export const DEBUG_NEW_BREAKPOINT = [...DEBUG_BREAKPOINT, 'a_new_breakpoint'];
67
- export const DEBUG_BREAKPOINTS = [...DEBUG, 'f_breakpoints'];
68
- }
69
-
70
- function nlsEditBreakpoint(breakpoint: string): string {
71
- return nls.localizeByDefault('Edit {0}...', nls.localizeByDefault(breakpoint));
72
- }
73
-
74
- function nlsRemoveBreakpoint(breakpoint: string): string {
75
- return nls.localizeByDefault('Remove {0}', nls.localizeByDefault(breakpoint));
76
- }
77
-
78
- function nlsEnableBreakpoint(breakpoint: string): string {
79
- return nls.localizeByDefault('Enable {0}', nls.localizeByDefault(breakpoint));
80
- }
81
-
82
- function nlsDisableBreakpoint(breakpoint: string): string {
83
- return nls.localizeByDefault('Disable {0}', nls.localizeByDefault(breakpoint));
84
- }
85
-
86
- export namespace DebugCommands {
87
-
88
- export const DEBUG_CATEGORY = 'Debug';
89
- export const DEBUG_CATEGORY_KEY = nls.getDefaultKey(DEBUG_CATEGORY);
90
-
91
- export const START = Command.toDefaultLocalizedCommand({
92
- id: 'workbench.action.debug.start',
93
- category: DEBUG_CATEGORY,
94
- label: 'Start Debugging',
95
- iconClass: codicon('debug-alt')
96
- });
97
- export const START_NO_DEBUG = Command.toDefaultLocalizedCommand({
98
- id: 'workbench.action.debug.run',
99
- category: DEBUG_CATEGORY,
100
- label: 'Start Without Debugging'
101
- });
102
- export const STOP = Command.toDefaultLocalizedCommand({
103
- id: 'workbench.action.debug.stop',
104
- category: DEBUG_CATEGORY,
105
- label: 'Stop',
106
- iconClass: codicon('debug-stop')
107
- });
108
- export const RESTART = Command.toDefaultLocalizedCommand({
109
- id: 'workbench.action.debug.restart',
110
- category: DEBUG_CATEGORY,
111
- label: 'Restart',
112
- });
113
-
114
- export const OPEN_CONFIGURATIONS = Command.toDefaultLocalizedCommand({
115
- id: 'debug.configurations.open',
116
- category: DEBUG_CATEGORY,
117
- label: 'Open Configurations'
118
- });
119
- export const ADD_CONFIGURATION = Command.toDefaultLocalizedCommand({
120
- id: 'debug.configurations.add',
121
- category: DEBUG_CATEGORY,
122
- label: 'Add Configuration...'
123
- });
124
-
125
- export const STEP_OVER = Command.toDefaultLocalizedCommand({
126
- id: 'workbench.action.debug.stepOver',
127
- category: DEBUG_CATEGORY,
128
- label: 'Step Over',
129
- iconClass: codicon('debug-step-over')
130
- });
131
- export const STEP_INTO = Command.toDefaultLocalizedCommand({
132
- id: 'workbench.action.debug.stepInto',
133
- category: DEBUG_CATEGORY,
134
- label: 'Step Into',
135
- iconClass: codicon('debug-step-into')
136
- });
137
- export const STEP_OUT = Command.toDefaultLocalizedCommand({
138
- id: 'workbench.action.debug.stepOut',
139
- category: DEBUG_CATEGORY,
140
- label: 'Step Out',
141
- iconClass: codicon('debug-step-out')
142
- });
143
- export const CONTINUE = Command.toDefaultLocalizedCommand({
144
- id: 'workbench.action.debug.continue',
145
- category: DEBUG_CATEGORY,
146
- label: 'Continue',
147
- iconClass: codicon('debug-continue')
148
- });
149
- export const PAUSE = Command.toDefaultLocalizedCommand({
150
- id: 'workbench.action.debug.pause',
151
- category: DEBUG_CATEGORY,
152
- label: 'Pause',
153
- iconClass: codicon('debug-pause')
154
- });
155
- export const CONTINUE_ALL = Command.toLocalizedCommand({
156
- id: 'debug.thread.continue.all',
157
- category: DEBUG_CATEGORY,
158
- label: 'Continue All',
159
- iconClass: codicon('debug-continue')
160
- }, 'theia/debug/continueAll', DEBUG_CATEGORY_KEY);
161
- export const PAUSE_ALL = Command.toLocalizedCommand({
162
- id: 'debug.thread.pause.all',
163
- category: DEBUG_CATEGORY,
164
- label: 'Pause All',
165
- iconClass: codicon('debug-pause')
166
- }, 'theia/debug/pauseAll', DEBUG_CATEGORY_KEY);
167
-
168
- export const TOGGLE_BREAKPOINT = Command.toDefaultLocalizedCommand({
169
- id: 'editor.debug.action.toggleBreakpoint',
170
- category: DEBUG_CATEGORY,
171
- label: 'Toggle Breakpoint',
172
- });
173
- export const INLINE_BREAKPOINT = Command.toDefaultLocalizedCommand({
174
- id: 'editor.debug.action.inlineBreakpoint',
175
- category: DEBUG_CATEGORY,
176
- label: 'Inline Breakpoint',
177
- });
178
- export const ADD_CONDITIONAL_BREAKPOINT = Command.toDefaultLocalizedCommand({
179
- id: 'debug.breakpoint.add.conditional',
180
- category: DEBUG_CATEGORY,
181
- label: 'Add Conditional Breakpoint...',
182
- });
183
- export const ADD_LOGPOINT = Command.toDefaultLocalizedCommand({
184
- id: 'debug.breakpoint.add.logpoint',
185
- category: DEBUG_CATEGORY,
186
- label: 'Add Logpoint...',
187
- });
188
- export const ADD_FUNCTION_BREAKPOINT = Command.toDefaultLocalizedCommand({
189
- id: 'debug.breakpoint.add.function',
190
- category: DEBUG_CATEGORY,
191
- label: 'Add Function Breakpoint',
192
- });
193
- export const ENABLE_ALL_BREAKPOINTS = Command.toDefaultLocalizedCommand({
194
- id: 'debug.breakpoint.enableAll',
195
- category: DEBUG_CATEGORY,
196
- label: 'Enable All Breakpoints',
197
- });
198
- export const DISABLE_ALL_BREAKPOINTS = Command.toDefaultLocalizedCommand({
199
- id: 'debug.breakpoint.disableAll',
200
- category: DEBUG_CATEGORY,
201
- label: 'Disable All Breakpoints',
202
- });
203
- export const EDIT_BREAKPOINT = Command.toLocalizedCommand({
204
- id: 'debug.breakpoint.edit',
205
- category: DEBUG_CATEGORY,
206
- originalLabel: 'Edit Breakpoint...',
207
- label: nlsEditBreakpoint('Breakpoint')
208
- }, '', DEBUG_CATEGORY_KEY);
209
- export const EDIT_LOGPOINT = Command.toLocalizedCommand({
210
- id: 'debug.logpoint.edit',
211
- category: DEBUG_CATEGORY,
212
- originalLabel: 'Edit Logpoint...',
213
- label: nlsEditBreakpoint('Logpoint')
214
- }, '', DEBUG_CATEGORY_KEY);
215
- export const EDIT_BREAKPOINT_CONDITION = Command.toLocalizedCommand({
216
- id: 'debug.breakpoint.editCondition',
217
- category: DEBUG_CATEGORY,
218
- label: 'Edit Condition...'
219
- }, '', DEBUG_CATEGORY_KEY);
220
- export const REMOVE_BREAKPOINT = Command.toLocalizedCommand({
221
- id: 'debug.breakpoint.remove',
222
- category: DEBUG_CATEGORY,
223
- originalLabel: 'Remove Breakpoint',
224
- label: nlsRemoveBreakpoint('Breakpoint')
225
- }, '', DEBUG_CATEGORY_KEY);
226
- export const REMOVE_LOGPOINT = Command.toLocalizedCommand({
227
- id: 'debug.logpoint.remove',
228
- category: DEBUG_CATEGORY,
229
- originalLabel: 'Remove Logpoint',
230
- label: nlsRemoveBreakpoint('Logpoint')
231
- }, '', DEBUG_CATEGORY_KEY);
232
- export const REMOVE_ALL_BREAKPOINTS = Command.toDefaultLocalizedCommand({
233
- id: 'debug.breakpoint.removeAll',
234
- category: DEBUG_CATEGORY,
235
- label: 'Remove All Breakpoints',
236
- });
237
- export const TOGGLE_BREAKPOINTS_ENABLED = Command.toLocalizedCommand({
238
- id: 'debug.breakpoint.toggleEnabled'
239
- });
240
- export const SHOW_HOVER = Command.toDefaultLocalizedCommand({
241
- id: 'editor.debug.action.showDebugHover',
242
- label: 'Debug: Show Hover'
243
- });
244
-
245
- export const RESTART_FRAME = Command.toDefaultLocalizedCommand({
246
- id: 'debug.frame.restart',
247
- category: DEBUG_CATEGORY,
248
- label: 'Restart Frame',
249
- });
250
- export const COPY_CALL_STACK = Command.toDefaultLocalizedCommand({
251
- id: 'debug.callStack.copy',
252
- category: DEBUG_CATEGORY,
253
- label: 'Copy Call Stack',
254
- });
255
-
256
- export const SET_VARIABLE_VALUE = Command.toDefaultLocalizedCommand({
257
- id: 'debug.variable.setValue',
258
- category: DEBUG_CATEGORY,
259
- label: 'Set Value',
260
- });
261
- export const COPY_VARIABLE_VALUE = Command.toDefaultLocalizedCommand({
262
- id: 'debug.variable.copyValue',
263
- category: DEBUG_CATEGORY,
264
- label: 'Copy Value',
265
- });
266
- export const COPY_VARIABLE_AS_EXPRESSION = Command.toDefaultLocalizedCommand({
267
- id: 'debug.variable.copyAsExpression',
268
- category: DEBUG_CATEGORY,
269
- label: 'Copy as Expression',
270
- });
271
- export const WATCH_VARIABLE = Command.toDefaultLocalizedCommand({
272
- id: 'debug.variable.watch',
273
- category: DEBUG_CATEGORY,
274
- label: 'Add to Watch',
275
- });
276
-
277
- export const ADD_WATCH_EXPRESSION = Command.toDefaultLocalizedCommand({
278
- id: 'debug.watch.addExpression',
279
- category: DEBUG_CATEGORY,
280
- label: 'Add Expression'
281
- });
282
- export const EDIT_WATCH_EXPRESSION = Command.toDefaultLocalizedCommand({
283
- id: 'debug.watch.editExpression',
284
- category: DEBUG_CATEGORY,
285
- label: 'Edit Expression'
286
- });
287
- export const COPY_WATCH_EXPRESSION_VALUE = Command.toLocalizedCommand({
288
- id: 'debug.watch.copyExpressionValue',
289
- category: DEBUG_CATEGORY,
290
- label: 'Copy Expression Value'
291
- }, 'theia/debug/copyExpressionValue', DEBUG_CATEGORY_KEY);
292
- export const REMOVE_WATCH_EXPRESSION = Command.toDefaultLocalizedCommand({
293
- id: 'debug.watch.removeExpression',
294
- category: DEBUG_CATEGORY,
295
- label: 'Remove Expression'
296
- });
297
- export const COLLAPSE_ALL_WATCH_EXPRESSIONS = Command.toDefaultLocalizedCommand({
298
- id: 'debug.watch.collapseAllExpressions',
299
- category: DEBUG_CATEGORY,
300
- label: 'Collapse All'
301
- });
302
- export const REMOVE_ALL_WATCH_EXPRESSIONS = Command.toDefaultLocalizedCommand({
303
- id: 'debug.watch.removeAllExpressions',
304
- category: DEBUG_CATEGORY,
305
- label: 'Remove All Expressions'
306
- });
307
- }
308
- export namespace DebugThreadContextCommands {
309
- export const STEP_OVER = {
310
- id: 'debug.thread.context.context.next'
311
- };
312
- export const STEP_INTO = {
313
- id: 'debug.thread.context.stepin'
314
- };
315
- export const STEP_OUT = {
316
- id: 'debug.thread.context.stepout'
317
- };
318
- export const CONTINUE = {
319
- id: 'debug.thread.context.continue'
320
- };
321
- export const PAUSE = {
322
- id: 'debug.thread.context.pause'
323
- };
324
- export const TERMINATE = {
325
- id: 'debug.thread.context.terminate'
326
- };
327
- }
328
- export namespace DebugSessionContextCommands {
329
- export const STOP = {
330
- id: 'debug.session.context.stop'
331
- };
332
- export const RESTART = {
333
- id: 'debug.session.context.restart'
334
- };
335
- export const PAUSE_ALL = {
336
- id: 'debug.session.context.pauseAll'
337
- };
338
- export const CONTINUE_ALL = {
339
- id: 'debug.session.context.continueAll'
340
- };
341
- export const REVEAL = {
342
- id: 'debug.session.context.reveal'
343
- };
344
- }
345
- export namespace DebugEditorContextCommands {
346
- export const ADD_BREAKPOINT = {
347
- id: 'debug.editor.context.addBreakpoint'
348
- };
349
- export const ADD_CONDITIONAL_BREAKPOINT = {
350
- id: 'debug.editor.context.addBreakpoint.conditional'
351
- };
352
- export const ADD_LOGPOINT = {
353
- id: 'debug.editor.context.add.logpoint'
354
- };
355
- export const REMOVE_BREAKPOINT = {
356
- id: 'debug.editor.context.removeBreakpoint'
357
- };
358
- export const EDIT_BREAKPOINT = {
359
- id: 'debug.editor.context.edit.breakpoint'
360
- };
361
- export const ENABLE_BREAKPOINT = {
362
- id: 'debug.editor.context.enableBreakpoint'
363
- };
364
- export const DISABLE_BREAKPOINT = {
365
- id: 'debug.editor.context.disableBreakpoint'
366
- };
367
- export const REMOVE_LOGPOINT = {
368
- id: 'debug.editor.context.logpoint.remove'
369
- };
370
- export const EDIT_LOGPOINT = {
371
- id: 'debug.editor.context.logpoint.edit'
372
- };
373
- export const ENABLE_LOGPOINT = {
374
- id: 'debug.editor.context.logpoint.enable'
375
- };
376
- export const DISABLE_LOGPOINT = {
377
- id: 'debug.editor.context.logpoint.disable'
378
- };
379
- }
380
- export namespace DebugBreakpointWidgetCommands {
381
- export const ACCEPT = {
382
- id: 'debug.breakpointWidget.accept'
383
- };
384
- export const CLOSE = {
385
- id: 'debug.breakpointWidget.close'
386
- };
387
- }
388
-
389
- @injectable()
390
- export class DebugFrontendApplicationContribution extends AbstractViewContribution<DebugWidget>
391
- implements TabBarToolbarContribution, ColorContribution, FrontendApplicationContribution {
392
-
393
- @inject(DebugService)
394
- protected readonly debug: DebugService;
395
-
396
- @inject(DebugSessionManager)
397
- protected readonly manager: DebugSessionManager;
398
-
399
- @inject(DebugConfigurationManager)
400
- protected readonly configurations: DebugConfigurationManager;
401
-
402
- @inject(BreakpointManager)
403
- protected readonly breakpointManager: BreakpointManager;
404
-
405
- @inject(DebugEditorService)
406
- protected readonly editors: DebugEditorService;
407
-
408
- @inject(DebugConsoleContribution)
409
- protected readonly console: DebugConsoleContribution;
410
-
411
- @inject(DebugSchemaUpdater)
412
- protected readonly schemaUpdater: DebugSchemaUpdater;
413
-
414
- @inject(DebugPreferences)
415
- protected readonly preference: DebugPreferences;
416
-
417
- @inject(DebugWatchManager)
418
- protected readonly watchManager: DebugWatchManager;
419
-
420
- @inject(LabelProvider)
421
- protected readonly labelProvider: LabelProvider;
422
-
423
- @inject(EditorManager)
424
- protected readonly editorManager: EditorManager;
425
-
426
- constructor() {
427
- super({
428
- widgetId: DebugWidget.ID,
429
- widgetName: DebugWidget.LABEL,
430
- defaultWidgetOptions: {
431
- area: 'left',
432
- rank: 400
433
- },
434
- toggleCommandId: 'debug:toggle',
435
- toggleKeybinding: 'ctrlcmd+shift+d'
436
- });
437
- }
438
-
439
- async initializeLayout(): Promise<void> {
440
- await this.openView();
441
- }
442
-
443
- protected firstSessionStart = true;
444
- async onStart(): Promise<void> {
445
- this.manager.onDidCreateDebugSession(session => this.openSession(session, { reveal: false }));
446
- this.manager.onDidStartDebugSession(session => {
447
- const { noDebug } = session.configuration;
448
- const openDebug = session.configuration.openDebug || this.preference['debug.openDebug'];
449
- const internalConsoleOptions = session.configuration.internalConsoleOptions || this.preference['debug.internalConsoleOptions'];
450
- if (internalConsoleOptions === 'openOnSessionStart' ||
451
- (internalConsoleOptions === 'openOnFirstSessionStart' && this.firstSessionStart)) {
452
- this.console.openView({
453
- reveal: true,
454
- activate: false,
455
- });
456
- }
457
- const shouldOpenDebug = openDebug === 'openOnSessionStart' || (openDebug === 'openOnFirstSessionStart' && this.firstSessionStart);
458
- // Do not open debug view when suppressed via configuration
459
- if (!noDebug && !this.getOption(session, 'suppressDebugView') && shouldOpenDebug) {
460
- this.openSession(session);
461
- }
462
- this.firstSessionStart = false;
463
- });
464
- this.manager.onDidStopDebugSession(session => {
465
- const { openDebug } = session.configuration;
466
- if (!this.getOption(session, 'suppressDebugView') && openDebug === 'openOnDebugBreak') {
467
- this.openSession(session);
468
- }
469
- });
470
-
471
- this.updateStatusBar();
472
- this.manager.onDidChange(() => this.updateStatusBar());
473
-
474
- this.schemaUpdater.update();
475
- this.configurations.load();
476
- this.breakpointManager.load();
477
- this.watchManager.load();
478
- }
479
-
480
- onStop(): void {
481
- this.configurations.save();
482
- this.breakpointManager.save();
483
- this.watchManager.save();
484
- }
485
-
486
- onWillStop(): OnWillStopAction | undefined {
487
- if (this.preference['debug.confirmOnExit'] === 'always' && this.manager.currentSession) {
488
- return {
489
- reason: 'active-debug-sessions',
490
- action: async () => {
491
- if (this.manager.currentSession) {
492
- const msg = this.manager.sessions.length === 1
493
- ? nls.localizeByDefault('There is an active debug session, are you sure you want to stop it?')
494
- : nls.localizeByDefault('There are active debug sessions, are you sure you want to stop them?');
495
- const safeToExit = await new ConfirmDialog({
496
- title: '',
497
- msg,
498
- ok: nls.localizeByDefault('Stop Debugging'),
499
- cancel: Dialog.CANCEL,
500
- }).open();
501
- return safeToExit === true;
502
- }
503
- return true;
504
- },
505
- };
506
- }
507
- }
508
-
509
- override registerMenus(menus: MenuModelRegistry): void {
510
- super.registerMenus(menus);
511
- const registerMenuActions = (menuPath: string[], ...commands: Command[]) => {
512
- for (const [index, command] of commands.entries()) {
513
- const label = command.label;
514
- const debug = `${DebugCommands.DEBUG_CATEGORY}:`;
515
- menus.registerMenuAction(menuPath, {
516
- commandId: command.id,
517
- label: label && label.startsWith(debug) && label.slice(debug.length).trimStart() || label,
518
- icon: command.iconClass,
519
- order: String.fromCharCode('a'.charCodeAt(0) + index)
520
- });
521
- }
522
- };
523
-
524
- menus.registerSubmenu(DebugMenus.DEBUG, nls.localizeByDefault('Run'));
525
- registerMenuActions(DebugMenus.DEBUG_CONTROLS,
526
- DebugCommands.START,
527
- DebugCommands.START_NO_DEBUG,
528
- DebugCommands.STOP,
529
- DebugCommands.RESTART
530
- );
531
- registerMenuActions(DebugMenus.DEBUG_CONFIGURATION,
532
- DebugCommands.OPEN_CONFIGURATIONS,
533
- DebugCommands.ADD_CONFIGURATION
534
- );
535
- registerMenuActions(DebugMenus.DEBUG_THREADS,
536
- DebugCommands.CONTINUE,
537
- DebugCommands.STEP_OVER,
538
- DebugCommands.STEP_INTO,
539
- DebugCommands.STEP_OUT,
540
- DebugCommands.PAUSE
541
- );
542
- registerMenuActions(DebugMenus.DEBUG_SESSIONS,
543
- DebugCommands.CONTINUE_ALL,
544
- DebugCommands.PAUSE_ALL
545
- );
546
- registerMenuActions(DebugMenus.DEBUG_BREAKPOINT,
547
- DebugCommands.TOGGLE_BREAKPOINT
548
- );
549
- menus.registerSubmenu(DebugMenus.DEBUG_NEW_BREAKPOINT, nls.localizeByDefault('New Breakpoint'));
550
- registerMenuActions(DebugMenus.DEBUG_NEW_BREAKPOINT,
551
- DebugCommands.ADD_CONDITIONAL_BREAKPOINT,
552
- DebugCommands.INLINE_BREAKPOINT,
553
- DebugCommands.ADD_FUNCTION_BREAKPOINT,
554
- DebugCommands.ADD_LOGPOINT,
555
- );
556
- registerMenuActions(DebugMenus.DEBUG_BREAKPOINTS,
557
- DebugCommands.ENABLE_ALL_BREAKPOINTS,
558
- DebugCommands.DISABLE_ALL_BREAKPOINTS,
559
- DebugCommands.REMOVE_ALL_BREAKPOINTS
560
- );
561
-
562
- registerMenuActions(DebugThreadsWidget.CONTROL_MENU,
563
- { ...DebugCommands.PAUSE, ...DebugThreadContextCommands.PAUSE },
564
- { ...DebugCommands.CONTINUE, ...DebugThreadContextCommands.CONTINUE },
565
- { ...DebugCommands.STEP_OVER, ...DebugThreadContextCommands.STEP_OVER },
566
- { ...DebugCommands.STEP_INTO, ...DebugThreadContextCommands.STEP_INTO },
567
- { ...DebugCommands.STEP_OUT, ...DebugThreadContextCommands.STEP_OUT },
568
- { ...DebugCommands.PAUSE_ALL, ...DebugSessionContextCommands.PAUSE_ALL },
569
- { ...DebugCommands.CONTINUE_ALL, ...DebugSessionContextCommands.CONTINUE_ALL }
570
- );
571
- registerMenuActions(DebugThreadsWidget.TERMINATE_MENU,
572
- { ...DebugCommands.RESTART, ...DebugSessionContextCommands.RESTART },
573
- { ...DebugCommands.STOP, ...DebugSessionContextCommands.STOP },
574
- { ...DebugThreadContextCommands.TERMINATE, label: nls.localizeByDefault('Terminate Thread') }
575
- );
576
- registerMenuActions(DebugThreadsWidget.OPEN_MENU, { ...DebugSessionContextCommands.REVEAL, label: nls.localize('theia/debug/reveal', 'Reveal') });
577
-
578
- registerMenuActions(DebugStackFramesWidget.CONTEXT_MENU,
579
- DebugCommands.RESTART_FRAME,
580
- DebugCommands.COPY_CALL_STACK
581
- );
582
-
583
- registerMenuActions(DebugVariablesWidget.EDIT_MENU,
584
- DebugCommands.SET_VARIABLE_VALUE,
585
- DebugCommands.COPY_VARIABLE_VALUE,
586
- DebugCommands.COPY_VARIABLE_AS_EXPRESSION
587
- );
588
- registerMenuActions(DebugVariablesWidget.WATCH_MENU,
589
- DebugCommands.WATCH_VARIABLE
590
- );
591
-
592
- registerMenuActions(DebugWatchWidget.EDIT_MENU,
593
- DebugCommands.EDIT_WATCH_EXPRESSION,
594
- DebugCommands.COPY_WATCH_EXPRESSION_VALUE
595
- );
596
- registerMenuActions(DebugWatchWidget.REMOVE_MENU,
597
- DebugCommands.REMOVE_WATCH_EXPRESSION,
598
- DebugCommands.REMOVE_ALL_WATCH_EXPRESSIONS
599
- );
600
-
601
- registerMenuActions(DebugBreakpointsWidget.EDIT_MENU,
602
- DebugCommands.EDIT_BREAKPOINT,
603
- DebugCommands.EDIT_LOGPOINT,
604
- DebugCommands.EDIT_BREAKPOINT_CONDITION
605
- );
606
- registerMenuActions(DebugBreakpointsWidget.REMOVE_MENU,
607
- DebugCommands.REMOVE_BREAKPOINT,
608
- DebugCommands.REMOVE_LOGPOINT,
609
- DebugCommands.REMOVE_ALL_BREAKPOINTS
610
- );
611
- registerMenuActions(DebugBreakpointsWidget.ENABLE_MENU,
612
- DebugCommands.ENABLE_ALL_BREAKPOINTS,
613
- DebugCommands.DISABLE_ALL_BREAKPOINTS
614
- );
615
-
616
- registerMenuActions(DebugEditorModel.CONTEXT_MENU,
617
- { ...DebugEditorContextCommands.ADD_BREAKPOINT, label: nls.localizeByDefault('Add Breakpoint') },
618
- { ...DebugEditorContextCommands.ADD_CONDITIONAL_BREAKPOINT, label: DebugCommands.ADD_CONDITIONAL_BREAKPOINT.label },
619
- { ...DebugEditorContextCommands.ADD_LOGPOINT, label: DebugCommands.ADD_LOGPOINT.label },
620
- { ...DebugEditorContextCommands.REMOVE_BREAKPOINT, label: DebugCommands.REMOVE_BREAKPOINT.label },
621
- { ...DebugEditorContextCommands.EDIT_BREAKPOINT, label: DebugCommands.EDIT_BREAKPOINT.label },
622
- { ...DebugEditorContextCommands.ENABLE_BREAKPOINT, label: nlsEnableBreakpoint('Breakpoint') },
623
- { ...DebugEditorContextCommands.DISABLE_BREAKPOINT, label: nlsDisableBreakpoint('Breakpoint') },
624
- { ...DebugEditorContextCommands.REMOVE_LOGPOINT, label: DebugCommands.REMOVE_LOGPOINT.label },
625
- { ...DebugEditorContextCommands.EDIT_LOGPOINT, label: DebugCommands.EDIT_LOGPOINT.label },
626
- { ...DebugEditorContextCommands.ENABLE_LOGPOINT, label: nlsEnableBreakpoint('Logpoint') },
627
- { ...DebugEditorContextCommands.DISABLE_LOGPOINT, label: nlsDisableBreakpoint('Logpoint') }
628
- );
629
- menus.linkSubmenu(EDITOR_LINENUMBER_CONTEXT_MENU, DebugEditorModel.CONTEXT_MENU, { role: CompoundMenuNodeRole.Group });
630
- }
631
-
632
- override registerCommands(registry: CommandRegistry): void {
633
- super.registerCommands(registry);
634
- registry.registerCommand(DebugCommands.START, {
635
- execute: (config?: DebugSessionOptions) => this.start(false, config)
636
- });
637
- registry.registerCommand(DebugCommands.START_NO_DEBUG, {
638
- execute: (config?: DebugSessionOptions) => this.start(true, config)
639
- });
640
- registry.registerCommand(DebugCommands.STOP, {
641
- execute: () => this.manager.terminateSession(),
642
- isEnabled: () => this.manager.state !== DebugState.Inactive
643
- });
644
- registry.registerCommand(DebugCommands.RESTART, {
645
- execute: () => this.manager.restartSession(),
646
- isEnabled: () => this.manager.state !== DebugState.Inactive
647
- });
648
-
649
- registry.registerCommand(DebugCommands.OPEN_CONFIGURATIONS, {
650
- execute: () => this.configurations.openConfiguration()
651
- });
652
- registry.registerCommand(DebugCommands.ADD_CONFIGURATION, {
653
- execute: () => this.configurations.addConfiguration()
654
- });
655
-
656
- registry.registerCommand(DebugCommands.STEP_OVER, {
657
- execute: () => this.manager.currentThread && this.manager.currentThread.stepOver(),
658
- isEnabled: () => this.manager.state === DebugState.Stopped
659
- });
660
- registry.registerCommand(DebugCommands.STEP_INTO, {
661
- execute: () => this.manager.currentThread && this.manager.currentThread.stepIn(),
662
- isEnabled: () => this.manager.state === DebugState.Stopped
663
- });
664
- registry.registerCommand(DebugCommands.STEP_OUT, {
665
- execute: () => this.manager.currentThread && this.manager.currentThread.stepOut(),
666
- isEnabled: () => this.manager.state === DebugState.Stopped
667
- });
668
- registry.registerCommand(DebugCommands.CONTINUE, {
669
- execute: () => this.manager.currentThread && this.manager.currentThread.continue(),
670
- isEnabled: () => this.manager.state === DebugState.Stopped
671
- });
672
- registry.registerCommand(DebugCommands.PAUSE, {
673
- execute: () => this.manager.currentThread && this.manager.currentThread.pause(),
674
- isEnabled: () => this.manager.state === DebugState.Running
675
- });
676
- registry.registerCommand(DebugCommands.PAUSE_ALL, {
677
- execute: () => this.manager.currentSession && this.manager.currentSession.pauseAll(),
678
- isEnabled: () => !!this.manager.currentSession && !!this.manager.currentSession.runningThreads.next().value
679
- });
680
- registry.registerCommand(DebugCommands.CONTINUE_ALL, {
681
- execute: () => this.manager.currentSession && this.manager.currentSession.continueAll(),
682
- isEnabled: () => !!this.manager.currentSession && !!this.manager.currentSession.stoppedThreads.next().value
683
- });
684
-
685
- registry.registerCommand(DebugThreadContextCommands.STEP_OVER, {
686
- execute: () => this.selectedThread && this.selectedThread.stepOver(),
687
- isEnabled: () => !!this.selectedThread && this.selectedThread.stopped,
688
- isVisible: () => !!this.selectedThread
689
- });
690
- registry.registerCommand(DebugThreadContextCommands.STEP_INTO, {
691
- execute: () => this.selectedThread && this.selectedThread.stepIn(),
692
- isEnabled: () => !!this.selectedThread && this.selectedThread.stopped,
693
- isVisible: () => !!this.selectedThread
694
- });
695
- registry.registerCommand(DebugThreadContextCommands.STEP_OUT, {
696
- execute: () => this.selectedThread && this.selectedThread.stepOut(),
697
- isEnabled: () => !!this.selectedThread && this.selectedThread.stopped,
698
- isVisible: () => !!this.selectedThread
699
- });
700
- registry.registerCommand(DebugThreadContextCommands.CONTINUE, {
701
- execute: () => this.selectedThread && this.selectedThread.continue(),
702
- isEnabled: () => !!this.selectedThread && this.selectedThread.stopped,
703
- isVisible: () => !!this.selectedThread && this.selectedThread.stopped,
704
- });
705
- registry.registerCommand(DebugThreadContextCommands.PAUSE, {
706
- execute: () => this.selectedThread && this.selectedThread.pause(),
707
- isEnabled: () => !!this.selectedThread && !this.selectedThread.stopped,
708
- isVisible: () => !!this.selectedThread && !this.selectedThread.stopped,
709
- });
710
- registry.registerCommand(DebugThreadContextCommands.TERMINATE, {
711
- execute: () => this.selectedThread && this.selectedThread.terminate(),
712
- isEnabled: () => !!this.selectedThread && this.selectedThread.supportsTerminate,
713
- isVisible: () => !!this.selectedThread && this.selectedThread.supportsTerminate
714
- });
715
-
716
- registry.registerCommand(DebugSessionContextCommands.STOP, {
717
- execute: () => this.selectedSession && this.manager.terminateSession(this.selectedSession),
718
- isEnabled: () => !!this.selectedSession && this.selectedSession.state !== DebugState.Inactive,
719
- isVisible: () => !this.selectedThread
720
- });
721
- registry.registerCommand(DebugSessionContextCommands.RESTART, {
722
- execute: () => this.selectedSession && this.manager.restartSession(this.selectedSession),
723
- isEnabled: () => !!this.selectedSession && this.selectedSession.state !== DebugState.Inactive,
724
- isVisible: () => !this.selectedThread
725
- });
726
- registry.registerCommand(DebugSessionContextCommands.CONTINUE_ALL, {
727
- execute: () => this.selectedSession && this.selectedSession.continueAll(),
728
- isEnabled: () => !!this.selectedSession && !!this.selectedSession.stoppedThreads.next().value,
729
- isVisible: () => !this.selectedThread
730
- });
731
- registry.registerCommand(DebugSessionContextCommands.PAUSE_ALL, {
732
- execute: () => this.selectedSession && this.selectedSession.pauseAll(),
733
- isEnabled: () => !!this.selectedSession && !!this.selectedSession.runningThreads.next().value,
734
- isVisible: () => !this.selectedThread
735
- });
736
- registry.registerCommand(DebugSessionContextCommands.REVEAL, {
737
- execute: () => this.selectedSession && this.revealSession(this.selectedSession),
738
- isEnabled: () => Boolean(this.selectedSession),
739
- isVisible: () => !this.selectedThread && Boolean(this.selectedSession)
740
- });
741
- registry.registerCommand(DebugCommands.TOGGLE_BREAKPOINT, {
742
- execute: () => this.editors.toggleBreakpoint(),
743
- isEnabled: () => !!this.editors.model
744
- });
745
- registry.registerCommand(DebugCommands.INLINE_BREAKPOINT, {
746
- execute: () => this.editors.addInlineBreakpoint(),
747
- isEnabled: () => !!this.editors.model && !this.editors.getInlineBreakpoint()
748
- });
749
- registry.registerCommand(DebugCommands.ADD_CONDITIONAL_BREAKPOINT, {
750
- execute: () => this.editors.addBreakpoint('condition'),
751
- isEnabled: () => !!this.editors.model && !this.editors.anyBreakpoint()
752
- });
753
- registry.registerCommand(DebugCommands.ADD_LOGPOINT, {
754
- execute: () => this.editors.addBreakpoint('logMessage'),
755
- isEnabled: () => !!this.editors.model && !this.editors.anyBreakpoint()
756
- });
757
- registry.registerCommand(DebugCommands.ADD_FUNCTION_BREAKPOINT, {
758
- execute: async () => {
759
- const { labelProvider, breakpointManager, editorManager } = this;
760
- const options = { labelProvider, breakpoints: breakpointManager, editorManager };
761
- await new DebugFunctionBreakpoint(FunctionBreakpoint.create({ name: '' }), options).open();
762
- },
763
- isEnabled: widget => !(widget instanceof Widget) || widget instanceof DebugBreakpointsWidget,
764
- isVisible: widget => !(widget instanceof Widget) || widget instanceof DebugBreakpointsWidget
765
- });
766
- registry.registerCommand(DebugCommands.ENABLE_ALL_BREAKPOINTS, {
767
- execute: () => this.breakpointManager.enableAllBreakpoints(true),
768
- isEnabled: () => this.breakpointManager.hasBreakpoints()
769
- });
770
- registry.registerCommand(DebugCommands.DISABLE_ALL_BREAKPOINTS, {
771
- execute: () => this.breakpointManager.enableAllBreakpoints(false),
772
- isEnabled: () => this.breakpointManager.hasBreakpoints()
773
- });
774
- registry.registerCommand(DebugCommands.EDIT_BREAKPOINT, {
775
- execute: async () => {
776
- const { selectedBreakpoint, selectedFunctionBreakpoint } = this;
777
- if (selectedBreakpoint) {
778
- await this.editors.editBreakpoint(selectedBreakpoint);
779
- } else if (selectedFunctionBreakpoint) {
780
- await selectedFunctionBreakpoint.open();
781
- }
782
- },
783
- isEnabled: () => !!this.selectedBreakpoint || !!this.selectedFunctionBreakpoint,
784
- isVisible: () => !!this.selectedBreakpoint || !!this.selectedFunctionBreakpoint
785
- });
786
- registry.registerCommand(DebugCommands.EDIT_LOGPOINT, {
787
- execute: async () => {
788
- const { selectedLogpoint } = this;
789
- if (selectedLogpoint) {
790
- await this.editors.editBreakpoint(selectedLogpoint);
791
- }
792
- },
793
- isEnabled: () => !!this.selectedLogpoint,
794
- isVisible: () => !!this.selectedLogpoint
795
- });
796
- registry.registerCommand(DebugCommands.EDIT_BREAKPOINT_CONDITION, {
797
- execute: async () => {
798
- const { selectedExceptionBreakpoint } = this;
799
- if (selectedExceptionBreakpoint) {
800
- await selectedExceptionBreakpoint.editCondition();
801
- }
802
- },
803
- isEnabled: () => !!this.selectedExceptionBreakpoint?.data.raw.supportsCondition,
804
- isVisible: () => !!this.selectedExceptionBreakpoint?.data.raw.supportsCondition
805
- });
806
- registry.registerCommand(DebugCommands.REMOVE_BREAKPOINT, {
807
- execute: () => {
808
- const selectedBreakpoint = this.selectedSettableBreakpoint;
809
- if (selectedBreakpoint) {
810
- selectedBreakpoint.remove();
811
- }
812
- },
813
- isEnabled: () => Boolean(this.selectedSettableBreakpoint),
814
- isVisible: () => Boolean(this.selectedSettableBreakpoint),
815
- });
816
- registry.registerCommand(DebugCommands.REMOVE_LOGPOINT, {
817
- execute: () => {
818
- const { selectedLogpoint } = this;
819
- if (selectedLogpoint) {
820
- selectedLogpoint.remove();
821
- }
822
- },
823
- isEnabled: () => !!this.selectedLogpoint,
824
- isVisible: () => !!this.selectedLogpoint
825
- });
826
- registry.registerCommand(DebugCommands.REMOVE_ALL_BREAKPOINTS, {
827
- execute: () => this.breakpointManager.removeBreakpoints(),
828
- isEnabled: () => this.breakpointManager.hasBreakpoints(),
829
- isVisible: widget => !(widget instanceof Widget) || (widget instanceof DebugBreakpointsWidget)
830
- });
831
- registry.registerCommand(DebugCommands.TOGGLE_BREAKPOINTS_ENABLED, {
832
- execute: () => this.breakpointManager.breakpointsEnabled = !this.breakpointManager.breakpointsEnabled,
833
- isVisible: arg => arg instanceof DebugBreakpointsWidget
834
- });
835
- registry.registerCommand(DebugCommands.SHOW_HOVER, {
836
- execute: () => this.editors.showHover(),
837
- isEnabled: () => this.editors.canShowHover()
838
- });
839
-
840
- registry.registerCommand(DebugCommands.RESTART_FRAME, {
841
- execute: () => this.selectedFrame && this.selectedFrame.restart(),
842
- isEnabled: () => !!this.selectedFrame
843
- });
844
- registry.registerCommand(DebugCommands.COPY_CALL_STACK, {
845
- execute: () => {
846
- const { frames } = this;
847
- const selection = document.getSelection();
848
- if (frames && selection) {
849
- selection.selectAllChildren(frames.node);
850
- document.execCommand('copy');
851
- }
852
- },
853
- isEnabled: () => document.queryCommandSupported('copy'),
854
- isVisible: () => document.queryCommandSupported('copy')
855
- });
856
-
857
- registry.registerCommand(DebugCommands.SET_VARIABLE_VALUE, {
858
- execute: () => this.selectedVariable && this.selectedVariable.open(),
859
- isEnabled: () => !!this.selectedVariable && this.selectedVariable.supportSetVariable,
860
- isVisible: () => !!this.selectedVariable && this.selectedVariable.supportSetVariable
861
- });
862
- registry.registerCommand(DebugCommands.COPY_VARIABLE_VALUE, {
863
- execute: () => this.selectedVariable && this.selectedVariable.copyValue(),
864
- isEnabled: () => !!this.selectedVariable && this.selectedVariable.supportCopyValue,
865
- isVisible: () => !!this.selectedVariable && this.selectedVariable.supportCopyValue
866
- });
867
- registry.registerCommand(DebugCommands.COPY_VARIABLE_AS_EXPRESSION, {
868
- execute: () => this.selectedVariable && this.selectedVariable.copyAsExpression(),
869
- isEnabled: () => !!this.selectedVariable && this.selectedVariable.supportCopyAsExpression,
870
- isVisible: () => !!this.selectedVariable && this.selectedVariable.supportCopyAsExpression
871
- });
872
- registry.registerCommand(DebugCommands.WATCH_VARIABLE, {
873
- execute: () => {
874
- const { selectedVariable, watch } = this;
875
- if (selectedVariable && watch) {
876
- watch.viewModel.addWatchExpression(selectedVariable.name);
877
- }
878
- },
879
- isEnabled: () => !!this.selectedVariable && !!this.watch,
880
- isVisible: () => !!this.selectedVariable && !!this.watch,
881
- });
882
-
883
- // Debug context menu commands
884
- registry.registerCommand(DebugEditorContextCommands.ADD_BREAKPOINT, {
885
- execute: position => this.isPosition(position) && this.editors.toggleBreakpoint(this.asPosition(position)),
886
- isEnabled: position => this.isPosition(position) && !this.editors.anyBreakpoint(this.asPosition(position)),
887
- isVisible: position => this.isPosition(position) && !this.editors.anyBreakpoint(this.asPosition(position))
888
- });
889
- registry.registerCommand(DebugEditorContextCommands.ADD_CONDITIONAL_BREAKPOINT, {
890
- execute: position => this.isPosition(position) && this.editors.addBreakpoint('condition', this.asPosition(position)),
891
- isEnabled: position => this.isPosition(position) && !this.editors.anyBreakpoint(this.asPosition(position)),
892
- isVisible: position => this.isPosition(position) && !this.editors.anyBreakpoint(this.asPosition(position))
893
- });
894
- registry.registerCommand(DebugEditorContextCommands.ADD_LOGPOINT, {
895
- execute: position => this.isPosition(position) && this.editors.addBreakpoint('logMessage', this.asPosition(position)),
896
- isEnabled: position => this.isPosition(position) && !this.editors.anyBreakpoint(this.asPosition(position)),
897
- isVisible: position => this.isPosition(position) && !this.editors.anyBreakpoint(this.asPosition(position))
898
- });
899
- registry.registerCommand(DebugEditorContextCommands.REMOVE_BREAKPOINT, {
900
- execute: position => this.isPosition(position) && this.editors.toggleBreakpoint(this.asPosition(position)),
901
- isEnabled: position => this.isPosition(position) && !!this.editors.getBreakpoint(this.asPosition(position)),
902
- isVisible: position => this.isPosition(position) && !!this.editors.getBreakpoint(this.asPosition(position))
903
- });
904
- registry.registerCommand(DebugEditorContextCommands.EDIT_BREAKPOINT, {
905
- execute: position => this.isPosition(position) && this.editors.editBreakpoint(this.asPosition(position)),
906
- isEnabled: position => this.isPosition(position) && !!this.editors.getBreakpoint(this.asPosition(position)),
907
- isVisible: position => this.isPosition(position) && !!this.editors.getBreakpoint(this.asPosition(position))
908
- });
909
- registry.registerCommand(DebugEditorContextCommands.ENABLE_BREAKPOINT, {
910
- execute: position => this.isPosition(position) && this.editors.setBreakpointEnabled(this.asPosition(position), true),
911
- isEnabled: position => this.isPosition(position) && this.editors.getBreakpointEnabled(this.asPosition(position)) === false,
912
- isVisible: position => this.isPosition(position) && this.editors.getBreakpointEnabled(this.asPosition(position)) === false
913
- });
914
- registry.registerCommand(DebugEditorContextCommands.DISABLE_BREAKPOINT, {
915
- execute: position => this.isPosition(position) && this.editors.setBreakpointEnabled(this.asPosition(position), false),
916
- isEnabled: position => this.isPosition(position) && !!this.editors.getBreakpointEnabled(this.asPosition(position)),
917
- isVisible: position => this.isPosition(position) && !!this.editors.getBreakpointEnabled(this.asPosition(position))
918
- });
919
- registry.registerCommand(DebugEditorContextCommands.REMOVE_LOGPOINT, {
920
- execute: position => this.isPosition(position) && this.editors.toggleBreakpoint(this.asPosition(position)),
921
- isEnabled: position => this.isPosition(position) && !!this.editors.getLogpoint(this.asPosition(position)),
922
- isVisible: position => this.isPosition(position) && !!this.editors.getLogpoint(this.asPosition(position))
923
- });
924
- registry.registerCommand(DebugEditorContextCommands.EDIT_LOGPOINT, {
925
- execute: position => this.isPosition(position) && this.editors.editBreakpoint(this.asPosition(position)),
926
- isEnabled: position => this.isPosition(position) && !!this.editors.getLogpoint(this.asPosition(position)),
927
- isVisible: position => this.isPosition(position) && !!this.editors.getLogpoint(this.asPosition(position))
928
- });
929
- registry.registerCommand(DebugEditorContextCommands.ENABLE_LOGPOINT, {
930
- execute: position => this.isPosition(position) && this.editors.setBreakpointEnabled(this.asPosition(position), true),
931
- isEnabled: position => this.isPosition(position) && this.editors.getLogpointEnabled(this.asPosition(position)) === false,
932
- isVisible: position => this.isPosition(position) && this.editors.getLogpointEnabled(this.asPosition(position)) === false
933
- });
934
- registry.registerCommand(DebugEditorContextCommands.DISABLE_LOGPOINT, {
935
- execute: position => this.isPosition(position) && this.editors.setBreakpointEnabled(this.asPosition(position), false),
936
- isEnabled: position => this.isPosition(position) && !!this.editors.getLogpointEnabled(this.asPosition(position)),
937
- isVisible: position => this.isPosition(position) && !!this.editors.getLogpointEnabled(this.asPosition(position))
938
- });
939
-
940
- registry.registerCommand(DebugBreakpointWidgetCommands.ACCEPT, {
941
- execute: () => this.editors.acceptBreakpoint()
942
- });
943
- registry.registerCommand(DebugBreakpointWidgetCommands.CLOSE, {
944
- execute: () => this.editors.closeBreakpoint()
945
- });
946
-
947
- registry.registerCommand(DebugCommands.ADD_WATCH_EXPRESSION, {
948
- execute: widget => {
949
- if (widget instanceof Widget) {
950
- if (widget instanceof DebugWatchWidget) {
951
- widget.viewModel.addWatchExpression();
952
- }
953
- } else if (this.watch) {
954
- this.watch.viewModel.addWatchExpression();
955
- }
956
- },
957
- isEnabled: widget => widget instanceof Widget ? widget instanceof DebugWatchWidget : !!this.watch,
958
- isVisible: widget => widget instanceof Widget ? widget instanceof DebugWatchWidget : !!this.watch
959
- });
960
- registry.registerCommand(DebugCommands.EDIT_WATCH_EXPRESSION, {
961
- execute: () => {
962
- const { watchExpression } = this;
963
- if (watchExpression) {
964
- watchExpression.open();
965
- }
966
- },
967
- isEnabled: () => !!this.watchExpression,
968
- isVisible: () => !!this.watchExpression
969
- });
970
- registry.registerCommand(DebugCommands.COPY_WATCH_EXPRESSION_VALUE, {
971
- execute: () => this.watchExpression && this.watchExpression.copyValue(),
972
- isEnabled: () => !!this.watchExpression && this.watchExpression.supportCopyValue,
973
- isVisible: () => !!this.watchExpression && this.watchExpression.supportCopyValue
974
- });
975
- registry.registerCommand(DebugCommands.COLLAPSE_ALL_WATCH_EXPRESSIONS, {
976
- execute: widget => {
977
- if (widget instanceof DebugWatchWidget) {
978
- const root = widget.model.root;
979
- widget.model.collapseAll(CompositeTreeNode.is(root) ? root : undefined);
980
- }
981
- },
982
- isEnabled: widget => widget instanceof DebugWatchWidget,
983
- isVisible: widget => widget instanceof DebugWatchWidget
984
- });
985
- registry.registerCommand(DebugCommands.REMOVE_WATCH_EXPRESSION, {
986
- execute: () => {
987
- const { watch, watchExpression } = this;
988
- if (watch && watchExpression) {
989
- watch.viewModel.removeWatchExpression(watchExpression);
990
- }
991
- },
992
- isEnabled: () => !!this.watchExpression,
993
- isVisible: () => !!this.watchExpression
994
- });
995
- registry.registerCommand(DebugCommands.REMOVE_ALL_WATCH_EXPRESSIONS, {
996
- execute: widget => {
997
- if (widget instanceof Widget) {
998
- if (widget instanceof DebugWatchWidget) {
999
- widget.viewModel.removeWatchExpressions();
1000
- }
1001
- } else if (this.watch) {
1002
- this.watch.viewModel.removeWatchExpressions();
1003
- }
1004
- },
1005
- isEnabled: widget => widget instanceof Widget ? widget instanceof DebugWatchWidget : !!this.watch,
1006
- isVisible: widget => widget instanceof Widget ? widget instanceof DebugWatchWidget : !!this.watch
1007
- });
1008
- }
1009
-
1010
- override registerKeybindings(keybindings: KeybindingRegistry): void {
1011
- super.registerKeybindings(keybindings);
1012
- keybindings.registerKeybinding({
1013
- command: DebugCommands.START.id,
1014
- keybinding: 'f5'
1015
- });
1016
- keybindings.registerKeybinding({
1017
- command: DebugCommands.START_NO_DEBUG.id,
1018
- keybinding: 'ctrl+f5'
1019
- });
1020
- keybindings.registerKeybinding({
1021
- command: DebugCommands.STOP.id,
1022
- keybinding: 'shift+f5',
1023
- when: 'inDebugMode'
1024
- });
1025
-
1026
- keybindings.registerKeybinding({
1027
- command: DebugCommands.RESTART.id,
1028
- keybinding: 'shift+ctrlcmd+f5',
1029
- when: 'inDebugMode'
1030
- });
1031
- keybindings.registerKeybinding({
1032
- command: DebugCommands.STEP_OVER.id,
1033
- keybinding: 'f10',
1034
- when: 'inDebugMode'
1035
- });
1036
- keybindings.registerKeybinding({
1037
- command: DebugCommands.STEP_INTO.id,
1038
- keybinding: 'f11',
1039
- when: 'inDebugMode'
1040
- });
1041
- keybindings.registerKeybinding({
1042
- command: DebugCommands.STEP_OUT.id,
1043
- keybinding: 'shift+f11',
1044
- when: 'inDebugMode'
1045
- });
1046
- keybindings.registerKeybinding({
1047
- command: DebugCommands.CONTINUE.id,
1048
- keybinding: 'f5',
1049
- when: 'inDebugMode'
1050
- });
1051
- keybindings.registerKeybinding({
1052
- command: DebugCommands.PAUSE.id,
1053
- keybinding: 'f6',
1054
- when: 'inDebugMode'
1055
- });
1056
-
1057
- keybindings.registerKeybinding({
1058
- command: DebugCommands.TOGGLE_BREAKPOINT.id,
1059
- keybinding: 'f9',
1060
- when: 'editorTextFocus'
1061
- });
1062
- keybindings.registerKeybinding({
1063
- command: DebugCommands.INLINE_BREAKPOINT.id,
1064
- keybinding: 'shift+f9',
1065
- when: 'editorTextFocus'
1066
- });
1067
-
1068
- keybindings.registerKeybinding({
1069
- command: DebugBreakpointWidgetCommands.ACCEPT.id,
1070
- keybinding: 'enter',
1071
- when: 'breakpointWidgetFocus'
1072
- });
1073
- keybindings.registerKeybinding({
1074
- command: DebugBreakpointWidgetCommands.CLOSE.id,
1075
- keybinding: 'esc',
1076
- when: 'isBreakpointWidgetVisible || breakpointWidgetFocus'
1077
- });
1078
- }
1079
-
1080
- registerToolbarItems(toolbar: TabBarToolbarRegistry): void {
1081
- const onDidChangeToggleBreakpointsEnabled = new Emitter<void>();
1082
- const toggleBreakpointsEnabled: Mutable<TabBarToolbarItem> = {
1083
- id: DebugCommands.TOGGLE_BREAKPOINTS_ENABLED.id,
1084
- command: DebugCommands.TOGGLE_BREAKPOINTS_ENABLED.id,
1085
- icon: codicon('activate-breakpoints'),
1086
- onDidChange: onDidChangeToggleBreakpointsEnabled.event,
1087
- priority: 1
1088
- };
1089
- const updateToggleBreakpointsEnabled = () => {
1090
- const activateBreakpoints = nls.localizeByDefault('Enable All Breakpoints');
1091
- const deactivateBreakpoints = nls.localizeByDefault('Disable All Breakpoints');
1092
- const tooltip = this.breakpointManager.breakpointsEnabled ? deactivateBreakpoints : activateBreakpoints;
1093
- if (toggleBreakpointsEnabled.tooltip !== tooltip) {
1094
- toggleBreakpointsEnabled.tooltip = tooltip;
1095
- onDidChangeToggleBreakpointsEnabled.fire(undefined);
1096
- }
1097
- };
1098
- toolbar.registerItem({
1099
- id: DebugCommands.ADD_FUNCTION_BREAKPOINT.id,
1100
- command: DebugCommands.ADD_FUNCTION_BREAKPOINT.id,
1101
- icon: codicon('add'),
1102
- tooltip: DebugCommands.ADD_FUNCTION_BREAKPOINT.label
1103
- });
1104
- updateToggleBreakpointsEnabled();
1105
- this.breakpointManager.onDidChangeBreakpoints(updateToggleBreakpointsEnabled);
1106
- toolbar.registerItem(toggleBreakpointsEnabled);
1107
- toolbar.registerItem({
1108
- id: DebugCommands.REMOVE_ALL_BREAKPOINTS.id,
1109
- command: DebugCommands.REMOVE_ALL_BREAKPOINTS.id,
1110
- icon: codicon('close-all'),
1111
- priority: 2
1112
- });
1113
-
1114
- toolbar.registerItem({
1115
- id: DebugCommands.ADD_WATCH_EXPRESSION.id,
1116
- command: DebugCommands.ADD_WATCH_EXPRESSION.id,
1117
- icon: codicon('add'),
1118
- tooltip: DebugCommands.ADD_WATCH_EXPRESSION.label
1119
- });
1120
- toolbar.registerItem({
1121
- id: DebugCommands.COLLAPSE_ALL_WATCH_EXPRESSIONS.id,
1122
- command: DebugCommands.COLLAPSE_ALL_WATCH_EXPRESSIONS.id,
1123
- icon: codicon('collapse-all'),
1124
- tooltip: DebugCommands.COLLAPSE_ALL_WATCH_EXPRESSIONS.label,
1125
- priority: 1
1126
- });
1127
- toolbar.registerItem({
1128
- id: DebugCommands.REMOVE_ALL_WATCH_EXPRESSIONS.id,
1129
- command: DebugCommands.REMOVE_ALL_WATCH_EXPRESSIONS.id,
1130
- icon: codicon('close-all'),
1131
- tooltip: DebugCommands.REMOVE_ALL_WATCH_EXPRESSIONS.label,
1132
- priority: 2
1133
- });
1134
- }
1135
-
1136
- protected async openSession(
1137
- session: DebugSession,
1138
- options?: {
1139
- reveal?: boolean;
1140
- }
1141
- ): Promise<DebugWidget | DebugSessionWidget> {
1142
- const { reveal } = {
1143
- reveal: true,
1144
- ...options
1145
- };
1146
- const debugWidget = await this.openView({ reveal });
1147
- debugWidget.sessionManager.currentSession = session;
1148
- return debugWidget['sessionWidget'];
1149
- }
1150
-
1151
- protected revealSession(session: DebugSession): DebugSessionWidget | undefined {
1152
- const widget = this.tryGetWidget()?.['sessionWidget'];
1153
- if (widget) {
1154
- this.shell.revealWidget(widget.id);
1155
- }
1156
- return widget;
1157
- }
1158
-
1159
- async start(noDebug?: boolean, debugSessionOptions?: DebugSessionOptions): Promise<void> {
1160
- let current = debugSessionOptions ? debugSessionOptions : this.configurations.current;
1161
- // If no configurations are currently present, create the `launch.json` and prompt users to select the config.
1162
- if (!current) {
1163
- await this.configurations.addConfiguration();
1164
- return;
1165
- }
1166
-
1167
- if (noDebug !== undefined) {
1168
- if (current.configuration) {
1169
- current = {
1170
- ...current,
1171
- configuration: {
1172
- ...current.configuration,
1173
- noDebug
1174
- }
1175
- };
1176
- } else {
1177
- current = {
1178
- ...current,
1179
- noDebug
1180
- };
1181
- }
1182
- }
1183
-
1184
- await this.manager.start(current);
1185
- }
1186
-
1187
- get threads(): DebugThreadsWidget | undefined {
1188
- const { currentWidget } = this.shell;
1189
- return currentWidget instanceof DebugThreadsWidget && currentWidget || undefined;
1190
- }
1191
- get selectedSession(): DebugSession | undefined {
1192
- const { threads } = this;
1193
- return threads && threads.selectedElement instanceof DebugSession && threads.selectedElement || undefined;
1194
- }
1195
- get selectedThread(): DebugThread | undefined {
1196
- const { threads } = this;
1197
- return threads && threads.selectedElement instanceof DebugThread && threads.selectedElement || undefined;
1198
- }
1199
-
1200
- get frames(): DebugStackFramesWidget | undefined {
1201
- const { currentWidget } = this.shell;
1202
- return currentWidget instanceof DebugStackFramesWidget && currentWidget || undefined;
1203
- }
1204
- get selectedFrame(): DebugStackFrame | undefined {
1205
- const { frames } = this;
1206
- return frames && frames.selectedElement instanceof DebugStackFrame && frames.selectedElement || undefined;
1207
- }
1208
-
1209
- get breakpoints(): DebugBreakpointsWidget | undefined {
1210
- const { currentWidget } = this.shell;
1211
- return currentWidget instanceof DebugBreakpointsWidget && currentWidget || undefined;
1212
- }
1213
- get selectedAnyBreakpoint(): DebugBreakpoint | undefined {
1214
- const { breakpoints } = this;
1215
- const selectedElement = breakpoints && breakpoints.selectedElement;
1216
- return selectedElement instanceof DebugBreakpoint ? selectedElement : undefined;
1217
- }
1218
- get selectedBreakpoint(): DebugSourceBreakpoint | undefined {
1219
- const breakpoint = this.selectedAnyBreakpoint;
1220
- return breakpoint && breakpoint instanceof DebugSourceBreakpoint && !breakpoint.logMessage ? breakpoint : undefined;
1221
- }
1222
- get selectedLogpoint(): DebugSourceBreakpoint | undefined {
1223
- const breakpoint = this.selectedAnyBreakpoint;
1224
- return breakpoint && breakpoint instanceof DebugSourceBreakpoint && !!breakpoint.logMessage ? breakpoint : undefined;
1225
- }
1226
- get selectedFunctionBreakpoint(): DebugFunctionBreakpoint | undefined {
1227
- const breakpoint = this.selectedAnyBreakpoint;
1228
- return breakpoint && breakpoint instanceof DebugFunctionBreakpoint ? breakpoint : undefined;
1229
- }
1230
- get selectedInstructionBreakpoint(): DebugInstructionBreakpoint | undefined {
1231
- if (this.selectedAnyBreakpoint instanceof DebugInstructionBreakpoint) {
1232
- return this.selectedAnyBreakpoint;
1233
- }
1234
- }
1235
- get selectedExceptionBreakpoint(): DebugExceptionBreakpoint | undefined {
1236
- const { breakpoints } = this;
1237
- const selectedElement = breakpoints && breakpoints.selectedElement;
1238
- return selectedElement instanceof DebugExceptionBreakpoint ? selectedElement : undefined;
1239
- }
1240
-
1241
- get selectedSettableBreakpoint(): DebugFunctionBreakpoint | DebugInstructionBreakpoint | DebugSourceBreakpoint | undefined {
1242
- const selected = this.selectedAnyBreakpoint;
1243
- if (selected instanceof DebugFunctionBreakpoint || selected instanceof DebugInstructionBreakpoint || selected instanceof DebugSourceBreakpoint) {
1244
- return selected;
1245
- }
1246
- }
1247
-
1248
- get variables(): DebugVariablesWidget | undefined {
1249
- const { currentWidget } = this.shell;
1250
- return currentWidget instanceof DebugVariablesWidget && currentWidget || undefined;
1251
- }
1252
- get selectedVariable(): DebugVariable | undefined {
1253
- const { variables } = this;
1254
- return variables && variables.selectedElement instanceof DebugVariable && variables.selectedElement || undefined;
1255
- }
1256
-
1257
- get watch(): DebugWatchWidget | undefined {
1258
- const { currentWidget } = this.shell;
1259
- return currentWidget instanceof DebugWatchWidget && currentWidget || undefined;
1260
- }
1261
- get watchExpression(): DebugWatchExpression | undefined {
1262
- const { watch } = this;
1263
- return watch && watch.selectedElement instanceof DebugWatchExpression && watch.selectedElement || undefined;
1264
- }
1265
-
1266
- protected isPosition(position: unknown): boolean {
1267
- return monaco.Position.isIPosition(position);
1268
- }
1269
-
1270
- protected asPosition(position: monaco.IPosition): monaco.Position {
1271
- return monaco.Position.lift(position);
1272
- }
1273
-
1274
- registerColors(colors: ColorRegistry): void {
1275
- colors.register(
1276
- // Debug colors should be aligned with https://code.visualstudio.com/api/references/theme-color#debug-colors
1277
- {
1278
- id: 'editor.stackFrameHighlightBackground',
1279
- defaults: {
1280
- dark: '#ffff0033',
1281
- light: '#ffff6673',
1282
- hcDark: '#fff600',
1283
- hcLight: '#ffff6673'
1284
- }, description: 'Background color for the highlight of line at the top stack frame position.'
1285
- },
1286
- {
1287
- id: 'editor.focusedStackFrameHighlightBackground',
1288
- defaults: {
1289
- dark: '#7abd7a4d',
1290
- light: '#cee7ce73',
1291
- hcDark: '#cee7ce',
1292
- hcLight: '#cee7ce73'
1293
- }, description: 'Background color for the highlight of line at focused stack frame position.'
1294
- },
1295
- // Status bar colors should be aligned with debugging colors from https://code.visualstudio.com/api/references/theme-color#status-bar-colors
1296
- {
1297
- id: 'statusBar.debuggingBackground', defaults: {
1298
- dark: '#CC6633',
1299
- light: '#CC6633',
1300
- hcDark: '#CC6633',
1301
- hcLight: '#B5200D'
1302
- }, description: 'Status bar background color when a program is being debugged. The status bar is shown in the bottom of the window'
1303
- },
1304
- {
1305
- id: 'statusBar.debuggingForeground', defaults: {
1306
- dark: 'statusBar.foreground',
1307
- light: 'statusBar.foreground',
1308
- hcDark: 'statusBar.foreground',
1309
- hcLight: 'statusBar.foreground'
1310
- }, description: 'Status bar foreground color when a program is being debugged. The status bar is shown in the bottom of the window'
1311
- },
1312
- {
1313
- id: 'statusBar.debuggingBorder', defaults: {
1314
- dark: 'statusBar.border',
1315
- light: 'statusBar.border',
1316
- hcDark: 'statusBar.border',
1317
- hcLight: 'statusBar.border'
1318
- }, description: 'Status bar border color separating to the sidebar and editor when a program is being debugged. The status bar is shown in the bottom of the window'
1319
- },
1320
- // Debug Exception Widget colors should be aligned with
1321
- // https://github.com/microsoft/vscode/blob/ff5f581425da6230b6f9216ecf19abf6c9d285a6/src/vs/workbench/contrib/debug/browser/exceptionWidget.ts#L23
1322
- {
1323
- id: 'debugExceptionWidget.border', defaults: {
1324
- dark: '#a31515',
1325
- light: '#a31515',
1326
- hcDark: '#a31515',
1327
- hcLight: '#a31515'
1328
- }, description: 'Exception widget border color.',
1329
- },
1330
- {
1331
- id: 'debugExceptionWidget.background', defaults: {
1332
- dark: '#420b0d',
1333
- light: '#f1dfde',
1334
- hcDark: '#420b0d',
1335
- hcLight: '#f1dfde'
1336
- }, description: 'Exception widget background color.'
1337
- },
1338
- // Debug Icon colors should be aligned with
1339
- // https://code.visualstudio.com/api/references/theme-color#debug-icons-colors
1340
- {
1341
- id: 'debugIcon.breakpointForeground', defaults: {
1342
- dark: '#E51400',
1343
- light: '#E51400',
1344
- hcDark: '#E51400',
1345
- hcLight: '#E51400'
1346
- },
1347
- description: 'Icon color for breakpoints.'
1348
- },
1349
- {
1350
- id: 'debugIcon.breakpointDisabledForeground', defaults: {
1351
- dark: '#848484',
1352
- light: '#848484',
1353
- hcDark: '#848484',
1354
- hcLight: '#848484'
1355
- },
1356
- description: 'Icon color for disabled breakpoints.'
1357
- },
1358
- {
1359
- id: 'debugIcon.breakpointUnverifiedForeground', defaults: {
1360
- dark: '#848484',
1361
- light: '#848484',
1362
- hcDark: '#848484',
1363
- hcLight: '#848484'
1364
- },
1365
- description: 'Icon color for unverified breakpoints.'
1366
- },
1367
- {
1368
- id: 'debugIcon.breakpointCurrentStackframeForeground', defaults: {
1369
- dark: '#FFCC00',
1370
- light: '#BE8700',
1371
- hcDark: '#FFCC00',
1372
- hcLight: '#BE8700'
1373
- },
1374
- description: 'Icon color for the current breakpoint stack frame.'
1375
- },
1376
- {
1377
- id: 'debugIcon.breakpointStackframeForeground', defaults: {
1378
- dark: '#89D185',
1379
- light: '#89D185',
1380
- hcDark: '#89D185',
1381
- hcLight: '#89D185'
1382
- },
1383
- description: 'Icon color for all breakpoint stack frames.'
1384
- },
1385
- {
1386
- id: 'debugIcon.startForeground', defaults: {
1387
- dark: '#89D185',
1388
- light: '#388A34',
1389
- hcDark: '#89D185',
1390
- hcLight: '#388A34'
1391
- }, description: 'Debug toolbar icon for start debugging.'
1392
- },
1393
- {
1394
- id: 'debugIcon.pauseForeground', defaults: {
1395
- dark: '#75BEFF',
1396
- light: '#007ACC',
1397
- hcDark: '#75BEFF',
1398
- hcLight: '#007ACC'
1399
- }, description: 'Debug toolbar icon for pause.'
1400
- },
1401
- {
1402
- id: 'debugIcon.stopForeground', defaults: {
1403
- dark: '#F48771',
1404
- light: '#A1260D',
1405
- hcDark: '#F48771',
1406
- hcLight: '#A1260D'
1407
- }, description: 'Debug toolbar icon for stop.'
1408
- },
1409
- {
1410
- id: 'debugIcon.disconnectForeground', defaults: {
1411
- dark: '#F48771',
1412
- light: '#A1260D',
1413
- hcDark: '#F48771',
1414
- hcLight: '#A1260D'
1415
- }, description: 'Debug toolbar icon for disconnect.'
1416
- },
1417
- {
1418
- id: 'debugIcon.restartForeground', defaults: {
1419
- dark: '#89D185',
1420
- light: '#388A34',
1421
- hcDark: '#89D185',
1422
- hcLight: '#388A34'
1423
- }, description: 'Debug toolbar icon for restart.'
1424
- },
1425
- {
1426
- id: 'debugIcon.stepOverForeground', defaults: {
1427
- dark: '#75BEFF',
1428
- light: '#007ACC',
1429
- hcDark: '#75BEFF',
1430
- hcLight: '#007ACC',
1431
- }, description: 'Debug toolbar icon for step over.'
1432
- },
1433
- {
1434
- id: 'debugIcon.stepIntoForeground', defaults: {
1435
- dark: '#75BEFF',
1436
- light: '#007ACC',
1437
- hcDark: '#75BEFF',
1438
- hcLight: '#007ACC'
1439
- }, description: 'Debug toolbar icon for step into.'
1440
- },
1441
- {
1442
- id: 'debugIcon.stepOutForeground', defaults: {
1443
- dark: '#75BEFF',
1444
- light: '#007ACC',
1445
- hcDark: '#75BEFF',
1446
- hcLight: '#007ACC',
1447
- }, description: 'Debug toolbar icon for step over.'
1448
- },
1449
- {
1450
- id: 'debugIcon.continueForeground', defaults: {
1451
- dark: '#75BEFF',
1452
- light: '#007ACC',
1453
- hcDark: '#75BEFF',
1454
- hcLight: '#007ACC'
1455
- }, description: 'Debug toolbar icon for continue.'
1456
- },
1457
- {
1458
- id: 'debugIcon.stepBackForeground', defaults: {
1459
- dark: '#75BEFF',
1460
- light: '#007ACC',
1461
- hcDark: '#75BEFF',
1462
- hcLight: '#007ACC'
1463
- }, description: 'Debug toolbar icon for step back.'
1464
- },
1465
- {
1466
- id: 'debugConsole.infoForeground', defaults: {
1467
- dark: 'editorInfo.foreground',
1468
- light: 'editorInfo.foreground',
1469
- hcDark: 'foreground',
1470
- hcLight: 'foreground'
1471
- }, description: 'Foreground color for info messages in debug REPL console.'
1472
- },
1473
- {
1474
- id: 'debugConsole.warningForeground', defaults: {
1475
- dark: 'editorWarning.foreground',
1476
- light: 'editorWarning.foreground',
1477
- hcDark: '#008000',
1478
- hcLight: 'editorWarning.foreground'
1479
- },
1480
- description: 'Foreground color for warning messages in debug REPL console.'
1481
- },
1482
- {
1483
- id: 'debugConsole.errorForeground', defaults: {
1484
- dark: 'errorForeground',
1485
- light: 'errorForeground',
1486
- hcDark: 'errorForeground',
1487
- hcLight: 'errorForeground'
1488
- },
1489
- description: 'Foreground color for error messages in debug REPL console.',
1490
- },
1491
- {
1492
- id: 'debugConsole.sourceForeground', defaults: {
1493
- dark: 'foreground',
1494
- light: 'foreground',
1495
- hcDark: 'foreground',
1496
- hcLight: 'foreground'
1497
- },
1498
- description: 'Foreground color for source filenames in debug REPL console.',
1499
- },
1500
- {
1501
- id: 'debugConsoleInputIcon.foreground', defaults: {
1502
- dark: 'foreground',
1503
- light: 'foreground',
1504
- hcDark: 'foreground',
1505
- hcLight: 'foreground'
1506
- },
1507
- description: 'Foreground color for debug console input marker icon.'
1508
- }
1509
- );
1510
- }
1511
-
1512
- protected updateStatusBar(): void {
1513
- if (this.debuggingStatusBar === document.body.classList.contains('theia-mod-debugging')) {
1514
- return;
1515
- }
1516
- document.body.classList.toggle('theia-mod-debugging');
1517
- }
1518
-
1519
- protected get debuggingStatusBar(): boolean {
1520
- if (this.manager.state < DebugState.Running) {
1521
- return false;
1522
- }
1523
-
1524
- const session = this.manager.currentSession;
1525
- if (session) {
1526
- if (session.configuration.noDebug) {
1527
- return false;
1528
- }
1529
- if (this.getOption(session, 'suppressDebugStatusbar')) {
1530
- return false;
1531
- }
1532
- }
1533
-
1534
- return true;
1535
- }
1536
-
1537
- protected getOption(session: DebugSession | undefined, option: keyof {
1538
- [Property in keyof DebugConfiguration]: boolean;
1539
- }): boolean | undefined {
1540
- // If session is undefined there will be no option
1541
- if (!session) {
1542
- return false;
1543
- }
1544
- // If undefined take the value of the parent
1545
- if (option in session.configuration && session.configuration[option] !== undefined) {
1546
- return session.configuration[option];
1547
- }
1548
-
1549
- return this.getOption(session.parentSession, option);
1550
- }
1551
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 TypeFox 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import {
18
+ AbstractViewContribution, KeybindingRegistry, Widget, CompositeTreeNode, LabelProvider, codicon, OnWillStopAction, FrontendApplicationContribution, ConfirmDialog, Dialog
19
+ } from '@theia/core/lib/browser';
20
+ import { injectable, inject } from '@theia/core/shared/inversify';
21
+ import * as monaco from '@theia/monaco-editor-core';
22
+ import { MenuModelRegistry, CommandRegistry, MAIN_MENU_BAR, Command, Emitter, Mutable, CompoundMenuNodeRole } from '@theia/core/lib/common';
23
+ import { EDITOR_LINENUMBER_CONTEXT_MENU, EditorManager } from '@theia/editor/lib/browser';
24
+ import { DebugSessionManager } from './debug-session-manager';
25
+ import { DebugWidget } from './view/debug-widget';
26
+ import { FunctionBreakpoint } from './breakpoint/breakpoint-marker';
27
+ import { BreakpointManager } from './breakpoint/breakpoint-manager';
28
+ import { DebugConfigurationManager } from './debug-configuration-manager';
29
+ import { DebugState, DebugSession } from './debug-session';
30
+ import { DebugBreakpointsWidget } from './view/debug-breakpoints-widget';
31
+ import { DebugSourceBreakpoint } from './model/debug-source-breakpoint';
32
+ import { DebugThreadsWidget } from './view/debug-threads-widget';
33
+ import { DebugThread } from './model/debug-thread';
34
+ import { DebugStackFramesWidget } from './view/debug-stack-frames-widget';
35
+ import { DebugStackFrame } from './model/debug-stack-frame';
36
+ import { DebugVariablesWidget } from './view/debug-variables-widget';
37
+ import { DebugVariable } from './console/debug-console-items';
38
+ import { DebugSessionWidget } from './view/debug-session-widget';
39
+ import { DebugEditorModel } from './editor/debug-editor-model';
40
+ import { DebugEditorService } from './editor/debug-editor-service';
41
+ import { DebugConsoleContribution } from './console/debug-console-contribution';
42
+ import { DebugService } from '../common/debug-service';
43
+ import { DebugSchemaUpdater } from './debug-schema-updater';
44
+ import { DebugPreferences } from './debug-preferences';
45
+ import { TabBarToolbarContribution, TabBarToolbarRegistry, RenderedToolbarItem } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
46
+ import { DebugWatchWidget } from './view/debug-watch-widget';
47
+ import { DebugWatchExpression } from './view/debug-watch-expression';
48
+ import { DebugWatchManager } from './debug-watch-manager';
49
+ import { DebugSessionOptions } from './debug-session-options';
50
+ import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
51
+ import { ColorRegistry } from '@theia/core/lib/browser/color-registry';
52
+ import { DebugFunctionBreakpoint } from './model/debug-function-breakpoint';
53
+ import { DebugBreakpoint } from './model/debug-breakpoint';
54
+ import { nls } from '@theia/core/lib/common/nls';
55
+ import { DebugInstructionBreakpoint } from './model/debug-instruction-breakpoint';
56
+ import { DebugConfiguration } from '../common/debug-configuration';
57
+ import { DebugExceptionBreakpoint } from './view/debug-exception-breakpoint';
58
+
59
+ export namespace DebugMenus {
60
+ export const DEBUG = [...MAIN_MENU_BAR, '6_debug'];
61
+ export const DEBUG_CONTROLS = [...DEBUG, 'a_controls'];
62
+ export const DEBUG_CONFIGURATION = [...DEBUG, 'b_configuration'];
63
+ export const DEBUG_THREADS = [...DEBUG, 'c_threads'];
64
+ export const DEBUG_SESSIONS = [...DEBUG, 'd_sessions'];
65
+ export const DEBUG_BREAKPOINT = [...DEBUG, 'e_breakpoint'];
66
+ export const DEBUG_NEW_BREAKPOINT = [...DEBUG_BREAKPOINT, 'a_new_breakpoint'];
67
+ export const DEBUG_BREAKPOINTS = [...DEBUG, 'f_breakpoints'];
68
+ }
69
+
70
+ function nlsEditBreakpoint(breakpoint: string): string {
71
+ return nls.localizeByDefault('Edit {0}...', nls.localizeByDefault(breakpoint));
72
+ }
73
+
74
+ function nlsRemoveBreakpoint(breakpoint: string): string {
75
+ return nls.localizeByDefault('Remove {0}', nls.localizeByDefault(breakpoint));
76
+ }
77
+
78
+ function nlsEnableBreakpoint(breakpoint: string): string {
79
+ return nls.localizeByDefault('Enable {0}', nls.localizeByDefault(breakpoint));
80
+ }
81
+
82
+ function nlsDisableBreakpoint(breakpoint: string): string {
83
+ return nls.localizeByDefault('Disable {0}', nls.localizeByDefault(breakpoint));
84
+ }
85
+
86
+ export namespace DebugCommands {
87
+
88
+ export const DEBUG_CATEGORY = 'Debug';
89
+ export const DEBUG_CATEGORY_KEY = nls.getDefaultKey(DEBUG_CATEGORY);
90
+
91
+ export const START = Command.toDefaultLocalizedCommand({
92
+ id: 'workbench.action.debug.start',
93
+ category: DEBUG_CATEGORY,
94
+ label: 'Start Debugging',
95
+ iconClass: codicon('debug-alt')
96
+ });
97
+ export const START_NO_DEBUG = Command.toDefaultLocalizedCommand({
98
+ id: 'workbench.action.debug.run',
99
+ category: DEBUG_CATEGORY,
100
+ label: 'Start Without Debugging'
101
+ });
102
+ export const STOP = Command.toDefaultLocalizedCommand({
103
+ id: 'workbench.action.debug.stop',
104
+ category: DEBUG_CATEGORY,
105
+ label: 'Stop',
106
+ iconClass: codicon('debug-stop')
107
+ });
108
+ export const RESTART = Command.toDefaultLocalizedCommand({
109
+ id: 'workbench.action.debug.restart',
110
+ category: DEBUG_CATEGORY,
111
+ label: 'Restart',
112
+ });
113
+
114
+ export const OPEN_CONFIGURATIONS = Command.toDefaultLocalizedCommand({
115
+ id: 'debug.configurations.open',
116
+ category: DEBUG_CATEGORY,
117
+ label: 'Open Configurations'
118
+ });
119
+ export const ADD_CONFIGURATION = Command.toDefaultLocalizedCommand({
120
+ id: 'debug.configurations.add',
121
+ category: DEBUG_CATEGORY,
122
+ label: 'Add Configuration...'
123
+ });
124
+
125
+ export const STEP_OVER = Command.toDefaultLocalizedCommand({
126
+ id: 'workbench.action.debug.stepOver',
127
+ category: DEBUG_CATEGORY,
128
+ label: 'Step Over',
129
+ iconClass: codicon('debug-step-over')
130
+ });
131
+ export const STEP_INTO = Command.toDefaultLocalizedCommand({
132
+ id: 'workbench.action.debug.stepInto',
133
+ category: DEBUG_CATEGORY,
134
+ label: 'Step Into',
135
+ iconClass: codicon('debug-step-into')
136
+ });
137
+ export const STEP_OUT = Command.toDefaultLocalizedCommand({
138
+ id: 'workbench.action.debug.stepOut',
139
+ category: DEBUG_CATEGORY,
140
+ label: 'Step Out',
141
+ iconClass: codicon('debug-step-out')
142
+ });
143
+ export const CONTINUE = Command.toDefaultLocalizedCommand({
144
+ id: 'workbench.action.debug.continue',
145
+ category: DEBUG_CATEGORY,
146
+ label: 'Continue',
147
+ iconClass: codicon('debug-continue')
148
+ });
149
+ export const PAUSE = Command.toDefaultLocalizedCommand({
150
+ id: 'workbench.action.debug.pause',
151
+ category: DEBUG_CATEGORY,
152
+ label: 'Pause',
153
+ iconClass: codicon('debug-pause')
154
+ });
155
+ export const CONTINUE_ALL = Command.toLocalizedCommand({
156
+ id: 'debug.thread.continue.all',
157
+ category: DEBUG_CATEGORY,
158
+ label: 'Continue All',
159
+ iconClass: codicon('debug-continue')
160
+ }, 'theia/debug/continueAll', DEBUG_CATEGORY_KEY);
161
+ export const PAUSE_ALL = Command.toLocalizedCommand({
162
+ id: 'debug.thread.pause.all',
163
+ category: DEBUG_CATEGORY,
164
+ label: 'Pause All',
165
+ iconClass: codicon('debug-pause')
166
+ }, 'theia/debug/pauseAll', DEBUG_CATEGORY_KEY);
167
+
168
+ export const TOGGLE_BREAKPOINT = Command.toDefaultLocalizedCommand({
169
+ id: 'editor.debug.action.toggleBreakpoint',
170
+ category: DEBUG_CATEGORY,
171
+ label: 'Toggle Breakpoint',
172
+ });
173
+ export const INLINE_BREAKPOINT = Command.toDefaultLocalizedCommand({
174
+ id: 'editor.debug.action.inlineBreakpoint',
175
+ category: DEBUG_CATEGORY,
176
+ label: 'Inline Breakpoint',
177
+ });
178
+ export const ADD_CONDITIONAL_BREAKPOINT = Command.toDefaultLocalizedCommand({
179
+ id: 'debug.breakpoint.add.conditional',
180
+ category: DEBUG_CATEGORY,
181
+ label: 'Add Conditional Breakpoint...',
182
+ });
183
+ export const ADD_LOGPOINT = Command.toDefaultLocalizedCommand({
184
+ id: 'debug.breakpoint.add.logpoint',
185
+ category: DEBUG_CATEGORY,
186
+ label: 'Add Logpoint...',
187
+ });
188
+ export const ADD_FUNCTION_BREAKPOINT = Command.toDefaultLocalizedCommand({
189
+ id: 'debug.breakpoint.add.function',
190
+ category: DEBUG_CATEGORY,
191
+ label: 'Add Function Breakpoint',
192
+ });
193
+ export const ENABLE_ALL_BREAKPOINTS = Command.toDefaultLocalizedCommand({
194
+ id: 'debug.breakpoint.enableAll',
195
+ category: DEBUG_CATEGORY,
196
+ label: 'Enable All Breakpoints',
197
+ });
198
+ export const DISABLE_ALL_BREAKPOINTS = Command.toDefaultLocalizedCommand({
199
+ id: 'debug.breakpoint.disableAll',
200
+ category: DEBUG_CATEGORY,
201
+ label: 'Disable All Breakpoints',
202
+ });
203
+ export const EDIT_BREAKPOINT = Command.toLocalizedCommand({
204
+ id: 'debug.breakpoint.edit',
205
+ category: DEBUG_CATEGORY,
206
+ originalLabel: 'Edit Breakpoint...',
207
+ label: nlsEditBreakpoint('Breakpoint')
208
+ }, '', DEBUG_CATEGORY_KEY);
209
+ export const EDIT_LOGPOINT = Command.toLocalizedCommand({
210
+ id: 'debug.logpoint.edit',
211
+ category: DEBUG_CATEGORY,
212
+ originalLabel: 'Edit Logpoint...',
213
+ label: nlsEditBreakpoint('Logpoint')
214
+ }, '', DEBUG_CATEGORY_KEY);
215
+ export const EDIT_BREAKPOINT_CONDITION = Command.toLocalizedCommand({
216
+ id: 'debug.breakpoint.editCondition',
217
+ category: DEBUG_CATEGORY,
218
+ label: 'Edit Condition...'
219
+ }, '', DEBUG_CATEGORY_KEY);
220
+ export const REMOVE_BREAKPOINT = Command.toLocalizedCommand({
221
+ id: 'debug.breakpoint.remove',
222
+ category: DEBUG_CATEGORY,
223
+ originalLabel: 'Remove Breakpoint',
224
+ label: nlsRemoveBreakpoint('Breakpoint')
225
+ }, '', DEBUG_CATEGORY_KEY);
226
+ export const REMOVE_LOGPOINT = Command.toLocalizedCommand({
227
+ id: 'debug.logpoint.remove',
228
+ category: DEBUG_CATEGORY,
229
+ originalLabel: 'Remove Logpoint',
230
+ label: nlsRemoveBreakpoint('Logpoint')
231
+ }, '', DEBUG_CATEGORY_KEY);
232
+ export const REMOVE_ALL_BREAKPOINTS = Command.toDefaultLocalizedCommand({
233
+ id: 'debug.breakpoint.removeAll',
234
+ category: DEBUG_CATEGORY,
235
+ label: 'Remove All Breakpoints',
236
+ });
237
+ export const TOGGLE_BREAKPOINTS_ENABLED = Command.toLocalizedCommand({
238
+ id: 'debug.breakpoint.toggleEnabled'
239
+ });
240
+ export const SHOW_HOVER = Command.toDefaultLocalizedCommand({
241
+ id: 'editor.debug.action.showDebugHover',
242
+ label: 'Debug: Show Hover'
243
+ });
244
+
245
+ export const RESTART_FRAME = Command.toDefaultLocalizedCommand({
246
+ id: 'debug.frame.restart',
247
+ category: DEBUG_CATEGORY,
248
+ label: 'Restart Frame',
249
+ });
250
+ export const COPY_CALL_STACK = Command.toDefaultLocalizedCommand({
251
+ id: 'debug.callStack.copy',
252
+ category: DEBUG_CATEGORY,
253
+ label: 'Copy Call Stack',
254
+ });
255
+
256
+ export const SET_VARIABLE_VALUE = Command.toDefaultLocalizedCommand({
257
+ id: 'debug.variable.setValue',
258
+ category: DEBUG_CATEGORY,
259
+ label: 'Set Value',
260
+ });
261
+ export const COPY_VARIABLE_VALUE = Command.toDefaultLocalizedCommand({
262
+ id: 'debug.variable.copyValue',
263
+ category: DEBUG_CATEGORY,
264
+ label: 'Copy Value',
265
+ });
266
+ export const COPY_VARIABLE_AS_EXPRESSION = Command.toDefaultLocalizedCommand({
267
+ id: 'debug.variable.copyAsExpression',
268
+ category: DEBUG_CATEGORY,
269
+ label: 'Copy as Expression',
270
+ });
271
+ export const WATCH_VARIABLE = Command.toDefaultLocalizedCommand({
272
+ id: 'debug.variable.watch',
273
+ category: DEBUG_CATEGORY,
274
+ label: 'Add to Watch',
275
+ });
276
+
277
+ export const ADD_WATCH_EXPRESSION = Command.toDefaultLocalizedCommand({
278
+ id: 'debug.watch.addExpression',
279
+ category: DEBUG_CATEGORY,
280
+ label: 'Add Expression'
281
+ });
282
+ export const EDIT_WATCH_EXPRESSION = Command.toDefaultLocalizedCommand({
283
+ id: 'debug.watch.editExpression',
284
+ category: DEBUG_CATEGORY,
285
+ label: 'Edit Expression'
286
+ });
287
+ export const COPY_WATCH_EXPRESSION_VALUE = Command.toLocalizedCommand({
288
+ id: 'debug.watch.copyExpressionValue',
289
+ category: DEBUG_CATEGORY,
290
+ label: 'Copy Expression Value'
291
+ }, 'theia/debug/copyExpressionValue', DEBUG_CATEGORY_KEY);
292
+ export const REMOVE_WATCH_EXPRESSION = Command.toDefaultLocalizedCommand({
293
+ id: 'debug.watch.removeExpression',
294
+ category: DEBUG_CATEGORY,
295
+ label: 'Remove Expression'
296
+ });
297
+ export const COLLAPSE_ALL_WATCH_EXPRESSIONS = Command.toDefaultLocalizedCommand({
298
+ id: 'debug.watch.collapseAllExpressions',
299
+ category: DEBUG_CATEGORY,
300
+ label: 'Collapse All'
301
+ });
302
+ export const REMOVE_ALL_WATCH_EXPRESSIONS = Command.toDefaultLocalizedCommand({
303
+ id: 'debug.watch.removeAllExpressions',
304
+ category: DEBUG_CATEGORY,
305
+ label: 'Remove All Expressions'
306
+ });
307
+ }
308
+ export namespace DebugThreadContextCommands {
309
+ export const STEP_OVER = {
310
+ id: 'debug.thread.context.context.next'
311
+ };
312
+ export const STEP_INTO = {
313
+ id: 'debug.thread.context.stepin'
314
+ };
315
+ export const STEP_OUT = {
316
+ id: 'debug.thread.context.stepout'
317
+ };
318
+ export const CONTINUE = {
319
+ id: 'debug.thread.context.continue'
320
+ };
321
+ export const PAUSE = {
322
+ id: 'debug.thread.context.pause'
323
+ };
324
+ export const TERMINATE = {
325
+ id: 'debug.thread.context.terminate'
326
+ };
327
+ }
328
+ export namespace DebugSessionContextCommands {
329
+ export const STOP = {
330
+ id: 'debug.session.context.stop'
331
+ };
332
+ export const RESTART = {
333
+ id: 'debug.session.context.restart'
334
+ };
335
+ export const PAUSE_ALL = {
336
+ id: 'debug.session.context.pauseAll'
337
+ };
338
+ export const CONTINUE_ALL = {
339
+ id: 'debug.session.context.continueAll'
340
+ };
341
+ export const REVEAL = {
342
+ id: 'debug.session.context.reveal'
343
+ };
344
+ }
345
+ export namespace DebugEditorContextCommands {
346
+ export const ADD_BREAKPOINT = {
347
+ id: 'debug.editor.context.addBreakpoint'
348
+ };
349
+ export const ADD_CONDITIONAL_BREAKPOINT = {
350
+ id: 'debug.editor.context.addBreakpoint.conditional'
351
+ };
352
+ export const ADD_LOGPOINT = {
353
+ id: 'debug.editor.context.add.logpoint'
354
+ };
355
+ export const REMOVE_BREAKPOINT = {
356
+ id: 'debug.editor.context.removeBreakpoint'
357
+ };
358
+ export const EDIT_BREAKPOINT = {
359
+ id: 'debug.editor.context.edit.breakpoint'
360
+ };
361
+ export const ENABLE_BREAKPOINT = {
362
+ id: 'debug.editor.context.enableBreakpoint'
363
+ };
364
+ export const DISABLE_BREAKPOINT = {
365
+ id: 'debug.editor.context.disableBreakpoint'
366
+ };
367
+ export const REMOVE_LOGPOINT = {
368
+ id: 'debug.editor.context.logpoint.remove'
369
+ };
370
+ export const EDIT_LOGPOINT = {
371
+ id: 'debug.editor.context.logpoint.edit'
372
+ };
373
+ export const ENABLE_LOGPOINT = {
374
+ id: 'debug.editor.context.logpoint.enable'
375
+ };
376
+ export const DISABLE_LOGPOINT = {
377
+ id: 'debug.editor.context.logpoint.disable'
378
+ };
379
+ }
380
+ export namespace DebugBreakpointWidgetCommands {
381
+ export const ACCEPT = {
382
+ id: 'debug.breakpointWidget.accept'
383
+ };
384
+ export const CLOSE = {
385
+ id: 'debug.breakpointWidget.close'
386
+ };
387
+ }
388
+
389
+ @injectable()
390
+ export class DebugFrontendApplicationContribution extends AbstractViewContribution<DebugWidget>
391
+ implements TabBarToolbarContribution, ColorContribution, FrontendApplicationContribution {
392
+
393
+ @inject(DebugService)
394
+ protected readonly debug: DebugService;
395
+
396
+ @inject(DebugSessionManager)
397
+ protected readonly manager: DebugSessionManager;
398
+
399
+ @inject(DebugConfigurationManager)
400
+ protected readonly configurations: DebugConfigurationManager;
401
+
402
+ @inject(BreakpointManager)
403
+ protected readonly breakpointManager: BreakpointManager;
404
+
405
+ @inject(DebugEditorService)
406
+ protected readonly editors: DebugEditorService;
407
+
408
+ @inject(DebugConsoleContribution)
409
+ protected readonly console: DebugConsoleContribution;
410
+
411
+ @inject(DebugSchemaUpdater)
412
+ protected readonly schemaUpdater: DebugSchemaUpdater;
413
+
414
+ @inject(DebugPreferences)
415
+ protected readonly preference: DebugPreferences;
416
+
417
+ @inject(DebugWatchManager)
418
+ protected readonly watchManager: DebugWatchManager;
419
+
420
+ @inject(LabelProvider)
421
+ protected readonly labelProvider: LabelProvider;
422
+
423
+ @inject(EditorManager)
424
+ protected readonly editorManager: EditorManager;
425
+
426
+ constructor() {
427
+ super({
428
+ widgetId: DebugWidget.ID,
429
+ widgetName: DebugWidget.LABEL,
430
+ defaultWidgetOptions: {
431
+ area: 'left',
432
+ rank: 400
433
+ },
434
+ toggleCommandId: 'debug:toggle',
435
+ toggleKeybinding: 'ctrlcmd+shift+d'
436
+ });
437
+ }
438
+
439
+ async initializeLayout(): Promise<void> {
440
+ await this.openView();
441
+ }
442
+
443
+ protected firstSessionStart = true;
444
+ async onStart(): Promise<void> {
445
+ this.manager.onDidCreateDebugSession(session => this.openSession(session, { reveal: false }));
446
+ this.manager.onDidStartDebugSession(session => {
447
+ const { noDebug } = session.configuration;
448
+ const openDebug = session.configuration.openDebug || this.preference['debug.openDebug'];
449
+ const internalConsoleOptions = session.configuration.internalConsoleOptions || this.preference['debug.internalConsoleOptions'];
450
+ if (internalConsoleOptions === 'openOnSessionStart' ||
451
+ (internalConsoleOptions === 'openOnFirstSessionStart' && this.firstSessionStart)) {
452
+ this.console.openView({
453
+ reveal: true,
454
+ activate: false,
455
+ });
456
+ }
457
+ const shouldOpenDebug = openDebug === 'openOnSessionStart' || (openDebug === 'openOnFirstSessionStart' && this.firstSessionStart);
458
+ // Do not open debug view when suppressed via configuration
459
+ if (!noDebug && !this.getOption(session, 'suppressDebugView') && shouldOpenDebug) {
460
+ this.openSession(session);
461
+ }
462
+ this.firstSessionStart = false;
463
+ });
464
+ this.manager.onDidStopDebugSession(session => {
465
+ const { openDebug } = session.configuration;
466
+ if (!this.getOption(session, 'suppressDebugView') && openDebug === 'openOnDebugBreak') {
467
+ this.openSession(session);
468
+ }
469
+ });
470
+
471
+ this.updateStatusBar();
472
+ this.manager.onDidChange(() => this.updateStatusBar());
473
+
474
+ this.schemaUpdater.update();
475
+ this.configurations.load();
476
+ this.breakpointManager.load();
477
+ this.watchManager.load();
478
+ }
479
+
480
+ onStop(): void {
481
+ this.configurations.save();
482
+ this.breakpointManager.save();
483
+ this.watchManager.save();
484
+ }
485
+
486
+ onWillStop(): OnWillStopAction | undefined {
487
+ if (this.preference['debug.confirmOnExit'] === 'always' && this.manager.currentSession) {
488
+ return {
489
+ reason: 'active-debug-sessions',
490
+ action: async () => {
491
+ if (this.manager.currentSession) {
492
+ const msg = this.manager.sessions.length === 1
493
+ ? nls.localizeByDefault('There is an active debug session, are you sure you want to stop it?')
494
+ : nls.localizeByDefault('There are active debug sessions, are you sure you want to stop them?');
495
+ const safeToExit = await new ConfirmDialog({
496
+ title: '',
497
+ msg,
498
+ ok: nls.localizeByDefault('Stop Debugging'),
499
+ cancel: Dialog.CANCEL,
500
+ }).open();
501
+ return safeToExit === true;
502
+ }
503
+ return true;
504
+ },
505
+ };
506
+ }
507
+ }
508
+
509
+ override registerMenus(menus: MenuModelRegistry): void {
510
+ super.registerMenus(menus);
511
+ const registerMenuActions = (menuPath: string[], ...commands: Command[]) => {
512
+ for (const [index, command] of commands.entries()) {
513
+ const label = command.label;
514
+ const debug = `${DebugCommands.DEBUG_CATEGORY}:`;
515
+ menus.registerMenuAction(menuPath, {
516
+ commandId: command.id,
517
+ label: label && label.startsWith(debug) && label.slice(debug.length).trimStart() || label,
518
+ icon: command.iconClass,
519
+ order: String.fromCharCode('a'.charCodeAt(0) + index)
520
+ });
521
+ }
522
+ };
523
+
524
+ menus.registerSubmenu(DebugMenus.DEBUG, nls.localizeByDefault('Run'));
525
+ registerMenuActions(DebugMenus.DEBUG_CONTROLS,
526
+ DebugCommands.START,
527
+ DebugCommands.START_NO_DEBUG,
528
+ DebugCommands.STOP,
529
+ DebugCommands.RESTART
530
+ );
531
+ registerMenuActions(DebugMenus.DEBUG_CONFIGURATION,
532
+ DebugCommands.OPEN_CONFIGURATIONS,
533
+ DebugCommands.ADD_CONFIGURATION
534
+ );
535
+ registerMenuActions(DebugMenus.DEBUG_THREADS,
536
+ DebugCommands.CONTINUE,
537
+ DebugCommands.STEP_OVER,
538
+ DebugCommands.STEP_INTO,
539
+ DebugCommands.STEP_OUT,
540
+ DebugCommands.PAUSE
541
+ );
542
+ registerMenuActions(DebugMenus.DEBUG_SESSIONS,
543
+ DebugCommands.CONTINUE_ALL,
544
+ DebugCommands.PAUSE_ALL
545
+ );
546
+ registerMenuActions(DebugMenus.DEBUG_BREAKPOINT,
547
+ DebugCommands.TOGGLE_BREAKPOINT
548
+ );
549
+ menus.registerSubmenu(DebugMenus.DEBUG_NEW_BREAKPOINT, nls.localizeByDefault('New Breakpoint'));
550
+ registerMenuActions(DebugMenus.DEBUG_NEW_BREAKPOINT,
551
+ DebugCommands.ADD_CONDITIONAL_BREAKPOINT,
552
+ DebugCommands.INLINE_BREAKPOINT,
553
+ DebugCommands.ADD_FUNCTION_BREAKPOINT,
554
+ DebugCommands.ADD_LOGPOINT,
555
+ );
556
+ registerMenuActions(DebugMenus.DEBUG_BREAKPOINTS,
557
+ DebugCommands.ENABLE_ALL_BREAKPOINTS,
558
+ DebugCommands.DISABLE_ALL_BREAKPOINTS,
559
+ DebugCommands.REMOVE_ALL_BREAKPOINTS
560
+ );
561
+
562
+ registerMenuActions(DebugThreadsWidget.CONTROL_MENU,
563
+ { ...DebugCommands.PAUSE, ...DebugThreadContextCommands.PAUSE },
564
+ { ...DebugCommands.CONTINUE, ...DebugThreadContextCommands.CONTINUE },
565
+ { ...DebugCommands.STEP_OVER, ...DebugThreadContextCommands.STEP_OVER },
566
+ { ...DebugCommands.STEP_INTO, ...DebugThreadContextCommands.STEP_INTO },
567
+ { ...DebugCommands.STEP_OUT, ...DebugThreadContextCommands.STEP_OUT },
568
+ { ...DebugCommands.PAUSE_ALL, ...DebugSessionContextCommands.PAUSE_ALL },
569
+ { ...DebugCommands.CONTINUE_ALL, ...DebugSessionContextCommands.CONTINUE_ALL }
570
+ );
571
+ registerMenuActions(DebugThreadsWidget.TERMINATE_MENU,
572
+ { ...DebugCommands.RESTART, ...DebugSessionContextCommands.RESTART },
573
+ { ...DebugCommands.STOP, ...DebugSessionContextCommands.STOP },
574
+ { ...DebugThreadContextCommands.TERMINATE, label: nls.localizeByDefault('Terminate Thread') }
575
+ );
576
+ registerMenuActions(DebugThreadsWidget.OPEN_MENU, { ...DebugSessionContextCommands.REVEAL, label: nls.localize('theia/debug/reveal', 'Reveal') });
577
+
578
+ registerMenuActions(DebugStackFramesWidget.CONTEXT_MENU,
579
+ DebugCommands.RESTART_FRAME,
580
+ DebugCommands.COPY_CALL_STACK
581
+ );
582
+
583
+ registerMenuActions(DebugVariablesWidget.EDIT_MENU,
584
+ DebugCommands.SET_VARIABLE_VALUE,
585
+ DebugCommands.COPY_VARIABLE_VALUE,
586
+ DebugCommands.COPY_VARIABLE_AS_EXPRESSION
587
+ );
588
+ registerMenuActions(DebugVariablesWidget.WATCH_MENU,
589
+ DebugCommands.WATCH_VARIABLE
590
+ );
591
+
592
+ registerMenuActions(DebugWatchWidget.EDIT_MENU,
593
+ DebugCommands.EDIT_WATCH_EXPRESSION,
594
+ DebugCommands.COPY_WATCH_EXPRESSION_VALUE
595
+ );
596
+ registerMenuActions(DebugWatchWidget.REMOVE_MENU,
597
+ DebugCommands.REMOVE_WATCH_EXPRESSION,
598
+ DebugCommands.REMOVE_ALL_WATCH_EXPRESSIONS
599
+ );
600
+
601
+ registerMenuActions(DebugBreakpointsWidget.EDIT_MENU,
602
+ DebugCommands.EDIT_BREAKPOINT,
603
+ DebugCommands.EDIT_LOGPOINT,
604
+ DebugCommands.EDIT_BREAKPOINT_CONDITION
605
+ );
606
+ registerMenuActions(DebugBreakpointsWidget.REMOVE_MENU,
607
+ DebugCommands.REMOVE_BREAKPOINT,
608
+ DebugCommands.REMOVE_LOGPOINT,
609
+ DebugCommands.REMOVE_ALL_BREAKPOINTS
610
+ );
611
+ registerMenuActions(DebugBreakpointsWidget.ENABLE_MENU,
612
+ DebugCommands.ENABLE_ALL_BREAKPOINTS,
613
+ DebugCommands.DISABLE_ALL_BREAKPOINTS
614
+ );
615
+
616
+ registerMenuActions(DebugEditorModel.CONTEXT_MENU,
617
+ { ...DebugEditorContextCommands.ADD_BREAKPOINT, label: nls.localizeByDefault('Add Breakpoint') },
618
+ { ...DebugEditorContextCommands.ADD_CONDITIONAL_BREAKPOINT, label: DebugCommands.ADD_CONDITIONAL_BREAKPOINT.label },
619
+ { ...DebugEditorContextCommands.ADD_LOGPOINT, label: DebugCommands.ADD_LOGPOINT.label },
620
+ { ...DebugEditorContextCommands.REMOVE_BREAKPOINT, label: DebugCommands.REMOVE_BREAKPOINT.label },
621
+ { ...DebugEditorContextCommands.EDIT_BREAKPOINT, label: DebugCommands.EDIT_BREAKPOINT.label },
622
+ { ...DebugEditorContextCommands.ENABLE_BREAKPOINT, label: nlsEnableBreakpoint('Breakpoint') },
623
+ { ...DebugEditorContextCommands.DISABLE_BREAKPOINT, label: nlsDisableBreakpoint('Breakpoint') },
624
+ { ...DebugEditorContextCommands.REMOVE_LOGPOINT, label: DebugCommands.REMOVE_LOGPOINT.label },
625
+ { ...DebugEditorContextCommands.EDIT_LOGPOINT, label: DebugCommands.EDIT_LOGPOINT.label },
626
+ { ...DebugEditorContextCommands.ENABLE_LOGPOINT, label: nlsEnableBreakpoint('Logpoint') },
627
+ { ...DebugEditorContextCommands.DISABLE_LOGPOINT, label: nlsDisableBreakpoint('Logpoint') }
628
+ );
629
+ menus.linkSubmenu(EDITOR_LINENUMBER_CONTEXT_MENU, DebugEditorModel.CONTEXT_MENU, { role: CompoundMenuNodeRole.Group });
630
+ }
631
+
632
+ override registerCommands(registry: CommandRegistry): void {
633
+ super.registerCommands(registry);
634
+ registry.registerCommand(DebugCommands.START, {
635
+ execute: (config?: DebugSessionOptions) => this.start(false, config)
636
+ });
637
+ registry.registerCommand(DebugCommands.START_NO_DEBUG, {
638
+ execute: (config?: DebugSessionOptions) => this.start(true, config)
639
+ });
640
+ registry.registerCommand(DebugCommands.STOP, {
641
+ execute: () => this.manager.terminateSession(),
642
+ isEnabled: () => this.manager.state !== DebugState.Inactive
643
+ });
644
+ registry.registerCommand(DebugCommands.RESTART, {
645
+ execute: () => this.manager.restartSession(),
646
+ isEnabled: () => this.manager.state !== DebugState.Inactive
647
+ });
648
+
649
+ registry.registerCommand(DebugCommands.OPEN_CONFIGURATIONS, {
650
+ execute: () => this.configurations.openConfiguration()
651
+ });
652
+ registry.registerCommand(DebugCommands.ADD_CONFIGURATION, {
653
+ execute: () => this.configurations.addConfiguration()
654
+ });
655
+
656
+ registry.registerCommand(DebugCommands.STEP_OVER, {
657
+ execute: () => this.manager.currentThread && this.manager.currentThread.stepOver(),
658
+ isEnabled: () => this.manager.state === DebugState.Stopped
659
+ });
660
+ registry.registerCommand(DebugCommands.STEP_INTO, {
661
+ execute: () => this.manager.currentThread && this.manager.currentThread.stepIn(),
662
+ isEnabled: () => this.manager.state === DebugState.Stopped
663
+ });
664
+ registry.registerCommand(DebugCommands.STEP_OUT, {
665
+ execute: () => this.manager.currentThread && this.manager.currentThread.stepOut(),
666
+ isEnabled: () => this.manager.state === DebugState.Stopped
667
+ });
668
+ registry.registerCommand(DebugCommands.CONTINUE, {
669
+ execute: () => this.manager.currentThread && this.manager.currentThread.continue(),
670
+ isEnabled: () => this.manager.state === DebugState.Stopped
671
+ });
672
+ registry.registerCommand(DebugCommands.PAUSE, {
673
+ execute: () => this.manager.currentThread && this.manager.currentThread.pause(),
674
+ isEnabled: () => this.manager.state === DebugState.Running
675
+ });
676
+ registry.registerCommand(DebugCommands.PAUSE_ALL, {
677
+ execute: () => this.manager.currentSession && this.manager.currentSession.pauseAll(),
678
+ isEnabled: () => !!this.manager.currentSession && !!this.manager.currentSession.runningThreads.next().value
679
+ });
680
+ registry.registerCommand(DebugCommands.CONTINUE_ALL, {
681
+ execute: () => this.manager.currentSession && this.manager.currentSession.continueAll(),
682
+ isEnabled: () => !!this.manager.currentSession && !!this.manager.currentSession.stoppedThreads.next().value
683
+ });
684
+
685
+ registry.registerCommand(DebugThreadContextCommands.STEP_OVER, {
686
+ execute: () => this.selectedThread && this.selectedThread.stepOver(),
687
+ isEnabled: () => !!this.selectedThread && this.selectedThread.stopped,
688
+ isVisible: () => !!this.selectedThread
689
+ });
690
+ registry.registerCommand(DebugThreadContextCommands.STEP_INTO, {
691
+ execute: () => this.selectedThread && this.selectedThread.stepIn(),
692
+ isEnabled: () => !!this.selectedThread && this.selectedThread.stopped,
693
+ isVisible: () => !!this.selectedThread
694
+ });
695
+ registry.registerCommand(DebugThreadContextCommands.STEP_OUT, {
696
+ execute: () => this.selectedThread && this.selectedThread.stepOut(),
697
+ isEnabled: () => !!this.selectedThread && this.selectedThread.stopped,
698
+ isVisible: () => !!this.selectedThread
699
+ });
700
+ registry.registerCommand(DebugThreadContextCommands.CONTINUE, {
701
+ execute: () => this.selectedThread && this.selectedThread.continue(),
702
+ isEnabled: () => !!this.selectedThread && this.selectedThread.stopped,
703
+ isVisible: () => !!this.selectedThread && this.selectedThread.stopped,
704
+ });
705
+ registry.registerCommand(DebugThreadContextCommands.PAUSE, {
706
+ execute: () => this.selectedThread && this.selectedThread.pause(),
707
+ isEnabled: () => !!this.selectedThread && !this.selectedThread.stopped,
708
+ isVisible: () => !!this.selectedThread && !this.selectedThread.stopped,
709
+ });
710
+ registry.registerCommand(DebugThreadContextCommands.TERMINATE, {
711
+ execute: () => this.selectedThread && this.selectedThread.terminate(),
712
+ isEnabled: () => !!this.selectedThread && this.selectedThread.supportsTerminate,
713
+ isVisible: () => !!this.selectedThread && this.selectedThread.supportsTerminate
714
+ });
715
+
716
+ registry.registerCommand(DebugSessionContextCommands.STOP, {
717
+ execute: () => this.selectedSession && this.manager.terminateSession(this.selectedSession),
718
+ isEnabled: () => !!this.selectedSession && this.selectedSession.state !== DebugState.Inactive,
719
+ isVisible: () => !this.selectedThread
720
+ });
721
+ registry.registerCommand(DebugSessionContextCommands.RESTART, {
722
+ execute: () => this.selectedSession && this.manager.restartSession(this.selectedSession),
723
+ isEnabled: () => !!this.selectedSession && this.selectedSession.state !== DebugState.Inactive,
724
+ isVisible: () => !this.selectedThread
725
+ });
726
+ registry.registerCommand(DebugSessionContextCommands.CONTINUE_ALL, {
727
+ execute: () => this.selectedSession && this.selectedSession.continueAll(),
728
+ isEnabled: () => !!this.selectedSession && !!this.selectedSession.stoppedThreads.next().value,
729
+ isVisible: () => !this.selectedThread
730
+ });
731
+ registry.registerCommand(DebugSessionContextCommands.PAUSE_ALL, {
732
+ execute: () => this.selectedSession && this.selectedSession.pauseAll(),
733
+ isEnabled: () => !!this.selectedSession && !!this.selectedSession.runningThreads.next().value,
734
+ isVisible: () => !this.selectedThread
735
+ });
736
+ registry.registerCommand(DebugSessionContextCommands.REVEAL, {
737
+ execute: () => this.selectedSession && this.revealSession(this.selectedSession),
738
+ isEnabled: () => Boolean(this.selectedSession),
739
+ isVisible: () => !this.selectedThread && Boolean(this.selectedSession)
740
+ });
741
+ registry.registerCommand(DebugCommands.TOGGLE_BREAKPOINT, {
742
+ execute: () => this.editors.toggleBreakpoint(),
743
+ isEnabled: () => !!this.editors.model
744
+ });
745
+ registry.registerCommand(DebugCommands.INLINE_BREAKPOINT, {
746
+ execute: () => this.editors.addInlineBreakpoint(),
747
+ isEnabled: () => !!this.editors.model && !this.editors.getInlineBreakpoint()
748
+ });
749
+ registry.registerCommand(DebugCommands.ADD_CONDITIONAL_BREAKPOINT, {
750
+ execute: () => this.editors.addBreakpoint('condition'),
751
+ isEnabled: () => !!this.editors.model && !this.editors.anyBreakpoint()
752
+ });
753
+ registry.registerCommand(DebugCommands.ADD_LOGPOINT, {
754
+ execute: () => this.editors.addBreakpoint('logMessage'),
755
+ isEnabled: () => !!this.editors.model && !this.editors.anyBreakpoint()
756
+ });
757
+ registry.registerCommand(DebugCommands.ADD_FUNCTION_BREAKPOINT, {
758
+ execute: async () => {
759
+ const { labelProvider, breakpointManager, editorManager } = this;
760
+ const options = { labelProvider, breakpoints: breakpointManager, editorManager };
761
+ await new DebugFunctionBreakpoint(FunctionBreakpoint.create({ name: '' }), options).open();
762
+ },
763
+ isEnabled: widget => !(widget instanceof Widget) || widget instanceof DebugBreakpointsWidget,
764
+ isVisible: widget => !(widget instanceof Widget) || widget instanceof DebugBreakpointsWidget
765
+ });
766
+ registry.registerCommand(DebugCommands.ENABLE_ALL_BREAKPOINTS, {
767
+ execute: () => this.breakpointManager.enableAllBreakpoints(true),
768
+ isEnabled: () => this.breakpointManager.hasBreakpoints()
769
+ });
770
+ registry.registerCommand(DebugCommands.DISABLE_ALL_BREAKPOINTS, {
771
+ execute: () => this.breakpointManager.enableAllBreakpoints(false),
772
+ isEnabled: () => this.breakpointManager.hasBreakpoints()
773
+ });
774
+ registry.registerCommand(DebugCommands.EDIT_BREAKPOINT, {
775
+ execute: async () => {
776
+ const { selectedBreakpoint, selectedFunctionBreakpoint } = this;
777
+ if (selectedBreakpoint) {
778
+ await this.editors.editBreakpoint(selectedBreakpoint);
779
+ } else if (selectedFunctionBreakpoint) {
780
+ await selectedFunctionBreakpoint.open();
781
+ }
782
+ },
783
+ isEnabled: () => !!this.selectedBreakpoint || !!this.selectedFunctionBreakpoint,
784
+ isVisible: () => !!this.selectedBreakpoint || !!this.selectedFunctionBreakpoint
785
+ });
786
+ registry.registerCommand(DebugCommands.EDIT_LOGPOINT, {
787
+ execute: async () => {
788
+ const { selectedLogpoint } = this;
789
+ if (selectedLogpoint) {
790
+ await this.editors.editBreakpoint(selectedLogpoint);
791
+ }
792
+ },
793
+ isEnabled: () => !!this.selectedLogpoint,
794
+ isVisible: () => !!this.selectedLogpoint
795
+ });
796
+ registry.registerCommand(DebugCommands.EDIT_BREAKPOINT_CONDITION, {
797
+ execute: async () => {
798
+ const { selectedExceptionBreakpoint } = this;
799
+ if (selectedExceptionBreakpoint) {
800
+ await selectedExceptionBreakpoint.editCondition();
801
+ }
802
+ },
803
+ isEnabled: () => !!this.selectedExceptionBreakpoint?.data.raw.supportsCondition,
804
+ isVisible: () => !!this.selectedExceptionBreakpoint?.data.raw.supportsCondition
805
+ });
806
+ registry.registerCommand(DebugCommands.REMOVE_BREAKPOINT, {
807
+ execute: () => {
808
+ const selectedBreakpoint = this.selectedSettableBreakpoint;
809
+ if (selectedBreakpoint) {
810
+ selectedBreakpoint.remove();
811
+ }
812
+ },
813
+ isEnabled: () => Boolean(this.selectedSettableBreakpoint),
814
+ isVisible: () => Boolean(this.selectedSettableBreakpoint),
815
+ });
816
+ registry.registerCommand(DebugCommands.REMOVE_LOGPOINT, {
817
+ execute: () => {
818
+ const { selectedLogpoint } = this;
819
+ if (selectedLogpoint) {
820
+ selectedLogpoint.remove();
821
+ }
822
+ },
823
+ isEnabled: () => !!this.selectedLogpoint,
824
+ isVisible: () => !!this.selectedLogpoint
825
+ });
826
+ registry.registerCommand(DebugCommands.REMOVE_ALL_BREAKPOINTS, {
827
+ execute: () => this.breakpointManager.removeBreakpoints(),
828
+ isEnabled: () => this.breakpointManager.hasBreakpoints(),
829
+ isVisible: widget => !(widget instanceof Widget) || (widget instanceof DebugBreakpointsWidget)
830
+ });
831
+ registry.registerCommand(DebugCommands.TOGGLE_BREAKPOINTS_ENABLED, {
832
+ execute: () => this.breakpointManager.breakpointsEnabled = !this.breakpointManager.breakpointsEnabled,
833
+ isVisible: arg => arg instanceof DebugBreakpointsWidget
834
+ });
835
+ registry.registerCommand(DebugCommands.SHOW_HOVER, {
836
+ execute: () => this.editors.showHover(),
837
+ isEnabled: () => this.editors.canShowHover()
838
+ });
839
+
840
+ registry.registerCommand(DebugCommands.RESTART_FRAME, {
841
+ execute: () => this.selectedFrame && this.selectedFrame.restart(),
842
+ isEnabled: () => !!this.selectedFrame
843
+ });
844
+ registry.registerCommand(DebugCommands.COPY_CALL_STACK, {
845
+ execute: () => {
846
+ const { frames } = this;
847
+ const selection = document.getSelection();
848
+ if (frames && selection) {
849
+ selection.selectAllChildren(frames.node);
850
+ document.execCommand('copy');
851
+ }
852
+ },
853
+ isEnabled: () => document.queryCommandSupported('copy'),
854
+ isVisible: () => document.queryCommandSupported('copy')
855
+ });
856
+
857
+ registry.registerCommand(DebugCommands.SET_VARIABLE_VALUE, {
858
+ execute: () => this.selectedVariable && this.selectedVariable.open(),
859
+ isEnabled: () => !!this.selectedVariable && this.selectedVariable.supportSetVariable,
860
+ isVisible: () => !!this.selectedVariable && this.selectedVariable.supportSetVariable
861
+ });
862
+ registry.registerCommand(DebugCommands.COPY_VARIABLE_VALUE, {
863
+ execute: () => this.selectedVariable && this.selectedVariable.copyValue(),
864
+ isEnabled: () => !!this.selectedVariable && this.selectedVariable.supportCopyValue,
865
+ isVisible: () => !!this.selectedVariable && this.selectedVariable.supportCopyValue
866
+ });
867
+ registry.registerCommand(DebugCommands.COPY_VARIABLE_AS_EXPRESSION, {
868
+ execute: () => this.selectedVariable && this.selectedVariable.copyAsExpression(),
869
+ isEnabled: () => !!this.selectedVariable && this.selectedVariable.supportCopyAsExpression,
870
+ isVisible: () => !!this.selectedVariable && this.selectedVariable.supportCopyAsExpression
871
+ });
872
+ registry.registerCommand(DebugCommands.WATCH_VARIABLE, {
873
+ execute: () => {
874
+ const { selectedVariable, watch } = this;
875
+ if (selectedVariable && watch) {
876
+ watch.viewModel.addWatchExpression(selectedVariable.name);
877
+ }
878
+ },
879
+ isEnabled: () => !!this.selectedVariable && !!this.watch,
880
+ isVisible: () => !!this.selectedVariable && !!this.watch,
881
+ });
882
+
883
+ // Debug context menu commands
884
+ registry.registerCommand(DebugEditorContextCommands.ADD_BREAKPOINT, {
885
+ execute: position => this.isPosition(position) && this.editors.toggleBreakpoint(this.asPosition(position)),
886
+ isEnabled: position => this.isPosition(position) && !this.editors.anyBreakpoint(this.asPosition(position)),
887
+ isVisible: position => this.isPosition(position) && !this.editors.anyBreakpoint(this.asPosition(position))
888
+ });
889
+ registry.registerCommand(DebugEditorContextCommands.ADD_CONDITIONAL_BREAKPOINT, {
890
+ execute: position => this.isPosition(position) && this.editors.addBreakpoint('condition', this.asPosition(position)),
891
+ isEnabled: position => this.isPosition(position) && !this.editors.anyBreakpoint(this.asPosition(position)),
892
+ isVisible: position => this.isPosition(position) && !this.editors.anyBreakpoint(this.asPosition(position))
893
+ });
894
+ registry.registerCommand(DebugEditorContextCommands.ADD_LOGPOINT, {
895
+ execute: position => this.isPosition(position) && this.editors.addBreakpoint('logMessage', this.asPosition(position)),
896
+ isEnabled: position => this.isPosition(position) && !this.editors.anyBreakpoint(this.asPosition(position)),
897
+ isVisible: position => this.isPosition(position) && !this.editors.anyBreakpoint(this.asPosition(position))
898
+ });
899
+ registry.registerCommand(DebugEditorContextCommands.REMOVE_BREAKPOINT, {
900
+ execute: position => this.isPosition(position) && this.editors.toggleBreakpoint(this.asPosition(position)),
901
+ isEnabled: position => this.isPosition(position) && !!this.editors.getBreakpoint(this.asPosition(position)),
902
+ isVisible: position => this.isPosition(position) && !!this.editors.getBreakpoint(this.asPosition(position))
903
+ });
904
+ registry.registerCommand(DebugEditorContextCommands.EDIT_BREAKPOINT, {
905
+ execute: position => this.isPosition(position) && this.editors.editBreakpoint(this.asPosition(position)),
906
+ isEnabled: position => this.isPosition(position) && !!this.editors.getBreakpoint(this.asPosition(position)),
907
+ isVisible: position => this.isPosition(position) && !!this.editors.getBreakpoint(this.asPosition(position))
908
+ });
909
+ registry.registerCommand(DebugEditorContextCommands.ENABLE_BREAKPOINT, {
910
+ execute: position => this.isPosition(position) && this.editors.setBreakpointEnabled(this.asPosition(position), true),
911
+ isEnabled: position => this.isPosition(position) && this.editors.getBreakpointEnabled(this.asPosition(position)) === false,
912
+ isVisible: position => this.isPosition(position) && this.editors.getBreakpointEnabled(this.asPosition(position)) === false
913
+ });
914
+ registry.registerCommand(DebugEditorContextCommands.DISABLE_BREAKPOINT, {
915
+ execute: position => this.isPosition(position) && this.editors.setBreakpointEnabled(this.asPosition(position), false),
916
+ isEnabled: position => this.isPosition(position) && !!this.editors.getBreakpointEnabled(this.asPosition(position)),
917
+ isVisible: position => this.isPosition(position) && !!this.editors.getBreakpointEnabled(this.asPosition(position))
918
+ });
919
+ registry.registerCommand(DebugEditorContextCommands.REMOVE_LOGPOINT, {
920
+ execute: position => this.isPosition(position) && this.editors.toggleBreakpoint(this.asPosition(position)),
921
+ isEnabled: position => this.isPosition(position) && !!this.editors.getLogpoint(this.asPosition(position)),
922
+ isVisible: position => this.isPosition(position) && !!this.editors.getLogpoint(this.asPosition(position))
923
+ });
924
+ registry.registerCommand(DebugEditorContextCommands.EDIT_LOGPOINT, {
925
+ execute: position => this.isPosition(position) && this.editors.editBreakpoint(this.asPosition(position)),
926
+ isEnabled: position => this.isPosition(position) && !!this.editors.getLogpoint(this.asPosition(position)),
927
+ isVisible: position => this.isPosition(position) && !!this.editors.getLogpoint(this.asPosition(position))
928
+ });
929
+ registry.registerCommand(DebugEditorContextCommands.ENABLE_LOGPOINT, {
930
+ execute: position => this.isPosition(position) && this.editors.setBreakpointEnabled(this.asPosition(position), true),
931
+ isEnabled: position => this.isPosition(position) && this.editors.getLogpointEnabled(this.asPosition(position)) === false,
932
+ isVisible: position => this.isPosition(position) && this.editors.getLogpointEnabled(this.asPosition(position)) === false
933
+ });
934
+ registry.registerCommand(DebugEditorContextCommands.DISABLE_LOGPOINT, {
935
+ execute: position => this.isPosition(position) && this.editors.setBreakpointEnabled(this.asPosition(position), false),
936
+ isEnabled: position => this.isPosition(position) && !!this.editors.getLogpointEnabled(this.asPosition(position)),
937
+ isVisible: position => this.isPosition(position) && !!this.editors.getLogpointEnabled(this.asPosition(position))
938
+ });
939
+
940
+ registry.registerCommand(DebugBreakpointWidgetCommands.ACCEPT, {
941
+ execute: () => this.editors.acceptBreakpoint()
942
+ });
943
+ registry.registerCommand(DebugBreakpointWidgetCommands.CLOSE, {
944
+ execute: () => this.editors.closeBreakpoint()
945
+ });
946
+
947
+ registry.registerCommand(DebugCommands.ADD_WATCH_EXPRESSION, {
948
+ execute: widget => {
949
+ if (widget instanceof Widget) {
950
+ if (widget instanceof DebugWatchWidget) {
951
+ widget.viewModel.addWatchExpression();
952
+ }
953
+ } else if (this.watch) {
954
+ this.watch.viewModel.addWatchExpression();
955
+ }
956
+ },
957
+ isEnabled: widget => widget instanceof Widget ? widget instanceof DebugWatchWidget : !!this.watch,
958
+ isVisible: widget => widget instanceof Widget ? widget instanceof DebugWatchWidget : !!this.watch
959
+ });
960
+ registry.registerCommand(DebugCommands.EDIT_WATCH_EXPRESSION, {
961
+ execute: () => {
962
+ const { watchExpression } = this;
963
+ if (watchExpression) {
964
+ watchExpression.open();
965
+ }
966
+ },
967
+ isEnabled: () => !!this.watchExpression,
968
+ isVisible: () => !!this.watchExpression
969
+ });
970
+ registry.registerCommand(DebugCommands.COPY_WATCH_EXPRESSION_VALUE, {
971
+ execute: () => this.watchExpression && this.watchExpression.copyValue(),
972
+ isEnabled: () => !!this.watchExpression && this.watchExpression.supportCopyValue,
973
+ isVisible: () => !!this.watchExpression && this.watchExpression.supportCopyValue
974
+ });
975
+ registry.registerCommand(DebugCommands.COLLAPSE_ALL_WATCH_EXPRESSIONS, {
976
+ execute: widget => {
977
+ if (widget instanceof DebugWatchWidget) {
978
+ const root = widget.model.root;
979
+ widget.model.collapseAll(CompositeTreeNode.is(root) ? root : undefined);
980
+ }
981
+ },
982
+ isEnabled: widget => widget instanceof DebugWatchWidget,
983
+ isVisible: widget => widget instanceof DebugWatchWidget
984
+ });
985
+ registry.registerCommand(DebugCommands.REMOVE_WATCH_EXPRESSION, {
986
+ execute: () => {
987
+ const { watch, watchExpression } = this;
988
+ if (watch && watchExpression) {
989
+ watch.viewModel.removeWatchExpression(watchExpression);
990
+ }
991
+ },
992
+ isEnabled: () => !!this.watchExpression,
993
+ isVisible: () => !!this.watchExpression
994
+ });
995
+ registry.registerCommand(DebugCommands.REMOVE_ALL_WATCH_EXPRESSIONS, {
996
+ execute: widget => {
997
+ if (widget instanceof Widget) {
998
+ if (widget instanceof DebugWatchWidget) {
999
+ widget.viewModel.removeWatchExpressions();
1000
+ }
1001
+ } else if (this.watch) {
1002
+ this.watch.viewModel.removeWatchExpressions();
1003
+ }
1004
+ },
1005
+ isEnabled: widget => widget instanceof Widget ? widget instanceof DebugWatchWidget : !!this.watch,
1006
+ isVisible: widget => widget instanceof Widget ? widget instanceof DebugWatchWidget : !!this.watch
1007
+ });
1008
+ }
1009
+
1010
+ override registerKeybindings(keybindings: KeybindingRegistry): void {
1011
+ super.registerKeybindings(keybindings);
1012
+ keybindings.registerKeybinding({
1013
+ command: DebugCommands.START.id,
1014
+ keybinding: 'f5'
1015
+ });
1016
+ keybindings.registerKeybinding({
1017
+ command: DebugCommands.START_NO_DEBUG.id,
1018
+ keybinding: 'ctrl+f5'
1019
+ });
1020
+ keybindings.registerKeybinding({
1021
+ command: DebugCommands.STOP.id,
1022
+ keybinding: 'shift+f5',
1023
+ when: 'inDebugMode'
1024
+ });
1025
+
1026
+ keybindings.registerKeybinding({
1027
+ command: DebugCommands.RESTART.id,
1028
+ keybinding: 'shift+ctrlcmd+f5',
1029
+ when: 'inDebugMode'
1030
+ });
1031
+ keybindings.registerKeybinding({
1032
+ command: DebugCommands.STEP_OVER.id,
1033
+ keybinding: 'f10',
1034
+ when: 'inDebugMode'
1035
+ });
1036
+ keybindings.registerKeybinding({
1037
+ command: DebugCommands.STEP_INTO.id,
1038
+ keybinding: 'f11',
1039
+ when: 'inDebugMode'
1040
+ });
1041
+ keybindings.registerKeybinding({
1042
+ command: DebugCommands.STEP_OUT.id,
1043
+ keybinding: 'shift+f11',
1044
+ when: 'inDebugMode'
1045
+ });
1046
+ keybindings.registerKeybinding({
1047
+ command: DebugCommands.CONTINUE.id,
1048
+ keybinding: 'f5',
1049
+ when: 'inDebugMode'
1050
+ });
1051
+ keybindings.registerKeybinding({
1052
+ command: DebugCommands.PAUSE.id,
1053
+ keybinding: 'f6',
1054
+ when: 'inDebugMode'
1055
+ });
1056
+
1057
+ keybindings.registerKeybinding({
1058
+ command: DebugCommands.TOGGLE_BREAKPOINT.id,
1059
+ keybinding: 'f9',
1060
+ when: 'editorTextFocus'
1061
+ });
1062
+ keybindings.registerKeybinding({
1063
+ command: DebugCommands.INLINE_BREAKPOINT.id,
1064
+ keybinding: 'shift+f9',
1065
+ when: 'editorTextFocus'
1066
+ });
1067
+
1068
+ keybindings.registerKeybinding({
1069
+ command: DebugBreakpointWidgetCommands.ACCEPT.id,
1070
+ keybinding: 'enter',
1071
+ when: 'breakpointWidgetFocus'
1072
+ });
1073
+ keybindings.registerKeybinding({
1074
+ command: DebugBreakpointWidgetCommands.CLOSE.id,
1075
+ keybinding: 'esc',
1076
+ when: 'isBreakpointWidgetVisible || breakpointWidgetFocus'
1077
+ });
1078
+ }
1079
+
1080
+ registerToolbarItems(toolbar: TabBarToolbarRegistry): void {
1081
+ const onDidChangeToggleBreakpointsEnabled = new Emitter<void>();
1082
+ const toggleBreakpointsEnabled: Mutable<RenderedToolbarItem> = {
1083
+ id: DebugCommands.TOGGLE_BREAKPOINTS_ENABLED.id,
1084
+ command: DebugCommands.TOGGLE_BREAKPOINTS_ENABLED.id,
1085
+ icon: codicon('activate-breakpoints'),
1086
+ onDidChange: onDidChangeToggleBreakpointsEnabled.event,
1087
+ priority: 1
1088
+ };
1089
+ const updateToggleBreakpointsEnabled = () => {
1090
+ const activateBreakpoints = nls.localizeByDefault('Enable All Breakpoints');
1091
+ const deactivateBreakpoints = nls.localizeByDefault('Disable All Breakpoints');
1092
+ const tooltip = this.breakpointManager.breakpointsEnabled ? deactivateBreakpoints : activateBreakpoints;
1093
+ if (toggleBreakpointsEnabled.tooltip !== tooltip) {
1094
+ toggleBreakpointsEnabled.tooltip = tooltip;
1095
+ onDidChangeToggleBreakpointsEnabled.fire(undefined);
1096
+ }
1097
+ };
1098
+ toolbar.registerItem({
1099
+ id: DebugCommands.ADD_FUNCTION_BREAKPOINT.id,
1100
+ command: DebugCommands.ADD_FUNCTION_BREAKPOINT.id,
1101
+ icon: codicon('add'),
1102
+ tooltip: DebugCommands.ADD_FUNCTION_BREAKPOINT.label
1103
+ });
1104
+ updateToggleBreakpointsEnabled();
1105
+ this.breakpointManager.onDidChangeBreakpoints(updateToggleBreakpointsEnabled);
1106
+ toolbar.registerItem(toggleBreakpointsEnabled);
1107
+ toolbar.registerItem({
1108
+ id: DebugCommands.REMOVE_ALL_BREAKPOINTS.id,
1109
+ command: DebugCommands.REMOVE_ALL_BREAKPOINTS.id,
1110
+ icon: codicon('close-all'),
1111
+ priority: 2
1112
+ });
1113
+
1114
+ toolbar.registerItem({
1115
+ id: DebugCommands.ADD_WATCH_EXPRESSION.id,
1116
+ command: DebugCommands.ADD_WATCH_EXPRESSION.id,
1117
+ icon: codicon('add'),
1118
+ tooltip: DebugCommands.ADD_WATCH_EXPRESSION.label
1119
+ });
1120
+ toolbar.registerItem({
1121
+ id: DebugCommands.COLLAPSE_ALL_WATCH_EXPRESSIONS.id,
1122
+ command: DebugCommands.COLLAPSE_ALL_WATCH_EXPRESSIONS.id,
1123
+ icon: codicon('collapse-all'),
1124
+ tooltip: DebugCommands.COLLAPSE_ALL_WATCH_EXPRESSIONS.label,
1125
+ priority: 1
1126
+ });
1127
+ toolbar.registerItem({
1128
+ id: DebugCommands.REMOVE_ALL_WATCH_EXPRESSIONS.id,
1129
+ command: DebugCommands.REMOVE_ALL_WATCH_EXPRESSIONS.id,
1130
+ icon: codicon('close-all'),
1131
+ tooltip: DebugCommands.REMOVE_ALL_WATCH_EXPRESSIONS.label,
1132
+ priority: 2
1133
+ });
1134
+ }
1135
+
1136
+ protected async openSession(
1137
+ session: DebugSession,
1138
+ options?: {
1139
+ reveal?: boolean;
1140
+ }
1141
+ ): Promise<DebugWidget | DebugSessionWidget> {
1142
+ const { reveal } = {
1143
+ reveal: true,
1144
+ ...options
1145
+ };
1146
+ const debugWidget = await this.openView({ reveal });
1147
+ debugWidget.sessionManager.currentSession = session;
1148
+ return debugWidget['sessionWidget'];
1149
+ }
1150
+
1151
+ protected revealSession(session: DebugSession): DebugSessionWidget | undefined {
1152
+ const widget = this.tryGetWidget()?.['sessionWidget'];
1153
+ if (widget) {
1154
+ this.shell.revealWidget(widget.id);
1155
+ }
1156
+ return widget;
1157
+ }
1158
+
1159
+ async start(noDebug?: boolean, debugSessionOptions?: DebugSessionOptions): Promise<void> {
1160
+ let current = debugSessionOptions ? debugSessionOptions : this.configurations.current;
1161
+ // If no configurations are currently present, create the `launch.json` and prompt users to select the config.
1162
+ if (!current) {
1163
+ await this.configurations.addConfiguration();
1164
+ return;
1165
+ }
1166
+
1167
+ if (noDebug !== undefined) {
1168
+ if (current.configuration) {
1169
+ current = {
1170
+ ...current,
1171
+ configuration: {
1172
+ ...current.configuration,
1173
+ noDebug
1174
+ }
1175
+ };
1176
+ } else {
1177
+ current = {
1178
+ ...current,
1179
+ noDebug
1180
+ };
1181
+ }
1182
+ }
1183
+
1184
+ await this.manager.start(current);
1185
+ }
1186
+
1187
+ get threads(): DebugThreadsWidget | undefined {
1188
+ const { currentWidget } = this.shell;
1189
+ return currentWidget instanceof DebugThreadsWidget && currentWidget || undefined;
1190
+ }
1191
+ get selectedSession(): DebugSession | undefined {
1192
+ const { threads } = this;
1193
+ return threads && threads.selectedElement instanceof DebugSession && threads.selectedElement || undefined;
1194
+ }
1195
+ get selectedThread(): DebugThread | undefined {
1196
+ const { threads } = this;
1197
+ return threads && threads.selectedElement instanceof DebugThread && threads.selectedElement || undefined;
1198
+ }
1199
+
1200
+ get frames(): DebugStackFramesWidget | undefined {
1201
+ const { currentWidget } = this.shell;
1202
+ return currentWidget instanceof DebugStackFramesWidget && currentWidget || undefined;
1203
+ }
1204
+ get selectedFrame(): DebugStackFrame | undefined {
1205
+ const { frames } = this;
1206
+ return frames && frames.selectedElement instanceof DebugStackFrame && frames.selectedElement || undefined;
1207
+ }
1208
+
1209
+ get breakpoints(): DebugBreakpointsWidget | undefined {
1210
+ const { currentWidget } = this.shell;
1211
+ return currentWidget instanceof DebugBreakpointsWidget && currentWidget || undefined;
1212
+ }
1213
+ get selectedAnyBreakpoint(): DebugBreakpoint | undefined {
1214
+ const { breakpoints } = this;
1215
+ const selectedElement = breakpoints && breakpoints.selectedElement;
1216
+ return selectedElement instanceof DebugBreakpoint ? selectedElement : undefined;
1217
+ }
1218
+ get selectedBreakpoint(): DebugSourceBreakpoint | undefined {
1219
+ const breakpoint = this.selectedAnyBreakpoint;
1220
+ return breakpoint && breakpoint instanceof DebugSourceBreakpoint && !breakpoint.logMessage ? breakpoint : undefined;
1221
+ }
1222
+ get selectedLogpoint(): DebugSourceBreakpoint | undefined {
1223
+ const breakpoint = this.selectedAnyBreakpoint;
1224
+ return breakpoint && breakpoint instanceof DebugSourceBreakpoint && !!breakpoint.logMessage ? breakpoint : undefined;
1225
+ }
1226
+ get selectedFunctionBreakpoint(): DebugFunctionBreakpoint | undefined {
1227
+ const breakpoint = this.selectedAnyBreakpoint;
1228
+ return breakpoint && breakpoint instanceof DebugFunctionBreakpoint ? breakpoint : undefined;
1229
+ }
1230
+ get selectedInstructionBreakpoint(): DebugInstructionBreakpoint | undefined {
1231
+ if (this.selectedAnyBreakpoint instanceof DebugInstructionBreakpoint) {
1232
+ return this.selectedAnyBreakpoint;
1233
+ }
1234
+ }
1235
+ get selectedExceptionBreakpoint(): DebugExceptionBreakpoint | undefined {
1236
+ const { breakpoints } = this;
1237
+ const selectedElement = breakpoints && breakpoints.selectedElement;
1238
+ return selectedElement instanceof DebugExceptionBreakpoint ? selectedElement : undefined;
1239
+ }
1240
+
1241
+ get selectedSettableBreakpoint(): DebugFunctionBreakpoint | DebugInstructionBreakpoint | DebugSourceBreakpoint | undefined {
1242
+ const selected = this.selectedAnyBreakpoint;
1243
+ if (selected instanceof DebugFunctionBreakpoint || selected instanceof DebugInstructionBreakpoint || selected instanceof DebugSourceBreakpoint) {
1244
+ return selected;
1245
+ }
1246
+ }
1247
+
1248
+ get variables(): DebugVariablesWidget | undefined {
1249
+ const { currentWidget } = this.shell;
1250
+ return currentWidget instanceof DebugVariablesWidget && currentWidget || undefined;
1251
+ }
1252
+ get selectedVariable(): DebugVariable | undefined {
1253
+ const { variables } = this;
1254
+ return variables && variables.selectedElement instanceof DebugVariable && variables.selectedElement || undefined;
1255
+ }
1256
+
1257
+ get watch(): DebugWatchWidget | undefined {
1258
+ const { currentWidget } = this.shell;
1259
+ return currentWidget instanceof DebugWatchWidget && currentWidget || undefined;
1260
+ }
1261
+ get watchExpression(): DebugWatchExpression | undefined {
1262
+ const { watch } = this;
1263
+ return watch && watch.selectedElement instanceof DebugWatchExpression && watch.selectedElement || undefined;
1264
+ }
1265
+
1266
+ protected isPosition(position: unknown): boolean {
1267
+ return monaco.Position.isIPosition(position);
1268
+ }
1269
+
1270
+ protected asPosition(position: monaco.IPosition): monaco.Position {
1271
+ return monaco.Position.lift(position);
1272
+ }
1273
+
1274
+ registerColors(colors: ColorRegistry): void {
1275
+ colors.register(
1276
+ // Debug colors should be aligned with https://code.visualstudio.com/api/references/theme-color#debug-colors
1277
+ {
1278
+ id: 'editor.stackFrameHighlightBackground',
1279
+ defaults: {
1280
+ dark: '#ffff0033',
1281
+ light: '#ffff6673',
1282
+ hcDark: '#fff600',
1283
+ hcLight: '#ffff6673'
1284
+ }, description: 'Background color for the highlight of line at the top stack frame position.'
1285
+ },
1286
+ {
1287
+ id: 'editor.focusedStackFrameHighlightBackground',
1288
+ defaults: {
1289
+ dark: '#7abd7a4d',
1290
+ light: '#cee7ce73',
1291
+ hcDark: '#cee7ce',
1292
+ hcLight: '#cee7ce73'
1293
+ }, description: 'Background color for the highlight of line at focused stack frame position.'
1294
+ },
1295
+ // Status bar colors should be aligned with debugging colors from https://code.visualstudio.com/api/references/theme-color#status-bar-colors
1296
+ {
1297
+ id: 'statusBar.debuggingBackground', defaults: {
1298
+ dark: '#CC6633',
1299
+ light: '#CC6633',
1300
+ hcDark: '#CC6633',
1301
+ hcLight: '#B5200D'
1302
+ }, description: 'Status bar background color when a program is being debugged. The status bar is shown in the bottom of the window'
1303
+ },
1304
+ {
1305
+ id: 'statusBar.debuggingForeground', defaults: {
1306
+ dark: 'statusBar.foreground',
1307
+ light: 'statusBar.foreground',
1308
+ hcDark: 'statusBar.foreground',
1309
+ hcLight: 'statusBar.foreground'
1310
+ }, description: 'Status bar foreground color when a program is being debugged. The status bar is shown in the bottom of the window'
1311
+ },
1312
+ {
1313
+ id: 'statusBar.debuggingBorder', defaults: {
1314
+ dark: 'statusBar.border',
1315
+ light: 'statusBar.border',
1316
+ hcDark: 'statusBar.border',
1317
+ hcLight: 'statusBar.border'
1318
+ }, description: 'Status bar border color separating to the sidebar and editor when a program is being debugged. The status bar is shown in the bottom of the window'
1319
+ },
1320
+ // Debug Exception Widget colors should be aligned with
1321
+ // https://github.com/microsoft/vscode/blob/ff5f581425da6230b6f9216ecf19abf6c9d285a6/src/vs/workbench/contrib/debug/browser/exceptionWidget.ts#L23
1322
+ {
1323
+ id: 'debugExceptionWidget.border', defaults: {
1324
+ dark: '#a31515',
1325
+ light: '#a31515',
1326
+ hcDark: '#a31515',
1327
+ hcLight: '#a31515'
1328
+ }, description: 'Exception widget border color.',
1329
+ },
1330
+ {
1331
+ id: 'debugExceptionWidget.background', defaults: {
1332
+ dark: '#420b0d',
1333
+ light: '#f1dfde',
1334
+ hcDark: '#420b0d',
1335
+ hcLight: '#f1dfde'
1336
+ }, description: 'Exception widget background color.'
1337
+ },
1338
+ // Debug Icon colors should be aligned with
1339
+ // https://code.visualstudio.com/api/references/theme-color#debug-icons-colors
1340
+ {
1341
+ id: 'debugIcon.breakpointForeground', defaults: {
1342
+ dark: '#E51400',
1343
+ light: '#E51400',
1344
+ hcDark: '#E51400',
1345
+ hcLight: '#E51400'
1346
+ },
1347
+ description: 'Icon color for breakpoints.'
1348
+ },
1349
+ {
1350
+ id: 'debugIcon.breakpointDisabledForeground', defaults: {
1351
+ dark: '#848484',
1352
+ light: '#848484',
1353
+ hcDark: '#848484',
1354
+ hcLight: '#848484'
1355
+ },
1356
+ description: 'Icon color for disabled breakpoints.'
1357
+ },
1358
+ {
1359
+ id: 'debugIcon.breakpointUnverifiedForeground', defaults: {
1360
+ dark: '#848484',
1361
+ light: '#848484',
1362
+ hcDark: '#848484',
1363
+ hcLight: '#848484'
1364
+ },
1365
+ description: 'Icon color for unverified breakpoints.'
1366
+ },
1367
+ {
1368
+ id: 'debugIcon.breakpointCurrentStackframeForeground', defaults: {
1369
+ dark: '#FFCC00',
1370
+ light: '#BE8700',
1371
+ hcDark: '#FFCC00',
1372
+ hcLight: '#BE8700'
1373
+ },
1374
+ description: 'Icon color for the current breakpoint stack frame.'
1375
+ },
1376
+ {
1377
+ id: 'debugIcon.breakpointStackframeForeground', defaults: {
1378
+ dark: '#89D185',
1379
+ light: '#89D185',
1380
+ hcDark: '#89D185',
1381
+ hcLight: '#89D185'
1382
+ },
1383
+ description: 'Icon color for all breakpoint stack frames.'
1384
+ },
1385
+ {
1386
+ id: 'debugIcon.startForeground', defaults: {
1387
+ dark: '#89D185',
1388
+ light: '#388A34',
1389
+ hcDark: '#89D185',
1390
+ hcLight: '#388A34'
1391
+ }, description: 'Debug toolbar icon for start debugging.'
1392
+ },
1393
+ {
1394
+ id: 'debugIcon.pauseForeground', defaults: {
1395
+ dark: '#75BEFF',
1396
+ light: '#007ACC',
1397
+ hcDark: '#75BEFF',
1398
+ hcLight: '#007ACC'
1399
+ }, description: 'Debug toolbar icon for pause.'
1400
+ },
1401
+ {
1402
+ id: 'debugIcon.stopForeground', defaults: {
1403
+ dark: '#F48771',
1404
+ light: '#A1260D',
1405
+ hcDark: '#F48771',
1406
+ hcLight: '#A1260D'
1407
+ }, description: 'Debug toolbar icon for stop.'
1408
+ },
1409
+ {
1410
+ id: 'debugIcon.disconnectForeground', defaults: {
1411
+ dark: '#F48771',
1412
+ light: '#A1260D',
1413
+ hcDark: '#F48771',
1414
+ hcLight: '#A1260D'
1415
+ }, description: 'Debug toolbar icon for disconnect.'
1416
+ },
1417
+ {
1418
+ id: 'debugIcon.restartForeground', defaults: {
1419
+ dark: '#89D185',
1420
+ light: '#388A34',
1421
+ hcDark: '#89D185',
1422
+ hcLight: '#388A34'
1423
+ }, description: 'Debug toolbar icon for restart.'
1424
+ },
1425
+ {
1426
+ id: 'debugIcon.stepOverForeground', defaults: {
1427
+ dark: '#75BEFF',
1428
+ light: '#007ACC',
1429
+ hcDark: '#75BEFF',
1430
+ hcLight: '#007ACC',
1431
+ }, description: 'Debug toolbar icon for step over.'
1432
+ },
1433
+ {
1434
+ id: 'debugIcon.stepIntoForeground', defaults: {
1435
+ dark: '#75BEFF',
1436
+ light: '#007ACC',
1437
+ hcDark: '#75BEFF',
1438
+ hcLight: '#007ACC'
1439
+ }, description: 'Debug toolbar icon for step into.'
1440
+ },
1441
+ {
1442
+ id: 'debugIcon.stepOutForeground', defaults: {
1443
+ dark: '#75BEFF',
1444
+ light: '#007ACC',
1445
+ hcDark: '#75BEFF',
1446
+ hcLight: '#007ACC',
1447
+ }, description: 'Debug toolbar icon for step over.'
1448
+ },
1449
+ {
1450
+ id: 'debugIcon.continueForeground', defaults: {
1451
+ dark: '#75BEFF',
1452
+ light: '#007ACC',
1453
+ hcDark: '#75BEFF',
1454
+ hcLight: '#007ACC'
1455
+ }, description: 'Debug toolbar icon for continue.'
1456
+ },
1457
+ {
1458
+ id: 'debugIcon.stepBackForeground', defaults: {
1459
+ dark: '#75BEFF',
1460
+ light: '#007ACC',
1461
+ hcDark: '#75BEFF',
1462
+ hcLight: '#007ACC'
1463
+ }, description: 'Debug toolbar icon for step back.'
1464
+ },
1465
+ {
1466
+ id: 'debugConsole.infoForeground', defaults: {
1467
+ dark: 'editorInfo.foreground',
1468
+ light: 'editorInfo.foreground',
1469
+ hcDark: 'foreground',
1470
+ hcLight: 'foreground'
1471
+ }, description: 'Foreground color for info messages in debug REPL console.'
1472
+ },
1473
+ {
1474
+ id: 'debugConsole.warningForeground', defaults: {
1475
+ dark: 'editorWarning.foreground',
1476
+ light: 'editorWarning.foreground',
1477
+ hcDark: '#008000',
1478
+ hcLight: 'editorWarning.foreground'
1479
+ },
1480
+ description: 'Foreground color for warning messages in debug REPL console.'
1481
+ },
1482
+ {
1483
+ id: 'debugConsole.errorForeground', defaults: {
1484
+ dark: 'errorForeground',
1485
+ light: 'errorForeground',
1486
+ hcDark: 'errorForeground',
1487
+ hcLight: 'errorForeground'
1488
+ },
1489
+ description: 'Foreground color for error messages in debug REPL console.',
1490
+ },
1491
+ {
1492
+ id: 'debugConsole.sourceForeground', defaults: {
1493
+ dark: 'foreground',
1494
+ light: 'foreground',
1495
+ hcDark: 'foreground',
1496
+ hcLight: 'foreground'
1497
+ },
1498
+ description: 'Foreground color for source filenames in debug REPL console.',
1499
+ },
1500
+ {
1501
+ id: 'debugConsoleInputIcon.foreground', defaults: {
1502
+ dark: 'foreground',
1503
+ light: 'foreground',
1504
+ hcDark: 'foreground',
1505
+ hcLight: 'foreground'
1506
+ },
1507
+ description: 'Foreground color for debug console input marker icon.'
1508
+ }
1509
+ );
1510
+ }
1511
+
1512
+ protected updateStatusBar(): void {
1513
+ if (this.debuggingStatusBar === document.body.classList.contains('theia-mod-debugging')) {
1514
+ return;
1515
+ }
1516
+ document.body.classList.toggle('theia-mod-debugging');
1517
+ }
1518
+
1519
+ protected get debuggingStatusBar(): boolean {
1520
+ if (this.manager.state < DebugState.Running) {
1521
+ return false;
1522
+ }
1523
+
1524
+ const session = this.manager.currentSession;
1525
+ if (session) {
1526
+ if (session.configuration.noDebug) {
1527
+ return false;
1528
+ }
1529
+ if (this.getOption(session, 'suppressDebugStatusbar')) {
1530
+ return false;
1531
+ }
1532
+ }
1533
+
1534
+ return true;
1535
+ }
1536
+
1537
+ protected getOption(session: DebugSession | undefined, option: keyof {
1538
+ [Property in keyof DebugConfiguration]: boolean;
1539
+ }): boolean | undefined {
1540
+ // If session is undefined there will be no option
1541
+ if (!session) {
1542
+ return false;
1543
+ }
1544
+ // If undefined take the value of the parent
1545
+ if (option in session.configuration && session.configuration[option] !== undefined) {
1546
+ return session.configuration[option];
1547
+ }
1548
+
1549
+ return this.getOption(session.parentSession, option);
1550
+ }
1551
+ }