diff --git a/src/vs/workbench/api/common/extHostTask.ts b/src/vs/workbench/api/common/extHostTask.ts index 46176947e29..9b0753a5709 100644 --- a/src/vs/workbench/api/common/extHostTask.ts +++ b/src/vs/workbench/api/common/extHostTask.ts @@ -188,6 +188,10 @@ export namespace CustomExecutionDTO { customExecution: 'customExecution' }; } + + export function to(taskId: string, providedCustomExeutions: Map): types.CustomExecution | undefined { + return providedCustomExeutions.get(taskId); + } } @@ -274,15 +278,17 @@ export namespace TaskDTO { }; return result; } - export async function to(value: tasks.TaskDTO | undefined, workspace: IExtHostWorkspaceProvider): Promise { + export async function to(value: tasks.TaskDTO | undefined, workspace: IExtHostWorkspaceProvider, providedCustomExeutions: Map): Promise { if (value === undefined || value === null) { return undefined; } - let execution: types.ShellExecution | types.ProcessExecution | undefined; + let execution: types.ShellExecution | types.ProcessExecution | types.CustomExecution | undefined; if (ProcessExecutionDTO.is(value.execution)) { execution = ProcessExecutionDTO.to(value.execution); } else if (ShellExecutionDTO.is(value.execution)) { execution = ShellExecutionDTO.to(value.execution); + } else if (CustomExecutionDTO.is(value.execution)) { + execution = CustomExecutionDTO.to(value._id, providedCustomExeutions); } const definition: vscode.TaskDefinition | undefined = TaskDefinitionDTO.to(value.definition); let scope: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder | undefined; @@ -354,13 +360,6 @@ class TaskExecutionImpl implements vscode.TaskExecution { } export namespace TaskExecutionDTO { - export async function to(value: tasks.TaskExecutionDTO, tasks: ExtHostTaskBase, workspaceProvider: IExtHostWorkspaceProvider): Promise { - const task = await TaskDTO.to(value.task, workspaceProvider); - if (!task) { - throw new Error('Unexpected: Task cannot be created.'); - } - return new TaskExecutionImpl(tasks, value.id, task); - } export function from(value: vscode.TaskExecution): tasks.TaskExecutionDTO { return { id: (value as TaskExecutionImpl)._id, @@ -447,7 +446,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape, IExtHostTask return this._proxy.$fetchTasks(TaskFilterDTO.from(filter)).then(async (values) => { const result: vscode.Task[] = []; for (let value of values) { - const task = await TaskDTO.to(value, this._workspaceProvider); + const task = await TaskDTO.to(value, this._workspaceProvider, this._providedCustomExecutions2); if (task) { result.push(task); } @@ -573,7 +572,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape, IExtHostTask throw new Error(`Unexpected: Task of type [${taskDTO.definition.type}] cannot be resolved by provider of type [${handler.type}].`); } - const task = await TaskDTO.to(taskDTO, this._workspaceProvider); + const task = await TaskDTO.to(taskDTO, this._workspaceProvider, this._providedCustomExecutions2); if (!task) { throw new Error('Unexpected: Task cannot be resolved.'); } @@ -631,7 +630,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape, IExtHostTask return result; } const createdResult: Promise = new Promise(async (resolve, reject) => { - const taskToCreate = task ? task : await TaskDTO.to(execution.task, this._workspaceProvider); + const taskToCreate = task ? task : await TaskDTO.to(execution.task, this._workspaceProvider, this._providedCustomExecutions2); if (!taskToCreate) { reject('Unexpected: Task does not exist.'); } else {