Skip to content

Commit

Permalink
Use flat structure for extension kind setting
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Apr 17, 2019
1 parent 0ca6026 commit 006078a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
21 changes: 13 additions & 8 deletions src/vs/platform/extensions/node/extensionsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@ import product from 'vs/platform/product/node/product';

export function isUIExtension(manifest: IExtensionManifest, uiContributions: string[], configurationService: IConfigurationService): boolean {
const extensionId = getGalleryExtensionId(manifest.publisher, manifest.name);
const { ui, workspace } = configurationService.getValue<{ ui: string[], workspace: string[] }>('extensions.extensionKind') || { ui: [], workspace: [] };
if (isNonEmptyArray(workspace) && workspace.some(id => areSameExtensions({ id }, { id: extensionId }))) {
return false;
}
if (isNonEmptyArray(ui) && ui.some(id => areSameExtensions({ id }, { id: extensionId }))) {
return true;
}
switch (manifest.extensionKind) {
const extensionKind = getExtensionKind(manifest, configurationService);
switch (extensionKind) {
case 'ui': return true;
case 'workspace': return false;
default: {
Expand All @@ -38,3 +32,14 @@ export function isUIExtension(manifest: IExtensionManifest, uiContributions: str
}
}
}

function getExtensionKind(manifest: IExtensionManifest, configurationService: IConfigurationService): string | undefined {
const extensionId = getGalleryExtensionId(manifest.publisher, manifest.name);
const configuredExtensionKinds = configurationService.getValue<{ [key: string]: string }>('extensions.extensionKind') || {};
for (const id of Object.keys(configuredExtensionKinds)) {
if (areSameExtensions({ id: extensionId }, { id })) {
return configuredExtensionKinds[id];
}
}
return manifest.extensionKind;
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,26 +244,23 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
},
'extensions.extensionKind': {
type: 'object',
description: localize('extensions.extensionKind', "Configure ui or workspace extensions and allow them to run locally or remotely in a remote window."),
properties: {
'ui': {
type: 'array',
items: {
type: 'string',
pattern: '^([a-z0-9A-Z][a-z0-9\-A-Z]*)\\.([a-z0-9A-Z][a-z0-9\-A-Z]*)$',
}
description: localize('extensions.extensionKind', "Configure ui or workspace extensions and allow them to enable locally or remotely in a remote window."),
patternProperties: {
'([a-z0-9A-Z][a-z0-9\-A-Z]*)\\.([a-z0-9A-Z][a-z0-9\-A-Z]*)$': {
type: 'string',
enum: [
'ui',
'workspace'
],
enumDescriptions: [
localize('ui', "UI extension kind. Such extensions are enabled only when available locally in a remote window."),
localize('workspace', "Workspace extension kind. Such extensions are enabled only when avialable on remote server in a remote window.")
],
default: 'ui'
},
'workspace': {
type: 'array',
items: {
type: 'string',
pattern: '^([a-z0-9A-Z][a-z0-9\-A-Z]*)\\.([a-z0-9A-Z][a-z0-9\-A-Z]*)$',
}
}
},
default: {
ui: [],
workspace: []
'pub.name': 'ui'
}
}
}
Expand Down

0 comments on commit 006078a

Please sign in to comment.