Skip to content

Commit

Permalink
[vscode] vscode.extension.contributes.configuration can be array
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Efftinge <sven.efftinge@typefox.io>
  • Loading branch information
svenefftinge committed Sep 2, 2019
1 parent 1bd17a3 commit cb213f4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/plugin-ext/src/common/plugin-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export namespace PluginPackage {
* This interface describes a package.json contribution section object.
*/
export interface PluginPackageContribution {
configuration?: RecursivePartial<PreferenceSchema>;
configuration?: RecursivePartial<PreferenceSchema> | RecursivePartial<PreferenceSchema>[];
configurationDefaults?: RecursivePartial<PreferenceSchemaProperties>;
languages?: PluginPackageLanguageContribution[];
grammars?: PluginPackageGrammarsContribution[];
Expand Down Expand Up @@ -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[];
Expand Down
14 changes: 12 additions & 2 deletions packages/plugin-ext/src/hosted/node/scanners/scanner-theia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cb213f4

Please sign in to comment.