提交 dd56a283 编写于 作者: I isidor

debug: schema for compound configurations names

上级 8b3b72d1
......@@ -460,7 +460,7 @@ export interface ILaunch {
* Returns the names of all configurations and compounds.
* Ignores configurations which are invalid.
*/
getConfigurationNames(): string[];
getConfigurationNames(includeCompounds?: boolean): string[];
/**
* Returns the resolved configuration.
......
......@@ -187,7 +187,12 @@ const schema: IJSONSchema = {
type: 'array',
default: [],
items: {
type: 'string'
oneOf: [{
enum: [],
description: nls.localize('useUniqueNames', "Please use unique configuration names.")
}, {
type: 'object'
}]
},
description: nls.localize('app.launch.json.compounds.configurations', "Names of configurations that will be started as part of this compound.")
}
......@@ -311,6 +316,8 @@ export class ConfigurationManager implements IConfigurationManager {
items.defaultSnippets.push(...configurationSnippets);
}
});
this.setCompoundSchemaValues();
});
breakpointsExtPoint.setHandler(extensions => {
......@@ -328,6 +335,7 @@ export class ConfigurationManager implements IConfigurationManager {
this.toDispose.push(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('launch')) {
this.selectConfiguration();
this.setCompoundSchemaValues();
}
}));
......@@ -345,6 +353,13 @@ export class ConfigurationManager implements IConfigurationManager {
}
}
private setCompoundSchemaValues(): void {
const compoundConfigurationsSchema = (<IJSONSchema>schema.properties['compounds'].items).properties['configurations'];
(<IJSONSchema>compoundConfigurationsSchema.items).oneOf[0].enum = this.launches.map(l =>
l.getConfigurationNames(false)).reduce((first, second) => first.concat(second), []);
jsonRegistry.registerSchema(launchSchemaId, schema);
}
public getLaunches(): ILaunch[] {
return this.launches;
}
......@@ -495,13 +510,13 @@ class Launch implements ILaunch {
return config.compounds.filter(compound => compound.name === name).pop();
}
public getConfigurationNames(): string[] {
public getConfigurationNames(includeCompounds = true): string[] {
const config = this.getConfig();
if (!config || !config.configurations || !Array.isArray(config.configurations)) {
return [];
} else {
const names = config.configurations.filter(cfg => cfg && typeof cfg.name === 'string').map(cfg => cfg.name);
if (names.length > 0 && config.compounds) {
if (includeCompounds && names.length > 0 && config.compounds) {
if (config.compounds) {
names.push(...config.compounds.filter(compound => typeof compound.name === 'string' && compound.configurations && compound.configurations.length)
.map(compound => compound.name));
......
......@@ -699,12 +699,9 @@ export class DebugService implements debug.IDebugService {
}
let rootForName = root;
if (launch === this.configurationManager.getWorkspaceLaunch()) {
// For workspace launches allow comound referencing configurations across folder
const launchContainingName = this.configurationManager.getLaunches().filter(l => !!l.getConfiguration(name)).pop();
if (launchContainingName) {
rootForName = launchContainingName.workspace;
}
const launchesContainingName = this.configurationManager.getLaunches().filter(l => !!l.getConfiguration(name));
if (launchesContainingName && launchesContainingName.length === 1) {
rootForName = launchesContainingName[0].workspace;
}
return this.startDebugging(rootForName, name, noDebug, topCompoundName || compound.name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册