mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 09:35:37 -05:00
* Fix initial build breaks from 1.67 merge (#2514) * Update yarn lock files * Update build scripts * Fix tsconfig * Build breaks * WIP * Update yarn lock files * Misc breaks * Updates to package.json * Breaks * Update yarn * Fix breaks * Breaks * Build breaks * Breaks * Breaks * Breaks * Breaks * Breaks * Missing file * Breaks * Breaks * Breaks * Breaks * Breaks * Fix several runtime breaks (#2515) * Missing files * Runtime breaks * Fix proxy ordering issue * Remove commented code * Fix breaks with opening query editor * Fix post merge break * Updates related to setup build and other breaks (#2516) * Fix bundle build issues * Update distro * Fix distro merge and update build JS files * Disable pipeline steps * Remove stats call * Update license name * Make new RPM dependencies a warning * Fix extension manager version checks * Update JS file * Fix a few runtime breaks * Fixes * Fix runtime issues * Fix build breaks * Update notebook tests (part 1) * Fix broken tests * Linting errors * Fix hygiene * Disable lint rules * Bump distro * Turn off smoke tests * Disable integration tests * Remove failing "activate" test * Remove failed test assertion * Disable other broken test * Disable query history tests * Disable extension unit tests * Disable failing tasks
85 lines
2.8 KiB
TypeScript
85 lines
2.8 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { validateConstraint } from 'vs/base/common/types';
|
|
import { ILogService } from 'vs/platform/log/common/log';
|
|
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
|
import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
|
|
|
|
import * as azdata from 'azdata';
|
|
|
|
import { ITaskHandlerDescription } from 'sql/workbench/services/tasks/common/tasks';
|
|
import { MainThreadTasksShape, ExtHostTasksShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
|
|
import { SqlMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
|
|
|
interface TaskHandler {
|
|
callback: Function;
|
|
thisArg: any;
|
|
description: ITaskHandlerDescription;
|
|
}
|
|
|
|
export class ExtHostTasks implements ExtHostTasksShape {
|
|
private _proxy: MainThreadTasksShape;
|
|
private _tasks = new Map<string, TaskHandler>();
|
|
|
|
constructor(
|
|
mainContext: IMainContext,
|
|
private logService: ILogService
|
|
) {
|
|
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadTasks);
|
|
}
|
|
|
|
registerTask(id: string, callback: azdata.tasks.ITaskHandler, thisArg?: any, description?: ITaskHandlerDescription): extHostTypes.Disposable {
|
|
this.logService.trace('ExtHostTasks#registerTask', id);
|
|
|
|
if (!id.trim().length) {
|
|
throw new Error('invalid id');
|
|
}
|
|
|
|
if (this._tasks.has(id)) {
|
|
throw new Error(`task '${id}' already exists`);
|
|
}
|
|
|
|
this._tasks.set(id, { callback, thisArg, description });
|
|
this._proxy.$registerTask(id);
|
|
|
|
return new extHostTypes.Disposable(() => {
|
|
if (this._tasks.delete(id)) {
|
|
this._proxy.$unregisterTask(id);
|
|
}
|
|
});
|
|
}
|
|
|
|
$executeContributedTask<T>(id: string, ...args: any[]): Thenable<T> {
|
|
let command = this._tasks.get(id);
|
|
if (!command) {
|
|
return Promise.reject(new Error(`Contributed task '${id}' does not exist.`));
|
|
}
|
|
|
|
let { callback, thisArg, description } = command;
|
|
|
|
if (description) {
|
|
for (let i = 0; i < description.args.length; i++) {
|
|
try {
|
|
validateConstraint(args[i], description.args[i].constraint);
|
|
} catch (err) {
|
|
return Promise.reject(new Error(`Running the contributed task:'${id}' failed. Illegal argument '${description.args[i].name}' - ${description.args[i].description}`));
|
|
}
|
|
}
|
|
}
|
|
|
|
try {
|
|
let result = callback.apply(thisArg, args);
|
|
return Promise.resolve(result);
|
|
} catch (err) {
|
|
return Promise.reject(new Error(`Running the contributed task:'${id}' failed.`));
|
|
}
|
|
}
|
|
|
|
$getContributedTaskHandlerDescriptions(): Promise<{ [id: string]: any; }> {
|
|
throw new Error('Method not implemented.');
|
|
}
|
|
}
|