Skip to content

Commit 70dc559

Browse files
committed
Marking arrays readonly in ExtensionPointUserDelta
1 parent 4707bc5 commit 70dc559

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/vs/workbench/api/browser/viewsExtensionPoint.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
210210
});
211211
}
212212

213-
private addCustomViewContainers(extensionPoints: IExtensionPointUser<ViewContainerExtensionPointType>[], existingViewContainers: ViewContainer[]): void {
213+
private addCustomViewContainers(extensionPoints: readonly IExtensionPointUser<ViewContainerExtensionPointType>[], existingViewContainers: ViewContainer[]): void {
214214
const viewContainersRegistry = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry);
215215
let order = TEST_VIEW_CONTAINER_ORDER + viewContainersRegistry.all.filter(v => !!v.extensionId).length + 1;
216216
for (let { value, collector, description } of extensionPoints) {
@@ -227,7 +227,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
227227
}
228228
}
229229

230-
private removeCustomViewContainers(extensionPoints: IExtensionPointUser<ViewContainerExtensionPointType>[]): void {
230+
private removeCustomViewContainers(extensionPoints: readonly IExtensionPointUser<ViewContainerExtensionPointType>[]): void {
231231
const viewContainersRegistry = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry);
232232
const removedExtensions: Set<string> = extensionPoints.reduce((result, e) => { result.add(ExtensionIdentifier.toKey(e.description.identifier)); return result; }, new Set<string>());
233233
for (const viewContainer of viewContainersRegistry.all) {
@@ -378,7 +378,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
378378
});
379379
}
380380

381-
private addViews(extensions: IExtensionPointUser<ViewExtensionPointType>[]): void {
381+
private addViews(extensions: readonly IExtensionPointUser<ViewExtensionPointType>[]): void {
382382
for (const extension of extensions) {
383383
const { value, collector } = extension;
384384

@@ -442,7 +442,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
442442
return this.viewContainersRegistry.get(EXPLORER)!;
443443
}
444444

445-
private removeViews(extensions: IExtensionPointUser<ViewExtensionPointType>[]): void {
445+
private removeViews(extensions: readonly IExtensionPointUser<ViewExtensionPointType>[]): void {
446446
const removedExtensions: Set<string> = extensions.reduce((result, e) => { result.add(ExtensionIdentifier.toKey(e.description.identifier)); return result; }, new Set<string>());
447447
for (const viewContainer of this.viewContainersRegistry.all) {
448448
const removedViews = this.viewsRegistry.getViews(viewContainer).filter((v: ICustomViewDescriptor) => v.extensionId && removedExtensions.has(ExtensionIdentifier.toKey(v.extensionId)));

src/vs/workbench/services/extensions/common/extensionsRegistry.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ export interface IExtensionPoint<T> {
7171

7272
export class ExtensionPointUserDelta<T> {
7373

74-
private static _toSet<T>(arr: IExtensionPointUser<T>[]): Set<string> {
74+
private static _toSet<T>(arr: readonly IExtensionPointUser<T>[]): Set<string> {
7575
const result = new Set<string>();
7676
for (let i = 0, len = arr.length; i < len; i++) {
7777
result.add(ExtensionIdentifier.toKey(arr[i].description.identifier));
7878
}
7979
return result;
8080
}
8181

82-
public static compute<T>(previous: IExtensionPointUser<T>[] | null, current: IExtensionPointUser<T>[]): ExtensionPointUserDelta<T> {
82+
public static compute<T>(previous: readonly IExtensionPointUser<T>[] | null, current: readonly IExtensionPointUser<T>[]): ExtensionPointUserDelta<T> {
8383
if (!previous || !previous.length) {
8484
return new ExtensionPointUserDelta<T>(current, []);
8585
}
@@ -97,8 +97,8 @@ export class ExtensionPointUserDelta<T> {
9797
}
9898

9999
constructor(
100-
public readonly added: IExtensionPointUser<T>[],
101-
public readonly removed: IExtensionPointUser<T>[],
100+
public readonly added: readonly IExtensionPointUser<T>[],
101+
public readonly removed: readonly IExtensionPointUser<T>[],
102102
) { }
103103
}
104104

0 commit comments

Comments
 (0)