Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/notebook/common/notebookExecutionStateService.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Event } from '../../../../base/common/event.js';
7
import { IDisposable } from '../../../../base/common/lifecycle.js';
8
import { URI, UriComponents } from '../../../../base/common/uri.js';
9
import { IRange } from '../../../../editor/common/core/range.js';
10
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
11
import { NotebookCellExecutionState, NotebookExecutionState } from './notebookCommon.js';
12
import { CellExecutionUpdateType, ICellExecuteOutputEdit, ICellExecuteOutputItemEdit } from './notebookExecutionService.js';
13
14
export type ICellExecuteUpdate = ICellExecuteOutputEdit | ICellExecuteOutputItemEdit | ICellExecutionStateUpdate;
15
16
export interface ICellExecutionStateUpdate {
17
editType: CellExecutionUpdateType.ExecutionState;
18
executionOrder?: number;
19
runStartTime?: number;
20
didPause?: boolean;
21
isPaused?: boolean;
22
}
23
24
export interface ICellErrorStackFrame {
25
/**
26
* The location of this stack frame. This should be provided as a URI if the
27
* location of the call frame can be accessed by the editor.
28
*/
29
readonly uri?: UriComponents;
30
31
readonly location?: IRange;
32
33
/**
34
* The name of the stack frame, typically a method or function name.
35
*/
36
readonly label: string;
37
}
38
39
export interface ICellExecutionError {
40
name: string;
41
message: string;
42
stack: string | ICellErrorStackFrame[] | undefined;
43
uri: UriComponents;
44
location: IRange | undefined;
45
}
46
47
export interface ICellExecutionComplete {
48
runEndTime?: number;
49
lastRunSuccess?: boolean;
50
error?: ICellExecutionError;
51
}
52
export enum NotebookExecutionType {
53
cell,
54
notebook
55
}
56
export interface ICellExecutionStateChangedEvent {
57
type: NotebookExecutionType.cell;
58
notebook: URI;
59
cellHandle: number;
60
changed?: INotebookCellExecution; // undefined -> execution was completed
61
affectsCell(cell: URI): boolean;
62
affectsNotebook(notebook: URI): boolean;
63
}
64
export interface IExecutionStateChangedEvent {
65
type: NotebookExecutionType.notebook;
66
notebook: URI;
67
changed?: INotebookExecution; // undefined -> execution was completed
68
affectsNotebook(notebook: URI): boolean;
69
}
70
export interface INotebookFailStateChangedEvent {
71
visible: boolean;
72
notebook: URI;
73
}
74
75
export interface IFailedCellInfo {
76
cellHandle: number;
77
disposable: IDisposable;
78
visible: boolean;
79
}
80
81
export const INotebookExecutionStateService = createDecorator<INotebookExecutionStateService>('INotebookExecutionStateService');
82
83
export interface INotebookExecutionStateService {
84
_serviceBrand: undefined;
85
86
onDidChangeExecution: Event<ICellExecutionStateChangedEvent | IExecutionStateChangedEvent>;
87
onDidChangeLastRunFailState: Event<INotebookFailStateChangedEvent>;
88
89
forceCancelNotebookExecutions(notebookUri: URI): void;
90
getCellExecutionsForNotebook(notebook: URI): INotebookCellExecution[];
91
getCellExecutionsByHandleForNotebook(notebook: URI): Map<number, INotebookCellExecution> | undefined;
92
getCellExecution(cellUri: URI): INotebookCellExecution | undefined;
93
createCellExecution(notebook: URI, cellHandle: number): INotebookCellExecution;
94
getExecution(notebook: URI): INotebookExecution | undefined;
95
createExecution(notebook: URI): INotebookExecution;
96
getLastFailedCellForNotebook(notebook: URI): number | undefined;
97
getLastCompletedCellForNotebook(notebook: URI): number | undefined;
98
}
99
100
export interface INotebookCellExecution {
101
readonly notebook: URI;
102
readonly cellHandle: number;
103
readonly state: NotebookCellExecutionState;
104
readonly didPause: boolean;
105
readonly isPaused: boolean;
106
107
confirm(): void;
108
update(updates: ICellExecuteUpdate[]): void;
109
complete(complete: ICellExecutionComplete): void;
110
}
111
export interface INotebookExecution {
112
readonly notebook: URI;
113
readonly state: NotebookExecutionState;
114
115
confirm(): void;
116
begin(): void;
117
complete(): void;
118
}
119
120