@codingame/monaco-vscode-debug-service-override 1.82.4 → 1.82.5-next.1

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 (73) hide show
  1. package/debug.d.ts +5 -0
  2. package/debug.js +24 -0
  3. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
  4. package/external/tslib/tslib.es6.js +11 -0
  5. package/index.d.ts +1 -1
  6. package/index.js +1 -1
  7. package/override/vs/platform/dialogs/common/dialogs.js +8 -0
  8. package/package.json +2 -2
  9. package/vscode/src/vs/editor/common/services/languageFeaturesService.js +44 -0
  10. package/vscode/src/vs/workbench/contrib/debug/browser/baseDebugView.js +200 -0
  11. package/vscode/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.js +785 -0
  12. package/vscode/src/vs/workbench/contrib/debug/browser/breakpointWidget.js +399 -0
  13. package/vscode/src/vs/workbench/contrib/debug/browser/breakpointsView.js +1298 -0
  14. package/vscode/src/vs/workbench/contrib/debug/browser/callStackEditorContribution.js +178 -0
  15. package/vscode/src/vs/workbench/contrib/debug/browser/callStackView.js +960 -0
  16. package/vscode/src/vs/workbench/contrib/debug/browser/debug.contribution.js +497 -0
  17. package/vscode/src/vs/workbench/contrib/debug/browser/debugANSIHandling.js +347 -0
  18. package/vscode/src/vs/workbench/contrib/debug/browser/debugActionViewItems.js +299 -0
  19. package/vscode/src/vs/workbench/contrib/debug/browser/debugAdapterManager.js +400 -0
  20. package/vscode/src/vs/workbench/contrib/debug/browser/debugCommands.js +827 -0
  21. package/vscode/src/vs/workbench/contrib/debug/browser/debugConfigurationManager.js +621 -0
  22. package/vscode/src/vs/workbench/contrib/debug/browser/debugConsoleQuickAccess.js +60 -0
  23. package/vscode/src/vs/workbench/contrib/debug/browser/debugEditorActions.js +527 -0
  24. package/vscode/src/vs/workbench/contrib/debug/browser/debugEditorContribution.js +681 -0
  25. package/vscode/src/vs/workbench/contrib/debug/browser/debugHover.js +356 -0
  26. package/vscode/src/vs/workbench/contrib/debug/browser/debugMemory.js +206 -0
  27. package/vscode/src/vs/workbench/contrib/debug/browser/debugProgress.js +82 -0
  28. package/vscode/src/vs/workbench/contrib/debug/browser/debugQuickAccess.js +143 -0
  29. package/vscode/src/vs/workbench/contrib/debug/browser/debugService.js +1174 -0
  30. package/vscode/src/vs/workbench/contrib/debug/browser/debugSession.js +1144 -0
  31. package/vscode/src/vs/workbench/contrib/debug/browser/debugSessionPicker.js +106 -0
  32. package/vscode/src/vs/workbench/contrib/debug/browser/debugStatus.js +68 -0
  33. package/vscode/src/vs/workbench/contrib/debug/browser/debugTaskRunner.js +275 -0
  34. package/vscode/src/vs/workbench/contrib/debug/browser/debugToolBar.js +314 -0
  35. package/vscode/src/vs/workbench/contrib/debug/browser/debugViewlet.js +168 -0
  36. package/vscode/src/vs/workbench/contrib/debug/browser/disassemblyView.js +663 -0
  37. package/vscode/src/vs/workbench/contrib/debug/browser/exceptionWidget.js +105 -0
  38. package/vscode/src/vs/workbench/contrib/debug/browser/linkDetector.js +231 -0
  39. package/vscode/src/vs/workbench/contrib/debug/browser/loadedScriptsView.js +631 -0
  40. package/vscode/src/vs/workbench/contrib/debug/browser/media/breakpointWidget.css.js +6 -0
  41. package/vscode/src/vs/workbench/contrib/debug/browser/media/callStackEditorContribution.css.js +6 -0
  42. package/vscode/src/vs/workbench/contrib/debug/browser/media/debug.contribution.css.js +6 -0
  43. package/vscode/src/vs/workbench/contrib/debug/browser/media/debugHover.css.js +6 -0
  44. package/vscode/src/vs/workbench/contrib/debug/browser/media/debugToolBar.css.js +6 -0
  45. package/vscode/src/vs/workbench/contrib/debug/browser/media/debugViewlet.css.js +6 -0
  46. package/vscode/src/vs/workbench/contrib/debug/browser/media/exceptionWidget.css.js +6 -0
  47. package/vscode/src/vs/workbench/contrib/debug/browser/media/repl.css.js +6 -0
  48. package/vscode/src/vs/workbench/contrib/debug/browser/rawDebugSession.js +695 -0
  49. package/vscode/src/vs/workbench/contrib/debug/browser/repl.js +953 -0
  50. package/vscode/src/vs/workbench/contrib/debug/browser/replFilter.js +48 -0
  51. package/vscode/src/vs/workbench/contrib/debug/browser/replViewer.js +336 -0
  52. package/vscode/src/vs/workbench/contrib/debug/browser/statusbarColorProvider.js +98 -0
  53. package/vscode/src/vs/workbench/contrib/debug/browser/variablesView.js +575 -0
  54. package/vscode/src/vs/workbench/contrib/debug/browser/watchExpressionsView.js +415 -0
  55. package/vscode/src/vs/workbench/contrib/debug/browser/welcomeView.js +102 -0
  56. package/vscode/src/vs/workbench/contrib/debug/common/breakpoints.js +21 -0
  57. package/vscode/src/vs/workbench/contrib/debug/common/debugCompoundRoot.js +17 -0
  58. package/vscode/src/vs/workbench/contrib/debug/common/debugContentProvider.js +100 -0
  59. package/vscode/src/vs/workbench/contrib/debug/common/debugLifecycle.js +59 -0
  60. package/vscode/src/vs/workbench/contrib/debug/common/debugModel.js +1482 -0
  61. package/vscode/src/vs/workbench/contrib/debug/common/debugSchemas.js +346 -0
  62. package/vscode/src/vs/workbench/contrib/debug/common/debugSource.js +123 -0
  63. package/vscode/src/vs/workbench/contrib/debug/common/debugStorage.js +175 -0
  64. package/vscode/src/vs/workbench/contrib/debug/common/debugTelemetry.js +36 -0
  65. package/vscode/src/vs/workbench/contrib/debug/common/debugViewModel.js +117 -0
  66. package/vscode/src/vs/workbench/contrib/debug/common/debugger.js +260 -0
  67. package/vscode/src/vs/workbench/contrib/debug/common/disassemblyViewInput.js +27 -0
  68. package/vscode/src/vs/workbench/contrib/debug/common/loadedScriptsPicker.js +83 -0
  69. package/vscode/src/vs/workbench/contrib/debug/common/replModel.js +283 -0
  70. package/vscode/src/vs/workbench/services/configurationResolver/browser/baseConfigurationResolverService.js +305 -0
  71. package/vscode/src/vs/workbench/services/configurationResolver/browser/configurationResolverService.js +28 -0
  72. package/vscode/src/vs/workbench/services/configurationResolver/common/configurationResolverSchema.js +176 -0
  73. package/vscode/src/vs/workbench/services/configurationResolver/common/configurationResolverUtils.js +12 -0
