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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/debug.js +4 -4
  2. package/package.json +2 -2
  3. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
  4. package/external/tslib/tslib.es6.js +0 -11
  5. package/override/vs/platform/dialogs/common/dialogs.js +0 -10
  6. package/vscode/src/vs/platform/debug/common/extensionHostDebugIpc.js +0 -73
  7. package/vscode/src/vs/workbench/contrib/debug/browser/callStackView.js +0 -1026
  8. package/vscode/src/vs/workbench/contrib/debug/browser/debug.contribution.js +0 -1004
  9. package/vscode/src/vs/workbench/contrib/debug/browser/debugANSIHandling.js +0 -347
  10. package/vscode/src/vs/workbench/contrib/debug/browser/debugActionViewItems.js +0 -337
  11. package/vscode/src/vs/workbench/contrib/debug/browser/debugAdapterManager.js +0 -432
  12. package/vscode/src/vs/workbench/contrib/debug/browser/debugCommands.js +0 -1039
  13. package/vscode/src/vs/workbench/contrib/debug/browser/debugConfigurationManager.js +0 -649
  14. package/vscode/src/vs/workbench/contrib/debug/browser/debugConsoleQuickAccess.js +0 -64
  15. package/vscode/src/vs/workbench/contrib/debug/browser/debugEditorActions.js +0 -636
  16. package/vscode/src/vs/workbench/contrib/debug/browser/debugEditorContribution.js +0 -740
  17. package/vscode/src/vs/workbench/contrib/debug/browser/debugHover.js +0 -408
  18. package/vscode/src/vs/workbench/contrib/debug/browser/debugMemory.js +0 -206
  19. package/vscode/src/vs/workbench/contrib/debug/browser/debugProgress.js +0 -80
  20. package/vscode/src/vs/workbench/contrib/debug/browser/debugQuickAccess.js +0 -169
  21. package/vscode/src/vs/workbench/contrib/debug/browser/debugService.js +0 -1271
  22. package/vscode/src/vs/workbench/contrib/debug/browser/debugSession.js +0 -1330
  23. package/vscode/src/vs/workbench/contrib/debug/browser/debugSessionPicker.js +0 -115
  24. package/vscode/src/vs/workbench/contrib/debug/browser/debugStatus.js +0 -77
  25. package/vscode/src/vs/workbench/contrib/debug/browser/debugTaskRunner.js +0 -307
  26. package/vscode/src/vs/workbench/contrib/debug/browser/debugTitle.js +0 -31
  27. package/vscode/src/vs/workbench/contrib/debug/browser/debugToolBar.js +0 -387
  28. package/vscode/src/vs/workbench/contrib/debug/browser/debugViewlet.js +0 -267
  29. package/vscode/src/vs/workbench/contrib/debug/browser/disassemblyView.js +0 -817
  30. package/vscode/src/vs/workbench/contrib/debug/browser/exceptionWidget.js +0 -131
  31. package/vscode/src/vs/workbench/contrib/debug/browser/extensionHostDebugService.js +0 -142
  32. package/vscode/src/vs/workbench/contrib/debug/browser/linkDetector.js +0 -262
  33. package/vscode/src/vs/workbench/contrib/debug/browser/loadedScriptsView.js +0 -669
  34. package/vscode/src/vs/workbench/contrib/debug/browser/media/debug.contribution.css.js +0 -6
  35. package/vscode/src/vs/workbench/contrib/debug/browser/media/debugHover.css.js +0 -6
  36. package/vscode/src/vs/workbench/contrib/debug/browser/media/debugToolBar.css.js +0 -6
  37. package/vscode/src/vs/workbench/contrib/debug/browser/media/debugViewlet.css.js +0 -6
  38. package/vscode/src/vs/workbench/contrib/debug/browser/media/exceptionWidget.css.js +0 -6
  39. package/vscode/src/vs/workbench/contrib/debug/browser/media/repl.css.js +0 -6
  40. package/vscode/src/vs/workbench/contrib/debug/browser/rawDebugSession.js +0 -709
  41. package/vscode/src/vs/workbench/contrib/debug/browser/repl.js +0 -1002
  42. package/vscode/src/vs/workbench/contrib/debug/browser/replFilter.js +0 -48
  43. package/vscode/src/vs/workbench/contrib/debug/browser/replViewer.js +0 -352
  44. package/vscode/src/vs/workbench/contrib/debug/browser/statusbarColorProvider.js +0 -129
  45. package/vscode/src/vs/workbench/contrib/debug/browser/variablesView.js +0 -734
  46. package/vscode/src/vs/workbench/contrib/debug/browser/watchExpressionsView.js +0 -501
  47. package/vscode/src/vs/workbench/contrib/debug/browser/welcomeView.js +0 -162
  48. package/vscode/src/vs/workbench/contrib/debug/common/breakpoints.js +0 -21
  49. package/vscode/src/vs/workbench/contrib/debug/common/debugCompoundRoot.js +0 -17
  50. package/vscode/src/vs/workbench/contrib/debug/common/debugContentProvider.js +0 -110
  51. package/vscode/src/vs/workbench/contrib/debug/common/debugLifecycle.js +0 -62
  52. package/vscode/src/vs/workbench/contrib/debug/common/debugSchemas.js +0 -460
  53. package/vscode/src/vs/workbench/contrib/debug/common/debugStorage.js +0 -166
  54. package/vscode/src/vs/workbench/contrib/debug/common/debugTelemetry.js +0 -36
  55. package/vscode/src/vs/workbench/contrib/debug/common/debugViewModel.js +0 -150
  56. package/vscode/src/vs/workbench/contrib/debug/common/debugger.js +0 -289
  57. package/vscode/src/vs/workbench/contrib/debug/common/loadedScriptsPicker.js +0 -87
  58. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariableCommands.js +0 -64
  59. package/vscode/src/vs/workbench/services/configurationResolver/browser/baseConfigurationResolverService.js +0 -311
  60. package/vscode/src/vs/workbench/services/configurationResolver/browser/configurationResolverService.js +0 -29
