forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathindex.d.ts
More file actions
751 lines (649 loc) · 21.6 KB
/
index.d.ts
File metadata and controls
751 lines (649 loc) · 21.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import {
Event,
GlobPattern,
Uri,
TextDocument,
ViewColumn,
CancellationToken,
Disposable,
DocumentSelector,
ProviderResult,
WorkspaceEditEntryMetadata,
Command,
AccessibilityInformation
} from 'vscode';
// Copy nb section from https://github.com/microsoft/vscode/blob/master/src/vs/vscode.proposed.d.ts.
//#region @rebornix: Notebook
export enum CellKind {
Markdown = 1,
Code = 2
}
export enum CellOutputKind {
Text = 1,
Error = 2,
Rich = 3
}
export interface CellStreamOutput {
outputKind: CellOutputKind.Text;
text: string;
}
export interface CellErrorOutput {
outputKind: CellOutputKind.Error;
/**
* Exception Name
*/
ename: string;
/**
* Exception Value
*/
evalue: string;
/**
* Exception call stack
*/
traceback: string[];
}
export interface NotebookCellOutputMetadata {
/**
* Additional attributes of a cell metadata.
*/
custom?: { [key: string]: any };
}
export interface CellDisplayOutput {
outputKind: CellOutputKind.Rich;
/**
* { mime_type: value }
*
* Example:
* ```json
* {
* "outputKind": vscode.CellOutputKind.Rich,
* "data": {
* "text/html": [
* "<h1>Hello</h1>"
* ],
* "text/plain": [
* "<IPython.lib.display.IFrame at 0x11dee3e80>"
* ]
* }
* }
*/
data: { [key: string]: any };
readonly metadata?: NotebookCellOutputMetadata;
}
export type CellOutput = CellStreamOutput | CellErrorOutput | CellDisplayOutput;
export enum NotebookCellRunState {
Running = 1,
Idle = 2,
Success = 3,
Error = 4
}
export enum NotebookRunState {
Running = 1,
Idle = 2
}
export interface NotebookCellMetadata {
/**
* Controls whether a cell's editor is editable/readonly.
*/
readonly editable?: boolean;
/**
* Controls if the cell is executable.
* This metadata is ignored for markdown cell.
*/
readonly runnable?: boolean;
/**
* Controls if the cell has a margin to support the breakpoint UI.
* This metadata is ignored for markdown cell.
*/
readonly breakpointMargin?: boolean;
/**
* Whether the [execution order](#NotebookCellMetadata.executionOrder) indicator will be displayed.
* Defaults to true.
*/
readonly hasExecutionOrder?: boolean;
/**
* The order in which this cell was executed.
*/
readonly executionOrder?: number;
/**
* A status message to be shown in the cell's status bar
*/
readonly statusMessage?: string;
/**
* The cell's current run state
*/
readonly runState?: NotebookCellRunState;
/**
* If the cell is running, the time at which the cell started running
*/
readonly runStartTime?: number;
/**
* The total duration of the cell's last run
*/
readonly lastRunDuration?: number;
/**
* Whether a code cell's editor is collapsed
*/
readonly inputCollapsed?: boolean;
/**
* Whether a code cell's outputs are collapsed
*/
readonly outputCollapsed?: boolean;
/**
* Additional attributes of a cell metadata.
*/
custom?: { [key: string]: any };
}
export interface NotebookCell {
readonly index: number;
readonly notebook: NotebookDocument;
readonly uri: Uri;
readonly cellKind: CellKind;
readonly document: TextDocument;
readonly language: string;
readonly outputs: CellOutput[];
readonly metadata: NotebookCellMetadata;
}
export interface NotebookDocumentMetadata {
/**
* Controls if users can add or delete cells
* Defaults to true
*/
readonly editable?: boolean;
/**
* Controls whether the full notebook can be run at once.
* Defaults to true
*/
readonly runnable?: boolean;
/**
* Default value for [cell editable metadata](#NotebookCellMetadata.editable).
* Defaults to true.
*/
readonly cellEditable?: boolean;
/**
* Default value for [cell runnable metadata](#NotebookCellMetadata.runnable).
* Defaults to true.
*/
readonly cellRunnable?: boolean;
/**
* Default value for [cell hasExecutionOrder metadata](#NotebookCellMetadata.hasExecutionOrder).
* Defaults to true.
*/
readonly cellHasExecutionOrder?: boolean;
readonly displayOrder?: GlobPattern[];
/**
* Additional attributes of the document metadata.
*/
readonly custom?: { [key: string]: any };
/**
* The document's current run state
*/
readonly runState?: NotebookRunState;
}
export interface NotebookDocumentContentOptions {
/**
* Controls if outputs change will trigger notebook document content change and if it will be used in the diff editor
* Default to false. If the content provider doesn't persisit the outputs in the file document, this should be set to true.
*/
readonly transientOutputs: boolean;
/**
* Controls if a meetadata property change will trigger notebook document content change and if it will be used in the diff editor
* Default to false. If the content provider doesn't persisit a metadata property in the file document, it should be set to true.
*/
readonly transientMetadata: { [K in keyof NotebookCellMetadata]?: boolean };
}
export interface NotebookDocument {
readonly uri: Uri;
readonly version: number;
readonly fileName: string;
readonly viewType: string;
readonly isDirty: boolean;
readonly isUntitled: boolean;
readonly cells: ReadonlyArray<NotebookCell>;
readonly contentOptions: Readonly<NotebookDocumentContentOptions>;
readonly languages: string[];
readonly metadata: Readonly<NotebookDocumentMetadata>;
}
export interface NotebookConcatTextDocument {
uri: Uri;
isClosed: boolean;
dispose(): void;
onDidChange: Event<void>;
version: number;
getText(): string;
getText(range: Range): string;
offsetAt(position: Position): number;
positionAt(offset: number): Position;
validateRange(range: Range): Range;
validatePosition(position: Position): Position;
locationAt(positionOrRange: Position | Range): Location;
positionAt(location: Location): Position;
contains(uri: Uri): boolean;
}
export interface WorkspaceEdit {
replaceNotebookMetadata(uri: Uri, value: NotebookDocumentMetadata): void;
replaceNotebookCells(
uri: Uri,
start: number,
end: number,
cells: NotebookCellData[],
metadata?: WorkspaceEditEntryMetadata
): void;
replaceNotebookCellOutput(
uri: Uri,
index: number,
outputs: CellOutput[],
metadata?: WorkspaceEditEntryMetadata
): void;
replaceNotebookCellMetadata(
uri: Uri,
index: number,
cellMetadata: NotebookCellMetadata,
metadata?: WorkspaceEditEntryMetadata
): void;
}
export interface NotebookEditorEdit {
replaceMetadata(value: NotebookDocumentMetadata): void;
replaceCells(start: number, end: number, cells: NotebookCellData[]): void;
replaceCellOutput(index: number, outputs: CellOutput[]): void;
replaceCellMetadata(index: number, metadata: NotebookCellMetadata): void;
}
export interface NotebookCellRange {
readonly start: number;
/**
* exclusive
*/
readonly end: number;
}
export enum NotebookEditorRevealType {
/**
* The range will be revealed with as little scrolling as possible.
*/
Default = 0,
/**
* The range will always be revealed in the center of the viewport.
*/
InCenter = 1,
/**
* If the range is outside the viewport, it will be revealed in the center of the viewport.
* Otherwise, it will be revealed with as little scrolling as possible.
*/
InCenterIfOutsideViewport = 2
}
export interface NotebookEditor {
/**
* The document associated with this notebook editor.
*/
readonly document: NotebookDocument;
/**
* The primary selected cell on this notebook editor.
*/
readonly selection?: NotebookCell;
/**
* The current visible ranges in the editor (vertically).
*/
readonly visibleRanges: NotebookCellRange[];
/**
* The column in which this editor shows.
*/
readonly viewColumn?: ViewColumn;
/**
* Whether the panel is active (focused by the user).
*/
readonly active: boolean;
/**
* Whether the panel is visible.
*/
readonly visible: boolean;
/**
* Fired when the panel is disposed.
*/
readonly onDidDispose: Event<void>;
/**
* Active kernel used in the editor
*/
readonly kernel?: NotebookKernel;
/**
* Fired when the output hosting webview posts a message.
*/
readonly onDidReceiveMessage: Event<any>;
/**
* Post a message to the output hosting webview.
*
* Messages are only delivered if the editor is live.
*
* @param message Body of the message. This must be a string or other json serilizable object.
*/
postMessage(message: any): Thenable<boolean>;
/**
* Convert a uri for the local file system to one that can be used inside outputs webview.
*/
asWebviewUri(localResource: Uri): Uri;
/**
* Perform an edit on the notebook associated with this notebook editor.
*
* The given callback-function is invoked with an [edit-builder](#NotebookEditorEdit) which must
* be used to make edits. Note that the edit-builder is only valid while the
* callback executes.
*
* @param callback A function which can create edits using an [edit-builder](#NotebookEditorEdit).
* @return A promise that resolves with a value indicating if the edits could be applied.
*/
edit(callback: (editBuilder: NotebookEditorEdit) => void): Thenable<boolean>;
setDecorations(decorationType: NotebookEditorDecorationType, range: NotebookCellRange): void;
revealRange(range: NotebookCellRange, revealType?: NotebookEditorRevealType): void;
}
export interface NotebookOutputSelector {
mimeTypes?: string[];
}
export interface NotebookRenderRequest {
output: CellDisplayOutput;
mimeType: string;
outputId: string;
}
export interface NotebookDocumentMetadataChangeEvent {
readonly document: NotebookDocument;
}
export interface NotebookCellsChangeData {
readonly start: number;
readonly deletedCount: number;
readonly deletedItems: NotebookCell[];
readonly items: NotebookCell[];
}
export interface NotebookCellsChangeEvent {
/**
* The affected document.
*/
readonly document: NotebookDocument;
readonly changes: ReadonlyArray<NotebookCellsChangeData>;
}
export interface NotebookCellMoveEvent {
/**
* The affected document.
*/
readonly document: NotebookDocument;
readonly index: number;
readonly newIndex: number;
}
export interface NotebookCellOutputsChangeEvent {
/**
* The affected document.
*/
readonly document: NotebookDocument;
readonly cells: NotebookCell[];
}
export interface NotebookCellLanguageChangeEvent {
/**
* The affected document.
*/
readonly document: NotebookDocument;
readonly cell: NotebookCell;
readonly language: string;
}
export interface NotebookCellMetadataChangeEvent {
readonly document: NotebookDocument;
readonly cell: NotebookCell;
}
export interface NotebookEditorSelectionChangeEvent {
readonly notebookEditor: NotebookEditor;
readonly selection?: NotebookCell;
}
export interface NotebookEditorVisibleRangesChangeEvent {
readonly notebookEditor: NotebookEditor;
readonly visibleRanges: ReadonlyArray<NotebookCellRange>;
}
export interface NotebookCellData {
readonly cellKind: CellKind;
readonly source: string;
readonly language: string;
readonly outputs: CellOutput[];
readonly metadata: NotebookCellMetadata | undefined;
}
export interface NotebookData {
readonly cells: NotebookCellData[];
readonly languages: string[];
readonly metadata: NotebookDocumentMetadata;
}
interface NotebookDocumentContentChangeEvent {
/**
* The document that the edit is for.
*/
readonly document: NotebookDocument;
}
interface NotebookDocumentEditEvent {
/**
* The document that the edit is for.
*/
readonly document: NotebookDocument;
/**
* Undo the edit operation.
*
* This is invoked by VS Code when the user undoes this edit. To implement `undo`, your
* extension should restore the document and editor to the state they were in just before this
* edit was added to VS Code's internal edit stack by `onDidChangeCustomDocument`.
*/
undo(): Thenable<void> | void;
/**
* Redo the edit operation.
*
* This is invoked by VS Code when the user redoes this edit. To implement `redo`, your
* extension should restore the document and editor to the state they were in just after this
* edit was added to VS Code's internal edit stack by `onDidChangeCustomDocument`.
*/
redo(): Thenable<void> | void;
/**
* Display name describing the edit.
*
* This will be shown to users in the UI for undo/redo operations.
*/
readonly label?: string;
}
interface NotebookDocumentBackup {
/**
* Unique identifier for the backup.
*
* This id is passed back to your extension in `openCustomDocument` when opening a notebook editor from a backup.
*/
readonly id: string;
/**
* Delete the current backup.
*
* This is called by VS Code when it is clear the current backup is no longer needed, such as when a new backup
* is made or when the file is saved.
*/
delete(): void;
}
interface NotebookDocumentBackupContext {
readonly destination: Uri;
}
interface NotebookDocumentOpenContext {
readonly backupId?: string;
}
/**
* Communication object passed to the {@link NotebookContentProvider} and
* {@link NotebookOutputRenderer} to communicate with the webview.
*/
export interface NotebookCommunication {
/**
* ID of the editor this object communicates with. A single notebook
* document can have multiple attached webviews and editors, when the
* notebook is split for instance. The editor ID lets you differentiate
* between them.
*/
readonly editorId: string;
/**
* Fired when the output hosting webview posts a message.
*/
readonly onDidReceiveMessage: Event<any>;
/**
* Post a message to the output hosting webview.
*
* Messages are only delivered if the editor is live.
*
* @param message Body of the message. This must be a string or other json serilizable object.
*/
postMessage(message: any): Thenable<boolean>;
/**
* Convert a uri for the local file system to one that can be used inside outputs webview.
*/
asWebviewUri(localResource: Uri): Uri;
}
export interface NotebookContentProvider {
readonly options?: NotebookDocumentContentOptions;
readonly onDidChangeNotebookContentOptions?: Event<NotebookDocumentContentOptions>;
readonly onDidChangeNotebook: Event<NotebookDocumentContentChangeEvent | NotebookDocumentEditEvent>;
/**
* Content providers should always use [file system providers](#FileSystemProvider) to
* resolve the raw content for `uri` as the resouce is not necessarily a file on disk.
*/
openNotebook(uri: Uri, openContext: NotebookDocumentOpenContext): NotebookData | Promise<NotebookData>;
resolveNotebook(document: NotebookDocument, webview: NotebookCommunication): Promise<void>;
saveNotebook(document: NotebookDocument, cancellation: CancellationToken): Promise<void>;
saveNotebookAs(targetResource: Uri, document: NotebookDocument, cancellation: CancellationToken): Promise<void>;
backupNotebook(
document: NotebookDocument,
context: NotebookDocumentBackupContext,
cancellation: CancellationToken
): Promise<NotebookDocumentBackup>;
}
export interface NotebookKernel {
readonly id?: string;
label: string;
description?: string;
detail?: string;
isPreferred?: boolean;
preloads?: Uri[];
executeCell(document: NotebookDocument, cell: NotebookCell): void;
cancelCellExecution(document: NotebookDocument, cell: NotebookCell): void;
executeAllCells(document: NotebookDocument): void;
cancelAllCellsExecution(document: NotebookDocument): void;
}
export type NotebookFilenamePattern = GlobPattern | { include: GlobPattern; exclude: GlobPattern };
export interface NotebookDocumentFilter {
viewType?: string | string[];
filenamePattern?: NotebookFilenamePattern;
}
export interface NotebookKernelProvider<T extends NotebookKernel = NotebookKernel> {
onDidChangeKernels?: Event<NotebookDocument | undefined>;
provideKernels(document: NotebookDocument, token: CancellationToken): ProviderResult<T[]>;
resolveKernel?(
kernel: T,
document: NotebookDocument,
webview: NotebookCommunication,
token: CancellationToken
): ProviderResult<void>;
}
/**
* Represents the alignment of status bar items.
*/
export enum NotebookCellStatusBarAlignment {
/**
* Aligned to the left side.
*/
Left = 1,
/**
* Aligned to the right side.
*/
Right = 2
}
export interface NotebookCellStatusBarItem {
readonly cell: NotebookCell;
readonly alignment: NotebookCellStatusBarAlignment;
readonly priority?: number;
text: string;
tooltip: string | undefined;
command: string | Command | undefined;
accessibilityInformation?: AccessibilityInformation;
show(): void;
hide(): void;
dispose(): void;
}
export interface NotebookEditorDecorationType {
readonly key: string;
dispose(): void;
}
export namespace notebook {
export function registerNotebookContentProvider(
notebookType: string,
provider: NotebookContentProvider,
options?: NotebookDocumentContentOptions & {
/**
* Not ready for production or development use yet.
*/
viewOptions?: {
displayName: string;
filenamePattern: NotebookFilenamePattern[];
exclusive?: boolean;
};
}
): Disposable;
export function registerNotebookKernelProvider(
selector: NotebookDocumentFilter,
provider: NotebookKernelProvider
): Disposable;
export const onDidOpenNotebookDocument: Event<NotebookDocument>;
export const onDidCloseNotebookDocument: Event<NotebookDocument>;
export const onDidSaveNotebookDocument: Event<NotebookDocument>;
/**
* All currently known notebook documents.
*/
export const notebookDocuments: ReadonlyArray<NotebookDocument>;
export const visibleNotebookEditors: NotebookEditor[];
export const onDidChangeVisibleNotebookEditors: Event<NotebookEditor[]>;
export const activeNotebookEditor: NotebookEditor | undefined;
export const onDidChangeActiveNotebookEditor: Event<NotebookEditor | undefined>;
export const onDidChangeNotebookEditorSelection: Event<NotebookEditorSelectionChangeEvent>;
export const onDidChangeNotebookEditorVisibleRanges: Event<NotebookEditorVisibleRangesChangeEvent>;
export const onDidChangeNotebookDocumentMetadata: Event<NotebookDocumentMetadataChangeEvent>;
export const onDidChangeNotebookCells: Event<NotebookCellsChangeEvent>;
export const onDidChangeCellOutputs: Event<NotebookCellOutputsChangeEvent>;
export const onDidChangeCellLanguage: Event<NotebookCellLanguageChangeEvent>;
export const onDidChangeCellMetadata: Event<NotebookCellMetadataChangeEvent>;
/**
* Create a document that is the concatenation of all notebook cells. By default all code-cells are included
* but a selector can be provided to narrow to down the set of cells.
*
* @param notebook
* @param selector
*/
export function createConcatTextDocument(
notebook: NotebookDocument,
selector?: DocumentSelector
): NotebookConcatTextDocument;
export const onDidChangeActiveNotebookKernel: Event<{
document: NotebookDocument;
kernel: NotebookKernel | undefined;
}>;
/**
* Creates a notebook cell status bar [item](#NotebookCellStatusBarItem).
* It will be disposed automatically when the notebook document is closed or the cell is deleted.
*
* @param cell The cell on which this item should be shown.
* @param alignment The alignment of the item.
* @param priority The priority of the item. Higher values mean the item should be shown more to the left.
* @return A new status bar item.
*/
export function createCellStatusBarItem(
cell: NotebookCell,
alignment?: NotebookCellStatusBarAlignment,
priority?: number
): NotebookCellStatusBarItem;
}
//#region debug
/**
* A DebugProtocolVariableContainer is an opaque stand-in type for the intersection of the Scope and Variable types defined in the Debug Adapter Protocol.
* See https://microsoft.github.io/debug-adapter-protocol/specification#Types_Scope and https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable.
*/
export interface DebugProtocolVariableContainer {
// Properties: the intersection of DAP's Scope and Variable types.
}
/**
* A DebugProtocolVariable is an opaque stand-in type for the Variable type defined in the Debug Adapter Protocol.
* See https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable.
*/
export interface DebugProtocolVariable {
// Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Base_Protocol_Variable).
}
//#endregion