Fixes 47563: Provide an API to fetch running task executions

This commit is contained in:
Dirk Baeumer
2018-04-20 11:48:11 +02:00
parent 54322a1ea1
commit bcfb7d4f16
10 changed files with 103 additions and 58 deletions

View File

@@ -21,7 +21,7 @@ import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace';
import * as vscode from 'vscode';
import {
TaskDefinitionDTO, TaskExecutionDTO, TaskPresentationOptionsDTO, ProcessExecutionOptionsDTO, ProcessExecutionDTO,
ShellExecutionOptionsDTO, ShellExecutionDTO, TaskDTO, TaskHandleDTO
ShellExecutionOptionsDTO, ShellExecutionDTO, TaskDTO, TaskHandleDTO, TaskFilterDTO
} from '../shared/tasks';
export { TaskExecutionDTO };
@@ -675,6 +675,19 @@ namespace TaskDTO {
}
}
namespace TaskFilterDTO {
export function from(value: vscode.TaskFilter): TaskFilterDTO {
return value;
}
export function to(value: TaskFilterDTO): vscode.TaskFilter {
if (!value) {
return undefined;
}
return Objects.assign(Object.create(null), value);
}
}
class TaskExecutionImpl implements vscode.TaskExecution {
constructor(readonly _id: string, private readonly _task: vscode.Task, private readonly _tasks: ExtHostTask) {
}
@@ -741,8 +754,8 @@ export class ExtHostTask implements ExtHostTaskShape {
});
}
public executeTaskProvider(): Thenable<vscode.Task[]> {
return this._proxy.$executeTaskProvider().then((values) => {
public fetchTasks(filter?: vscode.TaskFilter): Thenable<vscode.Task[]> {
return this._proxy.$fetchTasks(TaskFilterDTO.from(filter)).then((values) => {
let result: vscode.Task[] = [];
for (let value of values) {
let task = TaskDTO.to(value, this._extHostWorkspace);
@@ -774,6 +787,12 @@ export class ExtHostTask implements ExtHostTaskShape {
});
}
get taskExecutions(): vscode.TaskExecution[] {
let result: vscode.TaskExecution[] = [];
this._taskExecutions.forEach(value => result.push(value));
return result;
}
get onDidStartTask(): Event<vscode.TaskStartEvent> {
return this._onDidExecuteTask.event;
}