mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 15:01:57 +01:00
More adoption of @extHostNamedCustomer
This commit is contained in:
@@ -7,16 +7,29 @@
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
import { ITaskService } from 'vs/workbench/parts/tasks/common/taskService';
|
||||
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
|
||||
|
||||
import { ExtHostContext, MainThreadTaskShape, ExtHostTaskShape } from '../node/extHost.protocol';
|
||||
import { ExtHostContext, MainThreadTaskShape, ExtHostTaskShape, MainContext, IExtHostContext } from '../node/extHost.protocol';
|
||||
import { extHostNamedCustomer } from "vs/workbench/api/electron-browser/extHostCustomers";
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadTask)
|
||||
export class MainThreadTask implements MainThreadTaskShape {
|
||||
|
||||
private _proxy: ExtHostTaskShape;
|
||||
private _activeHandles: { [handle: number]: boolean; };
|
||||
|
||||
constructor( @IThreadService threadService: IThreadService, @ITaskService private _taskService: ITaskService) {
|
||||
this._proxy = threadService.get(ExtHostContext.ExtHostTask);
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@ITaskService private _taskService: ITaskService
|
||||
) {
|
||||
this._proxy = extHostContext.get(ExtHostContext.ExtHostTask);
|
||||
this._activeHandles = Object.create(null);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
Object.keys(this._activeHandles).forEach((handle) => {
|
||||
this._taskService.unregisterTaskProvider(parseInt(handle, 10));
|
||||
});
|
||||
this._activeHandles = Object.create(null);
|
||||
}
|
||||
|
||||
public $registerTaskProvider(handle: number): TPromise<void> {
|
||||
@@ -25,11 +38,13 @@ export class MainThreadTask implements MainThreadTaskShape {
|
||||
return this._proxy.$provideTasks(handle);
|
||||
}
|
||||
});
|
||||
this._activeHandles[handle] = true;
|
||||
return TPromise.as<void>(undefined);
|
||||
}
|
||||
|
||||
public $unregisterTaskProvider(handle: number): TPromise<any> {
|
||||
this._taskService.unregisterTaskProvider(handle);
|
||||
delete this._activeHandles[handle];
|
||||
return TPromise.as<void>(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user