Skip to content

Commit

Permalink
Fixes #29013: Tasks 2.0 integration with launch.json
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaeumer committed Jun 26, 2017
1 parent a5248f3 commit b5ae943
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/vs/workbench/parts/debug/electron-browser/debugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -855,9 +855,8 @@ export class DebugService implements debug.IDebugService {
}

// run a task before starting a debug session
return this.taskService.tasks().then(descriptions => {
const filteredTasks = descriptions.filter(task => task.name === taskName);
if (filteredTasks.length !== 1) {
return this.taskService.getTask(taskName).then(task => {
if (!task) {
return TPromise.wrapError(errors.create(nls.localize('DebugTaskNotFound', "Could not find the preLaunchTask \'{0}\'.", taskName)));
}

Expand All @@ -872,14 +871,14 @@ export class DebugService implements debug.IDebugService {
}

// no task running, execute the preLaunchTask.
const taskPromise = this.taskService.run(filteredTasks[0]).then(result => {
const taskPromise = this.taskService.run(task).then(result => {
this.lastTaskEvent = null;
return result;
}, err => {
this.lastTaskEvent = null;
});

if (filteredTasks[0].isBackground) {
if (task.isBackground) {
return new TPromise((c, e) => this.taskService.addOneTimeListener(TaskServiceEvents.Inactive, () => c(null)));
}

Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/parts/tasks/common/taskService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export interface ITaskService extends IEventEmitter {
terminate(task: string | Task): TPromise<TaskTerminateResponse>;
terminateAll(): TPromise<TaskTerminateResponse[]>;
tasks(): TPromise<Task[]>;
/**
* @param identifier The task's name, label or defined identifier.
*/
getTask(identifier: string): TPromise<Task>;
getTasksForGroup(group: string): TPromise<Task[]>;
getRecentlyUsedTasks(): LinkedMap<string, string>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ const version: IJSONSchema = {
description: nls.localize('JsonSchema.version', 'The config\'s version number.')
};

const identifier: IJSONSchema = {
type: 'string',
description: nls.localize('JsonSchema.tasks.identifier', 'A user defined identifier to reference the task in launch.json or a dependsOn clause.')
};

let taskConfiguration: IJSONSchema = {
type: 'object',
additionalProperties: false,
Expand All @@ -152,6 +157,7 @@ let taskConfiguration: IJSONSchema = {
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.')
},
identifier: Objects.deepClone(identifier),
group: Objects.deepClone(group),
isBackground: {
type: 'boolean',
Expand Down Expand Up @@ -204,6 +210,7 @@ let definitions = Objects.deepClone(commonSchema.definitions);
let taskDescription: IJSONSchema = definitions.taskDescription;
taskDescription.properties.isShellCommand = Objects.deepClone(shellCommand);
taskDescription.properties.dependsOn = dependsOn;
taskDescription.properties.identifier = Objects.deepClone(identifier);
definitions.showOutputType.deprecationMessage = nls.localize(
'JsonSchema.tasks.showOputput.deprecated',
'The property showOutput is deprecated. Use the reveal property inside the presentation property instead. See also the 1.14 release notes.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,13 @@ class TaskService extends EventEmitter implements ITaskService {
return this._providers.delete(handle);
}

public getTask(identifier: string): TPromise<Task> {
return this.getTaskSets().then((sets) => {
let resolver = this.createResolver(sets);
return resolver.resolve(identifier);
});
}

public tasks(): TPromise<Task[]> {
return this.getTaskSets().then((sets) => {
let result: Task[] = [];
Expand Down Expand Up @@ -1697,7 +1704,7 @@ schema.definitions = {
...schemaVersion1.definitions,
...schemaVersion2.definitions,
};
schema.oneOf = [...schemaVersion1.oneOf, ...schemaVersion2.oneOf];
schema.oneOf = [...schemaVersion2.oneOf, ...schemaVersion1.oneOf];


let jsonRegistry = <jsonContributionRegistry.IJSONContributionRegistry>Registry.as(jsonContributionRegistry.Extensions.JSONContribution);
Expand Down

0 comments on commit b5ae943

Please sign in to comment.