rename viewType to notebookType, https://github.com/microsoft/vscode/issues/122922

上级 220f89ba
......@@ -11371,11 +11371,14 @@ declare module 'vscode' {
*/
readonly uri: Uri;
/** @deprecated */
// todo@API remove
readonly viewType: string;
/**
* The type of notebook.
*/
// todo@API should this be called `notebookType` or `notebookKind`
readonly viewType: string;
readonly notebookType: string;
/**
* The version number of this notebook (it will strictly increase after each
......@@ -11872,15 +11875,14 @@ declare module 'vscode' {
* A notebook controller represents an entity that can execute notebook cells. This is often referred to as a kernel.
*
* There can be multiple controllers and the editor will let users choose which controller to use for a certain notebook. The
* {@link NotebookController.viewType `viewType`}-property defines for what kind of notebooks a controller is for and
* {@link NotebookController.notebookType `notebookType`}-property defines for what kind of notebooks a controller is for and
* the {@link NotebookController.updateNotebookAffinity `updateNotebookAffinity`}-function allows controllers to set a preference
* for specific notebooks.
* for specific notebook documents.
*
* When a cell is being run the editor will invoke the {@link NotebookController.executeHandler `executeHandler`} and a controller
* is expected to create and finalize a {@link NotebookCellExecution notebook cell execution}. However, controllers are also free
* to create executions by themselves.
*/
// todo@api adopt notebookType-rename in comment
export interface NotebookController {
/**
......@@ -11891,11 +11893,14 @@ declare module 'vscode' {
*/
readonly id: string;
// todo@api remove
/** @deprecated */
readonly viewType: string;
/**
* The notebook view type this controller is for.
* The notebook type this controller is for.
*/
// todo@api rename to notebookType
readonly viewType: string;
readonly notebookType: string;
/**
* An array of language identifiers that are supported by this
......@@ -12217,11 +12222,11 @@ declare module 'vscode' {
* path when the document is to be saved.
*
* @see {@link openNotebookDocument}
* @param viewType The notebook view type that should be used.
* @param notebookType The notebook type that should be used.
* @param content The initial contents of the notebook.
* @returns A promise that resolves to a {@link NotebookDocument notebook}.
*/
export function openNotebookDocument(viewType: string, content?: NotebookData): Thenable<NotebookDocument>;
export function openNotebookDocument(notebookType: string, content?: NotebookData): Thenable<NotebookDocument>;
/**
* An event that is emitted when a {@link NotebookDocument notebook} is opened.
......@@ -12255,17 +12260,16 @@ declare module 'vscode' {
* Creates a new notebook controller.
*
* @param id Identifier of the controller. Must be unique per extension.
* @param viewType A notebook view type for which this controller is for.
* @param notebookType A notebook type for which this controller is for.
* @param label The label of the controller.
* @param handler The execute-handler of the controller.
*/
//todo@API adopt viewType -> notebookType rename
export function createNotebookController(id: string, viewType: string, label: string, handler?: NotebookExecuteHandler): NotebookController;
export function createNotebookController(id: string, notebookType: string, label: string, handler?: NotebookExecuteHandler): NotebookController;
/**
* Register a {@link NotebookCellStatusBarItemProvider cell statusbar item provider} for the given notebook type.
*
* @param notebookType The notebook view type to register for.
* @param notebookType The notebook type to register for.
* @param provider A cell status bar provider.
* @return A {@link Disposable} that unregisters this provider when being disposed.
*/
......
......@@ -44,7 +44,7 @@ abstract class MainThreadKernel implements INotebookKernel {
constructor(data: INotebookKernelDto2, private _modeService: IModeService) {
this.id = data.id;
this.viewType = data.viewType;
this.viewType = data.notebookType;
this.extension = data.extensionId;
this.implementsInterrupt = data.supportsInterrupt ?? false;
......
......@@ -1079,8 +1079,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
registerNotebookSerializer(viewType: string, serializer: vscode.NotebookSerializer, options?: vscode.NotebookDocumentContentOptions, registration?: vscode.NotebookRegistrationData) {
return extHostNotebook.registerNotebookSerializer(extension, viewType, serializer, options, extension.enableProposedApi ? registration : undefined);
},
createNotebookController(id: string, viewType: string, label: string, handler?: vscode.NotebookExecuteHandler, rendererScripts?: vscode.NotebookRendererScript[]) {
return extHostNotebookKernels.createNotebookController(extension, id, viewType, label, handler, extension.enableProposedApi ? rendererScripts : undefined);
createNotebookController(id: string, notebookType: string, label: string, handler?: vscode.NotebookExecuteHandler, rendererScripts?: vscode.NotebookRendererScript[]) {
return extHostNotebookKernels.createNotebookController(extension, id, notebookType, label, handler, extension.enableProposedApi ? rendererScripts : undefined);
},
registerNotebookCellStatusBarItemProvider: (notebookType: string, provider: vscode.NotebookCellStatusBarItemProvider) => {
return extHostNotebook.registerNotebookCellStatusBarItemProvider(extension, notebookType, provider);
......
......@@ -907,7 +907,7 @@ export interface MainThreadNotebookDocumentsShape extends IDisposable {
export interface INotebookKernelDto2 {
id: string;
viewType: string;
notebookType: string;
extensionId: ExtensionIdentifier;
extensionLocation: UriComponents;
label: string;
......
......@@ -144,7 +144,7 @@ export class ExtHostNotebookDocument {
private readonly _textDocumentsAndEditors: ExtHostDocumentsAndEditors,
private readonly _textDocuments: ExtHostDocuments,
private readonly _emitter: INotebookEventEmitter,
private readonly _viewType: string,
private readonly _notebookType: string,
private _metadata: extHostTypes.NotebookDocumentMetadata,
readonly uri: URI,
) { }
......@@ -159,7 +159,8 @@ export class ExtHostNotebookDocument {
this._notebook = {
get uri() { return that.uri; },
get version() { return that._versionId; },
get viewType() { return that._viewType; },
get viewType() { return that._notebookType; },
get notebookType() { return that._notebookType; },
get isDirty() { return that._isDirty; },
get isUntitled() { return that.uri.scheme === Schemas.untitled; },
get isClosed() { return that._disposed; },
......
......@@ -72,7 +72,7 @@ export class ExtHostNotebookKernels implements ExtHostNotebookKernelsShape {
const data: INotebookKernelDto2 = {
id: `${extension.identifier.value}/${id}`,
viewType,
notebookType: viewType,
extensionId: extension.identifier,
extensionLocation: extension.extensionLocation,
label: label || extension.identifier.value,
......@@ -111,7 +111,8 @@ export class ExtHostNotebookKernels implements ExtHostNotebookKernelsShape {
const controller: vscode.NotebookController = {
get id() { return id; },
get viewType() { return data.viewType; },
get viewType() { return data.notebookType; },
get notebookType() { return data.notebookType; },
onDidChangeNotebookAssociation: onDidChangeSelection.event,
get label() {
return data.label;
......
......@@ -9,6 +9,8 @@ import { ExtensionsRegistry } from 'vs/workbench/services/extensions/common/exte
import { NotebookEditorPriority, NotebookRendererEntrypoint } from 'vs/workbench/contrib/notebook/common/notebookCommon';
namespace NotebookEditorContribution {
export const type = 'type';
/** @deprecated use type */
export const viewType = 'viewType';
export const displayName = 'displayName';
export const selector = 'selector';
......@@ -16,6 +18,8 @@ namespace NotebookEditorContribution {
}
export interface INotebookEditorContribution {
readonly [NotebookEditorContribution.type]: string;
/** @deprecated use type */
readonly [NotebookEditorContribution.viewType]: string;
readonly [NotebookEditorContribution.displayName]: string;
readonly [NotebookEditorContribution.selector]?: readonly { filenamePattern?: string; excludeFileNamePattern?: string; }[];
......@@ -23,6 +27,7 @@ export interface INotebookEditorContribution {
}
namespace NotebookRendererContribution {
/** @deprecated use type */
export const viewType = 'viewType';
export const id = 'id';
export const displayName = 'displayName';
......@@ -35,6 +40,7 @@ namespace NotebookRendererContribution {
export interface INotebookRendererContribution {
readonly [NotebookRendererContribution.id]?: string;
/** @deprecated use type */
readonly [NotebookRendererContribution.viewType]?: string;
readonly [NotebookRendererContribution.displayName]: string;
readonly [NotebookRendererContribution.mimeTypes]?: readonly string[];
......@@ -47,17 +53,22 @@ export interface INotebookRendererContribution {
const notebookProviderContribution: IJSONSchema = {
description: nls.localize('contributes.notebook.provider', 'Contributes notebook document provider.'),
type: 'array',
defaultSnippets: [{ body: [{ viewType: '', displayName: '', 'selector': [{ 'filenamePattern': '' }] }] }],
defaultSnippets: [{ body: [{ type: '', displayName: '', 'selector': [{ 'filenamePattern': '' }] }] }],
items: {
type: 'object',
required: [
NotebookEditorContribution.viewType,
NotebookEditorContribution.type,
NotebookEditorContribution.displayName,
NotebookEditorContribution.selector,
],
properties: {
[NotebookEditorContribution.type]: {
type: 'string',
description: nls.localize('contributes.notebook.provider.viewType', 'Unique identifier of the notebook.'),
},
[NotebookEditorContribution.viewType]: {
type: 'string',
deprecationMessage: nls.localize('contributes.notebook.provider.viewType.deprecated', 'Rename `viewType` to `id`.'),
description: nls.localize('contributes.notebook.provider.viewType', 'Unique identifier of the notebook.'),
},
[NotebookEditorContribution.displayName]: {
......
......@@ -96,7 +96,7 @@ export class NotebookProviderInfoStore extends Disposable {
for (const notebookContribution of extension.value) {
this.add(new NotebookProviderInfo({
extension: extension.description.identifier,
id: notebookContribution.viewType,
id: notebookContribution.type || notebookContribution.viewType,
displayName: notebookContribution.displayName,
selectors: notebookContribution.selector || [],
priority: this._convertPriority(notebookContribution.priority),
......
......@@ -138,7 +138,7 @@ suite('NotebookKernel', function () {
assert.strictEqual(first.id, 'nullExtensionDescription/foo');
assert.strictEqual(ExtensionIdentifier.equals(first.extensionId, nullExtensionDescription.identifier), true);
assert.strictEqual(first.label, 'Foo');
assert.strictEqual(first.viewType, '*');
assert.strictEqual(first.notebookType, '*');
kernel.dispose();
await rpcProtocol.sync();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册