Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne committed Jun 18, 2023
1 parent 90b24bf commit da7004c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/kernels/jupyter/connection/jupyterUriProviderRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ import { traceError } from '../../../platform/logging';
import { IJupyterServerUri, IJupyterUriProvider, JupyterServerUriHandle } from '../../../api';
import { Disposables } from '../../../platform/common/utils';
import { IServiceContainer } from '../../../platform/ioc/types';
import { IExtensionSyncActivationService } from '../../../platform/activation/types';

const REGISTRATION_ID_EXTENSION_OWNER_MEMENTO_KEY = 'REGISTRATION_ID_EXTENSION_OWNER_MEMENTO_KEY';

/**
* Handles registration of 3rd party URI providers.
*/
@injectable()
export class JupyterUriProviderRegistration implements IJupyterUriProviderRegistration {
export class JupyterUriProviderRegistration
extends Disposables
implements IJupyterUriProviderRegistration, IExtensionSyncActivationService
{
private readonly _onProvidersChanged = new EventEmitter<void>();
private loadedOtherExtensionsPromise: Promise<void> | undefined;
private _providers = new Map<string, JupyterUriProviderWrapper>();
Expand All @@ -42,14 +46,18 @@ export class JupyterUriProviderRegistration implements IJupyterUriProviderRegist
@inject(IExtensions) private readonly extensions: IExtensions,
@inject(IDisposableRegistry) disposables: IDisposableRegistry,
@inject(IMemento) @named(GLOBAL_MEMENTO) private readonly globalMemento: Memento,
@inject(IServiceContainer) serviceContainer: IServiceContainer
@inject(IServiceContainer) private readonly serviceContainer: IServiceContainer
) {
disposables.push(this._onProvidersChanged);
disposables.push(new Disposable(() => this._providers.forEach((p) => p.dispose())));
const serverStorage = serviceContainer.get<IJupyterServerUriStorage>(IJupyterServerUriStorage);
disposables.push(serverStorage.onDidRemove(this.onDidRemoveServer, this));
super();
disposables.push(this);
this.disposables.push(this._onProvidersChanged);
this.disposables.push(new Disposable(() => this._providers.forEach((p) => p.dispose())));
}

public activate(): void {
const serverStorage = this.serviceContainer.get<IJupyterServerUriStorage>(IJupyterServerUriStorage);
this.disposables.push(serverStorage.onDidRemove(this.onDidRemoveServer, this));
}
public async getProviders(): Promise<ReadonlyArray<IInternalJupyterUriProvider>> {
await this.loadOtherExtensions();

Expand Down Expand Up @@ -78,13 +86,15 @@ export class JupyterUriProviderRegistration implements IJupyterUriProviderRegist
}
this._onProvidersChanged.fire();

return {
const disposable = {
dispose: () => {
this._providers.get(provider.id)?.dispose();
this._providers.delete(provider.id);
this._onProvidersChanged.fire();
}
};
this.disposables.push(disposable);
return disposable;
}
public async getJupyterServerUri(id: string, handle: JupyterServerUriHandle): Promise<IJupyterServerUri> {
await this.loadOtherExtensions();
Expand Down
1 change: 1 addition & 0 deletions src/kernels/jupyter/serviceRegistry.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export function registerTypes(serviceManager: IServiceManager, _isDevMode: boole
IJupyterUriProviderRegistration,
JupyterUriProviderRegistration
);
serviceManager.addBinding(IJupyterUriProviderRegistration, IExtensionSyncActivationService);
serviceManager.addSingleton<IJupyterServerUriStorage>(IJupyterServerUriStorage, JupyterServerUriStorage);
serviceManager.addSingleton<INotebookStarter>(INotebookStarter, JupyterServerStarter);
serviceManager.addSingleton<IJupyterServerConnector>(IJupyterServerConnector, JupyterServerConnector);
Expand Down
1 change: 1 addition & 0 deletions src/kernels/jupyter/serviceRegistry.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function registerTypes(serviceManager: IServiceManager, _isDevMode: boole
IJupyterUriProviderRegistration,
JupyterUriProviderRegistration
);
serviceManager.addBinding(IJupyterUriProviderRegistration, IExtensionSyncActivationService);
serviceManager.addSingleton<IJupyterServerUriStorage>(IJupyterServerUriStorage, JupyterServerUriStorage);
serviceManager.addSingleton<IKernelSessionFactory>(IKernelSessionFactory, KernelSessionFactory);
serviceManager.addSingleton<JupyterKernelSessionFactory>(JupyterKernelSessionFactory, JupyterKernelSessionFactory);
Expand Down

0 comments on commit da7004c

Please sign in to comment.