mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 17:22:42 -05:00
Merge from vscode 81d7885dc2e9dc617e1522697a2966bc4025a45d (#5949)
* Merge from vscode 81d7885dc2e9dc617e1522697a2966bc4025a45d * Fix vs unit tests and hygiene issue * Fix strict null check issue
This commit is contained in:
62
src/sql/workbench/api/browser/mainThreadTasks.ts
Normal file
62
src/sql/workbench/api/browser/mainThreadTasks.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { TaskRegistry, ITaskHandlerDescription } from 'sql/platform/tasks/common/tasks';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
|
||||
import {
|
||||
SqlExtHostContext,
|
||||
SqlMainContext,
|
||||
ExtHostTasksShape,
|
||||
MainThreadTasksShape
|
||||
} from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
|
||||
import { IConnectionProfile } from 'azdata';
|
||||
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadTasks)
|
||||
export class MainThreadTasks implements MainThreadTasksShape {
|
||||
|
||||
private readonly _disposables = new Map<string, IDisposable>();
|
||||
private readonly _generateCommandsDocumentationRegistration: IDisposable;
|
||||
private readonly _proxy: ExtHostTasksShape;
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext
|
||||
) {
|
||||
this._proxy = extHostContext.getProxy(SqlExtHostContext.ExtHostTasks);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this._disposables.forEach(value => value.dispose());
|
||||
this._disposables.clear();
|
||||
|
||||
this._generateCommandsDocumentationRegistration.dispose();
|
||||
}
|
||||
|
||||
$registerTask(id: string): Promise<any> {
|
||||
this._disposables.set(
|
||||
id,
|
||||
TaskRegistry.registerTask(id, (accessor, profile: IConnectionProfile, ...args) => {
|
||||
if (profile instanceof ConnectionProfile) {
|
||||
profile = profile.toIConnectionProfile();
|
||||
}
|
||||
this._proxy.$executeContributedTask(id, profile, ...args);
|
||||
})
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
$unregisterTask(id: string): Promise<any> {
|
||||
if (this._disposables.has(id)) {
|
||||
this._disposables.get(id).dispose();
|
||||
this._disposables.delete(id);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user