clean up some disposable use (#6832)

This commit is contained in:
Anthony Dresser
2019-08-20 14:34:13 -07:00
committed by GitHub
parent 54cf062737
commit c540e81108
23 changed files with 139 additions and 244 deletions

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
import {
SqlExtHostContext, ExtHostDataProtocolShape,
MainThreadDataProtocolShape, SqlMainContext
@@ -30,13 +30,11 @@ import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
* Main thread class for handling data protocol management registration.
*/
@extHostNamedCustomer(SqlMainContext.MainThreadDataProtocol)
export class MainThreadDataProtocol implements MainThreadDataProtocolShape {
export class MainThreadDataProtocol extends Disposable implements MainThreadDataProtocolShape {
private _proxy: ExtHostDataProtocolShape;
private _toDispose: IDisposable[];
private _capabilitiesRegistrations: { [handle: number]: IDisposable; } = Object.create(null);
private _capabilitiesRegistrations: { [handle: number]: IDisposable; } = Object.create(null); // should we be registering these?
constructor(
extHostContext: IExtHostContext,
@@ -55,18 +53,15 @@ export class MainThreadDataProtocol implements MainThreadDataProtocolShape {
@ISerializationService private _serializationService: ISerializationService,
@IFileBrowserService private _fileBrowserService: IFileBrowserService
) {
super();
if (extHostContext) {
this._proxy = extHostContext.getProxy(SqlExtHostContext.ExtHostDataProtocol);
}
if (this._connectionManagementService) {
this._connectionManagementService.onLanguageFlavorChanged(e => this._proxy.$languageFlavorChanged(e), this, this._toDispose);
this._register(this._connectionManagementService.onLanguageFlavorChanged(e => this._proxy.$languageFlavorChanged(e)));
}
}
public dispose(): void {
this._toDispose = dispose(this._toDispose);
}
public $registerConnectionProvider(providerId: string, handle: number): Promise<any> {
const self = this;
this._connectionManagementService.registerProvider(providerId, <azdata.ConnectionProvider>{