@codingame/monaco-vscode-debug-service-override 4.1.0 → 4.1.2

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