From b48a7f385e221e2d4cb5ba65aed351783a3bec82 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Thu, 11 Nov 2021 12:55:28 +0100 Subject: [PATCH] tweak generation of propsal file a little bit --- build/lib/compilation.js | 12 ++++++------ build/lib/compilation.ts | 14 +++++++------- .../extensions/common/abstractExtensionService.ts | 7 ++++--- .../extensions/common/extensionsApiProposals.ts | 8 ++++---- .../extensions/common/extensionsRegistry.ts | 6 ++++-- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/build/lib/compilation.js b/build/lib/compilation.js index 1ee184505e4..0c0c15f555d 100644 --- a/build/lib/compilation.js +++ b/build/lib/compilation.js @@ -186,7 +186,7 @@ function apiProposalNamesGenerator() { for (let file of fs.readdirSync(dtsFolder)) { const match = pattern.exec(file); if (match) { - proposalNames.push(match[1]); + proposalNames.push([match[1], `https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/${file}`]); } } const source = [ @@ -197,11 +197,11 @@ function apiProposalNamesGenerator() { '', '// THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY.', '', - 'const apiProposals = {', - `${proposalNames.map(name => `\t${name}: true`).join(',\n')}`, - '};', - 'export type ApiProposalName = keyof typeof apiProposals;', - 'export const apiProposalNames: ReadonlySet = new Set(Object.keys(apiProposals));', + 'export const allApiProposals = Object.freeze({', + `${proposalNames.map(t => `\t${t[0]}: '${t[1]}'`).join(',\n')}`, + '});', + 'export type ApiProposalName = keyof typeof allApiProposals;', + 'export const allApiProposalNames = Object.keys(allApiProposals);', '', ].join('\n'); const outFile = path.join(dtsFolder, '../vs/workbench/services/extensions/common/extensionsApiProposals.ts'); diff --git a/build/lib/compilation.ts b/build/lib/compilation.ts index a983753d39a..f559e07ca77 100644 --- a/build/lib/compilation.ts +++ b/build/lib/compilation.ts @@ -223,11 +223,11 @@ function apiProposalNamesGenerator() { try { const t1 = Date.now(); - const proposalNames: string[] = []; + const proposalNames: [name: string, url: string][] = []; for (let file of fs.readdirSync(dtsFolder)) { const match = pattern.exec(file); if (match) { - proposalNames.push(match[1]); + proposalNames.push([match[1], `https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/${file}`]); } } @@ -239,11 +239,11 @@ function apiProposalNamesGenerator() { '', '// THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY.', '', - 'const apiProposals = {', - `${proposalNames.map(name => `\t${name}: true`).join(',\n')}`, - '};', - 'export type ApiProposalName = keyof typeof apiProposals;', - 'export const apiProposalNames: ReadonlySet = new Set(Object.keys(apiProposals));', + 'export const allApiProposals = Object.freeze({', + `${proposalNames.map(t => `\t${t[0]}: '${t[1]}'`).join(',\n')}`, + '});', + 'export type ApiProposalName = keyof typeof allApiProposals;', + 'export const allApiProposalNames = Object.keys(allApiProposals);', '', ].join('\n'); diff --git a/src/vs/workbench/services/extensions/common/abstractExtensionService.ts b/src/vs/workbench/services/extensions/common/abstractExtensionService.ts index 3de0967db6e..6379907d099 100644 --- a/src/vs/workbench/services/extensions/common/abstractExtensionService.ts +++ b/src/vs/workbench/services/extensions/common/abstractExtensionService.ts @@ -34,7 +34,7 @@ import { URI } from 'vs/base/common/uri'; import { IExtensionManifestPropertiesService } from 'vs/workbench/services/extensions/common/extensionManifestPropertiesService'; import { Logger } from 'vs/workbench/services/extensions/common/extensionPoints'; import { dedupExtensions } from 'vs/workbench/services/extensions/common/extensionsUtil'; -import { ApiProposalName, apiProposalNames } from 'vs/workbench/services/extensions/common/extensionsApiProposals'; +import { ApiProposalName, allApiProposalNames } from 'vs/workbench/services/extensions/common/extensionsApiProposals'; import { forEach } from 'vs/base/common/collections'; import { ILogService } from 'vs/platform/log/common/log'; @@ -1143,7 +1143,7 @@ class ProposedApiController { if (isNonEmptyArray(productService.extensionAllowedProposedApi)) { for (let id of productService.extensionAllowedProposedApi) { const key = ExtensionIdentifier.toKey(id); - this._productEnabledExtensions.set(key, Array.from(apiProposalNames)); + this._productEnabledExtensions.set(key, allApiProposalNames.slice()); } } @@ -1151,7 +1151,8 @@ class ProposedApiController { if (productService.extensionEnabledApiProposals) { forEach(productService.extensionEnabledApiProposals, entry => { const proposalNames = entry.value.filter(name => { - if (!apiProposalNames.has(name)) { + if (!allApiProposalNames.includes(name)) { + _logService.warn(`Extension '${key} wants API proposal '${name}' but that proposal DOES NOT EXIST.`); return false; } return true; diff --git a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts index a8da36dd7d5..a24989b2a56 100644 --- a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts +++ b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts @@ -5,8 +5,8 @@ // THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. -const apiProposals = { +export const allApiProposals = Object.freeze({ -}; -export type ApiProposalName = keyof typeof apiProposals; -export const apiProposalNames: ReadonlySet = new Set(Object.keys(apiProposals)); +}); +export type ApiProposalName = keyof typeof allApiProposals; +export const allApiProposalNames = Object.keys(allApiProposals); diff --git a/src/vs/workbench/services/extensions/common/extensionsRegistry.ts b/src/vs/workbench/services/extensions/common/extensionsRegistry.ts index 514ca593e37..a32b31f59a3 100644 --- a/src/vs/workbench/services/extensions/common/extensionsRegistry.ts +++ b/src/vs/workbench/services/extensions/common/extensionsRegistry.ts @@ -12,7 +12,8 @@ import { Extensions, IJSONContributionRegistry } from 'vs/platform/jsonschemas/c import { Registry } from 'vs/platform/registry/common/platform'; import { IMessage } from 'vs/workbench/services/extensions/common/extensions'; import { ExtensionIdentifier, IExtensionDescription, EXTENSION_CATEGORIES, ExtensionKind } from 'vs/platform/extensions/common/extensions'; -import { apiProposalNames } from 'vs/workbench/services/extensions/common/extensionsApiProposals'; +import { allApiProposals } from 'vs/workbench/services/extensions/common/extensionsApiProposals'; +import { values } from 'vs/base/common/collections'; const schemaRegistry = Registry.as(Extensions.JSONContribution); @@ -232,7 +233,8 @@ export const schema: IJSONSchema = { uniqueItems: true, items: { type: 'string', - enum: Array.from(apiProposalNames) + enum: Object.keys(allApiProposals), + markdownEnumDescriptions: values(allApiProposals) } }, activationEvents: {