From cb213f42b97fa71fa4f3f71ca7b404158b00233d Mon Sep 17 00:00:00 2001 From: Sven Efftinge Date: Sat, 31 Aug 2019 11:13:27 +0000 Subject: [PATCH] [vscode] vscode.extension.contributes.configuration can be array Signed-off-by: Sven Efftinge --- packages/plugin-ext/src/common/plugin-protocol.ts | 4 ++-- .../src/hosted/node/scanners/scanner-theia.ts | 14 ++++++++++++-- .../main/browser/plugin-contribution-handler.ts | 8 +++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/plugin-ext/src/common/plugin-protocol.ts b/packages/plugin-ext/src/common/plugin-protocol.ts index 0db4e0f0be4ff..98bf9fea184af 100644 --- a/packages/plugin-ext/src/common/plugin-protocol.ts +++ b/packages/plugin-ext/src/common/plugin-protocol.ts @@ -63,7 +63,7 @@ export namespace PluginPackage { * This interface describes a package.json contribution section object. */ export interface PluginPackageContribution { - configuration?: RecursivePartial; + configuration?: RecursivePartial | RecursivePartial[]; configurationDefaults?: RecursivePartial; languages?: PluginPackageLanguageContribution[]; grammars?: PluginPackageGrammarsContribution[]; @@ -388,7 +388,7 @@ export interface PluginModel { * This interface describes some static plugin contributions. */ export interface PluginContribution { - configuration?: PreferenceSchema; + configuration?: PreferenceSchema | PreferenceSchema[]; configurationDefaults?: PreferenceSchemaProperties; languages?: LanguageContribution[]; grammars?: GrammarsContribution[]; diff --git a/packages/plugin-ext/src/hosted/node/scanners/scanner-theia.ts b/packages/plugin-ext/src/hosted/node/scanners/scanner-theia.ts index 905eec79a1471..0ce788a9f8cd5 100644 --- a/packages/plugin-ext/src/hosted/node/scanners/scanner-theia.ts +++ b/packages/plugin-ext/src/hosted/node/scanners/scanner-theia.ts @@ -122,8 +122,18 @@ export class TheiaPluginScanner implements PluginScanner { const contributions: PluginContribution = {}; if (rawPlugin.contributes.configuration) { - const config = this.readConfiguration(rawPlugin.contributes.configuration, rawPlugin.packagePath); - contributions.configuration = config; + if (Array.isArray(rawPlugin.contributes.configuration)) { + contributions.configuration = []; + for (const c of rawPlugin.contributes.configuration) { + const config = this.readConfiguration(c, rawPlugin.packagePath); + if (config) { + contributions.configuration.push(config); + } + } + } else { + const config = this.readConfiguration(rawPlugin.contributes.configuration, rawPlugin.packagePath); + contributions.configuration = config; + } } const configurationDefaults = rawPlugin.contributes.configurationDefaults; contributions.configurationDefaults = PreferenceSchemaProperties.is(configurationDefaults) ? configurationDefaults : undefined; diff --git a/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts b/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts index dc208ada89cfb..d2cb71a269122 100644 --- a/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts +++ b/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts @@ -83,7 +83,13 @@ export class PluginContributionHandler { handleContributions(contributions: PluginContribution): void { if (contributions.configuration) { - this.updateConfigurationSchema(contributions.configuration); + if (Array.isArray(contributions.configuration)) { + for (const config of contributions.configuration) { + this.updateConfigurationSchema(config); + } + } else { + this.updateConfigurationSchema(contributions.configuration); + } } if (contributions.configurationDefaults) { this.updateDefaultOverridesSchema(contributions.configurationDefaults);