Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
change extension kind ui to be ui + workspace
deprecate string value for extension kind
  • Loading branch information
sandy081 committed Nov 29, 2019
1 parent 413a178 commit f9b6372
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 58 deletions.
2 changes: 1 addition & 1 deletion scripts/code-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async function handleRoot(req, res) {
return; // seems to fail to JSON.parse()?!
}

packageJSON.extensionKind = 'web'; // enable for Web
packageJSON.extensionKind = ['web']; // enable for Web

mapExtensionFolderToExtensionPackageJSON.set(extensionFolder, packageJSON);
} catch (error) {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,11 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
patternProperties: {
'([a-z0-9A-Z][a-z0-9\-A-Z]*)\\.([a-z0-9A-Z][a-z0-9\-A-Z]*)$': {
oneOf: [{ type: 'array', items: extensionKindSchema }, extensionKindSchema],
default: 'ui',
default: ['ui'],
},
},
default: {
'pub.name': 'ui'
'pub.name': ['ui']
}
},
'remote.downloadExtensionsLocally': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,68 +405,84 @@ suite('ExtensionEnablementService Test', () => {

test('test local workspace extension is disabled by kind', async () => {
instantiationService.stub(IExtensionManagementServerService, aMultiExtensionManagementServerService(instantiationService));
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: 'workspace' }, { location: URI.file(`pub.a`) });
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: ['workspace'] }, { location: URI.file(`pub.a`) });
testObject = new TestExtensionEnablementService(instantiationService);
assert.ok(!testObject.isEnabled(localWorkspaceExtension));
assert.deepEqual(testObject.getEnablementState(localWorkspaceExtension), EnablementState.DisabledByExtensionKind);
});

test('test local workspace + ui extension is enabled by kind', async () => {
instantiationService.stub(IExtensionManagementServerService, aMultiExtensionManagementServerService(instantiationService));
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: ['workspace', 'ui'] }, { location: URI.file(`pub.a`) });
testObject = new TestExtensionEnablementService(instantiationService);
assert.ok(testObject.isEnabled(localWorkspaceExtension));
assert.deepEqual(testObject.getEnablementState(localWorkspaceExtension), EnablementState.EnabledGlobally);
});

test('test local ui extension is not disabled by kind', async () => {
instantiationService.stub(IExtensionManagementServerService, aMultiExtensionManagementServerService(instantiationService));
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: 'ui' }, { location: URI.file(`pub.a`) });
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: ['ui'] }, { location: URI.file(`pub.a`) });
testObject = new TestExtensionEnablementService(instantiationService);
assert.ok(testObject.isEnabled(localWorkspaceExtension));
assert.deepEqual(testObject.getEnablementState(localWorkspaceExtension), EnablementState.EnabledGlobally);
});

test('test canChangeEnablement return false when the local workspace extension is disabled by kind', () => {
instantiationService.stub(IExtensionManagementServerService, aMultiExtensionManagementServerService(instantiationService));
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: 'workspace' }, { location: URI.file(`pub.a`) });
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: ['workspace'] }, { location: URI.file(`pub.a`) });
testObject = new TestExtensionEnablementService(instantiationService);
assert.equal(testObject.canChangeEnablement(localWorkspaceExtension), false);
});

test('test canChangeEnablement return true for local ui extension', () => {
instantiationService.stub(IExtensionManagementServerService, aMultiExtensionManagementServerService(instantiationService));
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: 'ui' }, { location: URI.file(`pub.a`) });
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: ['ui'] }, { location: URI.file(`pub.a`) });
testObject = new TestExtensionEnablementService(instantiationService);
assert.equal(testObject.canChangeEnablement(localWorkspaceExtension), true);
});

test('test remote ui extension is disabled by kind', async () => {
instantiationService.stub(IExtensionManagementServerService, aMultiExtensionManagementServerService(instantiationService));
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: 'ui' }, { location: URI.file(`pub.a`).with({ scheme: Schemas.vscodeRemote }) });
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: ['ui'] }, { location: URI.file(`pub.a`).with({ scheme: Schemas.vscodeRemote }) });
testObject = new TestExtensionEnablementService(instantiationService);
assert.ok(!testObject.isEnabled(localWorkspaceExtension));
assert.deepEqual(testObject.getEnablementState(localWorkspaceExtension), EnablementState.DisabledByExtensionKind);
});

