From 9d907212baff16ae3e62ba1d4d1d9ad2865bd277 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Thu, 27 May 2021 12:14:20 +0200 Subject: [PATCH] rename NotebookCellExecutionTask to NotebookCellExecution --- .../src/singlefolder-tests/notebook.test.ts | 12 ++++++------ .../vscode-notebook-tests/src/extension.ts | 2 +- src/vs/vscode.proposed.d.ts | 15 ++++++++------- .../api/common/extHostNotebookKernels.ts | 8 ++++---- .../browser/api/extHostNotebookKernel2.test.ts | 16 ++++++++-------- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts index 98b9ac8c12b..793dc37db5f 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts @@ -56,7 +56,7 @@ class Kernel { } protected async _runCell(cell: vscode.NotebookCell) { - const task = this.controller.createNotebookCellExecutionTask(cell); + const task = this.controller.createNotebookCellExecution(cell); task.start(); task.executionOrder = 1; if (cell.notebook.uri.path.endsWith('customRenderer.vsctestnb')) { @@ -180,7 +180,7 @@ suite('Notebook API tests', function () { } override async _runCell(cell: vscode.NotebookCell) { - const task = this.controller.createNotebookCellExecutionTask(cell); + const task = this.controller.createNotebookCellExecution(cell); task.start(); await task.replaceOutput([new vscode.NotebookCellOutput([ vscode.NotebookCellOutputItem.text('my second output', 'text/plain', undefined) @@ -772,7 +772,7 @@ suite('Notebook API tests', function () { override async _execute(cells: vscode.NotebookCell[]) { for (const cell of cells) { - const task = this.controller.createNotebookCellExecutionTask(cell); + const task = this.controller.createNotebookCellExecution(cell); task.start(); task.token.onCancellationRequested(async () => { await task.replaceOutput([new vscode.NotebookCellOutput([ @@ -812,10 +812,10 @@ suite('Notebook API tests', function () { this.controller.interruptHandler = this.interrupt.bind(this); } - private _task: vscode.NotebookCellExecutionTask | undefined; + private _task: vscode.NotebookCellExecution | undefined; override async _execute(cells: vscode.NotebookCell[]) { - this._task = this.controller.createNotebookCellExecutionTask(cells[0]); + this._task = this.controller.createNotebookCellExecution(cells[0]); this._task.start(); } @@ -1178,7 +1178,7 @@ suite('Notebook API tests', function () { override async _execute(cells: vscode.NotebookCell[]) { const [cell] = cells; - const task = this.controller.createNotebookCellExecutionTask(cell); + const task = this.controller.createNotebookCellExecution(cell); task.start(); await task.replaceOutput([new vscode.NotebookCellOutput([ vscode.NotebookCellOutputItem.text('Some output', 'text/plain', undefined) diff --git a/extensions/vscode-notebook-tests/src/extension.ts b/extensions/vscode-notebook-tests/src/extension.ts index 935968c0b4e..ae4fb948438 100644 --- a/extensions/vscode-notebook-tests/src/extension.ts +++ b/extensions/vscode-notebook-tests/src/extension.ts @@ -66,7 +66,7 @@ export function activate(context: vscode.ExtensionContext): any { controller.executeHandler = (cells) => { for (const cell of cells) { - const task = controller.createNotebookCellExecutionTask(cell); + const task = controller.createNotebookCellExecution(cell); task.start(); task.replaceOutput([new vscode.NotebookCellOutput([ vscode.NotebookCellOutputItem.text('test output', 'text/html', undefined) diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index d4f7a3315fe..53beb99d948 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1562,20 +1562,21 @@ declare module 'vscode' { endTime?: number; } - // todo@API jsdoc slightly outdated: kernel, notebook.createNotebookCellExecutionTask + // todo@API jsdoc slightly outdated: kernel, notebook.createNotebookCellExecution /** - * A NotebookCellExecutionTask is how the kernel modifies a notebook cell as it is executing. When - * {@link notebook.createNotebookCellExecutionTask `createNotebookCellExecutionTask`} is called, the cell + * A NotebookCellExecution is how the kernel modifies a notebook cell as it is executing. When + * {@link notebook.createNotebookCellExecution `createNotebookCellExecution`} is called, the cell * enters the Pending state. When `start()` is called on the execution task, it enters the Executing state. When * `end()` is called, it enters the Idle state. While in the Executing state, cell outputs can be * modified with the methods on the run task. * - * All outputs methods operate on this NotebookCellExecutionTask's cell by default. They optionally take + * All outputs methods operate on this NotebookCellExecution's cell by default. They optionally take * a cellIndex parameter that allows them to modify the outputs of other cells. `appendOutputItems` and * `replaceOutputItems` operate on the output with the given ID, which can be an output on any cell. They * all resolve once the output edit has been applied. */ - export interface NotebookCellExecutionTask { + export interface NotebookCellExecution { + readonly document: NotebookDocument; readonly cell: NotebookCell; readonly token: CancellationToken; @@ -1653,7 +1654,7 @@ declare module 'vscode' { /** * The interrupt handler is invoked the interrupt all execution. This is contrary to cancellation (available via - * [`NotebookCellExecutionTask#token`](NotebookCellExecutionTask#token)) and should only be used when + * [`NotebookCellExecution#token`](NotebookCellExecution#token)) and should only be used when * execution-level cancellation is supported */ interruptHandler?: NotebookInterruptHandler @@ -1690,7 +1691,7 @@ declare module 'vscode' { * @returns A notebook cell execution. */ // todo@API rename to NotebookCellExecution - createNotebookCellExecutionTask(cell: NotebookCell): NotebookCellExecutionTask; + createNotebookCellExecution(cell: NotebookCell): NotebookCellExecution; // todo@API find a better name than "preloads" // todo@API allow add, not remove diff --git a/src/vs/workbench/api/common/extHostNotebookKernels.ts b/src/vs/workbench/api/common/extHostNotebookKernels.ts index 2464bd06ad7..888de4966b1 100644 --- a/src/vs/workbench/api/common/extHostNotebookKernels.ts +++ b/src/vs/workbench/api/common/extHostNotebookKernels.ts @@ -164,7 +164,7 @@ export class ExtHostNotebookKernels implements ExtHostNotebookKernelsShape { data.supportsInterrupt = Boolean(value); _update(); }, - createNotebookCellExecutionTask(cell) { + createNotebookCellExecution(cell) { if (isDisposed) { throw new Error('notebook controller is DISPOSED'); } @@ -290,7 +290,7 @@ export class ExtHostNotebookKernels implements ExtHostNotebookKernelsShape { // --- - _createNotebookCellExecution(cell: vscode.NotebookCell): vscode.NotebookCellExecutionTask { + _createNotebookCellExecution(cell: vscode.NotebookCell): vscode.NotebookCellExecution { if (cell.index < 0) { throw new Error('CANNOT execute cell that has been REMOVED from notebook'); } @@ -403,9 +403,9 @@ class NotebookCellExecutionTask extends Disposable { }); } - asApiObject(): vscode.NotebookCellExecutionTask { + asApiObject(): vscode.NotebookCellExecution { const that = this; - return Object.freeze({ + return Object.freeze({ get token() { return that._tokenSource.token; }, get document() { return that._document.apiNotebook; }, get cell() { return that._cell.apiCell; }, diff --git a/src/vs/workbench/test/browser/api/extHostNotebookKernel2.test.ts b/src/vs/workbench/test/browser/api/extHostNotebookKernel2.test.ts index 5bfdd1356c3..7d5949f2f08 100644 --- a/src/vs/workbench/test/browser/api/extHostNotebookKernel2.test.ts +++ b/src/vs/workbench/test/browser/api/extHostNotebookKernel2.test.ts @@ -165,28 +165,28 @@ suite('NotebookKernel', function () { assert.strictEqual(first.label, 'Far'); }); - test('execute - simple createNotebookCellExecutionTask', function () { + test('execute - simple createNotebookCellExecution', function () { const kernel = extHostNotebookKernels.createNotebookController(nullExtensionDescription, 'foo', '*', 'Foo'); extHostNotebookKernels.$acceptNotebookAssociation(0, notebook.uri, true); const cell1 = notebook.apiNotebook.cellAt(0); - const task = kernel.createNotebookCellExecutionTask(cell1); + const task = kernel.createNotebookCellExecution(cell1); task.start(); task.end(); }); - test('createNotebookCellExecutionTask, must be selected/associated', function () { + test('createNotebookCellExecution, must be selected/associated', function () { const kernel = extHostNotebookKernels.createNotebookController(nullExtensionDescription, 'foo', '*', 'Foo'); assert.throws(() => { - kernel.createNotebookCellExecutionTask(notebook.apiNotebook.cellAt(0)); + kernel.createNotebookCellExecution(notebook.apiNotebook.cellAt(0)); }); extHostNotebookKernels.$acceptNotebookAssociation(0, notebook.uri, true); - kernel.createNotebookCellExecutionTask(notebook.apiNotebook.cellAt(0)); + kernel.createNotebookCellExecution(notebook.apiNotebook.cellAt(0)); }); - test('createNotebookCellExecutionTask, cell must be alive', function () { + test('createNotebookCellExecution, cell must be alive', function () { const kernel = extHostNotebookKernels.createNotebookController(nullExtensionDescription, 'foo', '*', 'Foo'); const cell1 = notebook.apiNotebook.cellAt(0); @@ -203,7 +203,7 @@ suite('NotebookKernel', function () { assert.strictEqual(cell1.index, -1); assert.throws(() => { - kernel.createNotebookCellExecutionTask(cell1); + kernel.createNotebookCellExecution(cell1); }); }); @@ -218,7 +218,7 @@ suite('NotebookKernel', function () { const cell1 = notebook.apiNotebook.cellAt(0); - const task = kernel.createNotebookCellExecutionTask(cell1); + const task = kernel.createNotebookCellExecution(cell1); task.token.onCancellationRequested(() => tokenCancelCount += 1); await extHostNotebookKernels.$cancelCells(0, notebook.uri, [0]);