@theia/debug 1.29.0-next.20 → 1.29.0-next.22
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.
- package/lib/browser/debug-configuration-manager.d.ts +15 -7
- package/lib/browser/debug-configuration-manager.d.ts.map +1 -1
- package/lib/browser/debug-configuration-manager.js +81 -31
- package/lib/browser/debug-configuration-manager.js.map +1 -1
- package/lib/browser/debug-configuration-model.d.ts +3 -0
- package/lib/browser/debug-configuration-model.d.ts.map +1 -1
- package/lib/browser/debug-configuration-model.js +17 -10
- package/lib/browser/debug-configuration-model.js.map +1 -1
- package/lib/browser/debug-frontend-application-contribution.d.ts.map +1 -1
- package/lib/browser/debug-frontend-application-contribution.js +6 -3
- package/lib/browser/debug-frontend-application-contribution.js.map +1 -1
- package/lib/browser/debug-prefix-configuration.js +3 -3
- package/lib/browser/debug-prefix-configuration.js.map +1 -1
- package/lib/browser/debug-schema-updater.d.ts.map +1 -1
- package/lib/browser/debug-schema-updater.js +55 -4
- package/lib/browser/debug-schema-updater.js.map +1 -1
- package/lib/browser/debug-session-contribution.d.ts +2 -2
- package/lib/browser/debug-session-contribution.d.ts.map +1 -1
- package/lib/browser/debug-session-contribution.js.map +1 -1
- package/lib/browser/debug-session-manager.d.ts +10 -4
- package/lib/browser/debug-session-manager.d.ts.map +1 -1
- package/lib/browser/debug-session-manager.js +64 -7
- package/lib/browser/debug-session-manager.js.map +1 -1
- package/lib/browser/debug-session-options.d.ts +36 -6
- package/lib/browser/debug-session-options.d.ts.map +1 -1
- package/lib/browser/debug-session-options.js +53 -10
- package/lib/browser/debug-session-options.js.map +1 -1
- package/lib/browser/debug-session.d.ts +3 -3
- package/lib/browser/debug-session.d.ts.map +1 -1
- package/lib/browser/debug-session.js +7 -0
- package/lib/browser/debug-session.js.map +1 -1
- package/lib/browser/view/debug-configuration-select.d.ts +4 -1
- package/lib/browser/view/debug-configuration-select.d.ts.map +1 -1
- package/lib/browser/view/debug-configuration-select.js +36 -14
- package/lib/browser/view/debug-configuration-select.js.map +1 -1
- package/lib/common/debug-compound.d.ts +15 -0
- package/lib/common/debug-compound.d.ts.map +1 -0
- package/lib/common/debug-compound.js +27 -0
- package/lib/common/debug-compound.js.map +1 -0
- package/package.json +14 -14
- package/src/browser/debug-configuration-manager.ts +92 -40
- package/src/browser/debug-configuration-model.ts +19 -10
- package/src/browser/debug-frontend-application-contribution.ts +10 -3
- package/src/browser/debug-prefix-configuration.ts +3 -3
- package/src/browser/debug-schema-updater.ts +56 -5
- package/src/browser/debug-session-contribution.ts +2 -2
- package/src/browser/debug-session-manager.ts +79 -8
- package/src/browser/debug-session-options.ts +72 -15
- package/src/browser/debug-session.tsx +8 -2
- package/src/browser/view/debug-configuration-select.tsx +42 -20
- package/src/common/debug-compound.ts +32 -0
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
|
|
17
17
|
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
18
18
|
import { JsonSchemaRegisterContext, JsonSchemaContribution } from '@theia/core/lib/browser/json-schema-store';
|
|
19
|
-
import { InMemoryResources, deepClone } from '@theia/core/lib/common';
|
|
19
|
+
import { InMemoryResources, deepClone, nls } from '@theia/core/lib/common';
|
|
20
20
|
import { IJSONSchema } from '@theia/core/lib/common/json-schema';
|
|
21
21
|
import URI from '@theia/core/lib/common/uri';
|
|
22
22
|
import { DebugService } from '../common/debug-service';
|
|
23
23
|
import { debugPreferencesSchema } from './debug-preferences';
|
|
24
24
|
import { inputsSchema } from '@theia/variable-resolver/lib/browser/variable-input-schema';
|
|
25
25
|
import { WorkspaceService } from '@theia/workspace/lib/browser';
|
|
26
|
+
import { defaultCompound } from '../common/debug-compound';
|
|
26
27
|
|
|
27
28
|
@injectable()
|
|
28
29
|
export class DebugSchemaUpdater implements JsonSchemaContribution {
|
|
@@ -73,24 +74,74 @@ export const launchSchemaId = 'vscode://schemas/launch';
|
|
|
73
74
|
const launchSchema: IJSONSchema = {
|
|
74
75
|
$id: launchSchemaId,
|
|
75
76
|
type: 'object',
|
|
76
|
-
title: 'Launch',
|
|
77
|
+
title: nls.localizeByDefault('Launch'),
|
|
77
78
|
required: [],
|
|
78
|
-
default: { version: '0.2.0', configurations: [] },
|
|
79
|
+
default: { version: '0.2.0', configurations: [], compounds: [] },
|
|
79
80
|
properties: {
|
|
80
81
|
version: {
|
|
81
82
|
type: 'string',
|
|
82
|
-
description: 'Version of this file format.',
|
|
83
|
+
description: nls.localizeByDefault('Version of this file format.'),
|
|
83
84
|
default: '0.2.0'
|
|
84
85
|
},
|
|
85
86
|
configurations: {
|
|
86
87
|
type: 'array',
|
|
87
|
-
description: 'List of configurations. Add new configurations or edit existing ones by using IntelliSense.',
|
|
88
|
+
description: nls.localizeByDefault('List of configurations. Add new configurations or edit existing ones by using IntelliSense.'),
|
|
88
89
|
items: {
|
|
89
90
|
defaultSnippets: [],
|
|
90
91
|
'type': 'object',
|
|
91
92
|
oneOf: []
|
|
92
93
|
}
|
|
93
94
|
},
|
|
95
|
+
compounds: {
|
|
96
|
+
type: 'array',
|
|
97
|
+
description: nls.localizeByDefault('List of compounds. Each compound references multiple configurations which will get launched together.'),
|
|
98
|
+
items: {
|
|
99
|
+
type: 'object',
|
|
100
|
+
required: ['name', 'configurations'],
|
|
101
|
+
properties: {
|
|
102
|
+
name: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
description: nls.localizeByDefault('Name of compound. Appears in the launch configuration drop down menu.')
|
|
105
|
+
},
|
|
106
|
+
configurations: {
|
|
107
|
+
type: 'array',
|
|
108
|
+
default: [],
|
|
109
|
+
items: {
|
|
110
|
+
oneOf: [{
|
|
111
|
+
type: 'string',
|
|
112
|
+
description: nls.localizeByDefault('Please use unique configuration names.')
|
|
113
|
+
}, {
|
|
114
|
+
type: 'object',
|
|
115
|
+
required: ['name'],
|
|
116
|
+
properties: {
|
|
117
|
+
name: {
|
|
118
|
+
enum: [],
|
|
119
|
+
description: nls.localizeByDefault('Name of compound. Appears in the launch configuration drop down menu.')
|
|
120
|
+
},
|
|
121
|
+
folder: {
|
|
122
|
+
enum: [],
|
|
123
|
+
description: nls.localizeByDefault('Name of folder in which the compound is located.')
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}]
|
|
127
|
+
},
|
|
128
|
+
description: nls.localizeByDefault('Names of configurations that will be started as part of this compound.')
|
|
129
|
+
},
|
|
130
|
+
stopAll: {
|
|
131
|
+
type: 'boolean',
|
|
132
|
+
default: false,
|
|
133
|
+
description: nls.localizeByDefault('Controls whether manually terminating one session will stop all of the compound sessions.')
|
|
134
|
+
},
|
|
135
|
+
preLaunchTask: {
|
|
136
|
+
type: 'string',
|
|
137
|
+
default: '',
|
|
138
|
+
description: nls.localizeByDefault('Task to run before any of the compound configurations start.')
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
default: defaultCompound
|
|
142
|
+
},
|
|
143
|
+
default: [defaultCompound]
|
|
144
|
+
},
|
|
94
145
|
inputs: inputsSchema.definitions!.inputs
|
|
95
146
|
},
|
|
96
147
|
allowComments: true,
|
|
@@ -22,7 +22,7 @@ import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-servi
|
|
|
22
22
|
import { WebSocketConnectionProvider } from '@theia/core/lib/browser/messaging/ws-connection-provider';
|
|
23
23
|
import { DebugSession } from './debug-session';
|
|
24
24
|
import { BreakpointManager } from './breakpoint/breakpoint-manager';
|
|
25
|
-
import { DebugSessionOptions } from './debug-session-options';
|
|
25
|
+
import { DebugConfigurationSessionOptions, DebugSessionOptions } from './debug-session-options';
|
|
26
26
|
import { OutputChannelManager, OutputChannel } from '@theia/output/lib/browser/output-channel';
|
|
27
27
|
import { DebugPreferences } from './debug-preferences';
|
|
28
28
|
import { DebugSessionConnection } from './debug-session-connection';
|
|
@@ -118,7 +118,7 @@ export class DefaultDebugSessionFactory implements DebugSessionFactory {
|
|
|
118
118
|
@inject(WorkspaceService)
|
|
119
119
|
protected readonly workspaceService: WorkspaceService;
|
|
120
120
|
|
|
121
|
-
get(sessionId: string, options:
|
|
121
|
+
get(sessionId: string, options: DebugConfigurationSessionOptions, parentSession?: DebugSession): DebugSession {
|
|
122
122
|
const connection = new DebugSessionConnection(
|
|
123
123
|
sessionId,
|
|
124
124
|
() => new Promise<DebugChannel>(resolve =>
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { DisposableCollection, Emitter, Event, MessageService, ProgressService, WaitUntilEvent } from '@theia/core';
|
|
17
|
+
import { DisposableCollection, Emitter, Event, MessageService, nls, ProgressService, WaitUntilEvent } from '@theia/core';
|
|
18
18
|
import { LabelProvider, ApplicationShell } from '@theia/core/lib/browser';
|
|
19
19
|
import { ContextKey, ContextKeyService } from '@theia/core/lib/browser/context-key-service';
|
|
20
20
|
import URI from '@theia/core/lib/common/uri';
|
|
@@ -29,7 +29,7 @@ import { BreakpointManager } from './breakpoint/breakpoint-manager';
|
|
|
29
29
|
import { DebugConfigurationManager } from './debug-configuration-manager';
|
|
30
30
|
import { DebugSession, DebugState } from './debug-session';
|
|
31
31
|
import { DebugSessionContributionRegistry, DebugSessionFactory } from './debug-session-contribution';
|
|
32
|
-
import { DebugSessionOptions, InternalDebugSessionOptions } from './debug-session-options';
|
|
32
|
+
import { DebugCompoundRoot, DebugCompoundSessionOptions, DebugConfigurationSessionOptions, DebugSessionOptions, InternalDebugSessionOptions } from './debug-session-options';
|
|
33
33
|
import { DebugStackFrame } from './model/debug-stack-frame';
|
|
34
34
|
import { DebugThread } from './model/debug-thread';
|
|
35
35
|
import { TaskIdentifier } from '@theia/task/lib/common';
|
|
@@ -191,7 +191,19 @@ export class DebugSessionManager {
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
async start(options:
|
|
194
|
+
async start(options: DebugCompoundSessionOptions): Promise<boolean | undefined>;
|
|
195
|
+
async start(options: DebugConfigurationSessionOptions): Promise<DebugSession | undefined>;
|
|
196
|
+
async start(options: DebugSessionOptions): Promise<DebugSession | boolean | undefined>;
|
|
197
|
+
async start(name: string): Promise<DebugSession | boolean | undefined>;
|
|
198
|
+
async start(optionsOrName: DebugSessionOptions | string): Promise<DebugSession | boolean | undefined> {
|
|
199
|
+
if (typeof optionsOrName === 'string') {
|
|
200
|
+
const options = this.debugConfigurationManager.find(optionsOrName);
|
|
201
|
+
return !!options && this.start(options);
|
|
202
|
+
}
|
|
203
|
+
return optionsOrName.configuration ? this.startConfiguration(optionsOrName) : this.startCompound(optionsOrName);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
protected async startConfiguration(options: DebugConfigurationSessionOptions): Promise<DebugSession | undefined> {
|
|
195
207
|
return this.progressService.withProgress('Start...', 'debug', async () => {
|
|
196
208
|
try {
|
|
197
209
|
if (!await this.saveAll()) {
|
|
@@ -200,7 +212,7 @@ export class DebugSessionManager {
|
|
|
200
212
|
await this.fireWillStartDebugSession();
|
|
201
213
|
const resolved = await this.resolveConfiguration(options);
|
|
202
214
|
|
|
203
|
-
if (!resolved) {
|
|
215
|
+
if (!resolved || !resolved.configuration) {
|
|
204
216
|
// As per vscode API: https://code.visualstudio.com/api/references/vscode-api#DebugConfigurationProvider
|
|
205
217
|
// "Returning the value 'undefined' prevents the debug session from starting.
|
|
206
218
|
// Returning the value 'null' prevents the debug session from starting and opens the
|
|
@@ -236,13 +248,70 @@ export class DebugSessionManager {
|
|
|
236
248
|
});
|
|
237
249
|
}
|
|
238
250
|
|
|
251
|
+
protected async startCompound(options: DebugCompoundSessionOptions): Promise<boolean | undefined> {
|
|
252
|
+
let configurations: DebugConfigurationSessionOptions[] = [];
|
|
253
|
+
try {
|
|
254
|
+
configurations = this.getCompoundConfigurations(options);
|
|
255
|
+
} catch (error) {
|
|
256
|
+
this.messageService.error(error.message);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (options.compound.preLaunchTask) {
|
|
261
|
+
const taskRun = await this.runTask(options.workspaceFolderUri, options.compound.preLaunchTask, true);
|
|
262
|
+
if (!taskRun) {
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Compound launch is a success only if each configuration launched successfully
|
|
268
|
+
const values = await Promise.all(configurations.map(configuration => this.startConfiguration(configuration)));
|
|
269
|
+
const result = values.every(success => !!success);
|
|
270
|
+
return result;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
protected getCompoundConfigurations(options: DebugCompoundSessionOptions): DebugConfigurationSessionOptions[] {
|
|
274
|
+
const compound = options.compound;
|
|
275
|
+
if (!compound.configurations) {
|
|
276
|
+
throw new Error(nls.localizeByDefault('Compound must have "configurations" attribute set in order to start multiple configurations.'));
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const compoundRoot = compound.stopAll ? new DebugCompoundRoot() : undefined;
|
|
280
|
+
const configurations: DebugConfigurationSessionOptions[] = [];
|
|
281
|
+
for (const configData of compound.configurations) {
|
|
282
|
+
const name = typeof configData === 'string' ? configData : configData.name;
|
|
283
|
+
if (name === compound.name) {
|
|
284
|
+
throw new Error(nls.localize('theia/debug/compound-cycle', "Launch configuration '{0}' contains a cycle with itself", name));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const workspaceFolderUri = typeof configData === 'string' ? options.workspaceFolderUri : configData.folder;
|
|
288
|
+
const matchingOptions = [...this.debugConfigurationManager.all]
|
|
289
|
+
.filter(option => option.name === name && !!option.configuration && option.workspaceFolderUri === workspaceFolderUri);
|
|
290
|
+
if (matchingOptions.length === 1) {
|
|
291
|
+
const match = matchingOptions[0];
|
|
292
|
+
if (DebugSessionOptions.isConfiguration(match)) {
|
|
293
|
+
configurations.push({ ...match, compoundRoot, configuration: { ...match.configuration, noDebug: options.noDebug } });
|
|
294
|
+
} else {
|
|
295
|
+
throw new Error(nls.localizeByDefault("Could not find launch configuration '{0}' in the workspace.", name));
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
throw new Error(matchingOptions.length === 0
|
|
299
|
+
? workspaceFolderUri
|
|
300
|
+
? nls.localizeByDefault("Can not find folder with name '{0}' for configuration '{1}' in compound '{2}'.", workspaceFolderUri, name, compound.name)
|
|
301
|
+
: nls.localizeByDefault("Could not find launch configuration '{0}' in the workspace.", name)
|
|
302
|
+
: nls.localizeByDefault("There are multiple launch configurations '{0}' in the workspace. Use folder name to qualify the configuration.", name));
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return configurations;
|
|
306
|
+
}
|
|
307
|
+
|
|
239
308
|
protected async fireWillStartDebugSession(): Promise<void> {
|
|
240
309
|
await WaitUntilEvent.fire(this.onWillStartDebugSessionEmitter, {});
|
|
241
310
|
}
|
|
242
311
|
|
|
243
312
|
protected configurationIds = new Map<string, number>();
|
|
244
313
|
protected async resolveConfiguration(
|
|
245
|
-
options: Readonly<
|
|
314
|
+
options: Readonly<DebugConfigurationSessionOptions>
|
|
246
315
|
): Promise<InternalDebugSessionOptions | undefined | null> {
|
|
247
316
|
if (InternalDebugSessionOptions.is(options)) {
|
|
248
317
|
return options;
|
|
@@ -275,10 +344,12 @@ export class DebugSessionManager {
|
|
|
275
344
|
const key = configuration.name + workspaceFolderUri;
|
|
276
345
|
const id = this.configurationIds.has(key) ? this.configurationIds.get(key)! + 1 : 0;
|
|
277
346
|
this.configurationIds.set(key, id);
|
|
347
|
+
|
|
278
348
|
return {
|
|
279
349
|
id,
|
|
280
|
-
|
|
281
|
-
|
|
350
|
+
...options,
|
|
351
|
+
name: configuration.name,
|
|
352
|
+
configuration
|
|
282
353
|
};
|
|
283
354
|
}
|
|
284
355
|
|
|
@@ -301,7 +372,7 @@ export class DebugSessionManager {
|
|
|
301
372
|
return this.debug.resolveDebugConfigurationWithSubstitutedVariables(configuration, workspaceFolderUri);
|
|
302
373
|
}
|
|
303
374
|
|
|
304
|
-
protected async doStart(sessionId: string, options:
|
|
375
|
+
protected async doStart(sessionId: string, options: DebugConfigurationSessionOptions): Promise<DebugSession> {
|
|
305
376
|
const parentSession = options.configuration.parentSession && this._sessions.get(options.configuration.parentSession.id);
|
|
306
377
|
const contrib = this.sessionContributionRegistry.get(options.configuration.type);
|
|
307
378
|
const sessionFactory = contrib ? contrib.debugSessionFactory() : this.debugSessionFactory;
|
|
@@ -14,44 +14,101 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
+
import { Emitter } from '@theia/core';
|
|
17
18
|
import { DebugConfiguration } from '../common/debug-common';
|
|
19
|
+
import { DebugCompound } from '../common/debug-compound';
|
|
20
|
+
|
|
21
|
+
export class DebugCompoundRoot {
|
|
22
|
+
private stopped = false;
|
|
23
|
+
private stopEmitter = new Emitter<void>();
|
|
24
|
+
onDidSessionStop = this.stopEmitter.event;
|
|
25
|
+
|
|
26
|
+
stopSession(): void {
|
|
27
|
+
if (!this.stopped) { // avoid sending extraneous terminate events
|
|
28
|
+
this.stopped = true;
|
|
29
|
+
this.stopEmitter.fire();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
18
33
|
|
|
19
34
|
export interface DebugSessionOptionsBase {
|
|
20
35
|
workspaceFolderUri?: string,
|
|
21
|
-
providerType?: string // Applicable to dynamic configurations
|
|
22
36
|
}
|
|
23
37
|
|
|
24
|
-
export interface
|
|
25
|
-
|
|
38
|
+
export interface DebugConfigurationSessionOptions extends DebugSessionOptionsBase {
|
|
39
|
+
name: string; // derived from the configuration
|
|
40
|
+
configuration: DebugConfiguration;
|
|
41
|
+
compound?: never;
|
|
42
|
+
compoundRoot?: DebugCompoundRoot;
|
|
43
|
+
providerType?: string // Applicable to dynamic configurations
|
|
26
44
|
}
|
|
27
45
|
|
|
28
|
-
export
|
|
46
|
+
export type DynamicDebugConfigurationSessionOptions = DebugConfigurationSessionOptions & { providerType: string };
|
|
47
|
+
|
|
48
|
+
export interface DebugCompoundSessionOptions extends DebugSessionOptionsBase {
|
|
49
|
+
name: string; // derived from the compound
|
|
50
|
+
configuration?: never;
|
|
51
|
+
compound: DebugCompound;
|
|
52
|
+
noDebug?: boolean,
|
|
29
53
|
}
|
|
30
54
|
|
|
31
|
-
export
|
|
32
|
-
|
|
55
|
+
export type DebugSessionOptions = DebugConfigurationSessionOptions | DebugCompoundSessionOptions;
|
|
56
|
+
|
|
57
|
+
export namespace DebugSessionOptions {
|
|
58
|
+
export function isConfiguration(options?: DebugSessionOptions): options is DebugConfigurationSessionOptions {
|
|
59
|
+
return !!options && 'configuration' in options && !!options.configuration;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function isDynamic(options?: DebugSessionOptions): options is DynamicDebugConfigurationSessionOptions {
|
|
63
|
+
return isConfiguration(options) && 'providerType' in options && !!options.providerType;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function isCompound(options?: DebugSessionOptions): options is DebugCompoundSessionOptions {
|
|
67
|
+
return !!options && 'compound' in options && !!options.compound;
|
|
68
|
+
}
|
|
33
69
|
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Flat and partial version of a debug session options usable to find the options later in the manager.
|
|
73
|
+
* @deprecated Not needed anymore, the recommended way is to serialize/deserialize the options directly using `JSON.stringify` and `JSON.parse`.
|
|
74
|
+
*/
|
|
75
|
+
export type DebugSessionOptionsData = DebugSessionOptionsBase & (DebugConfiguration | DebugCompound);
|
|
76
|
+
|
|
77
|
+
export type InternalDebugSessionOptions = DebugSessionOptions & { id: number };
|
|
78
|
+
|
|
34
79
|
export namespace InternalDebugSessionOptions {
|
|
35
80
|
|
|
36
81
|
const SEPARATOR = '__CONF__';
|
|
82
|
+
const SEPARATOR_CONFIGS = '__COMP__';
|
|
37
83
|
|
|
38
84
|
export function is(options: DebugSessionOptions): options is InternalDebugSessionOptions {
|
|
39
85
|
return 'id' in options;
|
|
40
86
|
}
|
|
41
87
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
88
|
+
/** @deprecated Please use `JSON.stringify` to serialize the options. */
|
|
89
|
+
export function toValue(options: DebugSessionOptions): string {
|
|
90
|
+
if (DebugSessionOptions.isCompound(options)) {
|
|
91
|
+
return options.compound.name + SEPARATOR +
|
|
92
|
+
options.workspaceFolderUri + SEPARATOR +
|
|
93
|
+
options.compound?.configurations.join(SEPARATOR_CONFIGS);
|
|
94
|
+
}
|
|
95
|
+
return options.configuration.name + SEPARATOR +
|
|
96
|
+
options.configuration.type + SEPARATOR +
|
|
97
|
+
options.configuration.request + SEPARATOR +
|
|
98
|
+
options.workspaceFolderUri + SEPARATOR +
|
|
99
|
+
options.providerType;
|
|
48
100
|
}
|
|
49
101
|
|
|
102
|
+
/** @deprecated Please use `JSON.parse` to restore previously serialized debug session options. */
|
|
103
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
50
104
|
export function parseValue(value: string): DebugSessionOptionsData {
|
|
51
105
|
const split = value.split(SEPARATOR);
|
|
52
|
-
if (split.length
|
|
53
|
-
|
|
106
|
+
if (split.length === 5) {
|
|
107
|
+
return { name: split[0], type: split[1], request: split[2], workspaceFolderUri: split[3], providerType: split[4] };
|
|
108
|
+
}
|
|
109
|
+
if (split.length === 3) {
|
|
110
|
+
return { name: split[0], workspaceFolderUri: split[1], configurations: split[2].split(SEPARATOR_CONFIGS) };
|
|
54
111
|
}
|
|
55
|
-
|
|
112
|
+
throw new Error('Unexpected argument, the argument is expected to have been generated by the \'toValue\' function');
|
|
56
113
|
}
|
|
57
114
|
}
|
|
@@ -33,7 +33,7 @@ import { DebugSourceBreakpoint } from './model/debug-source-breakpoint';
|
|
|
33
33
|
import debounce = require('p-debounce');
|
|
34
34
|
import URI from '@theia/core/lib/common/uri';
|
|
35
35
|
import { BreakpointManager } from './breakpoint/breakpoint-manager';
|
|
36
|
-
import {
|
|
36
|
+
import { DebugConfigurationSessionOptions, InternalDebugSessionOptions } from './debug-session-options';
|
|
37
37
|
import { DebugConfiguration, DebugConsoleMode } from '../common/debug-common';
|
|
38
38
|
import { SourceBreakpoint, ExceptionBreakpoint } from './breakpoint/breakpoint-marker';
|
|
39
39
|
import { TerminalWidgetOptions, TerminalWidget } from '@theia/terminal/lib/browser/base/terminal-widget';
|
|
@@ -76,7 +76,7 @@ export class DebugSession implements CompositeTreeElement {
|
|
|
76
76
|
|
|
77
77
|
constructor(
|
|
78
78
|
readonly id: string,
|
|
79
|
-
readonly options:
|
|
79
|
+
readonly options: DebugConfigurationSessionOptions,
|
|
80
80
|
readonly parentSession: DebugSession | undefined,
|
|
81
81
|
protected readonly connection: DebugSessionConnection,
|
|
82
82
|
protected readonly terminalServer: TerminalService,
|
|
@@ -117,6 +117,9 @@ export class DebugSession implements CompositeTreeElement {
|
|
|
117
117
|
this.connection.on('capabilities', event => this.updateCapabilities(event.body.capabilities)),
|
|
118
118
|
this.breakpoints.onDidChangeMarkers(uri => this.updateBreakpoints({ uri, sourceModified: true }))
|
|
119
119
|
]);
|
|
120
|
+
if (this.options.compoundRoot) {
|
|
121
|
+
this.toDispose.push(this.options.compoundRoot.onDidSessionStop(() => this.stop(false, () => { })));
|
|
122
|
+
}
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
get onDispose(): Event<void> {
|
|
@@ -352,6 +355,9 @@ export class DebugSession implements CompositeTreeElement {
|
|
|
352
355
|
console.error('Error on disconnect', e);
|
|
353
356
|
}
|
|
354
357
|
}
|
|
358
|
+
if (!isRestart) {
|
|
359
|
+
this.options.compoundRoot?.stopSession();
|
|
360
|
+
}
|
|
355
361
|
callback();
|
|
356
362
|
}
|
|
357
363
|
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import URI from '@theia/core/lib/common/uri';
|
|
18
18
|
import * as React from '@theia/core/shared/react';
|
|
19
19
|
import { DebugConfigurationManager } from '../debug-configuration-manager';
|
|
20
|
-
import { DebugSessionOptions
|
|
20
|
+
import { DebugSessionOptions } from '../debug-session-options';
|
|
21
21
|
import { SelectComponent, SelectOption } from '@theia/core/lib/browser/widgets/select-component';
|
|
22
22
|
import { QuickInputService } from '@theia/core/lib/browser';
|
|
23
23
|
import { nls } from '@theia/core/lib/common/nls';
|
|
@@ -40,6 +40,7 @@ export class DebugConfigurationSelect extends React.Component<DebugConfiguration
|
|
|
40
40
|
protected static readonly PICK = '__PICK__';
|
|
41
41
|
protected static readonly NO_CONFIGURATION = '__NO_CONF__';
|
|
42
42
|
protected static readonly ADD_CONFIGURATION = '__ADD_CONF__';
|
|
43
|
+
protected static readonly CONFIG_MARKER = '__CONFIG__';
|
|
43
44
|
|
|
44
45
|
private readonly selectRef = React.createRef<SelectComponent>();
|
|
45
46
|
private manager: DebugConfigurationManager;
|
|
@@ -65,7 +66,7 @@ export class DebugConfigurationSelect extends React.Component<DebugConfiguration
|
|
|
65
66
|
override render(): React.ReactNode {
|
|
66
67
|
return <SelectComponent
|
|
67
68
|
options={this.renderOptions()}
|
|
68
|
-
defaultValue={this.currentValue}
|
|
69
|
+
defaultValue={this.state.currentValue}
|
|
69
70
|
onChange={option => this.setCurrentConfiguration(option)}
|
|
70
71
|
onFocus={() => this.refreshDebugConfigurations()}
|
|
71
72
|
onBlur={() => this.refreshDebugConfigurations()}
|
|
@@ -75,7 +76,26 @@ export class DebugConfigurationSelect extends React.Component<DebugConfiguration
|
|
|
75
76
|
|
|
76
77
|
protected get currentValue(): string {
|
|
77
78
|
const { current } = this.manager;
|
|
78
|
-
|
|
79
|
+
const matchingOption = this.getCurrentOption(current);
|
|
80
|
+
return matchingOption ? matchingOption.value! : current ? JSON.stringify(current) : DebugConfigurationSelect.NO_CONFIGURATION;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
protected getCurrentOption(current: DebugSessionOptions | undefined): SelectOption | undefined {
|
|
84
|
+
if (!current || !this.selectRef.current) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const matchingOption = this.selectRef.current!.options.find(option =>
|
|
88
|
+
option.userData === DebugConfigurationSelect.CONFIG_MARKER
|
|
89
|
+
&& this.matchesOption(JSON.parse(option.value!), current)
|
|
90
|
+
);
|
|
91
|
+
return matchingOption;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
protected matchesOption(sessionOption: DebugSessionOptions, current: DebugSessionOptions): boolean {
|
|
95
|
+
const matchesNameAndWorkspace = sessionOption.name === current.name && sessionOption.workspaceFolderUri === current.workspaceFolderUri;
|
|
96
|
+
return DebugSessionOptions.isConfiguration(sessionOption) && DebugSessionOptions.isConfiguration(current)
|
|
97
|
+
? matchesNameAndWorkspace && sessionOption.providerType === current.providerType
|
|
98
|
+
: matchesNameAndWorkspace;
|
|
79
99
|
}
|
|
80
100
|
|
|
81
101
|
protected readonly setCurrentConfiguration = (option: SelectOption) => {
|
|
@@ -88,12 +108,9 @@ export class DebugConfigurationSelect extends React.Component<DebugConfiguration
|
|
|
88
108
|
const providerType = this.parsePickValue(value);
|
|
89
109
|
this.selectDynamicConfigFromQuickPick(providerType);
|
|
90
110
|
} else {
|
|
91
|
-
const
|
|
92
|
-
this.manager.current =
|
|
93
|
-
|
|
94
|
-
workspaceFolderUri,
|
|
95
|
-
providerType === 'undefined' ? undefined : providerType
|
|
96
|
-
);
|
|
111
|
+
const data = JSON.parse(value) as DebugSessionOptions;
|
|
112
|
+
this.manager.current = data;
|
|
113
|
+
this.refreshDebugConfigurations();
|
|
97
114
|
}
|
|
98
115
|
};
|
|
99
116
|
|
|
@@ -151,13 +168,15 @@ export class DebugConfigurationSelect extends React.Component<DebugConfiguration
|
|
|
151
168
|
protected refreshDebugConfigurations = async () => {
|
|
152
169
|
const configsPerType = await this.manager.provideDynamicDebugConfigurations();
|
|
153
170
|
const providerTypes = [];
|
|
154
|
-
for (const [
|
|
171
|
+
for (const [type, configurations] of Object.entries(configsPerType)) {
|
|
155
172
|
if (configurations.length > 0) {
|
|
156
173
|
providerTypes.push(type);
|
|
157
174
|
}
|
|
158
175
|
}
|
|
159
|
-
|
|
160
|
-
|
|
176
|
+
|
|
177
|
+
const value = this.currentValue;
|
|
178
|
+
this.selectRef.current!.value = value;
|
|
179
|
+
this.setState({ providerTypes, currentValue: value });
|
|
161
180
|
};
|
|
162
181
|
|
|
163
182
|
protected renderOptions(): SelectOption[] {
|
|
@@ -165,10 +184,11 @@ export class DebugConfigurationSelect extends React.Component<DebugConfiguration
|
|
|
165
184
|
|
|
166
185
|
// Add non dynamic debug configurations
|
|
167
186
|
for (const config of this.manager.all) {
|
|
168
|
-
const value =
|
|
187
|
+
const value = JSON.stringify(config);
|
|
169
188
|
options.push({
|
|
170
189
|
value,
|
|
171
|
-
label: this.toName(config, this.props.isMultiRoot)
|
|
190
|
+
label: this.toName(config, this.props.isMultiRoot),
|
|
191
|
+
userData: DebugConfigurationSelect.CONFIG_MARKER
|
|
172
192
|
});
|
|
173
193
|
}
|
|
174
194
|
|
|
@@ -181,10 +201,11 @@ export class DebugConfigurationSelect extends React.Component<DebugConfiguration
|
|
|
181
201
|
});
|
|
182
202
|
}
|
|
183
203
|
for (const dynamicOption of recentDynamicOptions) {
|
|
184
|
-
const value =
|
|
204
|
+
const value = JSON.stringify(dynamicOption);
|
|
185
205
|
options.push({
|
|
186
206
|
value,
|
|
187
|
-
label: this.toName(dynamicOption, this.props.isMultiRoot) + ' (' + dynamicOption.providerType + ')'
|
|
207
|
+
label: this.toName(dynamicOption, this.props.isMultiRoot) + ' (' + dynamicOption.providerType + ')',
|
|
208
|
+
userData: DebugConfigurationSelect.CONFIG_MARKER
|
|
188
209
|
});
|
|
189
210
|
}
|
|
190
211
|
}
|
|
@@ -225,10 +246,11 @@ export class DebugConfigurationSelect extends React.Component<DebugConfiguration
|
|
|
225
246
|
return options;
|
|
226
247
|
}
|
|
227
248
|
|
|
228
|
-
protected toName(
|
|
229
|
-
|
|
230
|
-
|
|
249
|
+
protected toName(options: DebugSessionOptions, multiRoot: boolean): string {
|
|
250
|
+
const name = options.configuration?.name ?? options.name;
|
|
251
|
+
if (!options.workspaceFolderUri || !multiRoot) {
|
|
252
|
+
return name;
|
|
231
253
|
}
|
|
232
|
-
return `${
|
|
254
|
+
return `${name} (${new URI(options.workspaceFolderUri).path.base})`;
|
|
233
255
|
}
|
|
234
256
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2022 EclipseSource and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { TaskIdentifier } from '@theia/task/lib/common';
|
|
18
|
+
|
|
19
|
+
export const defaultCompound: DebugCompound = { name: 'Compound', configurations: [] };
|
|
20
|
+
|
|
21
|
+
export interface DebugCompound {
|
|
22
|
+
name: string;
|
|
23
|
+
stopAll?: boolean;
|
|
24
|
+
preLaunchTask?: string | TaskIdentifier;
|
|
25
|
+
configurations: (string | { name: string, folder: string })[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export namespace DebugCompound {
|
|
29
|
+
export function is(arg: unknown): arg is DebugCompound {
|
|
30
|
+
return !!arg && typeof arg === 'object' && 'name' in arg && 'configurations' in arg;
|
|
31
|
+
}
|
|
32
|
+
}
|