提交 b8b6ffd5 编写于 作者: D Dirk Baeumer

More schema tweaks. Support for label in task customization

上级 2691c809
......@@ -13,6 +13,22 @@ import commonSchema from './jsonSchemaCommon';
import { ProblemMatcherRegistry } from 'vs/platform/markers/common/problemMatcher';
import { TaskTypeRegistry } from '../common/taskTypeRegistry';
function fixReferences(literal: any) {
if (Array.isArray(literal)) {
literal.forEach(fixReferences);
} else if (typeof literal === 'object') {
if (literal['$ref']) {
literal['$ref'] = literal['$ref'] + '2';
}
Object.getOwnPropertyNames(literal).forEach(property => {
let value = literal[property];
if (Array.isArray(value) || typeof value === 'object') {
fixReferences(value);
}
});
}
}
const shellCommand: IJSONSchema = {
anyOf: [
{
......@@ -111,6 +127,11 @@ let taskConfiguration: IJSONSchema = {
type: 'string',
description: nls.localize('JsonSchema.tasks.taskLabel', "The task's label")
},
taskName: {
type: 'string',
description: nls.localize('JsonSchema.tasks.taskName', 'The task\'s name'),
deprecationMessage: nls.localize('JsonSchema.tasks.taskName.deprecated', 'The task\'s name property is deprecated. Use the label property instead.')
},
group: Objects.deepClone(group),
isBackground: {
type: 'boolean',
......@@ -124,7 +145,7 @@ let taskConfiguration: IJSONSchema = {
},
presentation: Objects.deepClone(presentation),
problemMatcher: {
$ref: '#/definitions/problemMatcherType2',
$ref: '#/definitions/problemMatcherType',
description: nls.localize('JsonSchema.tasks.matchers', 'The problem matcher(s) to use. Can either be a string or a problem matcher definition or an array of strings and problem matchers.')
}
}
......@@ -134,6 +155,7 @@ let taskDefinitions: IJSONSchema[] = [];
TaskTypeRegistry.onReady().then(() => {
for (let taskType of TaskTypeRegistry.all()) {
let schema: IJSONSchema = Objects.deepClone(taskConfiguration);
// Since we do this after the schema is assigned we need to patch the refs.
schema.properties.type = {
type: 'string',
description: nls.localize('JsonSchema.customizations.customizes.type', 'The task type to customize'),
......@@ -146,10 +168,18 @@ TaskTypeRegistry.onReady().then(() => {
let property = taskType.properties[key];
schema.properties[key] = Objects.deepClone(property);
}
fixReferences(schema);
taskDefinitions.push(schema);
}
});
let customize = Objects.deepClone(taskConfiguration);
customize.properties.customize = {
type: 'string',
deprecationMessage: nls.localize('JsonSchema.tasks.customize.deprecated', 'The customize property is deprecated. See the 1.14 release notes on how to migrate to the new task customization approach')
};
taskDefinitions.push(customize);
let definitions = Objects.deepClone(commonSchema.definitions);
let taskDescription: IJSONSchema = definitions.taskDescription;
taskDescription.properties.isShellCommand = Objects.deepClone(shellCommand);
......@@ -218,22 +248,6 @@ Object.getOwnPropertyNames(definitions).forEach(key => {
definitions[newKey] = definitions[key];
delete definitions[key];
});
function fixReferences(literal: any) {
if (Array.isArray(literal)) {
literal.forEach(fixReferences);
} else if (typeof literal === 'object') {
if (literal['$ref']) {
literal['$ref'] = literal['$ref'] + '2';
}
Object.getOwnPropertyNames(literal).forEach(property => {
let value = literal[property];
if (Array.isArray(value) || typeof value === 'object') {
fixReferences(value);
}
});
}
}
fixReferences(schema);
ProblemMatcherRegistry.onReady().then(() => {
......
......@@ -203,6 +203,11 @@ export interface ConfigurationProperties {
*/
taskName?: string;
/**
* The UI label used for the task.
*/
label?: string;
/**
* An optional indentifier which can be used to reference a task
* in a dependsOn or other attributes.
......@@ -1016,6 +1021,9 @@ namespace ConfigurationProperties {
if (Types.isString(external.taskName)) {
result.name = external.taskName;
}
if (Types.isString(external.label) && context.schemaVersion === Tasks.JsonSchemaVersion.V2_0_0) {
result.name = external.label;
}
if (Types.isString(external.identifier)) {
result.identifier = external.identifier;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册