提交 741f9618 编写于 作者: D Dirk Baeumer

Fixes #29732: Make default group entry more usable

上级 208f3ae1
......@@ -251,7 +251,7 @@ export interface ConfigurationProperties {
/**
* Whether this task is a primary task in the task group.
*/
isPrimaryGroupEntry?: boolean;
isDefaultGroupEntry?: boolean;
/**
* The presentation options
......
......@@ -112,16 +112,22 @@ const group: IJSONSchema = {
default: 'none',
description: nls.localize('JsonSchema.tasks.group.kind', 'The task\'s execution group.')
},
isPrimary: {
isDefault: {
type: 'boolean',
default: false,
description: nls.localize('JsonSchema.tasks.group.isPrimary', 'Defines if this task is a primary task in a group.')
description: nls.localize('JsonSchema.tasks.group.isDefault', 'Defines if this task is the default task in the group.')
}
}
},
],
enum: ['none', 'build', 'test', { kind: 'build', isPrimary: true }, { kind: 'test', isPrimary: true }],
default: 'none',
enum: [{ kind: 'build', isDefault: true }, { kind: 'test', isDefault: true }, 'build', 'test', 'none'],
enumDescriptions: [
nls.localize('JsonSchema.tasks.group.defaultBuild', 'Marks the tasks as the default build task.'),
nls.localize('JsonSchema.tasks.group.defaultTest', 'Marks the tasks as the default test task.'),
nls.localize('JsonSchema.tasks.group.build', 'Marks the tasks as a build task accesible through the \'Run Build Task\' command.'),
nls.localize('JsonSchema.tasks.group.test', 'Marks the tasks as a test task accesible through the \'Run Test Task\' command.'),
nls.localize('JsonSchema.tasks.group.none', 'Assigns the task to no group')
],
description: nls.localize('JsonSchema.tasks.group', 'Defines to which execution group this task belongs to. It supports "build" to add it to the build group and "test" to add it to the test group.')
};
......
......@@ -1489,7 +1489,7 @@ class TaskService extends EventEmitter implements ITaskService {
}
let primaries: Task[] = [];
for (let task of tasks) {
if (task.isPrimaryGroupEntry) {
if (task.isDefaultGroupEntry) {
primaries.push(task);
}
}
......@@ -1527,7 +1527,7 @@ class TaskService extends EventEmitter implements ITaskService {
}
let primaries: Task[] = [];
for (let task of tasks) {
if (task.isPrimaryGroupEntry) {
if (task.isDefaultGroupEntry) {
primaries.push(task);
}
}
......
......@@ -199,7 +199,7 @@ export interface CommandProperties extends BaseCommandProperties {
export interface GroupKind {
kind?: string;
isPrimary?: boolean;
isDefault?: boolean;
}
export interface ConfigurationProperties {
......@@ -278,6 +278,8 @@ export interface BaseTaskRunnerConfiguration {
command?: string;
/**
* @deprecated Use type instead
*
* Specifies whether the command is a shell command and therefore must
* be executed in a shell interpreter (e.g. cmd.exe, bash, ...).
*
......@@ -285,6 +287,11 @@ export interface BaseTaskRunnerConfiguration {
*/
isShellCommand?: boolean;
/**
* The task type
*/
type?: string;
/**
* The command options used when the command is executed. Can be omitted.
*/
......@@ -1031,9 +1038,9 @@ namespace GroupKind {
return undefined;
}
let group: string = external.kind;
let primary: boolean = !!external.isPrimary;
let isDefault: boolean = !!external.isDefault;
return [group, primary];
return [group, isDefault];
}
}
......@@ -1069,12 +1076,12 @@ namespace ConfigurationProperties {
if (external.group !== void 0) {
if (Types.isString(external.group) && Tasks.TaskGroup.is(external.group)) {
result.group = external.group;
result.isPrimaryGroupEntry = false;
result.isDefaultGroupEntry = false;
} else {
let values = GroupKind.from(external.group);
if (values) {
result.group = values[0];
result.isPrimaryGroupEntry = values[1];
result.isDefaultGroupEntry = values[1];
}
}
}
......@@ -1261,8 +1268,8 @@ namespace CustomTask {
if (task.problemMatchers === void 0) {
task.problemMatchers = EMPTY_ARRAY;
}
if (task.group !== void 0 && task.isPrimaryGroupEntry === void 0) {
task.isPrimaryGroupEntry = false;
if (task.group !== void 0 && task.isDefaultGroupEntry === void 0) {
task.isDefaultGroupEntry = false;
}
}
......@@ -1279,7 +1286,7 @@ namespace CustomTask {
let resultConfigProps: Tasks.ConfigurationProperties = result;
assignProperty(resultConfigProps, configuredProps, 'group');
assignProperty(resultConfigProps, configuredProps, 'isPrimaryGroupEntry');
assignProperty(resultConfigProps, configuredProps, 'isDefaultGroupEntry');
assignProperty(resultConfigProps, configuredProps, 'isBackground');
assignProperty(resultConfigProps, configuredProps, 'dependsOn');
assignProperty(resultConfigProps, configuredProps, 'problemMatchers');
......@@ -1289,7 +1296,7 @@ namespace CustomTask {
let contributedConfigProps: Tasks.ConfigurationProperties = contributedTask;
fillProperty(resultConfigProps, contributedConfigProps, 'group');
fillProperty(resultConfigProps, contributedConfigProps, 'isPrimaryGroupEntry');
fillProperty(resultConfigProps, contributedConfigProps, 'isDefaultGroupEntry');
fillProperty(resultConfigProps, contributedConfigProps, 'isBackground');
fillProperty(resultConfigProps, contributedConfigProps, 'dependsOn');
fillProperty(resultConfigProps, contributedConfigProps, 'problemMatchers');
......@@ -1381,10 +1388,10 @@ namespace TaskParser {
}
if (defaultBuildTask.rank > -1 && defaultBuildTask.rank < 2) {
defaultBuildTask.task.group = Tasks.TaskGroup.Build;
defaultBuildTask.task.isPrimaryGroupEntry = false;
defaultBuildTask.task.isDefaultGroupEntry = false;
} else if (defaultTestTask.rank > -1 && defaultTestTask.rank < 2) {
defaultTestTask.task.group = Tasks.TaskGroup.Test;
defaultTestTask.task.isPrimaryGroupEntry = false;
defaultTestTask.task.isDefaultGroupEntry = false;
}
return result;
......@@ -1750,7 +1757,7 @@ class ConfigurationParser {
let value = GroupKind.from(fileConfig.group);
if (value) {
task.group = value[0];
task.isPrimaryGroupEntry = value[1];
task.isDefaultGroupEntry = value[1];
} else if (fileConfig.group === 'none') {
task.group = undefined;
}
......
......@@ -196,12 +196,12 @@ class CustomTaskBuilder {
public group(value: Tasks.TaskGroup): CustomTaskBuilder {
this.result.group = value;
this.result.isPrimaryGroupEntry = false;
this.result.isDefaultGroupEntry = false;
return this;
}
public isPrimary(value: boolean): CustomTaskBuilder {
this.result.isPrimaryGroupEntry = value;
this.result.isDefaultGroupEntry = value;
return this;
}
......@@ -455,7 +455,7 @@ function assertTask(actual: Tasks.Task, expected: Tasks.Task) {
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');
assert.strictEqual(actual.isDefaultGroupEntry, expected.isDefaultGroupEntry, 'isPrimaryGroupEntry');
if (actual.problemMatchers && expected.problemMatchers) {
assert.strictEqual(actual.problemMatchers.length, expected.problemMatchers.length);
for (let i = 0; i < actual.problemMatchers.length; i++) {
......@@ -1470,6 +1470,51 @@ suite('Tasks version 2.0.0', () => {
testConfiguration(external, builder);
});
test('Global group none', () => {
let external: ExternalTaskRunnerConfiguration = {
version: '2.0.0',
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 build', () => {
let external: ExternalTaskRunnerConfiguration = {
version: '2.0.0',
command: 'dir',
type: 'shell',
group: 'build'
};
let builder = new ConfiguationBuilder();
builder.task('dir', 'dir').
group(Tasks.TaskGroup.Build).
command().suppressTaskName(true).
runtime(Tasks.RuntimeType.Shell).
presentation().echo(true);
testConfiguration(external, builder);
});
test('Global group default build', () => {
let external: ExternalTaskRunnerConfiguration = {
version: '2.0.0',
command: 'dir',
type: 'shell',
group: { kind: 'build', isDefault: 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);
});
test('Local group none', () => {
let external: ExternalTaskRunnerConfiguration = {
version: '2.0.0',
tasks: [
......@@ -1488,7 +1533,27 @@ suite('Tasks version 2.0.0', () => {
presentation().echo(true);
testConfiguration(external, builder);
});
test('Global group primary build', () => {
test('Local group build', () => {
let external: ExternalTaskRunnerConfiguration = {
version: '2.0.0',
tasks: [
{
taskName: 'dir',
command: 'dir',
type: 'shell',
group: 'build'
}
]
};
let builder = new ConfiguationBuilder();
builder.task('dir', 'dir').
group(Tasks.TaskGroup.Build).
command().suppressTaskName(true).
runtime(Tasks.RuntimeType.Shell).
presentation().echo(true);
testConfiguration(external, builder);
});
test('Local group default build', () => {
let external: ExternalTaskRunnerConfiguration = {
version: '2.0.0',
tasks: [
......@@ -1496,7 +1561,7 @@ suite('Tasks version 2.0.0', () => {
taskName: 'dir',
command: 'dir',
type: 'shell',
group: { kind: 'build', isPrimary: true }
group: { kind: 'build', isDefault: true }
}
]
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册