test('test remote ui+workspace extension is disabled by kind', async () => {
instantiationService.stub(IExtensionManagementServerService, aMultiExtensionManagementServerService(instantiationService));
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: ['ui', 'workspace'] }, { location: URI.file(`pub.a`).with({ scheme: Schemas.vscodeRemote }) });
testObject = new TestExtensionEnablementService(instantiationService);
assert.ok(testObject.isEnabled(localWorkspaceExtension));
assert.deepEqual(testObject.getEnablementState(localWorkspaceExtension), EnablementState.EnabledGlobally);
});

test('test remote ui extension is disabled by kind when there is no local server', async () => {
instantiationService.stub(IExtensionManagementServerService, anExtensionManagementServerService(null, anExtensionManagementServer('vscode-remote', instantiationService)));
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: 'ui' }, { location: URI.file(`pub.a`).with({ scheme: Schemas.vscodeRemote }) });
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: ['ui'] }, { location: URI.file(`pub.a`).with({ scheme: Schemas.vscodeRemote }) });
testObject = new TestExtensionEnablementService(instantiationService);
assert.ok(!testObject.isEnabled(localWorkspaceExtension));
assert.deepEqual(testObject.getEnablementState(localWorkspaceExtension), EnablementState.DisabledByExtensionKind);
});

test('test remote workspace extension is not disabled by kind', async () => {
instantiationService.stub(IExtensionManagementServerService, aMultiExtensionManagementServerService(instantiationService));
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: 'workspace' }, { location: URI.file(`pub.a`).with({ scheme: Schemas.vscodeRemote }) });
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: ['workspace'] }, { location: URI.file(`pub.a`).with({ scheme: Schemas.vscodeRemote }) });
testObject = new TestExtensionEnablementService(instantiationService);
assert.ok(testObject.isEnabled(localWorkspaceExtension));
assert.deepEqual(testObject.getEnablementState(localWorkspaceExtension), EnablementState.EnabledGlobally);
});

test('test canChangeEnablement return false when the remote ui extension is disabled by kind', () => {
instantiationService.stub(IExtensionManagementServerService, aMultiExtensionManagementServerService(instantiationService));
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: 'ui' }, { location: URI.file(`pub.a`).with({ scheme: Schemas.vscodeRemote }) });
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: ['ui'] }, { location: URI.file(`pub.a`).with({ scheme: Schemas.vscodeRemote }) });
testObject = new TestExtensionEnablementService(instantiationService);
assert.equal(testObject.canChangeEnablement(localWorkspaceExtension), false);
});

test('test canChangeEnablement return true for remote workspace extension', () => {
instantiationService.stub(IExtensionManagementServerService, aMultiExtensionManagementServerService(instantiationService));
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: 'workspace' }, { location: URI.file(`pub.a`).with({ scheme: Schemas.vscodeRemote }) });
const localWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: ['workspace'] }, { location: URI.file(`pub.a`).with({ scheme: Schemas.vscodeRemote }) });
testObject = new TestExtensionEnablementService(instantiationService);
assert.equal(testObject.canChangeEnablement(localWorkspaceExtension), true);
});
Expand Down
15 changes: 12 additions & 3 deletions src/vs/workbench/services/extensions/common/extensionsRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,19 @@ export const schema: IJSONSchema = {
}
},
extensionKind: {
description: nls.localize('extensionKind', "Define the kind of an extension. `ui` extensions are installed and run on the local machine while `workspace` extensions are run on the remote."),
oneOf: [{ type: 'array', items: extensionKindSchema }, extensionKindSchema],
default: 'workspace',
description: nls.localize('extensionKind', "Define the kind of an extension. `ui` extensions are installed and run on the local machine while `workspace` extensions run on the remote."),
type: 'array',
items: extensionKindSchema,
default: ['workspace'],
defaultSnippets: [
{
body: ['ui'],
description: nls.localize('extensionKind.ui', "Define an extension which can run only on the local machine when connected to remote window.")
},
{
body: ['workspace'],
description: nls.localize('extensionKind.workspace', "Define an extension which can run only on the remote machine when connected remote window.")
},
{
body: ['ui', 'workspace'],
description: nls.localize('extensionKind.ui-workspace', "Define an extension which can run on either side, with a preference towards running on the local machine.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,5 @@ function toArray(extensionKind: ExtensionKind | ExtensionKind[]): ExtensionKind[
if (Array.isArray(extensionKind)) {
return extensionKind;
}
return [extensionKind];
return extensionKind === 'ui' ? ['ui', 'workspace'] : [extensionKind];
}

0 comments on commit f9b6372

Please sign in to comment.