提交 640caaef 编写于 作者: A Alex Ross

Finalize task custom execution variable resolving

Fixes #81007
上级 362e4922
...@@ -6123,9 +6123,10 @@ declare module 'vscode' { ...@@ -6123,9 +6123,10 @@ declare module 'vscode' {
* [Pseudoterminal.close](#Pseudoterminal.close). When the task is complete fire * [Pseudoterminal.close](#Pseudoterminal.close). When the task is complete fire
* [Pseudoterminal.onDidClose](#Pseudoterminal.onDidClose). * [Pseudoterminal.onDidClose](#Pseudoterminal.onDidClose).
* @param process The [Pseudoterminal](#Pseudoterminal) to be used by the task to display output. * @param process The [Pseudoterminal](#Pseudoterminal) to be used by the task to display output.
* @param callback The callback that will be called when the task is started by a user. * @param callback The callback that will be called when the task is started by a user. Any ${} style variables that
* were in the task definition will be resolved and passed into the callback.
*/ */
constructor(callback: () => Thenable<Pseudoterminal>); constructor(callback: (resolvedDefinition: TaskDefinition) => Thenable<Pseudoterminal>);
} }
/** /**
......
...@@ -981,7 +981,6 @@ declare module 'vscode' { ...@@ -981,7 +981,6 @@ declare module 'vscode' {
} }
//#endregion //#endregion
//#region CustomExecution: https://github.com/microsoft/vscode/issues/81007
/** /**
* A task to execute * A task to execute
*/ */
...@@ -989,19 +988,6 @@ declare module 'vscode' { ...@@ -989,19 +988,6 @@ declare module 'vscode' {
detail?: string; detail?: string;
} }
export class CustomExecution2 extends CustomExecution {
/**
* Constructs a CustomExecution task object. The callback will be executed the task is run, at which point the
* extension should return the Pseudoterminal it will "run in". The task should wait to do further execution until
* [Pseudoterminal.open](#Pseudoterminal.open) is called. Task cancellation should be handled using
* [Pseudoterminal.close](#Pseudoterminal.close). When the task is complete fire
* [Pseudoterminal.onDidClose](#Pseudoterminal.onDidClose).
* @param callback The callback that will be called when the task is started by a user.
*/
constructor(callback: (resolvedDefinition: TaskDefinition) => Thenable<Pseudoterminal>);
}
//#endregion
//#region Task presentation group: https://github.com/microsoft/vscode/issues/47265 //#region Task presentation group: https://github.com/microsoft/vscode/issues/47265
export interface TaskPresentationOptions { export interface TaskPresentationOptions {
/** /**
......
...@@ -418,8 +418,8 @@ export class MainThreadTask implements MainThreadTaskShape { ...@@ -418,8 +418,8 @@ export class MainThreadTask implements MainThreadTaskShape {
const task = event.__task!; const task = event.__task!;
if (event.kind === TaskEventKind.Start) { if (event.kind === TaskEventKind.Start) {
const execution = TaskExecutionDTO.from(task.getTaskExecution()); const execution = TaskExecutionDTO.from(task.getTaskExecution());
let resolvedDefinition: TaskDefinitionDTO | undefined; let resolvedDefinition: TaskDefinitionDTO = execution.task!.definition;
if (execution.task && execution.task.execution && CustomExecutionDTO.is(execution.task.execution) && event.resolvedVariables) { if (execution.task?.execution && CustomExecutionDTO.is(execution.task.execution) && event.resolvedVariables) {
const dictionary: IStringDictionary<string> = {}; const dictionary: IStringDictionary<string> = {};
Array.from(event.resolvedVariables.entries()).forEach(entry => dictionary[entry[0]] = entry[1]); Array.from(event.resolvedVariables.entries()).forEach(entry => dictionary[entry[0]] = entry[1]);
resolvedDefinition = await this._configurationResolverService.resolveAny(task.getWorkspaceFolder(), resolvedDefinition = await this._configurationResolverService.resolveAny(task.getWorkspaceFolder(),
......
...@@ -1039,7 +1039,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I ...@@ -1039,7 +1039,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
ExtensionMode: extHostTypes.ExtensionMode, ExtensionMode: extHostTypes.ExtensionMode,
ExtensionRuntime: extHostTypes.ExtensionRuntime, ExtensionRuntime: extHostTypes.ExtensionRuntime,
CustomExecution: extHostTypes.CustomExecution, CustomExecution: extHostTypes.CustomExecution,
CustomExecution2: extHostTypes.CustomExecution,
FileChangeType: extHostTypes.FileChangeType, FileChangeType: extHostTypes.FileChangeType,
FileSystemError: extHostTypes.FileSystemError, FileSystemError: extHostTypes.FileSystemError,
FileType: files.FileType, FileType: files.FileType,
......
...@@ -1449,7 +1449,7 @@ export interface ExtHostSCMShape { ...@@ -1449,7 +1449,7 @@ export interface ExtHostSCMShape {
export interface ExtHostTaskShape { export interface ExtHostTaskShape {
$provideTasks(handle: number, validTypes: { [key: string]: boolean; }): Thenable<tasks.TaskSetDTO>; $provideTasks(handle: number, validTypes: { [key: string]: boolean; }): Thenable<tasks.TaskSetDTO>;
$resolveTask(handle: number, taskDTO: tasks.TaskDTO): Thenable<tasks.TaskDTO | undefined>; $resolveTask(handle: number, taskDTO: tasks.TaskDTO): Thenable<tasks.TaskDTO | undefined>;
$onDidStartTask(execution: tasks.TaskExecutionDTO, terminalId: number, resolvedDefinition?: tasks.TaskDefinitionDTO): void; $onDidStartTask(execution: tasks.TaskExecutionDTO, terminalId: number, resolvedDefinition: tasks.TaskDefinitionDTO): void;
$onDidStartTaskProcess(value: tasks.TaskProcessStartedDTO): void; $onDidStartTaskProcess(value: tasks.TaskProcessStartedDTO): void;
$onDidEndTaskProcess(value: tasks.TaskProcessEndedDTO): void; $onDidEndTaskProcess(value: tasks.TaskProcessEndedDTO): void;
$OnDidEndTask(execution: tasks.TaskExecutionDTO): void; $OnDidEndTask(execution: tasks.TaskExecutionDTO): void;
......
...@@ -475,7 +475,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape, IExtHostTask ...@@ -475,7 +475,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape, IExtHostTask
return this._onDidExecuteTask.event; return this._onDidExecuteTask.event;
} }
public async $onDidStartTask(execution: tasks.TaskExecutionDTO, terminalId: number, resolvedDefinition?: tasks.TaskDefinitionDTO): Promise<void> { public async $onDidStartTask(execution: tasks.TaskExecutionDTO, terminalId: number, resolvedDefinition: tasks.TaskDefinitionDTO): Promise<void> {
const customExecution: types.CustomExecution | undefined = this._providedCustomExecutions2.get(execution.id); const customExecution: types.CustomExecution | undefined = this._providedCustomExecutions2.get(execution.id);
if (customExecution) { if (customExecution) {
if (this._activeCustomExecutions2.get(execution.id) !== undefined) { if (this._activeCustomExecutions2.get(execution.id) !== undefined) {
......
...@@ -1831,20 +1831,20 @@ export enum TaskScope { ...@@ -1831,20 +1831,20 @@ export enum TaskScope {
Workspace = 2 Workspace = 2
} }
export class CustomExecution implements vscode.CustomExecution2 { export class CustomExecution implements vscode.CustomExecution {
private _callback: (resolvedDefintion?: vscode.TaskDefinition) => Thenable<vscode.Pseudoterminal>; private _callback: (resolvedDefintion: vscode.TaskDefinition) => Thenable<vscode.Pseudoterminal>;
constructor(callback: (resolvedDefintion?: vscode.TaskDefinition) => Thenable<vscode.Pseudoterminal>) { constructor(callback: (resolvedDefintion: vscode.TaskDefinition) => Thenable<vscode.Pseudoterminal>) {
this._callback = callback; this._callback = callback;
} }
public computeId(): string { public computeId(): string {
return 'customExecution' + generateUuid(); return 'customExecution' + generateUuid();
} }
public set callback(value: (resolvedDefintion?: vscode.TaskDefinition) => Thenable<vscode.Pseudoterminal>) { public set callback(value: (resolvedDefintion: vscode.TaskDefinition) => Thenable<vscode.Pseudoterminal>) {
this._callback = value; this._callback = value;
} }
public get callback(): ((resolvedDefintion?: vscode.TaskDefinition) => Thenable<vscode.Pseudoterminal>) { public get callback(): ((resolvedDefintion: vscode.TaskDefinition) => Thenable<vscode.Pseudoterminal>) {
return this._callback; return this._callback;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册