mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
remove forEach usage (#154259)
* remove forEach usage * remove extra line
This commit is contained in:
parent
4ba0070de9
commit
585b6685dd
|
@ -5,7 +5,6 @@
|
|||
|
||||
import { isNonEmptyArray } from 'vs/base/common/arrays';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { forEach } from 'vs/base/common/collections';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IConfigBasedExtensionTip as IRawConfigBasedExtensionTip } from 'vs/base/common/product';
|
||||
import { joinPath } from 'vs/base/common/resources';
|
||||
|
@ -31,7 +30,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
|
|||
) {
|
||||
super();
|
||||
if (this.productService.configBasedExtensionTips) {
|
||||
forEach(this.productService.configBasedExtensionTips, ({ value }) => this.allConfigBasedTips.set(value.configPath, value));
|
||||
Object.entries(this.productService.configBasedExtensionTips).forEach(([, value]) => this.allConfigBasedTips.set(value.configPath, value));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +59,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
|
|||
try {
|
||||
const content = await this.fileService.readFile(joinPath(folder, configPath));
|
||||
const recommendationByRemote: Map<string, IConfigBasedExtensionTip> = new Map<string, IConfigBasedExtensionTip>();
|
||||
forEach(tip.recommendations, ({ key, value }) => {
|
||||
Object.entries(tip.recommendations).forEach(([key, value]) => {
|
||||
if (isNonEmptyArray(value.remotes)) {
|
||||
for (const remote of value.remotes) {
|
||||
recommendationByRemote.set(remote, {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { isNonEmptyArray } from 'vs/base/common/arrays';
|
||||
import { disposableTimeout, timeout } from 'vs/base/common/async';
|
||||
import { forEach, IStringDictionary } from 'vs/base/common/collections';
|
||||
import { IStringDictionary } from 'vs/base/common/collections';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { join } from 'vs/base/common/path';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
|
@ -67,11 +67,11 @@ export class ExtensionTipsService extends BaseExtensionTipsService {
|
|||
) {
|
||||
super(fileService, productService, requestService, logService);
|
||||
if (productService.exeBasedExtensionTips) {
|
||||
forEach(productService.exeBasedExtensionTips, ({ key, value: exeBasedExtensionTip }) => {
|
||||
Object.entries(productService.exeBasedExtensionTips).forEach(([key, exeBasedExtensionTip]) => {
|
||||
const highImportanceRecommendations: { extensionId: string; extensionName: string; isExtensionPack: boolean }[] = [];
|
||||
const mediumImportanceRecommendations: { extensionId: string; extensionName: string; isExtensionPack: boolean }[] = [];
|
||||
const otherRecommendations: { extensionId: string; extensionName: string; isExtensionPack: boolean }[] = [];
|
||||
forEach(exeBasedExtensionTip.recommendations, ({ key: extensionId, value }) => {
|
||||
Object.entries(exeBasedExtensionTip.recommendations).forEach(([extensionId, value]) => {
|
||||
if (value.important) {
|
||||
if (exeBasedExtensionTip.important) {
|
||||
highImportanceRecommendations.push({ extensionId, extensionName: value.name, isExtensionPack: !!value.isExtensionPack });
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { coalesce } from 'vs/base/common/arrays';
|
||||
import { forEach } from 'vs/base/common/collections';
|
||||
import { IJSONSchema } from 'vs/base/common/jsonSchema';
|
||||
import * as resources from 'vs/base/common/resources';
|
||||
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
|
||||
|
@ -322,16 +321,16 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
|
|||
let activityBarOrder = CUSTOM_VIEWS_START_ORDER + viewContainersRegistry.all.filter(v => !!v.extensionId && viewContainersRegistry.getViewContainerLocation(v) === ViewContainerLocation.Sidebar).length;
|
||||
let panelOrder = 5 + viewContainersRegistry.all.filter(v => !!v.extensionId && viewContainersRegistry.getViewContainerLocation(v) === ViewContainerLocation.Panel).length + 1;
|
||||
for (const { value, collector, description } of extensionPoints) {
|
||||
forEach(value, entry => {
|
||||
if (!this.isValidViewsContainer(entry.value, collector)) {
|
||||
Object.entries(value).forEach(([key, value]) => {
|
||||
if (!this.isValidViewsContainer(value, collector)) {
|
||||
return;
|
||||
}
|
||||
switch (entry.key) {
|
||||
switch (key) {
|
||||
case 'activitybar':
|
||||
activityBarOrder = this.registerCustomViewContainers(entry.value, description, activityBarOrder, existingViewContainers, ViewContainerLocation.Sidebar);
|
||||
activityBarOrder = this.registerCustomViewContainers(value, description, activityBarOrder, existingViewContainers, ViewContainerLocation.Sidebar);
|
||||
break;
|
||||
case 'panel':
|
||||
panelOrder = this.registerCustomViewContainers(entry.value, description, panelOrder, existingViewContainers, ViewContainerLocation.Panel);
|
||||
panelOrder = this.registerCustomViewContainers(value, description, panelOrder, existingViewContainers, ViewContainerLocation.Panel);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
@ -455,22 +454,22 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
|
|||
for (const extension of extensions) {
|
||||
const { value, collector } = extension;
|
||||
|
||||
forEach(value, entry => {
|
||||
if (!this.isValidViewDescriptors(entry.value, collector)) {
|
||||
Object.entries(value).forEach(([key, value]) => {
|
||||
if (!this.isValidViewDescriptors(value, collector)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.key === 'remote' && !isProposedApiEnabled(extension.description, 'contribViewsRemote')) {
|
||||
collector.warn(localize('ViewContainerRequiresProposedAPI', "View container '{0}' requires 'enabledApiProposals: [\"contribViewsRemote\"]' to be added to 'Remote'.", entry.key));
|
||||
if (key === 'remote' && !isProposedApiEnabled(extension.description, 'contribViewsRemote')) {
|
||||
collector.warn(localize('ViewContainerRequiresProposedAPI', "View container '{0}' requires 'enabledApiProposals: [\"contribViewsRemote\"]' to be added to 'Remote'.", key));
|
||||
return;
|
||||
}
|
||||
|
||||
const viewContainer = this.getViewContainer(entry.key);
|
||||
const viewContainer = this.getViewContainer(key);
|
||||
if (!viewContainer) {
|
||||
collector.warn(localize('ViewContainerDoesnotExist', "View container '{0}' does not exist and all views registered to it will be added to 'Explorer'.", entry.key));
|
||||
collector.warn(localize('ViewContainerDoesnotExist', "View container '{0}' does not exist and all views registered to it will be added to 'Explorer'.", key));
|
||||
}
|
||||
const container = viewContainer || this.getDefaultViewContainer();
|
||||
const viewDescriptors = coalesce(entry.value.map((item, index) => {
|
||||
const viewDescriptors = coalesce(value.map((item, index) => {
|
||||
// validate
|
||||
if (viewIds.has(item.id)) {
|
||||
collector.error(localize('duplicateView1', "Cannot register multiple views with same id `{0}`", item.id));
|
||||
|
@ -514,7 +513,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
|
|||
collapsed: this.showCollapsed(container) || initialVisibility === InitialVisibility.Collapsed,
|
||||
order: order,
|
||||
extensionId: extension.description.identifier,
|
||||
originalContainerId: entry.key,
|
||||
originalContainerId: key,
|
||||
group: item.group,
|
||||
remoteAuthority: item.remoteName || (<any>item).remoteAuthority, // TODO@roblou - delete after remote extensions are updated
|
||||
hideByDefault: initialVisibility === InitialVisibility.Hidden,
|
||||
|
|
|
@ -14,7 +14,7 @@ import { localize } from 'vs/nls';
|
|||
import { StorageScope, IStorageService, StorageTarget } from 'vs/platform/storage/common/storage';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { ImportantExtensionTip } from 'vs/base/common/product';
|
||||
import { forEach, IStringDictionary } from 'vs/base/common/collections';
|
||||
import { IStringDictionary } from 'vs/base/common/collections';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { basename, extname } from 'vs/base/common/resources';
|
||||
|
@ -115,10 +115,10 @@ export class FileBasedRecommendations extends ExtensionRecommendations {
|
|||
this.tasExperimentService = tasExperimentService;
|
||||
|
||||
if (productService.extensionTips) {
|
||||
forEach(productService.extensionTips, ({ key, value }) => this.extensionTips.set(key.toLowerCase(), value));
|
||||
Object.entries(productService.extensionTips).forEach(([key, value]) => this.extensionTips.set(key.toLowerCase(), value));
|
||||
}
|
||||
if (productService.extensionImportantTips) {
|
||||
forEach(productService.extensionImportantTips, ({ key, value }) => this.importantExtensionTips.set(key.toLowerCase(), value));
|
||||
Object.entries(productService.extensionImportantTips).forEach(([key, value]) => this.importantExtensionTips.set(key.toLowerCase(), value));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ export class FileBasedRecommendations extends ExtensionRecommendations {
|
|||
const cachedRecommendations = this.getCachedRecommendations();
|
||||
const now = Date.now();
|
||||
// Retire existing recommendations if they are older than a week or are not part of this.productService.extensionTips anymore
|
||||
forEach(cachedRecommendations, ({ key, value }) => {
|
||||
Object.entries(cachedRecommendations).forEach(([key, value]) => {
|
||||
const diff = (now - value) / milliSecondsInADay;
|
||||
if (diff <= 7 && allRecommendations.indexOf(key) > -1) {
|
||||
this.fileBasedRecommendations.set(key.toLowerCase(), { recommendedTime: value });
|
||||
|
@ -400,7 +400,7 @@ export class FileBasedRecommendations extends ExtensionRecommendations {
|
|||
storedRecommendations = storedRecommendations.reduce((result, id) => { result[id] = Date.now(); return result; }, <IStringDictionary<number>>{});
|
||||
}
|
||||
const result: IStringDictionary<number> = {};
|
||||
forEach(storedRecommendations, ({ key, value }) => {
|
||||
Object.entries(storedRecommendations).forEach(([key, value]) => {
|
||||
if (typeof value === 'number') {
|
||||
result[key.toLowerCase()] = value;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
|
|||
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
|
||||
import { IWorkspaceTrustManagementService } from 'vs/platform/workspace/common/workspaceTrust';
|
||||
import { delta, distinct } from 'vs/base/common/arrays';
|
||||
import { forEach, IStringDictionary } from 'vs/base/common/collections';
|
||||
import { IStringDictionary } from 'vs/base/common/collections';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { IWorkbenchAssignmentService } from 'vs/workbench/services/assignment/common/assignmentService';
|
||||
import { isUndefined } from 'vs/base/common/types';
|
||||
|
@ -1218,7 +1218,7 @@ class RegisterConfigurationSchemasContribution extends Disposable implements IWo
|
|||
}
|
||||
|
||||
const result: IStringDictionary<IConfigurationPropertySchema> = {};
|
||||
forEach(properties, ({ key, value }) => {
|
||||
Object.entries(properties).forEach(([key, value]) => {
|
||||
if (!value.restricted) {
|
||||
result[key] = value;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storag
|
|||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { validateExtensionManifest } from 'vs/platform/extensions/common/extensionValidator';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { IStringDictionary, forEach } from 'vs/base/common/collections';
|
||||
import { IStringDictionary } from 'vs/base/common/collections';
|
||||
|
||||
type GalleryExtensionInfo = { readonly id: string; preRelease?: boolean; migrateStorageFrom?: string };
|
||||
type ExtensionInfo = { readonly id: string; preRelease: boolean };
|
||||
|
@ -737,7 +737,7 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
|
|||
let packageNLSUris: Map<string, URI> | undefined;
|
||||
if (e.packageNLSUris) {
|
||||
packageNLSUris = new Map<string, URI>();
|
||||
forEach<UriComponents>(e.packageNLSUris, (entry) => packageNLSUris!.set(entry.key, URI.revive(entry.value)));
|
||||
Object.entries(e.packageNLSUris).forEach(([key, value]) => packageNLSUris!.set(key, URI.revive(value)));
|
||||
}
|
||||
|
||||
webExtensions.push({
|
||||
|
|
Loading…
Reference in a new issue