mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Change SQL kernel to check queryManagementService instead of hardcoding (#4098)
* Change SQL kernel to check queryManagementService instead of hardcoding * addressing PR comments
This commit is contained in:
@@ -12,6 +12,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
|||||||
import * as TelemetryKeys from 'sql/common/telemetryKeys';
|
import * as TelemetryKeys from 'sql/common/telemetryKeys';
|
||||||
import * as TelemetryUtils from 'sql/common/telemetryUtilities';
|
import * as TelemetryUtils from 'sql/common/telemetryUtilities';
|
||||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||||
|
import { Event, Emitter } from 'vs/base/common/event';
|
||||||
|
|
||||||
export const SERVICE_ID = 'queryManagementService';
|
export const SERVICE_ID = 'queryManagementService';
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ export interface IQueryManagementService {
|
|||||||
|
|
||||||
addQueryRequestHandler(queryType: string, runner: IQueryRequestHandler): IDisposable;
|
addQueryRequestHandler(queryType: string, runner: IQueryRequestHandler): IDisposable;
|
||||||
isProviderRegistered(providerId: string): boolean;
|
isProviderRegistered(providerId: string): boolean;
|
||||||
|
getRegisteredProviders(): string[];
|
||||||
registerRunner(runner: QueryRunner, uri: string): void;
|
registerRunner(runner: QueryRunner, uri: string): void;
|
||||||
|
|
||||||
cancelQuery(ownerUri: string): Thenable<sqlops.QueryCancelResult>;
|
cancelQuery(ownerUri: string): Thenable<sqlops.QueryCancelResult>;
|
||||||
@@ -87,6 +89,7 @@ export class QueryManagementService implements IQueryManagementService {
|
|||||||
public _serviceBrand: any;
|
public _serviceBrand: any;
|
||||||
|
|
||||||
private _requestHandlers = new Map<string, IQueryRequestHandler>();
|
private _requestHandlers = new Map<string, IQueryRequestHandler>();
|
||||||
|
private _onHandlerAddedEmitter = new Emitter<string>();
|
||||||
// public for testing only
|
// public for testing only
|
||||||
public _queryRunners = new Map<string, QueryRunner>();
|
public _queryRunners = new Map<string, QueryRunner>();
|
||||||
|
|
||||||
@@ -137,6 +140,7 @@ export class QueryManagementService implements IQueryManagementService {
|
|||||||
|
|
||||||
public addQueryRequestHandler(queryType: string, handler: IQueryRequestHandler): IDisposable {
|
public addQueryRequestHandler(queryType: string, handler: IQueryRequestHandler): IDisposable {
|
||||||
this._requestHandlers.set(queryType, handler);
|
this._requestHandlers.set(queryType, handler);
|
||||||
|
this._onHandlerAddedEmitter.fire(queryType);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
dispose: () => {
|
dispose: () => {
|
||||||
@@ -144,11 +148,19 @@ export class QueryManagementService implements IQueryManagementService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get onHandlerAdded(): Event<string> {
|
||||||
|
return this._onHandlerAddedEmitter.event;
|
||||||
|
}
|
||||||
|
|
||||||
public isProviderRegistered(providerId: string): boolean {
|
public isProviderRegistered(providerId: string): boolean {
|
||||||
let handler = this._requestHandlers.get(providerId);
|
let handler = this._requestHandlers.get(providerId);
|
||||||
return !!handler;
|
return !!handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getRegisteredProviders(): string[] {
|
||||||
|
return Array.from(this._requestHandlers.keys());
|
||||||
|
}
|
||||||
|
|
||||||
private addTelemetry(eventName: string, ownerUri: string, runOptions?: sqlops.ExecutionPlanOptions): void {
|
private addTelemetry(eventName: string, ownerUri: string, runOptions?: sqlops.ExecutionPlanOptions): void {
|
||||||
let providerId: string = this._connectionService.getProviderIdFromUri(ownerUri);
|
let providerId: string = this._connectionService.getProviderIdFromUri(ownerUri);
|
||||||
let data: TelemetryUtils.IConnectionTelemetryData = {
|
let data: TelemetryUtils.IConnectionTelemetryData = {
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorG
|
|||||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||||
import { registerNotebookThemes } from 'sql/parts/notebook/notebookStyles';
|
import { registerNotebookThemes } from 'sql/parts/notebook/notebookStyles';
|
||||||
import { ILanguageMagic } from 'sql/parts/notebook/models/modelInterfaces';
|
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
|
||||||
|
import { ILanguageMagic, notebookConstants } from 'sql/parts/notebook/models/modelInterfaces';
|
||||||
|
|
||||||
export interface NotebookProviderProperties {
|
export interface NotebookProviderProperties {
|
||||||
provider: string;
|
provider: string;
|
||||||
@@ -104,7 +105,8 @@ export class NotebookService extends Disposable implements INotebookService {
|
|||||||
@IEditorService private readonly _editorService: IEditorService,
|
@IEditorService private readonly _editorService: IEditorService,
|
||||||
@IEditorGroupsService private readonly _editorGroupsService: IEditorGroupsService,
|
@IEditorGroupsService private readonly _editorGroupsService: IEditorGroupsService,
|
||||||
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
||||||
@IThemeService private readonly _themeService: IThemeService
|
@IThemeService private readonly _themeService: IThemeService,
|
||||||
|
@IQueryManagementService private readonly _queryManagementService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this._register(notebookRegistry.onNewRegistration(this.updateRegisteredProviders, this));
|
this._register(notebookRegistry.onNewRegistration(this.updateRegisteredProviders, this));
|
||||||
@@ -113,8 +115,15 @@ export class NotebookService extends Disposable implements INotebookService {
|
|||||||
if (extensionService) {
|
if (extensionService) {
|
||||||
extensionService.whenInstalledExtensionsRegistered().then(() => {
|
extensionService.whenInstalledExtensionsRegistered().then(() => {
|
||||||
this.cleanupProviders();
|
this.cleanupProviders();
|
||||||
this._isRegistrationComplete = true;
|
|
||||||
this._registrationComplete.resolve();
|
// If providers have already registered by this point, add them now (since onHandlerAdded will never fire)
|
||||||
|
if (this._queryManagementService.registeredProviders && this._queryManagementService.registeredProviders.length > 0) {
|
||||||
|
this.updateSQLRegistrationWithConnectionProviders();
|
||||||
|
}
|
||||||
|
|
||||||
|
this._register(this._queryManagementService.onHandlerAdded((queryType) => {
|
||||||
|
this.updateSQLRegistrationWithConnectionProviders();
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (extensionManagementService) {
|
if (extensionManagementService) {
|
||||||
@@ -158,6 +167,23 @@ export class NotebookService extends Disposable implements INotebookService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private updateSQLRegistrationWithConnectionProviders() {
|
||||||
|
// Update the SQL extension
|
||||||
|
let sqlNotebookProvider = this._providerToStandardKernels.get(notebookConstants.SQL);
|
||||||
|
if (sqlNotebookProvider) {
|
||||||
|
let sqlConnectionTypes = this._queryManagementService.getRegisteredProviders();
|
||||||
|
let provider = sqlNotebookProvider.find(p => p.name === notebookConstants.SQL);
|
||||||
|
if (provider) {
|
||||||
|
this._providerToStandardKernels.set(notebookConstants.SQL, [{
|
||||||
|
name: notebookConstants.SQL,
|
||||||
|
connectionProviderIds: sqlConnectionTypes
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._isRegistrationComplete = true;
|
||||||
|
this._registrationComplete.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
private updateNotebookThemes() {
|
private updateNotebookThemes() {
|
||||||
let overrideEditorSetting = this._configurationService.getValue<boolean>(OVERRIDE_EDITOR_THEMING_SETTING);
|
let overrideEditorSetting = this._configurationService.getValue<boolean>(OVERRIDE_EDITOR_THEMING_SETTING);
|
||||||
if (overrideEditorSetting !== this._overrideEditorThemeSetting) {
|
if (overrideEditorSetting !== this._overrideEditorThemeSetting) {
|
||||||
|
|||||||
Reference in New Issue
Block a user