mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-14 18:46:34 -05:00
* various clean ups * formatting * remove linting * formatting * IConfigurationService is even better * messing with connection config tests * update tests * formatting * foramtting * remove unused code * add more tests
61 lines
2.1 KiB
TypeScript
61 lines
2.1 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
'use strict';
|
|
|
|
import { nb } from 'azdata';
|
|
import * as vscode from 'vscode';
|
|
import * as nls from 'vscode-nls';
|
|
const localize = nls.loadMessageBundle();
|
|
|
|
import * as constants from '../common/constants';
|
|
import { JupyterNotebookManager } from './jupyterNotebookManager';
|
|
import { LocalJupyterServerManager } from './jupyterServerManager';
|
|
|
|
export type ServerManagerFactory = (documentUri: vscode.Uri) => LocalJupyterServerManager;
|
|
|
|
export class JupyterNotebookProvider implements nb.NotebookProvider {
|
|
readonly providerId: string = constants.jupyterNotebookProviderId;
|
|
private managerTracker = new Map<string, JupyterNotebookManager>();
|
|
|
|
constructor(private createServerManager: ServerManagerFactory) {
|
|
}
|
|
|
|
public getNotebookManager(notebookUri: vscode.Uri): Thenable<nb.NotebookManager> {
|
|
if (!notebookUri) {
|
|
return Promise.reject(localize('errNotebookUriMissing', 'A notebook path is required'));
|
|
}
|
|
return Promise.resolve(this.doGetNotebookManager(notebookUri));
|
|
}
|
|
|
|
private doGetNotebookManager(notebookUri: vscode.Uri): nb.NotebookManager {
|
|
let uriString = notebookUri.toString();
|
|
let manager = this.managerTracker.get(uriString);
|
|
if (!manager) {
|
|
let serverManager = this.createServerManager(notebookUri);
|
|
manager = new JupyterNotebookManager(serverManager);
|
|
this.managerTracker.set(uriString, manager);
|
|
}
|
|
return manager;
|
|
}
|
|
|
|
handleNotebookClosed(notebookUri: vscode.Uri): void {
|
|
if (!notebookUri) {
|
|
// As this is a notification method, will skip throwing an error here
|
|
return;
|
|
}
|
|
let uriString = notebookUri.toString();
|
|
let manager = this.managerTracker.get(uriString);
|
|
if (manager) {
|
|
this.managerTracker.delete(uriString);
|
|
manager.dispose();
|
|
}
|
|
}
|
|
|
|
public get standardKernels(): nb.IStandardKernel[] {
|
|
return [];
|
|
}
|
|
}
|