mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 01:25:36 -05:00
Add notebook extension support for .NET Interactive. (#18334)
* Also updated kernel dropdown to only include SQL aliased kernels when using SQL notebook provider.
This commit is contained in:
@@ -22,5 +22,6 @@ export enum KernelsLanguage {
|
||||
SparkScala = 'scala',
|
||||
SparkR = 'sparkr',
|
||||
PowerShell = 'powershell',
|
||||
CSharp = 'cs'
|
||||
CSharp = 'csharp',
|
||||
FSharp = 'fsharp'
|
||||
}
|
||||
|
||||
@@ -55,6 +55,12 @@ let providerDescriptionType: IJSONSchema = {
|
||||
items: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
supportedLanguages: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,7 +118,8 @@ export interface INotebookProviderRegistry {
|
||||
|
||||
readonly onNewDescriptionRegistration: Event<{ id: string, registration: ProviderDescriptionRegistration }>;
|
||||
|
||||
updateProviderDescriptionLanguages(providerId: string, languages: string[]): void;
|
||||
updateProviderKernels(providerId: string, kernels: azdata.nb.IStandardKernel[]): void;
|
||||
updateKernelLanguages(providerId: string, kernelName: string, languages: string[]): void;
|
||||
registerProviderDescription(provider: ProviderDescriptionRegistration): void;
|
||||
registerNotebookLanguageMagic(magic: NotebookLanguageMagicRegistration): void;
|
||||
}
|
||||
@@ -124,24 +131,33 @@ class NotebookProviderRegistry implements INotebookProviderRegistry {
|
||||
private _onNewDescriptionRegistration = new Emitter<{ id: string, registration: ProviderDescriptionRegistration }>();
|
||||
public readonly onNewDescriptionRegistration: Event<{ id: string, registration: ProviderDescriptionRegistration }> = this._onNewDescriptionRegistration.event;
|
||||
|
||||
updateProviderDescriptionLanguages(providerId: string, languages: string[]): void {
|
||||
private readonly providerNotInRegistryError = (providerId: string): string => localize('providerNotInRegistryError', "The specified provider '{0}' is not present in the notebook registry.", providerId);
|
||||
|
||||
updateProviderKernels(providerId: string, kernels: azdata.nb.IStandardKernel[]): void {
|
||||
let registration = this._providerDescriptionRegistration.get(providerId);
|
||||
if (!registration) {
|
||||
throw new Error(localize('providerNotInRegistryError', "The specified provider '{0}' is not present in the notebook registry.", providerId));
|
||||
throw new Error(this.providerNotInRegistryError(providerId));
|
||||
}
|
||||
let kernels = languages.map<azdata.nb.IStandardKernel>(language => {
|
||||
return {
|
||||
name: language,
|
||||
displayName: language,
|
||||
connectionProviderIds: []
|
||||
};
|
||||
});
|
||||
registration.standardKernels = kernels;
|
||||
|
||||
// Update provider description with new info
|
||||
this.registerProviderDescription(registration);
|
||||
}
|
||||
|
||||
updateKernelLanguages(providerId: string, kernelName: string, languages: string[]): void {
|
||||
let registration = this._providerDescriptionRegistration.get(providerId);
|
||||
if (!registration) {
|
||||
throw new Error(this.providerNotInRegistryError(providerId));
|
||||
}
|
||||
let kernel = registration.standardKernels?.find(kernel => kernel.name === kernelName);
|
||||
if (kernel) {
|
||||
kernel.supportedLanguages = languages;
|
||||
}
|
||||
|
||||
// Update provider description with new info
|
||||
this.registerProviderDescription(registration);
|
||||
}
|
||||
|
||||
registerProviderDescription(registration: ProviderDescriptionRegistration): void {
|
||||
this._providerDescriptionRegistration.set(registration.provider, registration);
|
||||
this._onNewDescriptionRegistration.fire({ id: registration.provider, registration: registration });
|
||||
|
||||
Reference in New Issue
Block a user