diff --git a/src/client/api.ts b/src/client/api.ts index a16e2e212e2..7997a97d671 100644 --- a/src/client/api.ts +++ b/src/client/api.ts @@ -10,7 +10,6 @@ import { traceError } from './common/logger'; import { VSCodeNotebookProvider } from './datascience/constants'; import { IDataViewerDataProvider, IDataViewerFactory } from './datascience/data-viewing/types'; import { NotebookCellRunState } from './datascience/jupyter/kernels/types'; -import { CreationOptionService } from './datascience/notebook/creation/creationOptionsService'; import { KernelStateEventArgs } from './datascience/notebookExtensibility'; import { IJupyterUriProvider, @@ -58,19 +57,6 @@ export interface IExtensionApi { */ registerRemoteServerProvider(serverProvider: IJupyterUriProvider): void; registerPythonApi(pythonApi: PythonApi): void; - /** - * When called by other extensions we will display these extensions in a dropdown list when creating a new notebook. - */ - registerNewNotebookContent(options: { - /** - * Use this language as the language of cells for new notebooks created (when user picks this extension). - */ - defaultCellLanguage: string; - /** - * Value in the quickpick (if not provided, will use the displayName of the extension). - */ - label: string; - }): Promise; /** * Creates a blank notebook and defaults the empty cell to the language provided. */ @@ -110,11 +96,6 @@ export function buildApi( }, onKernelStateChange: notebookExtensibility.onKernelStateChange.bind(notebookExtensibility), registerCellToolbarButton: webviewExtensibility.registerCellToolbarButton.bind(webviewExtensibility), - registerNewNotebookContent(options: { defaultCellLanguage: string; label?: string }) { - return serviceContainer - .get(CreationOptionService) - .registerNewNotebookContent(options); - }, createBlankNotebook: async (options: { defaultCellLanguage: string }): Promise => { const service = serviceContainer.get(VSCodeNotebookProvider); await service.createNew(options); diff --git a/src/client/datascience/notebook/creation/creationOptionsService.ts b/src/client/datascience/notebook/creation/creationOptionsService.ts index 4559ca9f8b8..9ddb58377e9 100644 --- a/src/client/datascience/notebook/creation/creationOptionsService.ts +++ b/src/client/datascience/notebook/creation/creationOptionsService.ts @@ -10,7 +10,7 @@ import { Telemetry } from '../../constants'; @injectable() export class CreationOptionService { private readonly _registrations: { extensionId: string; displayName: string; defaultCellLanguage: string }[] = []; - constructor(@inject(IExtensions) private readonly extensions: IExtensions) { + constructor(@inject(IExtensions) extensions: IExtensions) { const contributingExtensions = extensions.all.filter((item) => item.packageJSON.contributes && item.packageJSON.contributes['jupyter.kernels'] ? true : false ); @@ -18,10 +18,11 @@ export class CreationOptionService { try { // eslint-disable-next-line @typescript-eslint/no-explicit-any ext.packageJSON.contributes['jupyter.kernels'].forEach((kernel: any) => { + sendTelemetryEvent(Telemetry.OpenNotebookSelectionRegistered, undefined, { extensionId: ext.id }); this._registrations.push({ extensionId: ext.id, displayName: kernel['title'], - defaultCellLanguage: kernel['defaultlanguage'] + defaultCellLanguage: kernel['defaultlanguage'] || kernel['defaultLanguage'] }); }); } catch { @@ -29,13 +30,11 @@ export class CreationOptionService { } }); } - public async registerNewNotebookContent(options: { defaultCellLanguage: string; label?: string }): Promise { - const info = await this.extensions.determineExtensionFromCallStack(); - if (this._registrations.find((item) => item.extensionId.toLowerCase() === info.extensionId)) { - return; - } - sendTelemetryEvent(Telemetry.OpenNotebookSelectionRegistered, undefined, { extensionId: info.extensionId }); - this._registrations.push({ ...info, ...options, displayName: options.label || info.displayName }); + /** + * Used purely for testing purposes. + */ + public async registerNewNotebookContent(defaultCellLanguage: string): Promise { + this._registrations.push({ displayName: defaultCellLanguage, defaultCellLanguage, extensionId: '' }); } public get registrations() { return this._registrations; diff --git a/src/client/extension.ts b/src/client/extension.ts index 8d5ae0244a9..bc99c0ef24d 100644 --- a/src/client/extension.ts +++ b/src/client/extension.ts @@ -74,7 +74,6 @@ export async function activate(context: IExtensionContext): Promise ({ dispose: noop }), ready: Promise.resolve(), registerCellToolbarButton: () => ({ dispose: noop }), - registerNewNotebookContent: () => Promise.resolve(), registerPythonApi: noop, registerRemoteServerProvider: noop, showDataViewer: () => Promise.resolve() diff --git a/src/test/datascience/dataScienceIocContainer.ts b/src/test/datascience/dataScienceIocContainer.ts index 79fda465fc3..73a3ac4ba2e 100644 --- a/src/test/datascience/dataScienceIocContainer.ts +++ b/src/test/datascience/dataScienceIocContainer.ts @@ -667,7 +667,6 @@ export class DataScienceIocContainer extends UnitTestIocContainer { this.serviceManager.addSingletonInstance(NotebookCreator, instance(mock(NotebookCreator))); const creationService = mock(); - when(creationService.registerNewNotebookContent(anything())).thenResolve(); when(creationService.registrations).thenReturn([]); this.serviceManager.addSingletonInstance( CreationOptionService, diff --git a/src/test/datascience/extensionapi/exampleextension/ms-ai-tools-test/package.json b/src/test/datascience/extensionapi/exampleextension/ms-ai-tools-test/package.json index 32fd488dd1e..008d3f5709a 100644 --- a/src/test/datascience/extensionapi/exampleextension/ms-ai-tools-test/package.json +++ b/src/test/datascience/extensionapi/exampleextension/ms-ai-tools-test/package.json @@ -34,6 +34,12 @@ "title": "Create new blank Julia notebook", "category": "Notebook" } + ], + "jupyter.kernels": [ + { + "title": "Julia", + "defaultLanguage": "julia" + } ] }, "scripts": { diff --git a/src/test/datascience/extensionapi/exampleextension/ms-ai-tools-test/src/extension.ts b/src/test/datascience/extensionapi/exampleextension/ms-ai-tools-test/src/extension.ts index a1de1ece603..0b95df10d9f 100644 --- a/src/test/datascience/extensionapi/exampleextension/ms-ai-tools-test/src/extension.ts +++ b/src/test/datascience/extensionapi/exampleextension/ms-ai-tools-test/src/extension.ts @@ -13,7 +13,6 @@ export async function activate(_context: vscode.ExtensionContext) { await jupyter.exports.ready; } jupyter.exports.registerRemoteServerProvider(new RemoteServerPickerExample()); - jupyter.exports.registerNewNotebookContent({ defaultCellLanguage: 'julia' }); vscode.commands.registerCommand( 'ms-toolsai-test.createBlankNotebook', () => void jupyter.exports.createBlankNotebook({ defaultCellLanguage: 'julia' }) diff --git a/src/test/datascience/notebook/creation/notebookCreation.vscode.test.ts b/src/test/datascience/notebook/creation/notebookCreation.vscode.test.ts index ddcd399e4df..39e3a9be713 100644 --- a/src/test/datascience/notebook/creation/notebookCreation.vscode.test.ts +++ b/src/test/datascience/notebook/creation/notebookCreation.vscode.test.ts @@ -54,7 +54,7 @@ suite('DataScience - VSCode Notebook - (Creation Integration)', function () { ); } test('With 3rd party integration, display quick pick when selecting create blank notebook command', async function () { - await creationOptions.registerNewNotebookContent({ defaultCellLanguage: 'julia' }); + await creationOptions.registerNewNotebookContent('julia'); assert.equal(creationOptions.registrations.length, 1); assert.isUndefined(vscodeNotebook.activeNotebookEditor);