mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 01:29:04 +01:00
Marking most private emitters as readonly
Emitters should generally not be reassigned as their corresponding event would also be lost. Marking these as readonly just to enforce this
This commit is contained in:
@@ -33,7 +33,7 @@ export class MainThreadCommentThread implements modes.CommentThread {
|
||||
this._onDidChangeInput.fire(value);
|
||||
}
|
||||
|
||||
private _onDidChangeInput = new Emitter<modes.CommentInput | undefined>();
|
||||
private readonly _onDidChangeInput = new Emitter<modes.CommentInput | undefined>();
|
||||
get onDidChangeInput(): Event<modes.CommentInput | undefined> { return this._onDidChangeInput.event; }
|
||||
|
||||
private _label: string | undefined;
|
||||
@@ -57,7 +57,7 @@ export class MainThreadCommentThread implements modes.CommentThread {
|
||||
this._contextValue = context;
|
||||
}
|
||||
|
||||
private _onDidChangeLabel = new Emitter<string | undefined>();
|
||||
private readonly _onDidChangeLabel = new Emitter<string | undefined>();
|
||||
readonly onDidChangeLabel: Event<string | undefined> = this._onDidChangeLabel.event;
|
||||
|
||||
private _comments: modes.Comment[] | undefined;
|
||||
@@ -71,7 +71,7 @@ export class MainThreadCommentThread implements modes.CommentThread {
|
||||
this._onDidChangeComments.fire(this._comments);
|
||||
}
|
||||
|
||||
private _onDidChangeComments = new Emitter<modes.Comment[] | undefined>();
|
||||
private readonly _onDidChangeComments = new Emitter<modes.Comment[] | undefined>();
|
||||
get onDidChangeComments(): Event<modes.Comment[] | undefined> { return this._onDidChangeComments.event; }
|
||||
|
||||
set range(range: IRange) {
|
||||
@@ -83,7 +83,7 @@ export class MainThreadCommentThread implements modes.CommentThread {
|
||||
return this._range;
|
||||
}
|
||||
|
||||
private _onDidChangeRange = new Emitter<IRange>();
|
||||
private readonly _onDidChangeRange = new Emitter<IRange>();
|
||||
public onDidChangeRange = this._onDidChangeRange.event;
|
||||
|
||||
private _collapsibleState: modes.CommentThreadCollapsibleState | undefined;
|
||||
@@ -96,7 +96,7 @@ export class MainThreadCommentThread implements modes.CommentThread {
|
||||
this._onDidChangeCollasibleState.fire(this._collapsibleState);
|
||||
}
|
||||
|
||||
private _onDidChangeCollasibleState = new Emitter<modes.CommentThreadCollapsibleState | undefined>();
|
||||
private readonly _onDidChangeCollasibleState = new Emitter<modes.CommentThreadCollapsibleState | undefined>();
|
||||
public onDidChangeCollasibleState = this._onDidChangeCollasibleState.event;
|
||||
|
||||
private _isDisposed: boolean;
|
||||
|
||||
@@ -308,10 +308,10 @@ export class MainThreadDocumentsAndEditors {
|
||||
private readonly _proxy: ExtHostDocumentsAndEditorsShape;
|
||||
private readonly _textEditors = new Map<string, MainThreadTextEditor>();
|
||||
|
||||
private _onTextEditorAdd = new Emitter<MainThreadTextEditor[]>();
|
||||
private _onTextEditorRemove = new Emitter<string[]>();
|
||||
private _onDocumentAdd = new Emitter<ITextModel[]>();
|
||||
private _onDocumentRemove = new Emitter<URI[]>();
|
||||
private readonly _onTextEditorAdd = new Emitter<MainThreadTextEditor[]>();
|
||||
private readonly _onTextEditorRemove = new Emitter<string[]>();
|
||||
private readonly _onDocumentAdd = new Emitter<ITextModel[]>();
|
||||
private readonly _onDocumentRemove = new Emitter<URI[]>();
|
||||
|
||||
readonly onTextEditorAdd: Event<MainThreadTextEditor[]> = this._onTextEditorAdd.event;
|
||||
readonly onTextEditorRemove: Event<string[]> = this._onTextEditorRemove.event;
|
||||
|
||||
@@ -18,12 +18,12 @@ class MainThreadSCMResourceGroup implements ISCMResourceGroup {
|
||||
|
||||
readonly elements: ISCMResource[] = [];
|
||||
|
||||
private _onDidSplice = new Emitter<ISplice<ISCMResource>>();
|
||||
private readonly _onDidSplice = new Emitter<ISplice<ISCMResource>>();
|
||||
readonly onDidSplice = this._onDidSplice.event;
|
||||
|
||||
get hideWhenEmpty(): boolean { return !!this.features.hideWhenEmpty; }
|
||||
|
||||
private _onDidChange = new Emitter<void>();
|
||||
private readonly _onDidChange = new Emitter<void>();
|
||||
readonly onDidChange: Event<void> = this._onDidChange.event;
|
||||
|
||||
constructor(
|
||||
@@ -104,7 +104,7 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
// // .filter(g => g.resources.elements.length > 0 || !g.features.hideWhenEmpty);
|
||||
// }
|
||||
|
||||
private _onDidChangeResources = new Emitter<void>();
|
||||
private readonly _onDidChangeResources = new Emitter<void>();
|
||||
readonly onDidChangeResources: Event<void> = this._onDidChangeResources.event;
|
||||
|
||||
private features: SCMProviderFeatures = {};
|
||||
@@ -119,13 +119,13 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
get statusBarCommands(): Command[] | undefined { return this.features.statusBarCommands; }
|
||||
get count(): number | undefined { return this.features.count; }
|
||||
|
||||
private _onDidChangeCommitTemplate = new Emitter<string>();
|
||||
private readonly _onDidChangeCommitTemplate = new Emitter<string>();
|
||||
readonly onDidChangeCommitTemplate: Event<string> = this._onDidChangeCommitTemplate.event;
|
||||
|
||||
private _onDidChangeStatusBarCommands = new Emitter<Command[]>();
|
||||
private readonly _onDidChangeStatusBarCommands = new Emitter<Command[]>();
|
||||
get onDidChangeStatusBarCommands(): Event<Command[]> { return this._onDidChangeStatusBarCommands.event; }
|
||||
|
||||
private _onDidChange = new Emitter<void>();
|
||||
private readonly _onDidChange = new Emitter<void>();
|
||||
readonly onDidChange: Event<void> = this._onDidChange.event;
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -239,7 +239,7 @@ export class ExtHostCommentThread implements vscode.CommentThread {
|
||||
return this._uri;
|
||||
}
|
||||
|
||||
private _onDidUpdateCommentThread = new Emitter<void>();
|
||||
private readonly _onDidUpdateCommentThread = new Emitter<void>();
|
||||
readonly onDidUpdateCommentThread = this._onDidUpdateCommentThread.event;
|
||||
|
||||
set range(range: vscode.Range) {
|
||||
|
||||
@@ -15,10 +15,10 @@ import * as vscode from 'vscode';
|
||||
|
||||
export class ExtHostDocuments implements ExtHostDocumentsShape {
|
||||
|
||||
private _onDidAddDocument = new Emitter<vscode.TextDocument>();
|
||||
private _onDidRemoveDocument = new Emitter<vscode.TextDocument>();
|
||||
private _onDidChangeDocument = new Emitter<vscode.TextDocumentChangeEvent>();
|
||||
private _onDidSaveDocument = new Emitter<vscode.TextDocument>();
|
||||
private readonly _onDidAddDocument = new Emitter<vscode.TextDocument>();
|
||||
private readonly _onDidRemoveDocument = new Emitter<vscode.TextDocument>();
|
||||
private readonly _onDidChangeDocument = new Emitter<vscode.TextDocumentChangeEvent>();
|
||||
private readonly _onDidSaveDocument = new Emitter<vscode.TextDocument>();
|
||||
|
||||
readonly onDidAddDocument: Event<vscode.TextDocument> = this._onDidAddDocument.event;
|
||||
readonly onDidRemoveDocument: Event<vscode.TextDocument> = this._onDidRemoveDocument.event;
|
||||
|
||||
@@ -16,9 +16,9 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'
|
||||
|
||||
class FileSystemWatcher implements vscode.FileSystemWatcher {
|
||||
|
||||
private _onDidCreate = new Emitter<vscode.Uri>();
|
||||
private _onDidChange = new Emitter<vscode.Uri>();
|
||||
private _onDidDelete = new Emitter<vscode.Uri>();
|
||||
private readonly _onDidCreate = new Emitter<vscode.Uri>();
|
||||
private readonly _onDidChange = new Emitter<vscode.Uri>();
|
||||
private readonly _onDidDelete = new Emitter<vscode.Uri>();
|
||||
private _disposable: Disposable;
|
||||
private _config: number;
|
||||
|
||||
|
||||
@@ -246,10 +246,10 @@ class ExtHostQuickInput implements QuickInput {
|
||||
private _placeholder: string;
|
||||
private _buttons: QuickInputButton[] = [];
|
||||
private _handlesToButtons = new Map<number, QuickInputButton>();
|
||||
private _onDidAcceptEmitter = new Emitter<void>();
|
||||
private _onDidChangeValueEmitter = new Emitter<string>();
|
||||
private _onDidTriggerButtonEmitter = new Emitter<QuickInputButton>();
|
||||
private _onDidHideEmitter = new Emitter<void>();
|
||||
private readonly _onDidAcceptEmitter = new Emitter<void>();
|
||||
private readonly _onDidChangeValueEmitter = new Emitter<string>();
|
||||
private readonly _onDidTriggerButtonEmitter = new Emitter<QuickInputButton>();
|
||||
private readonly _onDidHideEmitter = new Emitter<void>();
|
||||
private _updateTimeout: any;
|
||||
private _pendingUpdate: TransferQuickInput = { id: this._id };
|
||||
|
||||
@@ -486,9 +486,9 @@ class ExtHostQuickPick<T extends QuickPickItem> extends ExtHostQuickInput implem
|
||||
private _matchOnDescription = true;
|
||||
private _matchOnDetail = true;
|
||||
private _activeItems: T[] = [];
|
||||
private _onDidChangeActiveEmitter = new Emitter<T[]>();
|
||||
private readonly _onDidChangeActiveEmitter = new Emitter<T[]>();
|
||||
private _selectedItems: T[] = [];
|
||||
private _onDidChangeSelectionEmitter = new Emitter<T[]>();
|
||||
private readonly _onDidChangeSelectionEmitter = new Emitter<T[]>();
|
||||
|
||||
constructor(proxy: MainThreadQuickOpenShape, extensionId: ExtensionIdentifier, enableProposedApi: boolean, onDispose: () => void) {
|
||||
super(proxy, extensionId, onDispose);
|
||||
|
||||
@@ -157,7 +157,7 @@ export class ExtHostSCMInputBox implements vscode.SourceControlInputBox {
|
||||
this.updateValue(value);
|
||||
}
|
||||
|
||||
private _onDidChange = new Emitter<string>();
|
||||
private readonly _onDidChange = new Emitter<string>();
|
||||
|
||||
get onDidChange(): Event<string> {
|
||||
return this._onDidChange.event;
|
||||
@@ -233,9 +233,9 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
|
||||
private _resourceStatesMap: Map<ResourceStateHandle, vscode.SourceControlResourceState> = new Map<ResourceStateHandle, vscode.SourceControlResourceState>();
|
||||
private _resourceStatesCommandsMap: Map<ResourceStateHandle, vscode.Command> = new Map<ResourceStateHandle, vscode.Command>();
|
||||
|
||||
private _onDidUpdateResourceStates = new Emitter<void>();
|
||||
private readonly _onDidUpdateResourceStates = new Emitter<void>();
|
||||
readonly onDidUpdateResourceStates = this._onDidUpdateResourceStates.event;
|
||||
private _onDidDispose = new Emitter<void>();
|
||||
private readonly _onDidDispose = new Emitter<void>();
|
||||
readonly onDidDispose = this._onDidDispose.event;
|
||||
|
||||
private _handlesSnapshot: number[] = [];
|
||||
@@ -451,7 +451,7 @@ class ExtHostSourceControl implements vscode.SourceControl {
|
||||
return this._selected;
|
||||
}
|
||||
|
||||
private _onDidChangeSelection = new Emitter<boolean>();
|
||||
private readonly _onDidChangeSelection = new Emitter<boolean>();
|
||||
readonly onDidChangeSelection = this._onDidChangeSelection.event;
|
||||
|
||||
private handle: number = ExtHostSourceControl._handlePool++;
|
||||
@@ -535,7 +535,7 @@ export class ExtHostSCM implements ExtHostSCMShape {
|
||||
private _sourceControls: Map<ProviderHandle, ExtHostSourceControl> = new Map<ProviderHandle, ExtHostSourceControl>();
|
||||
private _sourceControlsByExtension: Map<string, ExtHostSourceControl[]> = new Map<string, ExtHostSourceControl[]>();
|
||||
|
||||
private _onDidChangeActiveProvider = new Emitter<vscode.SourceControl>();
|
||||
private readonly _onDidChangeActiveProvider = new Emitter<vscode.SourceControl>();
|
||||
get onDidChangeActiveProvider(): Event<vscode.SourceControl> { return this._onDidChangeActiveProvider.event; }
|
||||
|
||||
private _selectedSourceControlHandles = new Set<number>();
|
||||
|
||||
@@ -20,7 +20,7 @@ export class ExtHostStorage implements ExtHostStorageShape {
|
||||
|
||||
private _proxy: MainThreadStorageShape;
|
||||
|
||||
private _onDidChangeStorage = new Emitter<IStorageChangeEvent>();
|
||||
private readonly _onDidChangeStorage = new Emitter<IStorageChangeEvent>();
|
||||
readonly onDidChangeStorage = this._onDidChangeStorage.event;
|
||||
|
||||
constructor(mainContext: IExtHostRpcService) {
|
||||
|
||||
@@ -18,7 +18,7 @@ export class ExtHostWindow implements ExtHostWindowShape {
|
||||
|
||||
private _proxy: MainThreadWindowShape;
|
||||
|
||||
private _onDidChangeWindowState = new Emitter<WindowState>();
|
||||
private readonly _onDidChangeWindowState = new Emitter<WindowState>();
|
||||
readonly onDidChangeWindowState: Event<WindowState> = this._onDidChangeWindowState.event;
|
||||
|
||||
private _state = ExtHostWindow.InitialState;
|
||||
|
||||
Reference in New Issue
Block a user