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

Fixes #29013: Tasks 2.0 integration with launch.json

上级 a5248f36
......@@ -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)));
}
......@@ -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)));
}
......
......@@ -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>;
......
......@@ -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,
......@@ -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',
......@@ -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.'
......
......@@ -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[] = [];
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册