Skip to content

Commit 0284f05

Browse files
committed
Mark events as readonly in VS Code api
Event data should generally not be mutate as any mutations can leak to other listeners. This change marks most event type members as readonly
1 parent ba9266d commit 0284f05

2 files changed

Lines changed: 33 additions & 33 deletions

File tree

src/vs/vscode.d.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -531,16 +531,16 @@ declare module 'vscode' {
531531
/**
532532
* The [text editor](#TextEditor) for which the selections have changed.
533533
*/
534-
textEditor: TextEditor;
534+
readonly textEditor: TextEditor;
535535
/**
536536
* The new value for the [text editor's selections](#TextEditor.selections).
537537
*/
538-
selections: Selection[];
538+
readonly selections: ReadonlyArray<Selection>;
539539
/**
540540
* The [change kind](#TextEditorSelectionChangeKind) which has triggered this
541541
* event. Can be `undefined`.
542542
*/
543-
kind?: TextEditorSelectionChangeKind;
543+
readonly kind?: TextEditorSelectionChangeKind;
544544
}
545545

546546
/**
@@ -550,11 +550,11 @@ declare module 'vscode' {
550550
/**
551551
* The [text editor](#TextEditor) for which the visible ranges have changed.
552552
*/
553-
textEditor: TextEditor;
553+
readonly textEditor: TextEditor;
554554
/**
555555
* The new value for the [text editor's visible ranges](#TextEditor.visibleRanges).
556556
*/
557-
visibleRanges: Range[];
557+
readonly visibleRanges: ReadonlyArray<Range>;
558558
}
559559

560560
/**
@@ -564,11 +564,11 @@ declare module 'vscode' {
564564
/**
565565
* The [text editor](#TextEditor) for which the options have changed.
566566
*/
567-
textEditor: TextEditor;
567+
readonly textEditor: TextEditor;
568568
/**
569569
* The new value for the [text editor's options](#TextEditor.options).
570570
*/
571-
options: TextEditorOptions;
571+
readonly options: TextEditorOptions;
572572
}
573573

574574
/**
@@ -578,11 +578,11 @@ declare module 'vscode' {
578578
/**
579579
* The [text editor](#TextEditor) for which the view column has changed.
580580
*/
581-
textEditor: TextEditor;
581+
readonly textEditor: TextEditor;
582582
/**
583583
* The new value for the [text editor's view column](#TextEditor.viewColumn).
584584
*/
585-
viewColumn: ViewColumn;
585+
readonly viewColumn: ViewColumn;
586586
}
587587

588588
/**
@@ -4203,7 +4203,7 @@ declare module 'vscode' {
42034203
/**
42044204
* An array of resources for which diagnostics have changed.
42054205
*/
4206-
readonly uris: Uri[];
4206+
readonly uris: ReadonlyArray<Uri>;
42074207
}
42084208

42094209
/**
@@ -5331,7 +5331,7 @@ declare module 'vscode' {
53315331
/**
53325332
* The task item representing the task that got started.
53335333
*/
5334-
execution: TaskExecution;
5334+
readonly execution: TaskExecution;
53355335
}
53365336

53375337
/**
@@ -5343,7 +5343,7 @@ declare module 'vscode' {
53435343
/**
53445344
* The task item representing the task that finished.
53455345
*/
5346-
execution: TaskExecution;
5346+
readonly execution: TaskExecution;
53475347
}
53485348

53495349
/**
@@ -5355,12 +5355,12 @@ declare module 'vscode' {
53555355
/**
53565356
* The task execution for which the process got started.
53575357
*/
5358-
execution: TaskExecution;
5358+
readonly execution: TaskExecution;
53595359

53605360
/**
53615361
* The underlying process id.
53625362
*/
5363-
processId: number;
5363+
readonly processId: number;
53645364
}
53655365

53665366
/**
@@ -5372,12 +5372,12 @@ declare module 'vscode' {
53725372
/**
53735373
* The task execution for which the process got started.
53745374
*/
5375-
execution: TaskExecution;
5375+
readonly execution: TaskExecution;
53765376

