mirror of
https://github.com/Microsoft/vscode
synced 2024-07-17 11:07:22 +00:00
rename NotebookCellExecutionTask to NotebookCellExecution
This commit is contained in:
parent
23fb420737
commit
9d907212ba
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
15
src/vs/vscode.proposed.d.ts
vendored
15
src/vs/vscode.proposed.d.ts
vendored
|
@ -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
|
||||
|
|
|
@ -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(<vscode.NotebookCellExecutionTask>{
|
||||
return Object.freeze(<vscode.NotebookCellExecution>{
|
||||
get token() { return that._tokenSource.token; },
|
||||
get document() { return that._document.apiNotebook; },
|
||||
get cell() { return that._cell.apiCell; },
|
||||
|
|
|
@ -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]);
|
||||
|
|
Loading…
Reference in a new issue