Initial implementation for VSCode Notebook support (#17885)

This commit is contained in:
Cory Rivera
2022-01-03 15:59:37 -08:00
committed by GitHub
parent af5575a852
commit 2ecc3d35ca
45 changed files with 1533 additions and 260 deletions

View File

@@ -8,13 +8,13 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { Emitter } from 'vs/base/common/event';
import { DisposableStore, dispose, IDisposable } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
// import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers'; {{SQL CARBON EDIT}} Disable VS Code notebooks
import { INotebookCellStatusBarService } from 'vs/workbench/contrib/notebook/common/notebookCellStatusBarService';
import { INotebookCellStatusBarItemProvider, INotebookContributionData, NotebookDataDto, TransientCellMetadata, TransientDocumentMetadata, TransientOptions } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookContentProvider, INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
import { ExtHostContext, ExtHostNotebookShape, IExtHostContext, MainContext, MainThreadNotebookShape, NotebookExtensionDescription } from '../common/extHost.protocol';
import { ExtHostContext, ExtHostNotebookShape, IExtHostContext, MainThreadNotebookShape, NotebookExtensionDescription } from '../common/extHost.protocol'; // {{SQL CARBON EDIT}} Remove MainContext
@extHostNamedCustomer(MainContext.MainThreadNotebook)
// @extHostNamedCustomer(MainContext.MainThreadNotebook) {{SQL CARBON EDIT}} Disable VS Code notebooks
export class MainThreadNotebooks implements MainThreadNotebookShape {
private readonly _disposables = new DisposableStore();

View File

@@ -10,7 +10,7 @@ import { URI } from 'vs/base/common/uri';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { MainThreadNotebookDocuments } from 'vs/workbench/api/browser/mainThreadNotebookDocuments';
import { MainThreadNotebookEditors } from 'vs/workbench/api/browser/mainThreadNotebookEditors';
import { extHostCustomer } from 'vs/workbench/api/common/extHostCustomers';
// import { extHostCustomer } from 'vs/workbench/api/common/extHostCustomers'; {{SQL CARBON EDIT}} Disable VS Code notebooks
import { editorGroupToViewColumn } from 'vs/workbench/common/editor';
import { getNotebookEditorFromEditorPane, IActiveNotebookEditor, INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/notebookEditorService';
@@ -68,7 +68,7 @@ class NotebookAndEditorState {
}
}
@extHostCustomer
// @extHostCustomer {{SQL CARBON EDIT}} Disable VS Code notebooks
export class MainThreadNotebooksAndEditors {
private readonly _onDidAddNotebooks = new Emitter<NotebookTextModel[]>();

View File

@@ -9,12 +9,12 @@ import { combinedDisposable, DisposableStore, IDisposable } from 'vs/base/common
import { URI, UriComponents } from 'vs/base/common/uri';
import { IModeService } from 'vs/editor/common/services/modeService';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
// import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers'; {{SQL CARBON EDIT}} Disable VS Code notebooks
import { INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/notebookEditorService';
import { INotebookKernel, INotebookKernelChangeEvent } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { ExtHostContext, ExtHostNotebookKernelsShape, IExtHostContext, INotebookKernelDto2, MainContext, MainThreadNotebookKernelsShape } from '../common/extHost.protocol';
import { ExtHostContext, ExtHostNotebookKernelsShape, IExtHostContext, INotebookKernelDto2, MainThreadNotebookKernelsShape } from '../common/extHost.protocol';// {{SQL CARBON EDIT}} Remove MainContext
abstract class MainThreadKernel implements INotebookKernel {
@@ -88,7 +88,7 @@ abstract class MainThreadKernel implements INotebookKernel {
abstract cancelNotebookCellExecution(uri: URI, cellHandles: number[]): Promise<void>;
}
@extHostNamedCustomer(MainContext.MainThreadNotebookKernels)
// @extHostNamedCustomer(MainContext.MainThreadNotebookKernels) {{SQL CARBON EDIT}} Disable VS Code notebooks
export class MainThreadNotebookKernels implements MainThreadNotebookKernelsShape {
private readonly _editors = new Map<INotebookEditor, IDisposable>();

View File

@@ -4,11 +4,11 @@
*--------------------------------------------------------------------------------------------*/
import { Disposable } from 'vs/base/common/lifecycle';
import { ExtHostContext, ExtHostNotebookRenderersShape, IExtHostContext, MainContext, MainThreadNotebookRenderersShape } from 'vs/workbench/api/common/extHost.protocol';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { ExtHostContext, ExtHostNotebookRenderersShape, IExtHostContext, MainThreadNotebookRenderersShape } from 'vs/workbench/api/common/extHost.protocol'; // {{SQL CARBON EDIT}} Remove MainContext
// import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers'; {{SQL CARBON EDIT}}
import { INotebookRendererMessagingService } from 'vs/workbench/contrib/notebook/common/notebookRendererMessagingService';
@extHostNamedCustomer(MainContext.MainThreadNotebookRenderers)
// @extHostNamedCustomer(MainContext.MainThreadNotebookRenderers) {{SQL CARBON EDIT}}
export class MainThreadNotebookRenderers extends Disposable implements MainThreadNotebookRenderersShape {
private readonly proxy: ExtHostNotebookRenderersShape;

View File

@@ -58,19 +58,19 @@ import { getRemoteName } from 'vs/platform/remote/common/remoteHosts';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IExtHostDecorations } from 'vs/workbench/api/common/extHostDecorations';
import { IExtHostTask } from 'vs/workbench/api/common/extHostTask';
// import { IExtHostDebugService } from 'vs/workbench/api/common/extHostDebugService'; {{SQL CARBON EDIT}}
// import { IExtHostDebugService } from 'vs/workbench/api/common/extHostDebugService'; {{SQL CARBON EDIT}} remove debug service
import { IExtHostSearch } from 'vs/workbench/api/common/extHostSearch';
import { ILogService } from 'vs/platform/log/common/log';
import { IURITransformerService } from 'vs/workbench/api/common/extHostUriTransformerService';
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
import { ExtHostNotebookController } from 'vs/workbench/api/common/extHostNotebook';
// import { ExtHostNotebookController } from 'vs/workbench/api/common/extHostNotebook'; {{SQL CARBON EDIT}} Disable VS Code notebooks
import { ExtHostTheming } from 'vs/workbench/api/common/extHostTheming';
import { IExtHostTunnelService } from 'vs/workbench/api/common/extHostTunnelService';
import { IExtHostApiDeprecationService } from 'vs/workbench/api/common/extHostApiDeprecationService';
import { ExtHostAuthentication } from 'vs/workbench/api/common/extHostAuthentication';
import { ExtHostTimeline } from 'vs/workbench/api/common/extHostTimeline';
import { ExtHostNotebookConcatDocument } from 'vs/workbench/api/common/extHostNotebookConcatDocument';
// import { ExtHostNotebookConcatDocument } from 'vs/workbench/api/common/extHostNotebookConcatDocument'; {{SQL CARBON EDIT}} Disable VS Code notebooks
import { IExtensionStoragePaths } from 'vs/workbench/api/common/extHostStoragePaths';
import { IExtHostConsumerFileSystem } from 'vs/workbench/api/common/extHostFileSystemConsumer';
import { ExtHostWebviewViews } from 'vs/workbench/api/common/extHostWebviewView';
@@ -83,13 +83,15 @@ import { ExtHostUriOpeners } from 'vs/workbench/api/common/extHostUriOpener';
import { IExtHostSecretState } from 'vs/workbench/api/common/exHostSecretState';
import { IExtHostEditorTabs } from 'vs/workbench/api/common/extHostEditorTabs';
import { IExtHostTelemetry } from 'vs/workbench/api/common/extHostTelemetry';
import { ExtHostNotebookKernels } from 'vs/workbench/api/common/extHostNotebookKernels';
// import { ExtHostNotebookKernels } from 'vs/workbench/api/common/extHostNotebookKernels'; {{SQL CARBON EDIT}} Disable VS Code notebooks
import { TextSearchCompleteMessageType } from 'vs/workbench/services/search/common/searchExtTypes';
import { ExtHostNotebookRenderers } from 'vs/workbench/api/common/extHostNotebookRenderers';
// import { ExtHostNotebookRenderers } from 'vs/workbench/api/common/extHostNotebookRenderers'; {{SQL CARBON EDIT}} Disable VS Code notebooks
import { Schemas } from 'vs/base/common/network';
import { matchesScheme } from 'vs/platform/opener/common/opener';
import { ExtHostNotebookEditors } from 'vs/workbench/api/common/extHostNotebookEditors';
import { ExtHostNotebookDocuments } from 'vs/workbench/api/common/extHostNotebookDocuments';
// import { ExtHostNotebookEditors } from 'vs/workbench/api/common/extHostNotebookEditors'; {{SQL CARBON EDIT}} Disable VS Code notebooks
// import { ExtHostNotebookDocuments } from 'vs/workbench/api/common/extHostNotebookDocuments'; {{SQL CARBON EDIT}} Disable VS Code notebooks
import { ExtHostNotebook } from 'sql/workbench/api/common/extHostNotebook';
import { functionalityNotSupportedError } from 'sql/base/common/locConstants';
export interface IExtensionApiFactory {
(extension: IExtensionDescription, registry: ExtensionDescriptionRegistry, configProvider: ExtHostConfigProvider): typeof vscode;
@@ -98,7 +100,7 @@ export interface IExtensionApiFactory {
/**
* This method instantiates and returns the extension API surface
*/
export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): IExtensionApiFactory {
export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor, extHostNotebook: ExtHostNotebook): IExtensionApiFactory { // {{SQL CARBON EDIT}} Add ExtHostNotebook
// services
const initData = accessor.get(IExtHostInitDataService);
@@ -147,11 +149,13 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
const extHostDocuments = rpcProtocol.set(ExtHostContext.ExtHostDocuments, new ExtHostDocuments(rpcProtocol, extHostDocumentsAndEditors));
const extHostDocumentContentProviders = rpcProtocol.set(ExtHostContext.ExtHostDocumentContentProviders, new ExtHostDocumentContentProvider(rpcProtocol, extHostDocumentsAndEditors, extHostLogService));
const extHostDocumentSaveParticipant = rpcProtocol.set(ExtHostContext.ExtHostDocumentSaveParticipant, new ExtHostDocumentSaveParticipant(extHostLogService, extHostDocuments, rpcProtocol.getProxy(MainContext.MainThreadBulkEdits)));
/* {{SQL CARBON EDIT }} Disable VS Code notebooks
const extHostNotebook = rpcProtocol.set(ExtHostContext.ExtHostNotebook, new ExtHostNotebookController(rpcProtocol, extHostCommands, extHostDocumentsAndEditors, extHostDocuments, extensionStoragePaths));
const extHostNotebookDocuments = rpcProtocol.set(ExtHostContext.ExtHostNotebookDocuments, new ExtHostNotebookDocuments(extHostLogService, extHostNotebook));
const extHostNotebookEditors = rpcProtocol.set(ExtHostContext.ExtHostNotebookEditors, new ExtHostNotebookEditors(extHostLogService, rpcProtocol, extHostNotebook));
const extHostNotebookKernels = rpcProtocol.set(ExtHostContext.ExtHostNotebookKernels, new ExtHostNotebookKernels(rpcProtocol, initData, extHostNotebook, extHostLogService));
const extHostNotebookRenderers = rpcProtocol.set(ExtHostContext.ExtHostNotebookRenderers, new ExtHostNotebookRenderers(rpcProtocol, extHostNotebook));
*/
const extHostEditors = rpcProtocol.set(ExtHostContext.ExtHostEditors, new ExtHostEditors(rpcProtocol, extHostDocumentsAndEditors));
const extHostTreeViews = rpcProtocol.set(ExtHostContext.ExtHostTreeViews, new ExtHostTreeViews(rpcProtocol.getProxy(MainContext.MainThreadTreeViews), extHostCommands, extHostLogService));
const extHostEditorInsets = rpcProtocol.set(ExtHostContext.ExtHostEditorInsets, new ExtHostEditorInsets(rpcProtocol.getProxy(MainContext.MainThreadEditorInsets), extHostEditors, initData));
@@ -176,8 +180,15 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
// Check that no named customers are missing
// {{SQL CARBON EDIT}} filter out the services we don't expose
const filtered: ProxyIdentifier<any>[] = [ExtHostContext.ExtHostDebugService];
const expected: ProxyIdentifier<any>[] = values(ExtHostContext).filter(v => !filtered.find(x => x === v));
const filteredProxies: Set<ProxyIdentifier<any>> = new Set([
ExtHostContext.ExtHostDebugService,
ExtHostContext.ExtHostNotebook,
ExtHostContext.ExtHostNotebookDocuments,
ExtHostContext.ExtHostNotebookEditors,
ExtHostContext.ExtHostNotebookKernels,
ExtHostContext.ExtHostNotebookRenderers
]);
const expected: ProxyIdentifier<any>[] = values(ExtHostContext).filter(v => !filteredProxies.has(v));
rpcProtocol.assertRegistered(expected);
@@ -718,32 +729,46 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return extHostWebviewViews.registerWebviewViewProvider(extension, viewId, provider, options?.webviewOptions);
},
get activeNotebookEditor(): vscode.NotebookEditor | undefined {
checkProposedApiEnabled(extension);
return extHostNotebook.activeNotebookEditor;
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return extHostNotebook.activeNotebookEditor;
},
onDidChangeActiveNotebookEditor(listener, thisArgs?, disposables?) {
checkProposedApiEnabled(extension);
return extHostNotebook.onDidChangeActiveNotebookEditor(listener, thisArgs, disposables);
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return extHostNotebook.onDidChangeActiveNotebookEditor(listener, thisArgs, disposables);
},
get visibleNotebookEditors() {
checkProposedApiEnabled(extension);
return extHostNotebook.visibleNotebookEditors;
// {{SQL CARBON EDIT}} Disable VS Code notebooks
return undefined;
// checkProposedApiEnabled(extension);
// return extHostNotebook.visibleNotebookEditors;
},
get onDidChangeVisibleNotebookEditors() {
checkProposedApiEnabled(extension);
return extHostNotebook.onDidChangeVisibleNotebookEditors;
// {{SQL CARBON EDIT}} Disable VS Code notebooks
return undefined;
// checkProposedApiEnabled(extension);
// return extHostNotebook.onDidChangeVisibleNotebookEditors;
},
onDidChangeNotebookEditorSelection(listener, thisArgs?, disposables?) {
checkProposedApiEnabled(extension);
return extHostNotebookEditors.onDidChangeNotebookEditorSelection(listener, thisArgs, disposables);
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return extHostNotebookEditors.onDidChangeNotebookEditorSelection(listener, thisArgs, disposables);
},
onDidChangeNotebookEditorVisibleRanges(listener, thisArgs?, disposables?) {
checkProposedApiEnabled(extension);
return extHostNotebookEditors.onDidChangeNotebookEditorVisibleRanges(listener, thisArgs, disposables);
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return extHostNotebookEditors.onDidChangeNotebookEditorVisibleRanges(listener, thisArgs, disposables);
},
showNotebookDocument(uriOrDocument, options?) {
checkProposedApiEnabled(extension);
return extHostNotebook.showNotebookDocument(uriOrDocument, options);
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return extHostNotebook.showNotebookDocument(uriOrDocument, options);
},
registerExternalUriOpener(id: string, opener: vscode.ExternalUriOpener, metadata: vscode.ExternalUriOpenerMetadata) {
checkProposedApiEnabled(extension);
@@ -872,32 +897,42 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return extHostDocumentSaveParticipant.getOnWillSaveTextDocumentEvent(extension)(listener, thisArgs, disposables);
},
get notebookDocuments(): vscode.NotebookDocument[] {
return extHostNotebook.notebookDocuments.map(d => d.apiNotebook);
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// return extHostNotebook.notebookDocuments.map(d => d.apiNotebook);
},
async openNotebookDocument(uriOrType?: URI | string, content?: vscode.NotebookData) {
let uri: URI;
if (URI.isUri(uriOrType)) {
uri = uriOrType;
await extHostNotebook.openNotebookDocument(uriOrType);
} else if (typeof uriOrType === 'string') {
uri = URI.revive(await extHostNotebook.createNotebookDocument({ viewType: uriOrType, content }));
} else {
throw new Error('Invalid arguments');
}
return extHostNotebook.getNotebookDocument(uri).apiNotebook;
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// let uri: URI;
// if (URI.isUri(uriOrType)) {
// uri = uriOrType;
// await extHostNotebook.openNotebookDocument(uriOrType);
// } else if (typeof uriOrType === 'string') {
// uri = URI.revive(await extHostNotebook.createNotebookDocument({ viewType: uriOrType, content }));
// } else {
// throw new Error('Invalid arguments');
// }
// return extHostNotebook.getNotebookDocument(uri).apiNotebook;
},
get onDidOpenNotebookDocument(): Event<vscode.NotebookDocument> {
return extHostNotebook.onDidOpenNotebookDocument;
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// return extHostNotebook.onDidOpenNotebookDocument;
},
get onDidCloseNotebookDocument(): Event<vscode.NotebookDocument> {
return extHostNotebook.onDidCloseNotebookDocument;
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// return extHostNotebook.onDidCloseNotebookDocument;
},
registerNotebookSerializer(viewType: string, serializer: vscode.NotebookSerializer, options?: vscode.NotebookDocumentContentOptions, registration?: vscode.NotebookRegistrationData) {
return extHostNotebook.registerNotebookSerializer(extension, viewType, serializer, options, extension.enableProposedApi ? registration : undefined);
return extHostNotebook.registerNotebookSerializer(viewType, serializer, options, extension.enableProposedApi ? registration : undefined);
},
registerNotebookContentProvider: (viewType: string, provider: vscode.NotebookContentProvider, options?: vscode.NotebookDocumentContentOptions, registration?: vscode.NotebookRegistrationData) => {
checkProposedApiEnabled(extension);
return extHostNotebook.registerNotebookContentProvider(extension, viewType, provider, options, extension.enableProposedApi ? registration : undefined);
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return extHostNotebook.registerNotebookContentProvider(extension, viewType, provider, options, extension.enableProposedApi ? registration : undefined);
},
onDidChangeConfiguration: (listener: (_: any) => any, thisArgs?: any, disposables?: extHostTypes.Disposable[]) => {
return configProvider.onDidChangeConfiguration(listener, thisArgs, disposables);
@@ -1110,46 +1145,66 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
// namespace: notebook
const notebooks: typeof vscode.notebooks = {
createNotebookController(id: string, notebookType: string, label: string, handler?, rendererScripts?: vscode.NotebookRendererScript[]) {
return extHostNotebookKernels.createNotebookController(extension, id, notebookType, label, handler, extension.enableProposedApi ? rendererScripts : undefined);
return extHostNotebook.createNotebookController(extension, id, notebookType, label, handler, extension.enableProposedApi ? rendererScripts : undefined);
},
registerNotebookCellStatusBarItemProvider: (notebookType: string, provider: vscode.NotebookCellStatusBarItemProvider) => {
return extHostNotebook.registerNotebookCellStatusBarItemProvider(extension, notebookType, provider);
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// return extHostNotebook.registerNotebookCellStatusBarItemProvider(extension, notebookType, provider);
},
get onDidSaveNotebookDocument(): Event<vscode.NotebookDocument> {
checkProposedApiEnabled(extension);
return extHostNotebookDocuments.onDidSaveNotebookDocument;
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return extHostNotebookDocuments.onDidSaveNotebookDocument;
},
createNotebookEditorDecorationType(options: vscode.NotebookDecorationRenderOptions): vscode.NotebookEditorDecorationType {
checkProposedApiEnabled(extension);
return extHostNotebookEditors.createNotebookEditorDecorationType(options);
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return extHostNotebookEditors.createNotebookEditorDecorationType(options);
},
createRendererMessaging(rendererId) {
checkProposedApiEnabled(extension);
return extHostNotebookRenderers.createRendererMessaging(rendererId);
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return extHostNotebookRenderers.createRendererMessaging(rendererId);
},
onDidChangeNotebookDocumentMetadata(listener, thisArgs?, disposables?) {
checkProposedApiEnabled(extension);
return extHostNotebookDocuments.onDidChangeNotebookDocumentMetadata(listener, thisArgs, disposables);
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return extHostNotebookDocuments.onDidChangeNotebookDocumentMetadata(listener, thisArgs, disposables);
},
onDidChangeNotebookCells(listener, thisArgs?, disposables?) {
checkProposedApiEnabled(extension);
return extHostNotebook.onDidChangeNotebookCells(listener, thisArgs, disposables);
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return extHostNotebook.onDidChangeNotebookCells(listener, thisArgs, disposables);
},
onDidChangeNotebookCellExecutionState(listener, thisArgs?, disposables?) {
checkProposedApiEnabled(extension);
return extHostNotebook.onDidChangeNotebookCellExecutionState(listener, thisArgs, disposables);
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return extHostNotebook.onDidChangeNotebookCellExecutionState(listener, thisArgs, disposables);
},
onDidChangeCellOutputs(listener, thisArgs?, disposables?) {
checkProposedApiEnabled(extension);
return extHostNotebook.onDidChangeCellOutputs(listener, thisArgs, disposables);
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return extHostNotebook.onDidChangeCellOutputs(listener, thisArgs, disposables);
},
onDidChangeCellMetadata(listener, thisArgs?, disposables?) {
checkProposedApiEnabled(extension);
return extHostNotebook.onDidChangeCellMetadata(listener, thisArgs, disposables);
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return extHostNotebook.onDidChangeCellMetadata(listener, thisArgs, disposables);
},
createConcatTextDocument(notebook, selector) {
checkProposedApiEnabled(extension);
return new ExtHostNotebookConcatDocument(extHostNotebook, extHostDocuments, notebook, selector);
// {{SQL CARBON EDIT}} Disable VS Code notebooks
throw new Error(functionalityNotSupportedError);
// checkProposedApiEnabled(extension);
// return new ExtHostNotebookConcatDocument(extHostNotebook, extHostDocuments, notebook, selector);
},
};

View File

@@ -7,6 +7,8 @@ import { IJSONSchema } from 'vs/base/common/jsonSchema';
import * as nls from 'vs/nls';
import { ExtensionsRegistry } from 'vs/workbench/services/extensions/common/extensionsRegistry';
import { NotebookEditorPriority, NotebookRendererEntrypoint, RendererMessagingSpec } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { Registry } from 'vs/platform/registry/common/platform'; // {{SQL CARBON EDIT}} Register notebooks in SQL code instead
import { INotebookProviderRegistry, NotebookProviderRegistryId, ProviderDescriptionRegistration } from 'sql/workbench/services/notebook/common/notebookRegistry'; // {{SQL CARBON EDIT}} Register notebooks in SQL code instead
namespace NotebookEditorContribution {
export const type = 'type';
@@ -185,6 +187,31 @@ export const notebooksExtensionPoint = ExtensionsRegistry.registerExtensionPoint
jsonSchema: notebookProviderContribution
});
// {{SQL CARBON EDIT}} Convert VSCode notebook registrations into ADS equivalents
const adsNotebookRegistry = Registry.as<INotebookProviderRegistry>(NotebookProviderRegistryId);
notebooksExtensionPoint.setHandler(extensions => {
for (let extension of extensions) {
for (const notebookContribution of extension.value) {
// Remove any leading regex characters from the filename pattern
let extensions = notebookContribution.selector?.filter(ext => ext?.filenamePattern?.length > 0)
.map(s => {
let lastDotPosition = s.filenamePattern?.lastIndexOf('.');
if (lastDotPosition >= 0) {
return s.filenamePattern.slice(lastDotPosition);
}
return s.filenamePattern;
});
let adsProvider: ProviderDescriptionRegistration = {
provider: notebookContribution.type,
fileExtensions: extensions ?? [],
standardKernels: [] // Kernels get added later when a NotebookController is created for this provider
};
adsNotebookRegistry.registerProviderDescription(adsProvider);
}
}
});
export const notebookRendererExtensionPoint = ExtensionsRegistry.registerExtensionPoint<INotebookRendererContribution[]>(
{
extensionPoint: 'notebookRenderer',

View File

@@ -15,7 +15,7 @@ import { URI } from 'vs/base/common/uri';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { BareFontInfo } from 'vs/editor/common/config/fontInfo';
import { localize } from 'vs/nls';
// import { localize } from 'vs/nls'; {{SQL CARBON EDIT}} Notebook registration handled in SQL code
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IResourceEditorInput } from 'vs/platform/editor/common/editor';
@@ -27,12 +27,12 @@ import { NotebookExtensionDescription } from 'vs/workbench/api/common/extHost.pr
import { IEditorInput } from 'vs/workbench/common/editor';
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
import { Memento } from 'vs/workbench/common/memento';
import { INotebookEditorContribution, notebooksExtensionPoint, notebookRendererExtensionPoint } from 'vs/workbench/contrib/notebook/browser/extensionPoint';
import { notebookRendererExtensionPoint } from 'vs/workbench/contrib/notebook/browser/extensionPoint'; // {{SQL CARBON EDIT}} Remove INotebookEditorContribution, notebooksExtensionPoint
import { INotebookEditorOptions } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { NotebookDiffEditorInput } from 'vs/workbench/contrib/notebook/browser/notebookDiffEditorInput';
import { NotebookCellTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookCellTextModel';
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
import { ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER, BUILTIN_RENDERER_ID, CellUri, DisplayOrderKey, INotebookExclusiveDocumentFilter, INotebookContributionData, INotebookRendererInfo, INotebookTextModel, IOrderedMimeType, IOutputDto, mimeTypeIsAlwaysSecure, mimeTypeSupportedByCore, NotebookDataDto, NotebookEditorPriority, NotebookRendererMatch, NotebookTextDiffEditorPreview, RENDERER_NOT_AVAILABLE, sortMimeTypes, TransientOptions } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER, BUILTIN_RENDERER_ID, CellUri, DisplayOrderKey, INotebookExclusiveDocumentFilter, INotebookContributionData, INotebookRendererInfo, INotebookTextModel, IOrderedMimeType, IOutputDto, mimeTypeIsAlwaysSecure, mimeTypeSupportedByCore, NotebookDataDto, NotebookRendererMatch, NotebookTextDiffEditorPreview, RENDERER_NOT_AVAILABLE, sortMimeTypes, TransientOptions } from 'vs/workbench/contrib/notebook/common/notebookCommon'; // {{SQL CARBON EDIT}} Remove NotebookEditorPriority
import { NotebookEditorInput } from 'vs/workbench/contrib/notebook/common/notebookEditorInput';
import { updateEditorTopPadding } from 'vs/workbench/contrib/notebook/common/notebookOptions';
import { NotebookOutputRendererInfo } from 'vs/workbench/contrib/notebook/common/notebookOutputRenderer';
@@ -40,7 +40,7 @@ import { NotebookEditorDescriptor, NotebookProviderInfo } from 'vs/workbench/con
import { ComplexNotebookProviderInfo, INotebookContentProvider, INotebookSerializer, INotebookService, SimpleNotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/notebookService';
import { ContributedEditorPriority, DiffEditorInputFactoryFunction, EditorInputFactoryFunction, IEditorOverrideService, IEditorType } from 'vs/workbench/services/editor/common/editorOverrideService';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry';
// import { IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry'; {{SQL CARBON EDIT}} Notebook registration handled in SQL code
export class NotebookProviderInfoStore extends Disposable {
@@ -80,7 +80,7 @@ export class NotebookProviderInfoStore extends Disposable {
}
}));
notebooksExtensionPoint.setHandler(extensions => this._setupHandler(extensions));
// notebooksExtensionPoint.setHandler(extensions => this._setupHandler(extensions)); {{SQL CARBON EDIT}} Notebook registration handled in SQL code
}
override dispose(): void {
@@ -88,52 +88,53 @@ export class NotebookProviderInfoStore extends Disposable {
super.dispose();
}
private _setupHandler(extensions: readonly IExtensionPointUser<INotebookEditorContribution[]>[]) {
this._handled = true;
this._clear();
// {{SQL CARBON EDIT}} Notebook registration handled in SQL code
// private _setupHandler(extensions: readonly IExtensionPointUser<INotebookEditorContribution[]>[]) {
// this._handled = true;
// this._clear();
for (const extension of extensions) {
for (const notebookContribution of extension.value) {
// for (const extension of extensions) {
// for (const notebookContribution of extension.value) {
if (!notebookContribution.type) {
extension.collector.error(`Notebook does not specify type-property`);
continue;
}
// if (!notebookContribution.type) {
// extension.collector.error(`Notebook does not specify type-property`);
// continue;
// }
if (this.get(notebookContribution.type)) {
extension.collector.error(`Notebook type '${notebookContribution.type}' already used`);
continue;
}
// if (this.get(notebookContribution.type)) {
// extension.collector.error(`Notebook type '${notebookContribution.type}' already used`);
// continue;
// }
this.add(new NotebookProviderInfo({
extension: extension.description.identifier,
id: notebookContribution.type,
displayName: notebookContribution.displayName,
selectors: notebookContribution.selector || [],
priority: this._convertPriority(notebookContribution.priority),
providerDisplayName: extension.description.isBuiltin ? localize('builtinProviderDisplayName', "Built-in") : extension.description.displayName || extension.description.identifier.value,
exclusive: false
}));
}
}
// this.add(new NotebookProviderInfo({
// extension: extension.description.identifier,
// id: notebookContribution.type,
// displayName: notebookContribution.displayName,
// selectors: notebookContribution.selector || [],
// priority: this._convertPriority(notebookContribution.priority),
// providerDisplayName: extension.description.isBuiltin ? localize('builtinProviderDisplayName', "Built-in") : extension.description.displayName || extension.description.identifier.value,
// exclusive: false
// }));
// }
// }
const mementoObject = this._memento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
mementoObject[NotebookProviderInfoStore.CUSTOM_EDITORS_ENTRY_ID] = Array.from(this._contributedEditors.values());
this._memento.saveMemento();
}
// const mementoObject = this._memento.getMemento(StorageScope.GLOBAL, StorageTarget.MACHINE);
// mementoObject[NotebookProviderInfoStore.CUSTOM_EDITORS_ENTRY_ID] = Array.from(this._contributedEditors.values());
// this._memento.saveMemento();
// }
private _convertPriority(priority?: string) {
if (!priority) {
return ContributedEditorPriority.default;
}
// private _convertPriority(priority?: string) {
// if (!priority) {
// return ContributedEditorPriority.default;
// }
if (priority === NotebookEditorPriority.default) {
return ContributedEditorPriority.default;
}
// if (priority === NotebookEditorPriority.default) {
// return ContributedEditorPriority.default;
// }
return ContributedEditorPriority.option;
// return ContributedEditorPriority.option;
}
// }
private _registerContributionPoint(notebookProviderInfo: NotebookProviderInfo): IDisposable {

View File

@@ -213,7 +213,14 @@ export class ExtensionHostManager extends Disposable {
// Check that no named customers are missing
// {{SQL CARBON EDIT}} filter out services we don't expose
const filtered: ProxyIdentifier<any>[] = [MainContext.MainThreadDebugService];
const filtered: ProxyIdentifier<any>[] = [
MainContext.MainThreadDebugService,
MainContext.MainThreadNotebook,
MainContext.MainThreadNotebookDocuments,
MainContext.MainThreadNotebookEditors,
MainContext.MainThreadNotebookKernels,
MainContext.MainThreadNotebookRenderers
];
const expected: ProxyIdentifier<any>[] = Object.keys(MainContext).map((key) => (<any>MainContext)[key]).filter(v => !filtered.some(x => x === v));
this._rpcProtocol.assertRegistered(expected);