mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 17:22:45 -05:00
API improvement: make registerConnectionEventProvider return disposable (#11880)
* promote api to official * add comments * disposable * move getConnection out * comment for connection namespace * remove extra line * also fix registerQueryInfoHandler
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
import { ExtHostConnectionManagementShape, SqlMainContext, MainThreadConnectionManagementShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import * as azdata from 'azdata';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable } from 'vs/workbench/api/common/extHostTypes';
|
||||
|
||||
export class ExtHostConnectionManagement extends ExtHostConnectionManagementShape {
|
||||
|
||||
@@ -27,10 +29,15 @@ export class ExtHostConnectionManagement extends ExtHostConnectionManagementShap
|
||||
}
|
||||
}
|
||||
|
||||
public $registerConnectionEventListener(providerId: string, listener: azdata.connection.ConnectionEventListener): void {
|
||||
this._connectionListeners[this._nextListenerHandle] = listener;
|
||||
this._proxy.$registerConnectionEventListener(this._nextListenerHandle, providerId);
|
||||
this._nextListenerHandle++;
|
||||
public $registerConnectionEventListener(listener: azdata.connection.ConnectionEventListener): IDisposable {
|
||||
const handle = this._nextListenerHandle++;
|
||||
this._connectionListeners[handle] = listener;
|
||||
this._proxy.$registerConnectionEventListener(handle);
|
||||
|
||||
return new Disposable(() => {
|
||||
this._connectionListeners.delete(handle);
|
||||
this._proxy.$unregisterConnectionEventListener(handle);
|
||||
});
|
||||
}
|
||||
|
||||
public $getCurrentConnection(): Thenable<azdata.connection.ConnectionProfile> {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { ExtHostQueryEditorShape, SqlMainContext, MainThreadQueryEditorShape } f
|
||||
import * as azdata from 'azdata';
|
||||
import { IQueryEvent } from 'sql/workbench/services/query/common/queryModel';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { Disposable } from 'vs/workbench/api/common/extHostTypes';
|
||||
|
||||
class ExtHostQueryDocument implements azdata.queryeditor.QueryDocument {
|
||||
constructor(
|
||||
@@ -52,10 +53,14 @@ export class ExtHostQueryEditor implements ExtHostQueryEditorShape {
|
||||
return this._proxy.$runQuery(fileUri, runCurrentQuery);
|
||||
}
|
||||
|
||||
public $registerQueryInfoListener(listener: azdata.queryeditor.QueryEventListener): void {
|
||||
this._queryListeners[this._nextListenerHandle] = listener;
|
||||
this._proxy.$registerQueryInfoListener(this._nextListenerHandle);
|
||||
this._nextListenerHandle++;
|
||||
public $registerQueryInfoListener(listener: azdata.queryeditor.QueryEventListener): Disposable {
|
||||
const handle = this._nextListenerHandle++;
|
||||
this._queryListeners[handle] = listener;
|
||||
this._proxy.$registerQueryInfoListener(handle);
|
||||
return new Disposable(() => {
|
||||
this._queryListeners.delete(handle);
|
||||
this._proxy.$unregisterQueryInfoListener(handle);
|
||||
});
|
||||
}
|
||||
|
||||
public $onQueryEvent(providerId: string, handle: number, fileUri: string, event: IQueryEvent): void {
|
||||
|
||||
@@ -27,7 +27,6 @@ import { ExtHostNotebookDocumentsAndEditors } from 'sql/workbench/api/common/ext
|
||||
import { ExtHostExtensionManagement } from 'sql/workbench/api/common/extHostExtensionManagement';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
|
||||
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IURITransformerService } from 'vs/workbench/api/common/extHostUriTransformerService';
|
||||
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||
@@ -107,8 +106,8 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
||||
getConnections(activeConnectionsOnly?: boolean): Thenable<azdata.connection.ConnectionProfile[]> {
|
||||
return extHostConnectionManagement.$getConnections(activeConnectionsOnly);
|
||||
},
|
||||
registerConnectionEventListener(listener: azdata.connection.ConnectionEventListener): void {
|
||||
return extHostConnectionManagement.$registerConnectionEventListener(mssqlProviderName, listener);
|
||||
registerConnectionEventListener(listener: azdata.connection.ConnectionEventListener): vscode.Disposable {
|
||||
return extHostConnectionManagement.$registerConnectionEventListener(listener);
|
||||
},
|
||||
getConnection(uri: string): Thenable<azdata.connection.ConnectionProfile> {
|
||||
return extHostConnectionManagement.$getConnection(uri);
|
||||
@@ -485,8 +484,8 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
||||
extHostQueryEditor.$runQuery(fileUri, runCurrentQuery);
|
||||
},
|
||||
|
||||
registerQueryEventListener(listener: azdata.queryeditor.QueryEventListener): void {
|
||||
extHostQueryEditor.$registerQueryInfoListener(listener);
|
||||
registerQueryEventListener(listener: azdata.queryeditor.QueryEventListener): extHostTypes.Disposable {
|
||||
return extHostQueryEditor.$registerQueryInfoListener(listener);
|
||||
},
|
||||
|
||||
getQueryDocument(fileUri: string): Thenable<azdata.queryeditor.QueryDocument> {
|
||||
|
||||
@@ -615,7 +615,8 @@ export interface MainThreadDataProtocolShape extends IDisposable {
|
||||
}
|
||||
|
||||
export interface MainThreadConnectionManagementShape extends IDisposable {
|
||||
$registerConnectionEventListener(handle: number, providerId: string): void;
|
||||
$registerConnectionEventListener(handle: number): void;
|
||||
$unregisterConnectionEventListener(handle: number): void;
|
||||
$getConnections(activeConnectionsOnly?: boolean): Thenable<azdata.connection.ConnectionProfile[]>;
|
||||
$getConnection(uri: string): Thenable<azdata.connection.ConnectionProfile>;
|
||||
$getActiveConnections(): Thenable<azdata.connection.Connection[]>;
|
||||
@@ -830,6 +831,7 @@ export interface MainThreadQueryEditorShape extends IDisposable {
|
||||
$createQueryTab(fileUri: string, title: string, content: string): void;
|
||||
$setQueryExecutionOptions(fileUri: string, options: azdata.QueryExecutionOptions): Thenable<void>;
|
||||
$registerQueryInfoListener(handle: number): void;
|
||||
$unregisterQueryInfoListener(handle: number): void;
|
||||
}
|
||||
|
||||
export interface ExtHostNotebookShape {
|
||||
|
||||
Reference in New Issue
Block a user