@@ -1,649 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { flatten, distinct } from 'vscode/vscode/vs/base/common/arrays';
3
- import { sequence } from 'vscode/vscode/vs/base/common/async';
4
- import { CancellationTokenSource, CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
5
- import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
6
- import { parse } from 'vscode/vscode/vs/base/common/json';
7
- import { DisposableStore, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
8
- import { deepClone } from 'vscode/vscode/vs/base/common/objects';
9
- import { joinPath } from 'vscode/vscode/vs/base/common/resources';
10
- import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
11
- import { URI } from 'vscode/vscode/vs/base/common/uri';
12
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
13
- import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
14
- import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
15
- import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
16
- import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
17
- import { Extensions } from 'vscode/vscode/vs/platform/jsonschemas/common/jsonContributionRegistry';
18
- import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput';
19
- import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
20
- import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
21
- import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
22
- import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
23
- import { debugConfigure } from 'vscode/vscode/vs/workbench/contrib/debug/browser/debugIcons';
24
- import { CONTEXT_DEBUG_CONFIGURATION_TYPE, DebugConfigurationProviderTriggerKind } from 'vscode/vscode/vs/workbench/contrib/debug/common/debug';
25
- import { launchSchema } from '../common/debugSchemas.js';
26
- import { getVisibleAndSorted } from 'vscode/vscode/vs/workbench/contrib/debug/common/debugUtils';
27
- import { launchSchemaId } from 'vscode/vscode/vs/workbench/services/configuration/common/configuration';
28
- import { ACTIVE_GROUP, IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
29
- import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
30
- import { IHistoryService } from 'vscode/vscode/vs/workbench/services/history/common/history';
31
- import { IPreferencesService } from 'vscode/vscode/vs/workbench/services/preferences/common/preferences';
32
- import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles';
33
-
34
- const jsonRegistry = ( Registry.as(Extensions.JSONContribution));
35
- jsonRegistry.registerSchema(launchSchemaId, launchSchema);
36
- const DEBUG_SELECTED_CONFIG_NAME_KEY = 'debug.selectedconfigname';
37
- const DEBUG_SELECTED_ROOT = 'debug.selectedroot';
38
- const DEBUG_SELECTED_TYPE = 'debug.selectedtype';
39
- const DEBUG_RECENT_DYNAMIC_CONFIGURATIONS = 'debug.recentdynamicconfigurations';
40
- let ConfigurationManager = class ConfigurationManager {
41
- constructor(adapterManager, contextService, configurationService, quickInputService, instantiationService, storageService, extensionService, historyService, uriIdentityService, contextKeyService) {
42
- this.adapterManager = adapterManager;
43
- this.contextService = contextService;
44
- this.configurationService = configurationService;
45
- this.quickInputService = quickInputService;
46
- this.instantiationService = instantiationService;
47
- this.storageService = storageService;
48
- this.extensionService = extensionService;
49
- this.historyService = historyService;
50
- this.uriIdentityService = uriIdentityService;
51
- this.getSelectedConfig = () => Promise.resolve(undefined);
52
- this.selectedDynamic = false;
53
- this._onDidSelectConfigurationName = ( new Emitter());
54
- this._onDidChangeConfigurationProviders = ( new Emitter());
55
- this.onDidChangeConfigurationProviders = this._onDidChangeConfigurationProviders.event;
56
- this.configProviders = [];
57
- this.toDispose = [this._onDidChangeConfigurationProviders];
58
- this.initLaunches();
59
- this.setCompoundSchemaValues();
60
- this.registerListeners();
61
- const previousSelectedRoot = this.storageService.get(DEBUG_SELECTED_ROOT, 1 );
62
- const previousSelectedType = this.storageService.get(DEBUG_SELECTED_TYPE, 1 );
63
- const previousSelectedLaunch = this.launches.find(l => ( l.uri.toString()) === previousSelectedRoot);
64
- const previousSelectedName = this.storageService.get(DEBUG_SELECTED_CONFIG_NAME_KEY, 1 );
65
- this.debugConfigurationTypeContext = CONTEXT_DEBUG_CONFIGURATION_TYPE.bindTo(contextKeyService);
66
- const dynamicConfig = previousSelectedType ? { type: previousSelectedType } : undefined;
67
- if (previousSelectedLaunch && previousSelectedLaunch.getConfigurationNames().length) {
68
- this.selectConfiguration(previousSelectedLaunch, previousSelectedName, undefined, dynamicConfig);
69
- }
70
- else if (this.launches.length > 0) {
71
- this.selectConfiguration(undefined, previousSelectedName, undefined, dynamicConfig);
72
- }
73
- }
74
- registerDebugConfigurationProvider(debugConfigurationProvider) {
75
- this.configProviders.push(debugConfigurationProvider);
76
- this._onDidChangeConfigurationProviders.fire();
77
- return {
78
- dispose: () => {
79
- this.unregisterDebugConfigurationProvider(debugConfigurationProvider);
80
- this._onDidChangeConfigurationProviders.fire();
81
- }
82
- };
83
- }
84
- unregisterDebugConfigurationProvider(debugConfigurationProvider) {
85
- const ix = this.configProviders.indexOf(debugConfigurationProvider);
86
- if (ix >= 0) {
87
- this.configProviders.splice(ix, 1);
88
- }
89
- }
90
- hasDebugConfigurationProvider(debugType, triggerKind) {
91
- if (triggerKind === undefined) {
92
- triggerKind = DebugConfigurationProviderTriggerKind.Initial;
93
- }
94
- const provider = this.configProviders.find(p => p.provideDebugConfigurations && (p.type === debugType) && (p.triggerKind === triggerKind));
95
- return !!provider;
96
- }
97
- async resolveConfigurationByProviders(folderUri, type, config, token) {
98
- const resolveDebugConfigurationForType = async (type, config) => {
99
- if (type !== '*') {
100
- await this.adapterManager.activateDebuggers('onDebugResolve', type);
101
- }
102
- for (const p of this.configProviders) {
103
- if (p.type === type && p.resolveDebugConfiguration && config) {
104
- config = await p.resolveDebugConfiguration(folderUri, config, token);
105
- }
106
- }
107
- return config;
108
- };
109
- let resolvedType = config.type ?? type;
110
- let result = config;
111
- for (let seen = ( new Set()); result && !( seen.has(resolvedType));) {
112
- seen.add(resolvedType);
113
- result = await resolveDebugConfigurationForType(resolvedType, result);
114
- result = await resolveDebugConfigurationForType('*', result);
115
- resolvedType = result?.type ?? type;
116
- }
117
- return result;
118
- }
119
- async resolveDebugConfigurationWithSubstitutedVariables(folderUri, type, config, token) {
120
- const providers = this.configProviders.filter(p => p.type === type && p.resolveDebugConfigurationWithSubstitutedVariables)
121
- .concat(this.configProviders.filter(p => p.type === '*' && p.resolveDebugConfigurationWithSubstitutedVariables));
122
- let result = config;
123
- await sequence(( providers.map(provider => async () => {
124
- if (result) {
125
- result = await provider.resolveDebugConfigurationWithSubstitutedVariables(folderUri, result, token);
126
- }
127
- })));
128
- return result;
129
- }
130
- async provideDebugConfigurations(folderUri, type, token) {
131
- await this.adapterManager.activateDebuggers('onDebugInitialConfigurations');
132
- const results = await Promise.all(( this.configProviders.filter(p => p.type === type && p.triggerKind === DebugConfigurationProviderTriggerKind.Initial && p.provideDebugConfigurations).map(p => p.provideDebugConfigurations(folderUri, token))));
133
- return results.reduce((first, second) => first.concat(second), []);
134
- }
135
- async getDynamicProviders() {
136
- await this.extensionService.whenInstalledExtensionsRegistered();
137
- const onDebugDynamicConfigurationsName = 'onDebugDynamicConfigurations';
138
- const debugDynamicExtensionsTypes = this.extensionService.extensions.reduce((acc, e) => {
139
- if (!e.activationEvents) {
140
- return acc;
141
- }
142
- const explicitTypes = [];
143
- let hasGenericEvent = false;
144
- for (const event of e.activationEvents) {
145
- if (event === onDebugDynamicConfigurationsName) {
146
- hasGenericEvent = true;
147
- }
148
- else if (event.startsWith(`${onDebugDynamicConfigurationsName}:`)) {
149
- explicitTypes.push(event.slice(onDebugDynamicConfigurationsName.length + 1));
150
- }
151
- }
152
- if (explicitTypes.length) {
153
- explicitTypes.forEach(t => acc.add(t));
154
- }
155
- else if (hasGenericEvent) {
156
- const debuggerType = e.contributes?.debuggers?.[0].type;
157
- if (debuggerType) {
158
- acc.add(debuggerType);
159
- }
160
- }
161
- return acc;
162
- }, ( new Set()));
163
- for (const configProvider of this.configProviders) {
164
- if (configProvider.triggerKind === DebugConfigurationProviderTriggerKind.Dynamic) {
165
- debugDynamicExtensionsTypes.add(configProvider.type);
166
- }
167
- }
168
- return ( [...debugDynamicExtensionsTypes].map(type => {
169
- return {
170
- label: this.adapterManager.getDebuggerLabel(type),
171
- getProvider: async () => {
172
- await this.adapterManager.activateDebuggers(onDebugDynamicConfigurationsName, type);
173
- return this.configProviders.find(p => p.type === type && p.triggerKind === DebugConfigurationProviderTriggerKind.Dynamic && p.provideDebugConfigurations);
174
- },
175
- type,
176
- pick: async () => {
177
- await this.adapterManager.activateDebuggers(onDebugDynamicConfigurationsName, type);
178
- const token = ( new CancellationTokenSource());
179
- const picks = [];
180
- const provider = this.configProviders.find(p => p.type === type && p.triggerKind === DebugConfigurationProviderTriggerKind.Dynamic && p.provideDebugConfigurations);
181
- this.getLaunches().forEach(launch => {
182
- if (launch.workspace && provider) {
183
- picks.push(provider.provideDebugConfigurations(launch.workspace.uri, token.token).then(configurations => ( configurations.map(config => ({
184
- label: config.name,
185
- description: launch.name,
186
- config,
187
- buttons: [{
188
- iconClass: ThemeIcon.asClassName(debugConfigure),
189
- tooltip: ( localizeWithPath(
190
- 'vs/workbench/contrib/debug/browser/debugConfigurationManager',
191
- 'editLaunchConfig',
192
- "Edit Debug Configuration in launch.json"
193
- ))
194
- }],
195
- launch
196
- })))));
197
- }
198
- });
199
- const disposables = ( new DisposableStore());
200
- const input = disposables.add(this.quickInputService.createQuickPick());
201
- input.busy = true;
202
- input.placeholder = ( localizeWithPath(
203
- 'vs/workbench/contrib/debug/browser/debugConfigurationManager',
204
- 'selectConfiguration',
205
- "Select Launch Configuration"
206
- ));
207
- const chosenPromise = ( new Promise(resolve => {
208
- disposables.add(input.onDidAccept(() => resolve(input.activeItems[0])));
209
- disposables.add(input.onDidTriggerItemButton(async (context) => {
210
- resolve(undefined);
211
- const { launch, config } = context.item;
212
- await launch.openConfigFile({ preserveFocus: false, type: config.type, suppressInitialConfigs: true });
213
- await launch.writeConfiguration(config);
214
- await this.selectConfiguration(launch, config.name);
215
- this.removeRecentDynamicConfigurations(config.name, config.type);
216
- }));
217
- disposables.add(input.onDidHide(() => resolve(undefined)));
218
- }));
219
- const nestedPicks = await Promise.all(picks);
220
- const items = flatten(nestedPicks);
221
- input.items = items;
222
- input.busy = false;
223
- input.show();
224
- const chosen = await chosenPromise;
225
- disposables.dispose();
226
- if (!chosen) {
227
- token.cancel();
228
- return;
229
- }
230
- return chosen;
231
- }
232
- };
233
- }));
234
- }
235
- getAllConfigurations() {
236
- const all = [];
237
- for (const l of this.launches) {
238
- for (const name of l.getConfigurationNames()) {
239
- const config = l.getConfiguration(name) || l.getCompound(name);
240
- if (config) {
241
- all.push({ launch: l, name, presentation: config.presentation });
242
- }
243
- }
244
- }
245
- return getVisibleAndSorted(all);
246
- }
247
- removeRecentDynamicConfigurations(name, type) {
248
- const remaining = this.getRecentDynamicConfigurations().filter(c => c.name !== name || c.type !== type);
249
- this.storageService.store(DEBUG_RECENT_DYNAMIC_CONFIGURATIONS, JSON.stringify(remaining), 1 , 1 );
250
- if (this.selectedConfiguration.name === name && this.selectedType === type && this.selectedDynamic) {
251
- this.selectConfiguration(undefined, undefined);
252
- }
253
- else {
254
- this._onDidSelectConfigurationName.fire();
255
- }
256
- }
257
- getRecentDynamicConfigurations() {
258
- return JSON.parse(this.storageService.get(DEBUG_RECENT_DYNAMIC_CONFIGURATIONS, 1 , '[]'));
259
- }
260
- registerListeners() {
261
- this.toDispose.push(Event.any(this.contextService.onDidChangeWorkspaceFolders, this.contextService.onDidChangeWorkbenchState)(() => {
262
- this.initLaunches();
263
- this.selectConfiguration(undefined);
264
- this.setCompoundSchemaValues();
265
- }));
266
- this.toDispose.push(this.configurationService.onDidChangeConfiguration(async (e) => {
267
- if (e.affectsConfiguration('launch')) {
268
- await this.selectConfiguration(undefined);
269
- this.setCompoundSchemaValues();
270
- }
271
- }));
272
- this.toDispose.push(this.adapterManager.onDidDebuggersExtPointRead(() => {
273
- this.setCompoundSchemaValues();
274
- }));
275
- }
276
- initLaunches() {
277
- this.launches = ( this.contextService.getWorkspace().folders.map(
278
- folder => this.instantiationService.createInstance(Launch, this, this.adapterManager, folder)
279
- ));
280
- if (this.contextService.getWorkbenchState() === 3 ) {
281
- this.launches.push(this.instantiationService.createInstance(WorkspaceLaunch, this, this.adapterManager));
282
- }
283
- this.launches.push(this.instantiationService.createInstance(UserLaunch, this, this.adapterManager));
284
- if (this.selectedLaunch && this.launches.indexOf(this.selectedLaunch) === -1) {
285
- this.selectConfiguration(undefined);
286
- }
287
- }
288
- setCompoundSchemaValues() {
289
- const compoundConfigurationsSchema = launchSchema.properties['compounds'].items.properties['configurations'];
290
- const launchNames = ( this.launches.map(l => l.getConfigurationNames(true))).reduce((first, second) => first.concat(second), []);
291
- compoundConfigurationsSchema.items.oneOf[0].enum = launchNames;
292
- compoundConfigurationsSchema.items.oneOf[1].properties.name.enum = launchNames;
293
- const folderNames = ( this.contextService.getWorkspace().folders.map(f => f.name));
294
- compoundConfigurationsSchema.items.oneOf[1].properties.folder.enum = folderNames;
295
- jsonRegistry.registerSchema(launchSchemaId, launchSchema);
296
- }
297
- getLaunches() {
298
- return this.launches;
299
- }
300
- getLaunch(workspaceUri) {
301
- if (!URI.isUri(workspaceUri)) {
302
- return undefined;
303
- }
304
- return this.launches.find(l => l.workspace && this.uriIdentityService.extUri.isEqual(l.workspace.uri, workspaceUri));
305
- }
306
- get selectedConfiguration() {
307
- return {
308
- launch: this.selectedLaunch,
309
- name: this.selectedName,
310
- getConfig: this.getSelectedConfig,
311
- type: this.selectedType
312
- };
313
- }
314
- get onDidSelectConfiguration() {
315
- return this._onDidSelectConfigurationName.event;
316
- }
317
- getWorkspaceLaunch() {
318
- if (this.contextService.getWorkbenchState() === 3 ) {
319
- return this.launches[this.launches.length - 1];
320
- }
321
- return undefined;
322
- }
323
- async selectConfiguration(launch, name, config, dynamicConfig) {
324
- if (typeof launch === 'undefined') {
325
- const rootUri = this.historyService.getLastActiveWorkspaceRoot();
326
- launch = this.getLaunch(rootUri);
327
- if (!launch || launch.getConfigurationNames().length === 0) {
328
- launch = this.launches.find(l => !!(l && l.getConfigurationNames().length)) || launch || this.launches[0];
329
- }
330
- }
331
- const previousLaunch = this.selectedLaunch;
332
- const previousName = this.selectedName;
333
- const previousSelectedDynamic = this.selectedDynamic;
334
- this.selectedLaunch = launch;
335
- if (this.selectedLaunch) {
336
- this.storageService.store(DEBUG_SELECTED_ROOT, ( this.selectedLaunch.uri.toString()), 1 , 1 );
337
- }
338
- else {
339
- this.storageService.remove(DEBUG_SELECTED_ROOT, 1 );
340
- }
341
- const names = launch ? launch.getConfigurationNames() : [];
342
- this.getSelectedConfig = () => {
343
- const selected = this.selectedName ? launch?.getConfiguration(this.selectedName) : undefined;
344
- return Promise.resolve(selected || config);
345
- };
346
- let type = config?.type;
347
- if (name && names.indexOf(name) >= 0) {
348
- this.setSelectedLaunchName(name);
349
- }
350
- else if (dynamicConfig && dynamicConfig.type) {
351
- type = dynamicConfig.type;
352
- if (!config) {
353
- const providers = (await this.getDynamicProviders()).filter(p => p.type === type);
354
- this.getSelectedConfig = async () => {
355
- const activatedProviders = await Promise.all(( providers.map(p => p.getProvider())));
356
- const provider = activatedProviders.length > 0 ? activatedProviders[0] : undefined;
357
- if (provider && launch && launch.workspace) {
358
- const token = ( new CancellationTokenSource());
359
- const dynamicConfigs = await provider.provideDebugConfigurations(launch.workspace.uri, token.token);
360
- const dynamicConfig = dynamicConfigs.find(c => c.name === name);
361
- if (dynamicConfig) {
362
- return dynamicConfig;
363
- }
364
- }
365
- return undefined;
366
- };
367
- }
368
- this.setSelectedLaunchName(name);
369
- let recentDynamicProviders = this.getRecentDynamicConfigurations();
370
- if (name && dynamicConfig.type) {
371
- recentDynamicProviders.unshift({ name, type: dynamicConfig.type });
372
- recentDynamicProviders = distinct(recentDynamicProviders, t => `${t.name} : ${t.type}`);
373
- this.storageService.store(DEBUG_RECENT_DYNAMIC_CONFIGURATIONS, JSON.stringify(recentDynamicProviders), 1 , 1 );
374
- }
375
- }
376
- else if (!this.selectedName || names.indexOf(this.selectedName) === -1) {
377
- const nameToSet = names.length ? names[0] : undefined;
378
- this.setSelectedLaunchName(nameToSet);
379
- }
380
- if (!config && launch && this.selectedName) {
381
- config = launch.getConfiguration(this.selectedName);
382
- type = config?.type;
383
- }
384
- this.selectedType = dynamicConfig?.type || config?.type;
385
- this.selectedDynamic = !!dynamicConfig;
386
- this.storageService.store(DEBUG_SELECTED_TYPE, dynamicConfig ? this.selectedType : undefined, 1 , 1 );
387
- if (type) {
388
- this.debugConfigurationTypeContext.set(type);
389
- }
390
- else {
391
- this.debugConfigurationTypeContext.reset();
392
- }
393
- if (this.selectedLaunch !== previousLaunch || this.selectedName !== previousName || previousSelectedDynamic !== this.selectedDynamic) {
394
- this._onDidSelectConfigurationName.fire();
395
- }
396
- }
397
- setSelectedLaunchName(selectedName) {
398
- this.selectedName = selectedName;
399
- if (this.selectedName) {
400
- this.storageService.store(DEBUG_SELECTED_CONFIG_NAME_KEY, this.selectedName, 1 , 1 );
401
- }
402
- else {
403
- this.storageService.remove(DEBUG_SELECTED_CONFIG_NAME_KEY, 1 );
404
- }
405
- }
406
- dispose() {
407
- this.toDispose = dispose(this.toDispose);
408
- }
409
- };
410
- ConfigurationManager = ( __decorate([
411
- ( __param(1, IWorkspaceContextService)),
412
- ( __param(2, IConfigurationService)),
413
- ( __param(3, IQuickInputService)),
414
- ( __param(4, IInstantiationService)),
415
- ( __param(5, IStorageService)),
416
- ( __param(6, IExtensionService)),
417
- ( __param(7, IHistoryService)),
418
- ( __param(8, IUriIdentityService)),
419
- ( __param(9, IContextKeyService))
420
- ], ConfigurationManager));
421
- class AbstractLaunch {
422
- constructor(configurationManager, adapterManager) {
423
- this.configurationManager = configurationManager;
424
- this.adapterManager = adapterManager;
425
- }
426
- getCompound(name) {
427
- const config = this.getConfig();
428
- if (!config || !config.compounds) {
429
- return undefined;
430
- }
431
- return config.compounds.find(compound => compound.name === name);
432
- }
433
- getConfigurationNames(ignoreCompoundsAndPresentation = false) {
434
- const config = this.getConfig();
435
- if (!config || (!Array.isArray(config.configurations) && !Array.isArray(config.compounds))) {
436
- return [];
437
- }
438
- else {
439
- const configurations = [];
440
- if (config.configurations) {
441
- configurations.push(...config.configurations.filter(cfg => cfg && typeof cfg.name === 'string'));
442
- }
443
- if (ignoreCompoundsAndPresentation) {
444
- return ( configurations.map(c => c.name));
445
- }
446
- if (config.compounds) {
447
- configurations.push(...config.compounds.filter(compound => typeof compound.name === 'string' && compound.configurations && compound.configurations.length));
448
- }
449
- return ( getVisibleAndSorted(configurations).map(c => c.name));
450
- }
451
- }
452
- getConfiguration(name) {
453
- const config = deepClone(this.getConfig());
454
- if (!config || !config.configurations) {
455
- return undefined;
456
- }
457
- const configuration = config.configurations.find(config => config && config.name === name);
458
- if (configuration) {
459
- if (this instanceof UserLaunch) {
460
- configuration.__configurationTarget = 2 ;
461
- }
462
- else if (this instanceof WorkspaceLaunch) {
463
- configuration.__configurationTarget = 5 ;
464
- }
465
- else {
466
- configuration.__configurationTarget = 6 ;
467
- }
468
- }
469
- return configuration;
470
- }
471
- async getInitialConfigurationContent(folderUri, type, useInitialConfigs, token) {
472
- let content = '';
473
- const adapter = type ? this.adapterManager.getEnabledDebugger(type) : await this.adapterManager.guessDebugger(true);
474
- if (adapter) {
475
- const initialConfigs = useInitialConfigs ?
476
- await this.configurationManager.provideDebugConfigurations(folderUri, adapter.type, token || CancellationToken.None) :
477
- [];
478
- content = await adapter.getInitialConfigurationContent(initialConfigs);
479
- }
480
- return content;
481
- }
482
- get hidden() {
483
- return false;
484
- }
485
- }
486
- let Launch = class Launch extends AbstractLaunch {
487
- constructor(configurationManager, adapterManager, workspace, fileService, textFileService, editorService, configurationService) {
488
- super(configurationManager, adapterManager);
489
- this.workspace = workspace;
490
- this.fileService = fileService;
491
- this.textFileService = textFileService;
492
- this.editorService = editorService;
493
- this.configurationService = configurationService;
494
- }
495
- get uri() {
496
- return joinPath(this.workspace.uri, '/.vscode/launch.json');
497
- }
498
- get name() {
499
- return this.workspace.name;
500
- }
501
- getConfig() {
502
- return this.configurationService.inspect('launch', { resource: this.workspace.uri }).workspaceFolderValue;
503
- }
504
- async openConfigFile({ preserveFocus, type, suppressInitialConfigs }, token) {
505
- const resource = this.uri;
506
- let created = false;
507
- let content = '';
508
- try {
509
- const fileContent = await this.fileService.readFile(resource);
510
- content = ( fileContent.value.toString());
511
- }
512
- catch {
513
- content = await this.getInitialConfigurationContent(this.workspace.uri, type, !suppressInitialConfigs, token);
514
- if (!content) {
515
- return { editor: null, created: false };
516
- }
517
- created = true;
518
- try {
519
- await this.textFileService.write(resource, content);
520
- }
521
- catch (error) {
522
- throw new Error(localizeWithPath('vs/workbench/contrib/debug/browser/debugConfigurationManager', 'DebugConfig.failed', "Unable to create 'launch.json' file inside the '.vscode' folder ({0}).", error.message));
523
- }
524
- }
525
- const index = content.indexOf(`"${this.configurationManager.selectedConfiguration.name}"`);
526
- let startLineNumber = 1;
527
- for (let i = 0; i < index; i++) {
528
- if (content.charAt(i) === '\n') {
529
- startLineNumber++;
530
- }
531
- }
532
- const selection = startLineNumber > 1 ? { startLineNumber, startColumn: 4 } : undefined;
533
- const editor = await this.editorService.openEditor({
534
- resource,
535
- options: {
536
- selection,
537
- preserveFocus,
538
- pinned: created,
539
- revealIfVisible: true
540
- },
541
- }, ACTIVE_GROUP);
542
- return ({
543
- editor: editor ?? null,
544
- created
545
- });
546
- }
547
- async writeConfiguration(configuration) {
548
- const fullConfig = deepClone(this.getConfig());
549
- if (!fullConfig.configurations) {
550
- fullConfig.configurations = [];
551
- }
552
- fullConfig.configurations.push(configuration);
553
- await this.configurationService.updateValue('launch', fullConfig, { resource: this.workspace.uri }, 6 );
554
- }
555
- };
556
- Launch = ( __decorate([
557
- ( __param(3, IFileService)),
558
- ( __param(4, ITextFileService)),
559
- ( __param(5, IEditorService)),
560
- ( __param(6, IConfigurationService))
561
- ], Launch));
562
- let WorkspaceLaunch = class WorkspaceLaunch extends AbstractLaunch {
563
- constructor(configurationManager, adapterManager, editorService, configurationService, contextService) {
564
- super(configurationManager, adapterManager);
565
- this.editorService = editorService;
566
- this.configurationService = configurationService;
567
- this.contextService = contextService;
568
- }
569
- get workspace() {
570
- return undefined;
571
- }
572
- get uri() {
573
- return this.contextService.getWorkspace().configuration;
574
- }
575
- get name() {
576
- return ( localizeWithPath(
577
- 'vs/workbench/contrib/debug/browser/debugConfigurationManager',
578
- 'workspace',
579
- "workspace"
580
- ));
581
- }
582
- getConfig() {
583
- return this.configurationService.inspect('launch').workspaceValue;
584
- }
585
- async openConfigFile({ preserveFocus, type, useInitialConfigs }, token) {
586
- const launchExistInFile = !!this.getConfig();
587
- if (!launchExistInFile) {
588
- const content = await this.getInitialConfigurationContent(undefined, type, useInitialConfigs, token);
589
- if (content) {
590
- await this.configurationService.updateValue('launch', parse(content), 5 );
591
- }
592
- else {
593
- return { editor: null, created: false };
594
- }
595
- }
596
- const editor = await this.editorService.openEditor({
597
- resource: this.contextService.getWorkspace().configuration,
598
- options: { preserveFocus }
599
- }, ACTIVE_GROUP);
600
- return ({
601
- editor: editor ?? null,
602
- created: false
603
- });
604
- }
605
- };
606
- WorkspaceLaunch = ( __decorate([
607
- ( __param(2, IEditorService)),
608
- ( __param(3, IConfigurationService)),
609
- ( __param(4, IWorkspaceContextService))
610
- ], WorkspaceLaunch));
611
- let UserLaunch = class UserLaunch extends AbstractLaunch {
612
- constructor(configurationManager, adapterManager, configurationService, preferencesService) {
613
- super(configurationManager, adapterManager);
614
- this.configurationService = configurationService;
615
- this.preferencesService = preferencesService;
616
- }
617
- get workspace() {
618
- return undefined;
619
- }
620
- get uri() {
621
- return this.preferencesService.userSettingsResource;
622
- }
623
- get name() {
624
- return ( localizeWithPath(
625
- 'vs/workbench/contrib/debug/browser/debugConfigurationManager',
626
- 'user settings',
627
- "user settings"
628
- ));
629
- }
630
- get hidden() {
631
- return true;
632
- }
633
- getConfig() {
634
- return this.configurationService.inspect('launch').userValue;
635
- }
636
- async openConfigFile({ preserveFocus, type, useInitialContent }) {
637
- const editor = await this.preferencesService.openUserSettings({ jsonEditor: true, preserveFocus, revealSetting: { key: 'launch' } });
638
- return ({
639
- editor: editor ?? null,
640
- created: false
641
- });
642
- }
643
- };
644
- UserLaunch = ( __decorate([
645
- ( __param(2, IConfigurationService)),
646
- ( __param(3, IPreferencesService))
647
- ], UserLaunch));
648
-
649
- export { ConfigurationManager };