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

Support group and presentation in global schema

上级 38b523c3
......@@ -229,7 +229,7 @@ definitions.taskDescription.properties.isTestCommand.deprecationMessage = nls.lo
taskDescription.properties.type = Objects.deepClone(taskType);
taskDescription.properties.presentation = Objects.deepClone(presentation);
taskDescription.properties.terminal = terminal;
taskDescription.properties.group = group;
taskDescription.properties.group = Objects.deepClone(group);
taskDefinitions.push({
$ref: '#/definitions/taskDescription'
......@@ -247,11 +247,13 @@ definitions.options.properties.shell = {
definitions.taskRunnerConfiguration.properties.isShellCommand = Objects.deepClone(shellCommand);
definitions.taskRunnerConfiguration.properties.type = Objects.deepClone(taskType);
definitions.taskRunnerConfiguration.properties.version = Objects.deepClone(version);
definitions.taskRunnerConfiguration.properties.group = Objects.deepClone(group);
definitions.taskRunnerConfiguration.properties.presentation = Objects.deepClone(presentation);
let osSpecificTaskRunnerConfiguration = Objects.deepClone(definitions.taskRunnerConfiguration);
delete osSpecificTaskRunnerConfiguration.properties.tasks;
osSpecificTaskRunnerConfiguration.additionalProperties = false;
definitions.osSpecificTaskRunnerConfiguration = osSpecificTaskRunnerConfiguration;
definitions.taskRunnerConfiguration.properties.version = Objects.deepClone(version);
const schema: IJSONSchema = {
oneOf: [
......
......@@ -311,6 +311,10 @@ export interface BaseTaskRunnerConfiguration {
*/
echoCommand?: boolean;
/**
* The group
*/
group?: string | GroupKind;
/**
* Controls the behavior of the used terminal
*/
......@@ -1011,21 +1015,32 @@ const source: Tasks.TaskSource = {
detail: '.settins\\tasks.json'
};
namespace ConfigurationProperties {
namespace GroupKind {
export function from(this: void, external: GroupKind): [string, boolean] {
if (external === void 0 || !Types.isString(external.kind)) {
namespace GroupKind {
export function from(this: void, external: string | GroupKind): [string, boolean] {
if (external === void 0) {
return undefined;
}
if (Types.isString(external)) {
if (Tasks.TaskGroup.is(external)) {
return [external, false];
} else {
return undefined;
}
let group: string = external.kind;
let primary: boolean = !!external.isPrimary;
return [group, primary];
}
if (!Types.isString(external.kind) || !Tasks.TaskGroup.is(external.kind)) {
return undefined;
}
let group: string = external.kind;
let primary: boolean = !!external.isPrimary;
return [group, primary];
}
}
namespace ConfigurationProperties {
const properties: MetaData<Tasks.ConfigurationProperties, any>[] = [
{ property: 'name' }, { property: 'identifier' }, { property: 'group' }, { property: 'isBackground' },
{ property: 'promptOnClose' }, { property: 'dependsOn' },
{ property: 'presentation', type: CommandConfiguration.PresentationOptions }, { property: 'problemMatchers' }
......@@ -1246,6 +1261,9 @@ namespace CustomTask {
if (task.problemMatchers === void 0) {
task.problemMatchers = EMPTY_ARRAY;
}
if (task.group !== void 0 && task.isPrimaryGroupEntry === void 0) {
task.isPrimaryGroupEntry = false;
}
}
export function createCustomTask(contributedTask: Tasks.ContributedTask, configuredProps: Tasks.ConfigurationProperties & { _id: string }): Tasks.CustomTask {
......@@ -1363,8 +1381,10 @@ namespace TaskParser {
}
if (defaultBuildTask.rank > -1 && defaultBuildTask.rank < 2) {
defaultBuildTask.task.group = Tasks.TaskGroup.Build;
defaultBuildTask.task.isPrimaryGroupEntry = false;
} else if (defaultTestTask.rank > -1 && defaultTestTask.rank < 2) {
defaultTestTask.task.group = Tasks.TaskGroup.Test;
defaultTestTask.task.isPrimaryGroupEntry = false;
}
return result;
......@@ -1727,6 +1747,13 @@ class ConfigurationParser {
isBackground: isBackground,
problemMatchers: matchers
};
let value = GroupKind.from(fileConfig.group);
if (value) {
task.group = value[0];
task.isPrimaryGroupEntry = value[1];
} else if (fileConfig.group === 'none') {
task.group = undefined;
}
CustomTask.fillGlobals(task, globals);
CustomTask.fillDefaults(task, context);
result.custom = [task];
......
......@@ -196,6 +196,12 @@ class CustomTaskBuilder {
public group(value: Tasks.TaskGroup): CustomTaskBuilder {
this.result.group = value;
this.result.isPrimaryGroupEntry = false;
return this;
}
public isPrimary(value: boolean): CustomTaskBuilder {
this.result.isPrimaryGroupEntry = value;
return this;
}
......@@ -446,8 +452,10 @@ function assertTask(actual: Tasks.Task, expected: Tasks.Task) {
assert.strictEqual(actual.name, expected.name, 'name');
assertCommandConfiguration(actual.command, expected.command);
assert.strictEqual(actual.isBackground, expected.isBackground, 'isBackground');
assert.strictEqual(actual.promptOnClose, expected.promptOnClose, 'promptOnClose');
assert.strictEqual(typeof actual.problemMatchers, typeof expected.problemMatchers);
assert.strictEqual(actual.promptOnClose, expected.promptOnClose, 'promptOnClose');
assert.strictEqual(actual.group, expected.group, 'group');
assert.strictEqual(actual.isPrimaryGroupEntry, expected.isPrimaryGroupEntry, 'isPrimaryGroupEntry');
if (actual.problemMatchers && expected.problemMatchers) {
assert.strictEqual(actual.problemMatchers.length, expected.problemMatchers.length);
for (let i = 0; i < actual.problemMatchers.length; i++) {
......@@ -1461,7 +1469,46 @@ suite('Tasks version 2.0.0', () => {
presentation().echo(true);
testConfiguration(external, builder);
});
test('Global group none', () => {
let external: ExternalTaskRunnerConfiguration = {
version: '2.0.0',
tasks: [
{
taskName: 'dir',
command: 'dir',
type: 'shell',
group: 'none'
}
]
};
let builder = new ConfiguationBuilder();
builder.task('dir', 'dir').
command().suppressTaskName(true).
runtime(Tasks.RuntimeType.Shell).
presentation().echo(true);
testConfiguration(external, builder);
});
test('Global group primary build', () => {
let external: ExternalTaskRunnerConfiguration = {
version: '2.0.0',
tasks: [
{
taskName: 'dir',
command: 'dir',
type: 'shell',
group: { kind: 'build', isPrimary: true }
}
]
};
let builder = new ConfiguationBuilder();
builder.task('dir', 'dir').
group(Tasks.TaskGroup.Build).
isPrimary(true).
command().suppressTaskName(true).
runtime(Tasks.RuntimeType.Shell).
presentation().echo(true);
testConfiguration(external, builder);
});
});
suite('Bugs / regression tests', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册