From 5fb48ff7577e1d9505fb71f89aaffa30eb3cf55a Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 11 May 2022 09:53:39 -0700 Subject: [PATCH 1/2] Remove the textDocumentNotebook API proposal All consumers have now been migrated off of this proposal, so it is safe to remove from our code --- extensions/vscode-api-tests/package.json | 1 - .../workbench/api/common/extHost.api.impl.ts | 3 ++- .../api/common/extHostDocumentData.ts | 3 +-- .../api/test/browser/extHostNotebook.test.ts | 8 ------ .../common/extensionsApiProposals.ts | 1 - .../vscode.proposed.textDocumentNotebook.d.ts | 26 ------------------- 6 files changed, 3 insertions(+), 39 deletions(-) delete mode 100644 src/vscode-dts/vscode.proposed.textDocumentNotebook.d.ts diff --git a/extensions/vscode-api-tests/package.json b/extensions/vscode-api-tests/package.json index db39a05c74016..0f7f928dc81b3 100644 --- a/extensions/vscode-api-tests/package.json +++ b/extensions/vscode-api-tests/package.json @@ -42,7 +42,6 @@ "terminalNameChangeEvent", "testCoverage", "testObserver", - "textDocumentNotebook", "textSearchProvider", "timeline", "tokenInformation", diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index bba2d04f64eaf..d7da9d1ee99a8 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -453,7 +453,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I return extHostLanguages.changeLanguage(document.uri, languageId); }, match(selector: vscode.DocumentSelector, document: vscode.TextDocument): number { - return score(typeConverters.LanguageSelector.from(selector), document.uri, document.languageId, true, document.notebook?.notebookType); + const notebookType = extHostDocuments.getDocumentData(document.uri)?.notebook?.notebookType; + return score(typeConverters.LanguageSelector.from(selector), document.uri, document.languageId, true, notebookType); }, registerCodeActionsProvider(selector: vscode.DocumentSelector, provider: vscode.CodeActionProvider, metadata?: vscode.CodeActionProviderMetadata): vscode.Disposable { return extHostLanguageFeatures.registerCodeActionProvider(extension, checkSelector(selector), provider, metadata); diff --git a/src/vs/workbench/api/common/extHostDocumentData.ts b/src/vs/workbench/api/common/extHostDocumentData.ts index 92fd321b1220b..bf20cb30665a5 100644 --- a/src/vs/workbench/api/common/extHostDocumentData.ts +++ b/src/vs/workbench/api/common/extHostDocumentData.ts @@ -37,7 +37,7 @@ export class ExtHostDocumentData extends MirrorTextModel { uri: URI, lines: string[], eol: string, versionId: number, private _languageId: string, private _isDirty: boolean, - private readonly _notebook?: vscode.NotebookDocument | undefined + public readonly notebook?: vscode.NotebookDocument | undefined ) { super(uri, lines, eol, versionId); } @@ -66,7 +66,6 @@ export class ExtHostDocumentData extends MirrorTextModel { get version() { return that._versionId; }, get isClosed() { return that._isDisposed; }, get isDirty() { return that._isDirty; }, - get notebook() { return that._notebook; }, save() { return that._save(); }, getText(range?) { return range ? that._getTextInRange(range) : that.getText(); }, get eol() { return that._eol === '\n' ? EndOfLine.LF : EndOfLine.CRLF; }, diff --git a/src/vs/workbench/api/test/browser/extHostNotebook.test.ts b/src/vs/workbench/api/test/browser/extHostNotebook.test.ts index e4f6d0f2a1331..8eaf147fcfe88 100644 --- a/src/vs/workbench/api/test/browser/extHostNotebook.test.ts +++ b/src/vs/workbench/api/test/browser/extHostNotebook.test.ts @@ -115,13 +115,11 @@ suite('NotebookCell#Document', function () { assert.ok(d1); assert.strictEqual(d1.languageId, c1.document.languageId); assert.strictEqual(d1.version, 1); - assert.ok(d1.notebook === notebook.apiNotebook); const d2 = extHostDocuments.getDocument(c2.document.uri); assert.ok(d2); assert.strictEqual(d2.languageId, c2.document.languageId); assert.strictEqual(d2.version, 1); - assert.ok(d2.notebook === notebook.apiNotebook); }); test('cell document goes when notebook closes', async function () { @@ -264,12 +262,6 @@ suite('NotebookCell#Document', function () { assert.throws(() => extHostDocuments.getDocument(cell1.document.uri)); }); - test('cell document knows notebook', function () { - for (let cells of notebook.apiNotebook.getCells()) { - assert.strictEqual(cells.document.notebook === notebook.apiNotebook, true); - } - }); - test('cell#index', function () { assert.strictEqual(notebook.apiNotebook.cellCount, 2); diff --git a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts index 4b51252484a14..310cf6d7745ba 100644 --- a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts +++ b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts @@ -55,7 +55,6 @@ export const allApiProposals = Object.freeze({ terminalNameChangeEvent: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalNameChangeEvent.d.ts', testCoverage: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testCoverage.d.ts', testObserver: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testObserver.d.ts', - textDocumentNotebook: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textDocumentNotebook.d.ts', textEditorDrop: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textEditorDrop.d.ts', textSearchProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textSearchProvider.d.ts', timeline: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.timeline.d.ts', diff --git a/src/vscode-dts/vscode.proposed.textDocumentNotebook.d.ts b/src/vscode-dts/vscode.proposed.textDocumentNotebook.d.ts deleted file mode 100644 index 1a9e0769a0ce8..0000000000000 --- a/src/vscode-dts/vscode.proposed.textDocumentNotebook.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -declare module 'vscode' { - - // https://github.com/microsoft/vscode/issues/102091 - - export interface TextDocument { - - /** - * @deprecated - * - * This proposal won't be finalized like this, see https://github.com/microsoft/vscode/issues/102091#issuecomment-865050645. - * Already today you can use - * - * ```ts - * vscode.workspace.notebookDocuments.find(notebook => notebook.getCells().some(cell => cell.document === myTextDocument)) - * ``` - * - * - */ - notebook: NotebookDocument | undefined; - } -} From 905ae5fe0e60c701bf9fbaebe5d829d151fe8e49 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 11 May 2022 15:42:09 -0700 Subject: [PATCH 2/2] Remove deprecated api usage from test --- .../src/singlefolder-tests/notebook.document.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.document.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.document.test.ts index 951ac132c5c6e..a35824f058bdd 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.document.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.document.test.ts @@ -128,7 +128,6 @@ suite.skip('Notebook Document', function () { const doc = vscode.workspace.textDocuments.find(doc => doc.uri.toString() === cell.document.uri.toString()); assert.ok(doc); - assert.strictEqual(doc.notebook === notebook, true); assert.strictEqual(doc === cell.document, true); assert.strictEqual(doc?.languageId, cell.document.languageId); assert.strictEqual(doc?.isDirty, false);