@@ -0,0 +1,681 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { addDisposableListener } from 'monaco-editor/esm/vs/base/browser/dom.js';
3
+ import { DomEmitter } from 'monaco-editor/esm/vs/base/browser/event.js';
4
+ import { StandardKeyboardEvent } from 'monaco-editor/esm/vs/base/browser/keyboardEvent.js';
5
+ import { flatten, distinct } from 'monaco-editor/esm/vs/base/common/arrays.js';
6
+ import { RunOnceScheduler } from 'monaco-editor/esm/vs/base/common/async.js';
7
+ import { CancellationTokenSource } from 'monaco-editor/esm/vs/base/common/cancellation.js';
8
+ import { memoize } from 'monaco-editor/esm/vs/base/common/decorators.js';
9
+ import { onUnexpectedExternalError } from 'monaco-editor/esm/vs/base/common/errors.js';
10
+ import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
11
+ import { visit } from 'monaco-editor/esm/vs/base/common/json.js';
12
+ import { setProperty } from 'vscode/vscode/vs/base/common/jsonEdit';
13
+ import { dispose } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
14
+ import { basename } from 'monaco-editor/esm/vs/base/common/path.js';
15
+ import * as platform from 'monaco-editor/esm/vs/base/common/platform.js';
16
+ import * as strings from 'monaco-editor/esm/vs/base/common/strings.js';
17
+ import { CoreEditingCommands } from 'monaco-editor/esm/vs/editor/browser/coreCommands.js';
18
+ import { EditOperation } from 'monaco-editor/esm/vs/editor/common/core/editOperation.js';
19
+ import { Position } from 'monaco-editor/esm/vs/editor/common/core/position.js';
20
+ import { Range } from 'monaco-editor/esm/vs/editor/common/core/range.js';
21
+ import { DEFAULT_WORD_REGEXP } from 'monaco-editor/esm/vs/editor/common/core/wordHelper.js';
22
+ import { InjectedTextCursorStops } from 'monaco-editor/esm/vs/editor/common/model.js';
23
+ import { ILanguageFeatureDebounceService } from 'monaco-editor/esm/vs/editor/common/services/languageFeatureDebounce.js';
24
+ import { ILanguageFeaturesService } from 'monaco-editor/esm/vs/editor/common/services/languageFeatures.js';
25
+ import { ModesHoverController } from 'monaco-editor/esm/vs/editor/contrib/hover/browser/hover.js';
26
+ import * as nls from 'monaco-editor/esm/vs/nls.js';
27
+ import { ICommandService } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
28
+ import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
29
+ import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
30
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
31
+ import { registerColor } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
32
+ import { IUriIdentityService } from 'monaco-editor/esm/vs/platform/uriIdentity/common/uriIdentity.js';
33
+ import { DebugHoverWidget } from './debugHover.js';
34
+ import { ExceptionWidget } from './exceptionWidget.js';
35
+ import { CONTEXT_EXCEPTION_WIDGET_VISIBLE, IDebugService } from 'vscode/vscode/vs/workbench/contrib/debug/common/debug';
36
+ import { Expression } from '../common/debugModel.js';
37
+ import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host';
38
+
39
+ const MAX_NUM_INLINE_VALUES = 100;
40
+ const MAX_INLINE_DECORATOR_LENGTH = 150;
41
+ const MAX_TOKENIZATION_LINE_LEN = 500;
42
+ const DEAFULT_INLINE_DEBOUNCE_DELAY = 200;
43
+ registerColor('editor.inlineValuesForeground', {
44
+ dark: '#ffffff80',
45
+ light: '#00000080',
46
+ hcDark: '#ffffff80',
47
+ hcLight: '#00000080'
48
+ }, ( nls.localize('editor.inlineValuesForeground', "Color for the debug inline value text.")));
49
+ registerColor('editor.inlineValuesBackground', {
50
+ dark: '#ffc80033',
51
+ light: '#ffc80033',
52
+ hcDark: '#ffc80033',
53
+ hcLight: '#ffc80033'
54
+ }, ( nls.localize(
55
+ 'editor.inlineValuesBackground',
56
+ "Color for the debug inline value background."
57
+ )));
58
+ class InlineSegment {
59
+ constructor(column, text) {
60
+ this.column = column;
61
+ this.text = text;
62
+ }
63
+ }
64
+ function createInlineValueDecoration(lineNumber, contentText, column = 1073741824 ) {
65
+ if (contentText.length > MAX_INLINE_DECORATOR_LENGTH) {
66
+ contentText = contentText.substring(0, MAX_INLINE_DECORATOR_LENGTH) + '...';
67
+ }
68
+ return [
69
+ {
70
+ range: {
71
+ startLineNumber: lineNumber,
72
+ endLineNumber: lineNumber,
73
+ startColumn: column,
74
+ endColumn: column
75
+ },
76
+ options: {
77
+ description: 'debug-inline-value-decoration-spacer',
78
+ after: {
79
+ content: strings.noBreakWhitespace,
80
+ cursorStops: InjectedTextCursorStops.None
81
+ },
82
+ showIfCollapsed: true,
83
+ }
84
+ },
85
+ {
86
+ range: {
87
+ startLineNumber: lineNumber,
88
+ endLineNumber: lineNumber,
89
+ startColumn: column,
90
+ endColumn: column
91
+ },
92
+ options: {
93
+ description: 'debug-inline-value-decoration',
94
+ after: {
95
+ content: replaceWsWithNoBreakWs(contentText),
96
+ inlineClassName: 'debug-inline-value',
97
+ inlineClassNameAffectsLetterSpacing: true,
98
+ cursorStops: InjectedTextCursorStops.None
99
+ },
100
+ showIfCollapsed: true,
101
+ }
102
+ },
103
+ ];
104
+ }
105
+ function replaceWsWithNoBreakWs(str) {
106
+ return str.replace(/[ \t]/g, strings.noBreakWhitespace);
107
+ }
108
+ function createInlineValueDecorationsInsideRange(expressions, range, model, wordToLineNumbersMap) {
109
+ const nameValueMap = ( new Map());
110
+ for (const expr of expressions) {
111
+ nameValueMap.set(expr.name, expr.value);
112
+ if (nameValueMap.size >= MAX_NUM_INLINE_VALUES) {
113
+ break;
114
+ }
115
+ }
116
+ const lineToNamesMap = ( new Map());
117
+ nameValueMap.forEach((_value, name) => {
118
+ const lineNumbers = wordToLineNumbersMap.get(name);
119
+ if (lineNumbers) {
120
+ for (const lineNumber of lineNumbers) {
121
+ if (range.containsPosition(( new Position(lineNumber, 0)))) {
122
+ if (!( lineToNamesMap.has(lineNumber))) {
123
+ lineToNamesMap.set(lineNumber, []);
124
+ }
125
+ if (lineToNamesMap.get(lineNumber).indexOf(name) === -1) {
126
+ lineToNamesMap.get(lineNumber).push(name);
127
+ }
128
+ }
129
+ }
130
+ }
131
+ });
132
+ const decorations = [];
133
+ lineToNamesMap.forEach((names, line) => {
134
+ const contentText = ( names.sort((first, second) => {
135
+ const content = model.getLineContent(line);
136
+ return content.indexOf(first) - content.indexOf(second);
137
+ }).map(name => `${name} = ${nameValueMap.get(name)}`)).join(', ');
138
+ decorations.push(...createInlineValueDecoration(line, contentText));
139
+ });
140
+ return decorations;
141
+ }
142
+ function getWordToLineNumbersMap(model) {
143
+ const result = ( new Map());
144
+ if (!model) {
145
+ return result;
146
+ }
147
+ for (let lineNumber = 1, len = model.getLineCount(); lineNumber <= len; ++lineNumber) {
148
+ const lineContent = model.getLineContent(lineNumber);
149
+ if (lineContent.length > MAX_TOKENIZATION_LINE_LEN) {
150
+ continue;
151
+ }
152
+ model.tokenization.forceTokenization(lineNumber);
153
+ const lineTokens = model.tokenization.getLineTokens(lineNumber);
154
+ for (let tokenIndex = 0, tokenCount = lineTokens.getCount(); tokenIndex < tokenCount; tokenIndex++) {
155
+ const tokenType = lineTokens.getStandardTokenType(tokenIndex);
156
+ if (tokenType === 0 ) {
157
+ DEFAULT_WORD_REGEXP.lastIndex = 0;
158
+ const tokenStartOffset = lineTokens.getStartOffset(tokenIndex);
159
+ const tokenEndOffset = lineTokens.getEndOffset(tokenIndex);
160
+ const tokenStr = lineContent.substring(tokenStartOffset, tokenEndOffset);
161
+ const wordMatch = DEFAULT_WORD_REGEXP.exec(tokenStr);
162
+ if (wordMatch) {
163
+ const word = wordMatch[0];
164
+ if (!( result.has(word))) {
165
+ result.set(word, []);
166
+ }
167
+ result.get(word).push(lineNumber);
168
+ }
169
+ }
170
+ }
171
+ }
172
+ return result;
173
+ }
174
+ let DebugEditorContribution = class DebugEditorContribution {
175
+ constructor(editor, debugService, instantiationService, commandService, configurationService, hostService, uriIdentityService, contextKeyService, languageFeaturesService, featureDebounceService) {
176
+ this.editor = editor;
177
+ this.debugService = debugService;
178
+ this.instantiationService = instantiationService;
179
+ this.commandService = commandService;
180
+ this.configurationService = configurationService;
181
+ this.hostService = hostService;
182
+ this.uriIdentityService = uriIdentityService;
183
+ this.languageFeaturesService = languageFeaturesService;
184
+ this.hoverPosition = null;
185
+ this.mouseDown = false;
186
+ this.gutterIsHovered = false;
187
+ this.altPressed = false;
188
+ this.oldDecorations = this.editor.createDecorationsCollection();
189
+ this._wordToLineNumbersMap = undefined;
190
+ this.debounceInfo = featureDebounceService.for(languageFeaturesService.inlineValuesProvider, 'InlineValues', { min: DEAFULT_INLINE_DEBOUNCE_DELAY });
191
+ this.hoverWidget = this.instantiationService.createInstance(DebugHoverWidget, this.editor);
192
+ this.toDispose = [];
193
+ this.registerListeners();
194
+ this.exceptionWidgetVisible = CONTEXT_EXCEPTION_WIDGET_VISIBLE.bindTo(contextKeyService);
195
+ this.toggleExceptionWidget();
196
+ }
197
+ registerListeners() {
198
+ this.toDispose.push(this.debugService.getViewModel().onDidFocusStackFrame(e => this.onFocusStackFrame(e.stackFrame)));
199
+ this.toDispose.push(this.editor.onMouseDown((e) => this.onEditorMouseDown(e)));
200
+ this.toDispose.push(this.editor.onMouseUp(() => this.mouseDown = false));
201
+ this.toDispose.push(this.editor.onMouseMove((e) => this.onEditorMouseMove(e)));
202
+ this.toDispose.push(this.editor.onMouseLeave((e) => {
203
+ const hoverDomNode = this.hoverWidget.getDomNode();
204
+ if (!hoverDomNode) {
205
+ return;
206
+ }
207
+ const rect = hoverDomNode.getBoundingClientRect();
208
+ if (e.event.posx < rect.left || e.event.posx > rect.right || e.event.posy < rect.top || e.event.posy > rect.bottom) {
209
+ this.hideHoverWidget();
210
+ }
211
+ }));
212
+ this.toDispose.push(this.editor.onKeyDown((e) => this.onKeyDown(e)));
213
+ this.toDispose.push(this.editor.onDidChangeModelContent(() => {
214
+ this._wordToLineNumbersMap = undefined;
215
+ this.updateInlineValuesScheduler.schedule();
216
+ }));
217
+ this.toDispose.push(this.debugService.getViewModel().onWillUpdateViews(() => this.updateInlineValuesScheduler.schedule()));
218
+ this.toDispose.push(this.debugService.getViewModel().onDidEvaluateLazyExpression(() => this.updateInlineValuesScheduler.schedule()));
219
+ this.toDispose.push(this.editor.onDidChangeModel(async () => {
220
+ this.updateHoverConfiguration();
221
+ this.toggleExceptionWidget();
222
+ this.hideHoverWidget();
223
+ this._wordToLineNumbersMap = undefined;
224
+ const stackFrame = this.debugService.getViewModel().focusedStackFrame;
225
+ await this.updateInlineValueDecorations(stackFrame);
226
+ }));
227
+ this.toDispose.push(this.editor.onDidScrollChange(() => {
228
+ this.hideHoverWidget();
229
+ const model = this.editor.getModel();
230
+ if (model && ( this.languageFeaturesService.inlineValuesProvider.has(model))) {
231
+ this.updateInlineValuesScheduler.schedule();
232
+ }
233
+ }));
234
+ this.toDispose.push(this.debugService.onDidChangeState((state) => {
235
+ if (state !== 2 ) {
236
+ this.toggleExceptionWidget();
237
+ }
238
+ }));
239
+ }
240
+ get wordToLineNumbersMap() {
241
+ if (!this._wordToLineNumbersMap) {
242
+ this._wordToLineNumbersMap = getWordToLineNumbersMap(this.editor.getModel());
243
+ }
244
+ return this._wordToLineNumbersMap;
245
+ }
246
+ updateHoverConfiguration() {
247
+ const stackFrame = this.debugService.getViewModel().focusedStackFrame;
248
+ const model = this.editor.getModel();
249
+ if (model) {
250
+ this.applyHoverConfiguration(model, stackFrame);
251
+ }
252
+ }
253
+ applyHoverConfiguration(model, stackFrame) {
254
+ if (stackFrame && this.uriIdentityService.extUri.isEqual(model.uri, stackFrame.source.uri)) {
255
+ if (this.altListener) {
256
+ this.altListener.dispose();
257
+ }
258
+ this.altListener = addDisposableListener(document, 'keydown', keydownEvent => {
259
+ const standardKeyboardEvent = ( new StandardKeyboardEvent(keydownEvent));
260
+ if (standardKeyboardEvent.keyCode === 6 ) {
261
+ this.altPressed = true;
262
+ const debugHoverWasVisible = this.hoverWidget.isVisible();
263
+ this.hoverWidget.hide();
264
+ this.enableEditorHover();
265
+ if (debugHoverWasVisible && this.hoverPosition) {
266
+ this.showEditorHover(this.hoverPosition, false);
267
+ }
268
+ const onKeyUp = ( new DomEmitter(document, 'keyup'));
269
+ const listener = Event.any(this.hostService.onDidChangeFocus, onKeyUp.event)(keyupEvent => {
270
+ let standardKeyboardEvent = undefined;
271
+ if (keyupEvent instanceof KeyboardEvent) {
272
+ standardKeyboardEvent = ( new StandardKeyboardEvent(keyupEvent));
273
+ }
274
+ if (!standardKeyboardEvent || standardKeyboardEvent.keyCode === 6 ) {
275
+ this.altPressed = false;
276
+ this.editor.updateOptions({ hover: { enabled: false } });
277
+ listener.dispose();
278
+ onKeyUp.dispose();
279
+ }
280
+ });
281
+ }
282
+ });
283
+ this.editor.updateOptions({ hover: { enabled: false } });
284
+ }
285
+ else {
286
+ this.altListener?.dispose();
287
+ this.enableEditorHover();
288
+ }
289
+ }
290
+ enableEditorHover() {
291
+ if (this.editor.hasModel()) {
292
+ const model = this.editor.getModel();
293
+ const overrides = {
294
+ resource: model.uri,
295
+ overrideIdentifier: model.getLanguageId()
296
+ };
297
+ const defaultConfiguration = this.configurationService.getValue('editor.hover', overrides);
298
+ this.editor.updateOptions({
299
+ hover: {
300
+ enabled: defaultConfiguration.enabled,
301
+ delay: defaultConfiguration.delay,
302
+ sticky: defaultConfiguration.sticky
303
+ }
304
+ });
305
+ }
306
+ }
307
+ async showHover(position, focus) {
308
+ const sf = this.debugService.getViewModel().focusedStackFrame;
309
+ const model = this.editor.getModel();
310
+ if (sf && model && this.uriIdentityService.extUri.isEqual(sf.source.uri, model.uri)) {
311
+ const result = await this.hoverWidget.showAt(position, focus);
312
+ if (result === 1 ) {
313
+ this.showEditorHover(position, focus);
314
+ }
315
+ }
316
+ else {
317
+ this.showEditorHover(position, focus);
318
+ }
319
+ }
320
+ showEditorHover(position, focus) {
321
+ const hoverController = this.editor.getContribution(ModesHoverController.ID);
322
+ const range = ( new Range(position.lineNumber, position.column, position.lineNumber, position.column));
323
+ hoverController?.showContentHover(range, 1 , 0 , focus);
324
+ }
325
+ async onFocusStackFrame(sf) {
326
+ const model = this.editor.getModel();
327
+ if (model) {
328
+ this.applyHoverConfiguration(model, sf);
329
+ if (sf && this.uriIdentityService.extUri.isEqual(sf.source.uri, model.uri)) {
330
+ await this.toggleExceptionWidget();
331
+ }
332
+ else {
333
+ this.hideHoverWidget();
334
+ }
335
+ }
336
+ await this.updateInlineValueDecorations(sf);
337
+ }
338
+ get showHoverScheduler() {
339
+ const hoverOption = this.editor.getOption(59 );
340
+ const scheduler = ( new RunOnceScheduler(() => {
341
+ if (this.hoverPosition && !this.altPressed) {
342
+ this.showHover(this.hoverPosition, false);
343
+ }
344
+ }, hoverOption.delay * 2));
345
+ this.toDispose.push(scheduler);
346
+ return scheduler;
347
+ }
348
+ get hideHoverScheduler() {
349
+ const scheduler = ( new RunOnceScheduler(() => {
350
+ if (!this.hoverWidget.isHovered()) {
351
+ this.hoverWidget.hide();
352
+ }
353
+ }, 0));
354
+ this.toDispose.push(scheduler);
355
+ return scheduler;
356
+ }
357
+ hideHoverWidget() {
358
+ if (!this.hideHoverScheduler.isScheduled() && this.hoverWidget.willBeVisible()) {
359
+ this.hideHoverScheduler.schedule();
360
+ }
361
+ this.showHoverScheduler.cancel();
362
+ }
363
+ onEditorMouseDown(mouseEvent) {
364
+ this.mouseDown = true;
365
+ if (mouseEvent.target.type === 9 && mouseEvent.target.detail === DebugHoverWidget.ID) {
366
+ return;
367
+ }
368
+ this.hideHoverWidget();
369
+ }
370
+ onEditorMouseMove(mouseEvent) {
371
+ if (this.debugService.state !== 2 ) {
372
+ return;
373
+ }
374
+ const target = mouseEvent.target;
375
+ const stopKey = platform.isMacintosh ? 'metaKey' : 'ctrlKey';
376
+ if (!this.altPressed) {
377
+ if (target.type === 2 ) {
378
+ this.editor.updateOptions({ hover: { enabled: true } });
379
+ this.gutterIsHovered = true;
380
+ }
381
+ else if (this.gutterIsHovered) {
382
+ this.gutterIsHovered = false;
383
+ this.updateHoverConfiguration();
384
+ }
385
+ }
386
+ if (target.type === 9 && target.detail === DebugHoverWidget.ID && !mouseEvent.event[stopKey]) {
387
+ return;
388
+ }
389
+ if (target.type === 6 ) {
390
+ if (target.position && !Position.equals(target.position, this.hoverPosition)) {
391
+ this.hoverPosition = target.position;
392
+ this.hideHoverScheduler.cancel();
393
+ this.showHoverScheduler.schedule();
394
+ }
395
+ }
396
+ else if (!this.mouseDown) {
397
+ this.hideHoverWidget();
398
+ }
399
+ }
400
+ onKeyDown(e) {
401
+ const stopKey = platform.isMacintosh ? 57 : 5 ;
402
+ if (e.keyCode !== stopKey) {
403
+ this.hideHoverWidget();
404
+ }
405
+ }
406
+ async toggleExceptionWidget() {
407
+ const model = this.editor.getModel();
408
+ const focusedSf = this.debugService.getViewModel().focusedStackFrame;
409
+ const callStack = focusedSf ? focusedSf.thread.getCallStack() : null;
410
+ if (!model || !focusedSf || !callStack || callStack.length === 0) {
411
+ this.closeExceptionWidget();
412
+ return;
413
+ }
414
+ const exceptionSf = callStack.find(sf => !!(sf && sf.source && sf.source.available && sf.source.presentationHint !== 'deemphasize'));
415
+ if (!exceptionSf || exceptionSf !== focusedSf) {
416
+ this.closeExceptionWidget();
417
+ return;
418
+ }
419
+ const sameUri = this.uriIdentityService.extUri.isEqual(exceptionSf.source.uri, model.uri);
420
+ if (this.exceptionWidget && !sameUri) {
421
+ this.closeExceptionWidget();
422
+ }
423
+ else if (sameUri) {
424
+ const exceptionInfo = await focusedSf.thread.exceptionInfo;
425
+ if (exceptionInfo) {
426
+ this.showExceptionWidget(exceptionInfo, this.debugService.getViewModel().focusedSession, exceptionSf.range.startLineNumber, exceptionSf.range.startColumn);
427
+ }
428
+ }
429
+ }
430
+ showExceptionWidget(exceptionInfo, debugSession, lineNumber, column) {
431
+ if (this.exceptionWidget) {
432
+ this.exceptionWidget.dispose();
433
+ }
434
+ this.exceptionWidget = this.instantiationService.createInstance(ExceptionWidget, this.editor, exceptionInfo, debugSession);
435
+ this.exceptionWidget.show({ lineNumber, column }, 0);
436
+ this.exceptionWidget.focus();
437
+ this.editor.revealRangeInCenter({
438
+ startLineNumber: lineNumber,
439
+ startColumn: column,
440
+ endLineNumber: lineNumber,
441
+ endColumn: column,
442
+ });
443
+ this.exceptionWidgetVisible.set(true);
444
+ }
445
+ closeExceptionWidget() {
446
+ if (this.exceptionWidget) {
447
+ const shouldFocusEditor = this.exceptionWidget.hasFocus();
448
+ this.exceptionWidget.dispose();
449
+ this.exceptionWidget = undefined;
450
+ this.exceptionWidgetVisible.set(false);
451
+ if (shouldFocusEditor) {
452
+ this.editor.focus();
453
+ }
454
+ }
455
+ }
456
+ async addLaunchConfiguration() {
457
+ const model = this.editor.getModel();
458
+ if (!model) {
459
+ return;
460
+ }
461
+ let configurationsArrayPosition;
462
+ let lastProperty;
463
+ const getConfigurationPosition = () => {
464
+ let depthInArray = 0;
465
+ visit(model.getValue(), {
466
+ onObjectProperty: (property) => {
467
+ lastProperty = property;
468
+ },
469
+ onArrayBegin: (offset) => {
470
+ if (lastProperty === 'configurations' && depthInArray === 0) {
471
+ configurationsArrayPosition = model.getPositionAt(offset + 1);
472
+ }
473
+ depthInArray++;
474
+ },
475
+ onArrayEnd: () => {
476
+ depthInArray--;
477
+ }
478
+ });
479
+ };
480
+ getConfigurationPosition();
481
+ if (!configurationsArrayPosition) {
482
+ const { tabSize, insertSpaces } = model.getOptions();
483
+ const eol = model.getEOL();
484
+ const edit = (basename(model.uri.fsPath) === 'launch.json') ?
485
+ setProperty(model.getValue(), ['configurations'], [], { tabSize, insertSpaces, eol })[0] :
486
+ setProperty(model.getValue(), ['launch'], { 'configurations': [] }, { tabSize, insertSpaces, eol })[0];
487
+ const startPosition = model.getPositionAt(edit.offset);
488
+ const lineNumber = startPosition.lineNumber;
489
+ const range = ( new Range(
490
+ lineNumber,
491
+ startPosition.column,
492
+ lineNumber,
493
+ model.getLineMaxColumn(lineNumber)
494
+ ));
495
+ model.pushEditOperations(null, [EditOperation.replace(range, edit.content)], () => null);
496
+ getConfigurationPosition();
497
+ }
498
+ if (!configurationsArrayPosition) {
499
+ return;
500
+ }
501
+ this.editor.focus();
502
+ const insertLine = (position) => {
503
+ if (model.getLineLastNonWhitespaceColumn(position.lineNumber) > position.column) {
504
+ this.editor.setPosition(position);
505
+ CoreEditingCommands.LineBreakInsert.runEditorCommand(null, this.editor, null);
506
+ }
507
+ this.editor.setPosition(position);
508
+ return this.commandService.executeCommand('editor.action.insertLineAfter');
509
+ };
510
+ await insertLine(configurationsArrayPosition);
511
+ await this.commandService.executeCommand('editor.action.triggerSuggest');
512
+ }
513
+ get removeInlineValuesScheduler() {
514
+ return ( new RunOnceScheduler(() => {
515
+ this.oldDecorations.clear();
516
+ }, 100));
517
+ }
518
+ get updateInlineValuesScheduler() {
519
+ const model = this.editor.getModel();
520
+ return ( new RunOnceScheduler(
521
+ async () => await this.updateInlineValueDecorations(this.debugService.getViewModel().focusedStackFrame),
522
+ model ? this.debounceInfo.get(model) : DEAFULT_INLINE_DEBOUNCE_DELAY
523
+ ));
524
+ }
525
+ async updateInlineValueDecorations(stackFrame) {
526
+ const var_value_format = '{0} = {1}';
527
+ const separator = ', ';
528
+ const model = this.editor.getModel();
529
+ const inlineValuesSetting = this.configurationService.getValue('debug').inlineValues;
530
+ const inlineValuesTurnedOn = inlineValuesSetting === true || inlineValuesSetting === 'on' || (inlineValuesSetting === 'auto' && model && ( this.languageFeaturesService.inlineValuesProvider.has(model)));
531
+ if (!inlineValuesTurnedOn || !model || !stackFrame || ( model.uri.toString()) !== ( stackFrame.source.uri.toString())) {
532
+ if (!this.removeInlineValuesScheduler.isScheduled()) {
533
+ this.removeInlineValuesScheduler.schedule();
534
+ }
535
+ return;
536
+ }
537
+ this.removeInlineValuesScheduler.cancel();
538
+ let allDecorations;
539
+ if (( this.languageFeaturesService.inlineValuesProvider.has(model))) {
540
+ const findVariable = async (_key, caseSensitiveLookup) => {
541
+ const scopes = await stackFrame.getMostSpecificScopes(stackFrame.range);
542
+ const key = caseSensitiveLookup ? _key : _key.toLowerCase();
543
+ for (const scope of scopes) {
544
+ const variables = await scope.getChildren();
545
+ const found = variables.find(v => caseSensitiveLookup ? (v.name === key) : (v.name.toLowerCase() === key));
546
+ if (found) {
547
+ return found.value;
548
+ }
549
+ }
550
+ return undefined;
551
+ };
552
+ const ctx = {
553
+ frameId: stackFrame.frameId,
554
+ stoppedLocation: ( new Range(
555
+ stackFrame.range.startLineNumber,
556
+ stackFrame.range.startColumn + 1,
557
+ stackFrame.range.endLineNumber,
558
+ stackFrame.range.endColumn + 1
559
+ ))
560
+ };
561
+ const token = ( new CancellationTokenSource()).token;
562
+ const ranges = this.editor.getVisibleRangesPlusViewportAboveBelow();
563
+ const providers = this.languageFeaturesService.inlineValuesProvider.ordered(model).reverse();
564
+ allDecorations = [];
565
+ const lineDecorations = ( new Map());
566
+ const promises = flatten(( providers.map(provider => ( ranges.map(
567
+ range => Promise.resolve(provider.provideInlineValues(model, range, ctx, token)).then(async (result) => {
568
+ if (result) {
569
+ for (const iv of result) {
570
+ let text = undefined;
571
+ switch (iv.type) {
572
+ case 'text':
573
+ text = iv.text;
574
+ break;
575
+ case 'variable': {
576
+ let va = iv.variableName;
577
+ if (!va) {
578
+ const lineContent = model.getLineContent(iv.range.startLineNumber);
579
+ va = lineContent.substring(iv.range.startColumn - 1, iv.range.endColumn - 1);
580
+ }
581
+ const value = await findVariable(va, iv.caseSensitiveLookup);
582
+ if (value) {
583
+ text = strings.format(var_value_format, va, value);
584
+ }
585
+ break;
586
+ }
587
+ case 'expression': {
588
+ let expr = iv.expression;
589
+ if (!expr) {
590
+ const lineContent = model.getLineContent(iv.range.startLineNumber);
591
+ expr = lineContent.substring(iv.range.startColumn - 1, iv.range.endColumn - 1);
592
+ }
593
+ if (expr) {
594
+ const expression = ( new Expression(expr));
595
+ await expression.evaluate(stackFrame.thread.session, stackFrame, 'watch', true);
596
+ if (expression.available) {
597
+ text = strings.format(var_value_format, expr, expression.value);
598
+ }
599
+ }
600
+ break;
601
+ }
602
+ }
603
+ if (text) {
604
+ const line = iv.range.startLineNumber;
605
+ let lineSegments = lineDecorations.get(line);
606
+ if (!lineSegments) {
607
+ lineSegments = [];
608
+ lineDecorations.set(line, lineSegments);
609
+ }
610
+ if (!( lineSegments.some(iv => iv.text === text))) {
611
+ lineSegments.push(( new InlineSegment(iv.range.startColumn, text)));
612
+ }
613
+ }
614
+ }
615
+ }
616
+ }, err => {
617
+ onUnexpectedExternalError(err);
618
+ })
619
+ )))));
620
+ const startTime = Date.now();
621
+ await Promise.all(promises);
622
+ this.updateInlineValuesScheduler.delay = this.debounceInfo.update(model, Date.now() - startTime);
623
+ lineDecorations.forEach((segments, line) => {
624
+ if (segments.length > 0) {
625
+ segments = segments.sort((a, b) => a.column - b.column);
626
+ const text = ( segments.map(s => s.text)).join(separator);
627
+ allDecorations.push(...createInlineValueDecoration(line, text));
628
+ }
629
+ });
630
+ }
631
+ else {
632
+ const scopes = await stackFrame.getMostSpecificScopes(stackFrame.range);
633
+ const decorationsPerScope = await Promise.all(( scopes.map(async (scope) => {
634
+ const variables = await scope.getChildren();
635
+ let range = ( new Range(0, 0, stackFrame.range.startLineNumber, stackFrame.range.startColumn));
636
+ if (scope.range) {
637
+ range = range.setStartPosition(scope.range.startLineNumber, scope.range.startColumn);
638
+ }
639
+ return createInlineValueDecorationsInsideRange(variables, range, model, this.wordToLineNumbersMap);
640
+ })));
641
+ allDecorations = distinct(decorationsPerScope.reduce((previous, current) => previous.concat(current), []),
642
+ decoration => `${decoration.range.startLineNumber}:${decoration?.options.after?.content}`);
643
+ }
644
+ this.oldDecorations.set(allDecorations);
645
+ }
646
+ dispose() {
647
+ if (this.hoverWidget) {
648
+ this.hoverWidget.dispose();
649
+ }
650
+ if (this.configurationWidget) {
651
+ this.configurationWidget.dispose();
652
+ }
653
+ this.toDispose = dispose(this.toDispose);
654
+ this.oldDecorations.clear();
655
+ }
656
+ };
657
+ DebugEditorContribution.__decorator = ( __decorate([
658
+ memoize
659
+ ], DebugEditorContribution.prototype, "showHoverScheduler", null));
660
+ DebugEditorContribution.__decorator = ( __decorate([
661
+ memoize
662
+ ], DebugEditorContribution.prototype, "hideHoverScheduler", null));
663
+ DebugEditorContribution.__decorator = ( __decorate([
664
+ memoize
665
+ ], DebugEditorContribution.prototype, "removeInlineValuesScheduler", null));
666
+ DebugEditorContribution.__decorator = ( __decorate([
667
+ memoize
668
+ ], DebugEditorContribution.prototype, "updateInlineValuesScheduler", null));
669
+ DebugEditorContribution = ( __decorate([
670
+ ( __param(1, IDebugService)),
671
+ ( __param(2, IInstantiationService)),
672
+ ( __param(3, ICommandService)),
673
+ ( __param(4, IConfigurationService)),
674
+ ( __param(5, IHostService)),
675
+ ( __param(6, IUriIdentityService)),
676
+ ( __param(7, IContextKeyService)),
677
+ ( __param(8, ILanguageFeaturesService)),
678
+ ( __param(9, ILanguageFeatureDebounceService))
679
+ ], DebugEditorContribution));
680
+
681
+ export { DebugEditorContribution };