diff --git a/src/vs/workbench/api/common/extHostTask.ts b/src/vs/workbench/api/common/extHostTask.ts index 106635b772c317e67ebd690de66d4b73f3da1355..8ae923128bc327c8fccb6343bb6182c4cb495277 100644 --- a/src/vs/workbench/api/common/extHostTask.ts +++ b/src/vs/workbench/api/common/extHostTask.ts @@ -25,6 +25,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation' import { Schemas } from 'vs/base/common/network'; import * as Platform from 'vs/base/common/platform'; import { ILogService } from 'vs/platform/log/common/log'; +import { IExtHostApiDeprecationService } from 'vs/workbench/api/common/extHostApiDeprecationService'; export interface IExtHostTask extends ExtHostTaskShape { @@ -376,6 +377,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape { protected readonly _configurationService: IExtHostConfiguration; protected readonly _terminalService: IExtHostTerminalService; protected readonly _logService: ILogService; + protected readonly _deprecationService: IExtHostApiDeprecationService; protected _handleCounter: number; protected _handlers: Map; protected _taskExecutions: Map; @@ -396,7 +398,8 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape { @IExtHostDocumentsAndEditors editorService: IExtHostDocumentsAndEditors, @IExtHostConfiguration configurationService: IExtHostConfiguration, @IExtHostTerminalService extHostTerminalService: IExtHostTerminalService, - @ILogService logService: ILogService + @ILogService logService: ILogService, + @IExtHostApiDeprecationService deprecationService: IExtHostApiDeprecationService ) { this._proxy = extHostRpc.getProxy(MainContext.MainThreadTask); this._workspaceProvider = workspaceService; @@ -410,6 +413,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape { this._notProvidedCustomExecutions = new Set(); this._activeCustomExecutions2 = new Map(); this._logService = logService; + this._deprecationService = deprecationService; } public registerTaskProvider(extension: IExtensionDescription, type: string, provider: vscode.TaskProvider): vscode.Disposable { @@ -576,6 +580,8 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape { return; } + this.checkDeprecation(resolvedTask, handler); + const resolvedTaskDTO: tasks.TaskDTO | undefined = TaskDTO.from(resolvedTask, handler.extension); if (!resolvedTaskDTO) { throw new Error('Unexpected: Task cannot be resolved.'); @@ -630,6 +636,13 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape { return createdResult; } + protected checkDeprecation(task: vscode.Task, handler: HandlerData) { + const tTask = (task as types.Task); + if (tTask._deprecated) { + this._deprecationService.report('Task.constructor', handler.extension, 'Use the Task constructor that takes a `scope` instead.'); + } + } + private customExecutionComplete(execution: tasks.TaskExecutionDTO): void { const extensionCallback2: vscode.CustomExecution | undefined = this._activeCustomExecutions2.get(execution.id); if (extensionCallback2) { @@ -666,9 +679,10 @@ export class WorkerExtHostTask extends ExtHostTaskBase { @IExtHostDocumentsAndEditors editorService: IExtHostDocumentsAndEditors, @IExtHostConfiguration configurationService: IExtHostConfiguration, @IExtHostTerminalService extHostTerminalService: IExtHostTerminalService, - @ILogService logService: ILogService + @ILogService logService: ILogService, + @IExtHostApiDeprecationService deprecationService: IExtHostApiDeprecationService ) { - super(extHostRpc, initData, workspaceService, editorService, configurationService, extHostTerminalService, logService); + super(extHostRpc, initData, workspaceService, editorService, configurationService, extHostTerminalService, logService, deprecationService); if (initData.remote.isRemote && initData.remote.authority) { this.registerTaskSystem(Schemas.vscodeRemote, { scheme: Schemas.vscodeRemote, @@ -700,6 +714,7 @@ export class WorkerExtHostTask extends ExtHostTaskBase { const taskDTOs: tasks.TaskDTO[] = []; if (value) { for (let task of value) { + this.checkDeprecation(task, handler); if (!task.definition || !validTypes[task.definition.type]) { this._logService.warn(`The task [${task.source}, ${task.name}] uses an undefined task type. The task will be ignored in the future.`); } diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index 55dbbf3a66ee60aa5e616d642a8aff131503a4e8..19acded0ac96b9c26316198f333ee2baeadfbed1 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -1838,6 +1838,7 @@ export class Task implements vscode.Task2 { private static EmptyType: string = '$empty'; private __id: string | undefined; + private __deprecated: boolean = false; private _definition: vscode.TaskDefinition; private _scope: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder | undefined; @@ -1862,6 +1863,7 @@ export class Task implements vscode.Task2 { this._source = this.source = arg3; this.execution = arg4; problemMatchers = arg5; + this.__deprecated = true; } else if (arg2 === TaskScope.Global || arg2 === TaskScope.Workspace) { this.target = arg2; this._name = this.name = arg3; @@ -1898,6 +1900,10 @@ export class Task implements vscode.Task2 { this.__id = value; } + get _deprecated(): boolean { + return this.__deprecated; + } + private clear(): void { if (this.__id === undefined) { return; diff --git a/src/vs/workbench/api/node/extHostTask.ts b/src/vs/workbench/api/node/extHostTask.ts index bcca770e837adb082c15c18b9fc8477731412313..3dfa716f0b45e54f4d14a16c26bbef4916c4e599 100644 --- a/src/vs/workbench/api/node/extHostTask.ts +++ b/src/vs/workbench/api/node/extHostTask.ts @@ -24,6 +24,7 @@ import { ExtHostTaskBase, TaskHandleDTO, TaskDTO, CustomExecutionDTO, HandlerDat import { Schemas } from 'vs/base/common/network'; import { ILogService } from 'vs/platform/log/common/log'; import { IProcessEnvironment } from 'vs/base/common/platform'; +import { IExtHostApiDeprecationService } from 'vs/workbench/api/common/extHostApiDeprecationService'; export class ExtHostTask extends ExtHostTaskBase { private _variableResolver: ExtHostVariableResolverService | undefined; @@ -35,9 +36,10 @@ export class ExtHostTask extends ExtHostTaskBase { @IExtHostDocumentsAndEditors editorService: IExtHostDocumentsAndEditors, @IExtHostConfiguration configurationService: IExtHostConfiguration, @IExtHostTerminalService extHostTerminalService: IExtHostTerminalService, - @ILogService logService: ILogService + @ILogService logService: ILogService, + @IExtHostApiDeprecationService deprecationService: IExtHostApiDeprecationService ) { - super(extHostRpc, initData, workspaceService, editorService, configurationService, extHostTerminalService, logService); + super(extHostRpc, initData, workspaceService, editorService, configurationService, extHostTerminalService, logService, deprecationService); if (initData.remote.isRemote && initData.remote.authority) { this.registerTaskSystem(Schemas.vscodeRemote, { scheme: Schemas.vscodeRemote, @@ -73,6 +75,8 @@ export class ExtHostTask extends ExtHostTaskBase { const taskDTOs: tasks.TaskDTO[] = []; if (value) { for (let task of value) { + this.checkDeprecation(task, handler); + if (!task.definition || !validTypes[task.definition.type]) { this._logService.warn(`The task [${task.source}, ${task.name}] uses an undefined task type. The task will be ignored in the future.`); }