Skip to content

Commit

Permalink
tweak generation of propsal file a little bit
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Nov 11, 2021
1 parent 6eac989 commit b48a7f3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
12 changes: 6 additions & 6 deletions build/lib/compilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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<ApiProposalName> = new Set(<ApiProposalName[]>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 = <readonly ApiProposalName[]><unknown>Object.keys(allApiProposals);',
'',
].join('\n');
const outFile = path.join(dtsFolder, '../vs/workbench/services/extensions/common/extensionsApiProposals.ts');
Expand Down
14 changes: 7 additions & 7 deletions build/lib/compilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`]);
}
}

Expand All @@ -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<ApiProposalName> = new Set(<ApiProposalName[]>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 = <readonly ApiProposalName[]><unknown>Object.keys(allApiProposals);',
'',
].join('\n');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -1143,15 +1143,16 @@ 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());
}
}

// NEW world - product.json spells out what proposals each extension can use
if (productService.extensionEnabledApiProposals) {
forEach(productService.extensionEnabledApiProposals, entry => {
const proposalNames = entry.value.filter(name => {
if (!apiProposalNames.has(<ApiProposalName>name)) {
if (!allApiProposalNames.includes(<ApiProposalName>name)) {
_logService.warn(`Extension '${key} wants API proposal '${name}' but that proposal DOES NOT EXIST.`);
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApiProposalName> = new Set(<ApiProposalName[]>Object.keys(apiProposals));
});
export type ApiProposalName = keyof typeof allApiProposals;
export const allApiProposalNames = <readonly ApiProposalName[]><unknown>Object.keys(allApiProposals);
Original file line number Diff line number Diff line change
Expand Up @@ -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<IJSONContributionRegistry>(Extensions.JSONContribution);

Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit b48a7f3

Please sign in to comment.