Skip to content

Commit 5b473bb

Browse files
committed
Use customize instead of identifier for customizing tasks
1 parent c204fe9 commit 5b473bb

4 files changed

Lines changed: 24 additions & 18 deletions

File tree

src/vs/workbench/parts/tasks/common/taskConfiguration.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ export interface TaskDescription extends PlatformTaskDescription {
105105
*/
106106
identifier?: string;
107107

108+
/**
109+
* The id of the customized task
110+
*/
111+
customize?: string;
112+
108113
/**
109114
* Windows specific task configuration
110115
*/
@@ -903,6 +908,9 @@ namespace TaskDescription {
903908
task.group = Tasks.TaskGroup.Test;
904909
}
905910
}
911+
if (Types.isString(externalTask.customize)) {
912+
task.customize = externalTask.customize;
913+
}
906914
if (externalTask.command !== void 0) {
907915
// if the task has its own command then we suppress the
908916
// task name by default.
@@ -1055,7 +1063,7 @@ namespace TaskDescription {
10551063
}
10561064

10571065
function isAnnotating(task: Tasks.Task): boolean {
1058-
return (task.command === void 0 || task.command.name === void 0) && (task.dependsOn === void 0 || task.dependsOn.length === 0);
1066+
return task.customize !== void 0 && (task.command === void 0 || task.command.name === void 0);
10591067
}
10601068

10611069
export function assignProperties(target: Tasks.Task, source: Tasks.Task): Tasks.Task {

src/vs/workbench/parts/tasks/common/tasks.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ export interface Task {
208208
*/
209209
identifier: string;
210210

211+
/**
212+
* The id of the customized task
213+
*/
214+
customize?: string;
215+
211216
/**
212217
* the task's group;
213218
*/

src/vs/workbench/parts/tasks/electron-browser/jsonSchema_v2.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ const version: IJSONSchema = {
8383
description: nls.localize('JsonSchema.version', 'The config\'s version number.')
8484
};
8585

86-
const identifier: IJSONSchema = {
86+
const customize: IJSONSchema = {
8787
type: 'string',
88-
description: nls.localize('JsonSchema.tasks.identifier', 'A unique identifier of the task.')
88+
description: nls.localize('JsonSchema.tasks.customize', 'The contributed task to be customized.')
8989
};
9090

9191
const schema: IJSONSchema = {
@@ -128,7 +128,7 @@ definitions.taskDescription.properties.dependsOn = dependsOn;
128128
// definitions.taskDescription.properties.echoCommand.deprecationMessage = nls.localize('JsonSchema.tasks.echoCommand.deprecated', 'The property echoCommand is deprecated. Use the terminal property instead.');
129129
// definitions.taskDescription.properties.isBuildCommand.deprecationMessage = nls.localize('JsonSchema.tasks.isBuildCommand.deprecated', 'The property isBuildCommand is deprecated. Use the group property instead.');
130130
// definitions.taskDescription.properties.isTestCommand.deprecationMessage = nls.localize('JsonSchema.tasks.isTestCommand.deprecated', 'The property isTestCommand is deprecated. Use the group property instead.');
131-
definitions.taskDescription.properties.identifier = identifier;
131+
definitions.taskDescription.properties.customize = customize;
132132
definitions.taskDescription.properties.type = Objects.deepClone(taskType);
133133
definitions.taskDescription.properties.terminal = terminal;
134134
definitions.taskDescription.properties.group = group;

src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import { Scope, IActionBarRegistry, Extensions as ActionBarExtensions } from 'vs
7171
import { ITerminalService } from 'vs/workbench/parts/terminal/common/terminal';
7272

7373
import { ITaskSystem, ITaskResolver, ITaskSummary, ITaskExecuteResult, TaskExecuteKind, TaskError, TaskErrors, TaskSystemEvents } from 'vs/workbench/parts/tasks/common/taskSystem';
74-
import { Task, TaskSet, TaskGroup, ExecutionEngine, TaskSourceKind } from 'vs/workbench/parts/tasks/common/tasks';
74+
import { Task, TaskSet, TaskGroup, ExecutionEngine, JsonSchemaVersion, TaskSourceKind } from 'vs/workbench/parts/tasks/common/tasks';
7575
import { ITaskService, TaskServiceEvents, ITaskProvider } from 'vs/workbench/parts/tasks/common/taskService';
7676
import { templates as taskTemplates } from 'vs/workbench/parts/tasks/common/taskTemplates';
7777

@@ -502,7 +502,6 @@ interface WorkspaceTaskResult {
502502
set: TaskSet;
503503
annotatingTasks: {
504504
byIdentifier: IStringDictionary<Task>;
505-
byLabel: IStringDictionary<Task>;
506505
};
507506
hasErrors: boolean;
508507
}
@@ -756,7 +755,7 @@ class TaskService extends EventEmitter implements ITaskService {
756755
return TPromise.as<void>(undefined);
757756
}
758757
let fileConfig = configuration.config;
759-
let customize = { taskName: task._label, identifier: task.identifier };
758+
let customize = { customize: task.identifier, taskName: task._label, problemMatcher: [] };
760759
if (!fileConfig) {
761760
fileConfig = {
762761
version: '2.0.0',
@@ -952,7 +951,7 @@ class TaskService extends EventEmitter implements ITaskService {
952951
resolve(result);
953952
}
954953
};
955-
if (this.getExecutionEngine() === ExecutionEngine.Terminal && this._providers.size > 0) {
954+
if (this.getJsonSchemaVersion() === JsonSchemaVersion.V2_0_0 && this._providers.size > 0) {
956955
this._providers.forEach((provider) => {
957956
counter++;
958957
provider.provideTasks().done(done, error);
@@ -970,7 +969,7 @@ class TaskService extends EventEmitter implements ITaskService {
970969
for (let set of result) {
971970
for (let task of set.tasks) {
972971
if (annotatingTasks) {
973-
let annotatingTask = annotatingTasks.byIdentifier[task.identifier] || annotatingTasks.byLabel[task._label];
972+
let annotatingTask = annotatingTasks.byIdentifier[task.identifier];
974973
if (annotatingTask) {
975974
TaskConfig.mergeTasks(task, annotatingTask);
976975
task.name = annotatingTask.name;
@@ -1123,17 +1122,13 @@ class TaskService extends EventEmitter implements ITaskService {
11231122
problemReporter.fatal(nls.localize('TaskSystem.configurationErrors', 'Error: the provided task configuration has validation errors and can\'t not be used. Please correct the errors first.'));
11241123
return { set: undefined, annotatingTasks: undefined, hasErrors };
11251124
}
1126-
let annotatingTasks: { byIdentifier: IStringDictionary<Task>; byLabel: IStringDictionary<Task>; };
1125+
let annotatingTasks: { byIdentifier: IStringDictionary<Task>; };
11271126
if (parseResult.annotatingTasks && parseResult.annotatingTasks.length > 0) {
11281127
annotatingTasks = {
1129-
byIdentifier: Object.create(null),
1130-
byLabel: Object.create(null)
1128+
byIdentifier: Object.create(null)
11311129
};
11321130
for (let task of parseResult.annotatingTasks) {
1133-
annotatingTasks.byIdentifier[task.identifier] = task;
1134-
if (task._label) {
1135-
annotatingTasks.byLabel[task._label] = task;
1136-
}
1131+
annotatingTasks.byIdentifier[task.customize] = task;
11371132
}
11381133
}
11391134
return { set: { tasks: parseResult.tasks }, annotatingTasks: annotatingTasks, hasErrors };
@@ -1149,15 +1144,13 @@ class TaskService extends EventEmitter implements ITaskService {
11491144
return TaskConfig.ExecutionEngine.from(config);
11501145
}
11511146

1152-
/*
11531147
private getJsonSchemaVersion(): JsonSchemaVersion {
11541148
let { config } = this.getConfiguration();
11551149
if (!config) {
11561150
return JsonSchemaVersion.V2_0_0;
11571151
}
11581152
return TaskConfig.JsonSchemaVersion.from(config);
11591153
}
1160-
*/
11611154

11621155
private getConfiguration(): { config: TaskConfig.ExternalTaskRunnerConfiguration; hasParseErrors: boolean } {
11631156
let result = this.configurationService.getConfiguration<TaskConfig.ExternalTaskRunnerConfiguration>('tasks');

0 commit comments

Comments
 (0)