53775377
/**
53785378
* The process's exit code.
53795379
*/
5380-
exitCode: number;
5380+
readonly exitCode: number;
53815381
}
53825382

53835383
export interface TaskFilter {
@@ -5584,12 +5584,12 @@ declare module 'vscode' {
55845584
/**
55855585
* The type of change.
55865586
*/
5587-
type: FileChangeType;
5587+
readonly type: FileChangeType;
55885588

55895589
/**
55905590
* The uri of the file that has changed.
55915591
*/
5592-
uri: Uri;
5592+
readonly uri: Uri;
55935593
}
55945594

55955595
/**
@@ -7331,12 +7331,12 @@ declare module 'vscode' {
73317331
/**
73327332
* The affected document.
73337333
*/
7334-
document: TextDocument;
7334+
readonly document: TextDocument;
73357335

73367336
/**
73377337
* An array of content changes.
73387338
*/
7339-
contentChanges: TextDocumentContentChangeEvent[];
7339+
readonly contentChanges: ReadonlyArray<TextDocumentContentChangeEvent>;
73407340
}
73417341

73427342
/**
@@ -7373,12 +7373,12 @@ declare module 'vscode' {
73737373
/**
73747374
* The document that will be saved.
73757375
*/
7376-
document: TextDocument;
7376+
readonly document: TextDocument;
73777377

73787378
/**
73797379
* The reason why save was triggered.
73807380
*/
7381-
reason: TextDocumentSaveReason;
7381+
readonly reason: TextDocumentSaveReason;
73827382

73837383
/**
73847384
* Allows to pause the event loop and to apply [pre-save-edits](#TextEdit).
@@ -7419,12 +7419,12 @@ declare module 'vscode' {
74197419
/**
74207420
* Added workspace folders.
74217421
*/
7422-
readonly added: WorkspaceFolder[];
7422+
readonly added: ReadonlyArray<WorkspaceFolder>;
74237423

74247424
/**
74257425
* Removed workspace folders.
74267426
*/
7427-
readonly removed: WorkspaceFolder[];
7427+
readonly removed: ReadonlyArray<WorkspaceFolder>;
74287428
}
74297429

74307430
/**
@@ -8500,17 +8500,17 @@ declare module 'vscode' {
85008500
/**
85018501
* The [debug session](#DebugSession) for which the custom event was received.
85028502
*/
8503-
session: DebugSession;
8503+
readonly session: DebugSession;
85048504

85058505
/**
85068506
* Type of event.
85078507
*/
8508-
event: string;
8508+
readonly event: string;
85098509

85108510
/**
85118511
* Event specific information.
85128512
*/
8513-
body?: any;
8513+
readonly body?: any;
85148514
}
85158515

85168516
/**
@@ -8707,17 +8707,17 @@ declare module 'vscode' {
87078707
/**
87088708
* Added breakpoints.
87098709
*/
8710-
readonly added: Breakpoint[];
8710+
readonly added: ReadonlyArray<Breakpoint>;
87118711

87128712
/**
87138713
* Removed breakpoints.
87148714
*/
8715-
readonly removed: Breakpoint[];
8715+
readonly removed: ReadonlyArray<Breakpoint>;
87168716

87178717
/**
87188718
* Changed breakpoints.
87198719
*/
8720-
readonly changed: Breakpoint[];
8720+
readonly changed: ReadonlyArray<Breakpoint>;
87218721
}
87228722

87238723
/**

src/vs/vscode.proposed.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -816,17 +816,17 @@ declare module 'vscode' {
816816
/**
817817
* Added comment threads.
818818
*/
819-
readonly added: CommentThread[];
819+
readonly added: ReadonlyArray<CommentThread>;
820820

821821
/**
822822
* Removed comment threads.
823823
*/
824-
readonly removed: CommentThread[];
824+
readonly removed: ReadonlyArray<CommentThread>;
825825

826826
/**
827827
* Changed comment threads.
828828
*/
829-
readonly changed: CommentThread[];
829+
readonly changed: ReadonlyArray<CommentThread>;
830830

831831
/**
832832
* Changed draft mode

0 commit comments

Comments
 (0)