Path: blob/main/src/vs/workbench/contrib/notebook/common/notebookExecutionStateService.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Event } from '../../../../base/common/event.js';6import { IDisposable } from '../../../../base/common/lifecycle.js';7import { URI, UriComponents } from '../../../../base/common/uri.js';8import { IRange } from '../../../../editor/common/core/range.js';9import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';10import { NotebookCellExecutionState, NotebookExecutionState } from './notebookCommon.js';11import { CellExecutionUpdateType, ICellExecuteOutputEdit, ICellExecuteOutputItemEdit } from './notebookExecutionService.js';1213export type ICellExecuteUpdate = ICellExecuteOutputEdit | ICellExecuteOutputItemEdit | ICellExecutionStateUpdate;1415export interface ICellExecutionStateUpdate {16editType: CellExecutionUpdateType.ExecutionState;17executionOrder?: number;18runStartTime?: number;19didPause?: boolean;20isPaused?: boolean;21}2223export interface ICellErrorStackFrame {24/**25* The location of this stack frame. This should be provided as a URI if the26* location of the call frame can be accessed by the editor.27*/28readonly uri?: UriComponents;2930readonly location?: IRange;3132/**33* The name of the stack frame, typically a method or function name.34*/35readonly label: string;36}3738export interface ICellExecutionError {39name: string;40message: string;41stack: string | ICellErrorStackFrame[] | undefined;42uri: UriComponents;43location: IRange | undefined;44}4546export interface ICellExecutionComplete {47runEndTime?: number;48lastRunSuccess?: boolean;49error?: ICellExecutionError;50}51export enum NotebookExecutionType {52cell,53notebook54}55export interface ICellExecutionStateChangedEvent {56type: NotebookExecutionType.cell;57notebook: URI;58cellHandle: number;59changed?: INotebookCellExecution; // undefined -> execution was completed60affectsCell(cell: URI): boolean;61affectsNotebook(notebook: URI): boolean;62}63export interface IExecutionStateChangedEvent {64type: NotebookExecutionType.notebook;65notebook: URI;66changed?: INotebookExecution; // undefined -> execution was completed67affectsNotebook(notebook: URI): boolean;68}69export interface INotebookFailStateChangedEvent {70visible: boolean;71notebook: URI;72}7374export interface IFailedCellInfo {75cellHandle: number;76disposable: IDisposable;77visible: boolean;78}7980export const INotebookExecutionStateService = createDecorator<INotebookExecutionStateService>('INotebookExecutionStateService');8182export interface INotebookExecutionStateService {83_serviceBrand: undefined;8485onDidChangeExecution: Event<ICellExecutionStateChangedEvent | IExecutionStateChangedEvent>;86onDidChangeLastRunFailState: Event<INotebookFailStateChangedEvent>;8788forceCancelNotebookExecutions(notebookUri: URI): void;89getCellExecutionsForNotebook(notebook: URI): INotebookCellExecution[];90getCellExecutionsByHandleForNotebook(notebook: URI): Map<number, INotebookCellExecution> | undefined;91getCellExecution(cellUri: URI): INotebookCellExecution | undefined;92createCellExecution(notebook: URI, cellHandle: number): INotebookCellExecution;93getExecution(notebook: URI): INotebookExecution | undefined;94createExecution(notebook: URI): INotebookExecution;95getLastFailedCellForNotebook(notebook: URI): number | undefined;96getLastCompletedCellForNotebook(notebook: URI): number | undefined;97}9899export interface INotebookCellExecution {100readonly notebook: URI;101readonly cellHandle: number;102readonly state: NotebookCellExecutionState;103readonly didPause: boolean;104readonly isPaused: boolean;105106confirm(): void;107update(updates: ICellExecuteUpdate[]): void;108complete(complete: ICellExecutionComplete): void;109}110export interface INotebookExecution {111readonly notebook: URI;112readonly state: NotebookExecutionState;113114confirm(): void;115begin(): void;116complete(): void;117}118119120