diff --git a/src/vs/editor/browser/standalone/simpleServices.ts b/src/vs/editor/browser/standalone/simpleServices.ts index 108f54ccfa6..6b4314ed50c 100644 --- a/src/vs/editor/browser/standalone/simpleServices.ts +++ b/src/vs/editor/browser/standalone/simpleServices.ts @@ -278,7 +278,7 @@ export class SimplePluginService extends AbstractPluginService throw new Error('unexpected'); } - protected _actualActivatePlugin(pluginDescription: IExtensionDescription): TPromise { + protected _actualActivatePlugin(extensionDescription: IExtensionDescription): TPromise { throw new Error('unexpected'); } diff --git a/src/vs/editor/common/worker/editorWorkerServer.ts b/src/vs/editor/common/worker/editorWorkerServer.ts index 54c5668f5f0..655c2b25abb 100644 --- a/src/vs/editor/common/worker/editorWorkerServer.ts +++ b/src/vs/editor/common/worker/editorWorkerServer.ts @@ -71,7 +71,7 @@ class WorkerPluginService extends AbstractPluginService { throw new Error('unexpected'); } - protected _actualActivatePlugin(pluginDescription: IExtensionDescription): TPromise { + protected _actualActivatePlugin(extensionDescription: IExtensionDescription): TPromise { throw new Error('unexpected'); } diff --git a/src/vs/editor/test/common/servicesTestUtils.ts b/src/vs/editor/test/common/servicesTestUtils.ts index c888003374e..56b68cf6b08 100644 --- a/src/vs/editor/test/common/servicesTestUtils.ts +++ b/src/vs/editor/test/common/servicesTestUtils.ts @@ -124,7 +124,7 @@ class MockPluginService extends AbstractPluginService { throw new Error('not implemented'); } - protected _actualActivatePlugin(pluginDescription): any { + protected _actualActivatePlugin(extensionDescription): any { throw new Error('not implemented'); } } diff --git a/src/vs/platform/extensions/common/abstractPluginService.ts b/src/vs/platform/extensions/common/abstractPluginService.ts index 9e402a1b945..6393aec6d0f 100644 --- a/src/vs/platform/extensions/common/abstractPluginService.ts +++ b/src/vs/platform/extensions/common/abstractPluginService.ts @@ -35,11 +35,11 @@ export abstract class ActivatedPlugin { } export interface IActivatedPluginMap { - [pluginId: string]: T; + [extensionId: string]: T; } interface IActivatingPluginMap { - [pluginId: string]: TPromise; + [extensionId: string]: TPromise; } export abstract class AbstractPluginService implements IExtensionService { @@ -87,23 +87,23 @@ export abstract class AbstractPluginService implement return null; } - public isActivated(pluginId: string): boolean { - return hasOwnProperty.call(this.activatedPlugins, pluginId); + public isActivated(extensionId: string): boolean { + return hasOwnProperty.call(this.activatedPlugins, extensionId); } public activateByEvent(activationEvent: string): TPromise { return this._onReady.then(() => { ExtensionsRegistry.triggerActivationEventListeners(activationEvent); - let activatePlugins = ExtensionsRegistry.getPluginDescriptionsForActivationEvent(activationEvent); + let activatePlugins = ExtensionsRegistry.getExtensionDescriptionsForActivationEvent(activationEvent); return this._activatePlugins(activatePlugins, 0); }); } - public activateById(pluginId: string): TPromise { + public activateById(extensionId: string): TPromise { return this._onReady.then(() => { - let desc = ExtensionsRegistry.getPluginDescription(pluginId); + let desc = ExtensionsRegistry.getExtensionDescription(extensionId); if (!desc) { - throw new Error('Plugin `' + pluginId + '` is not known'); + throw new Error('Plugin `' + extensionId + '` is not known'); } return this._activatePlugins([desc], 0); @@ -120,7 +120,7 @@ export abstract class AbstractPluginService implement for (let j = 0, lenJ = depIds.length; j < lenJ; j++) { let depId = depIds[j]; - let depDesc = ExtensionsRegistry.getPluginDescription(depId); + let depDesc = ExtensionsRegistry.getExtensionDescription(depId); if (!depDesc) { // Error condition 1: unknown dependency @@ -151,23 +151,23 @@ export abstract class AbstractPluginService implement } } - private _activatePlugins(pluginDescriptions: IExtensionDescription[], recursionLevel: number): TPromise { - // console.log(recursionLevel, '_activatePlugins: ', pluginDescriptions.map(p => p.id)); - if (pluginDescriptions.length === 0) { + private _activatePlugins(extensionDescriptions: IExtensionDescription[], recursionLevel: number): TPromise { + // console.log(recursionLevel, '_activatePlugins: ', extensionDescriptions.map(p => p.id)); + if (extensionDescriptions.length === 0) { return TPromise.as(void 0); } - pluginDescriptions = pluginDescriptions.filter((p) => !hasOwnProperty.call(this.activatedPlugins, p.id)); - if (pluginDescriptions.length === 0) { + extensionDescriptions = extensionDescriptions.filter((p) => !hasOwnProperty.call(this.activatedPlugins, p.id)); + if (extensionDescriptions.length === 0) { return TPromise.as(void 0); } if (recursionLevel > 10) { // More than 10 dependencies deep => most likely a dependency loop - for (let i = 0, len = pluginDescriptions.length; i < len; i++) { + for (let i = 0, len = extensionDescriptions.length; i < len; i++) { // Error condition 3: dependency loop - this._showMessage(Severity.Error, nls.localize('failedDep2', "Extension `{0}` failed to activate. Reason: more than 10 levels of dependencies (most likely a dependency loop).", pluginDescriptions[i].id)); - this.activatedPlugins[pluginDescriptions[i].id] = this._createFailedPlugin(); + this._showMessage(Severity.Error, nls.localize('failedDep2', "Extension `{0}` failed to activate. Reason: more than 10 levels of dependencies (most likely a dependency loop).", extensionDescriptions[i].id)); + this.activatedPlugins[extensionDescriptions[i].id] = this._createFailedPlugin(); } return TPromise.as(void 0); } @@ -175,8 +175,8 @@ export abstract class AbstractPluginService implement let greenMap: { [id: string]: IExtensionDescription; } = Object.create(null), red: IExtensionDescription[] = []; - for (let i = 0, len = pluginDescriptions.length; i < len; i++) { - this._handleActivateRequest(pluginDescriptions[i], greenMap, red); + for (let i = 0, len = extensionDescriptions.length; i < len; i++) { + this._handleActivateRequest(extensionDescriptions[i], greenMap, red); } // Make sure no red is also green @@ -201,30 +201,30 @@ export abstract class AbstractPluginService implement }); } - protected _activatePlugin(pluginDescription: IExtensionDescription): TPromise { - if (hasOwnProperty.call(this.activatedPlugins, pluginDescription.id)) { + protected _activatePlugin(extensionDescription: IExtensionDescription): TPromise { + if (hasOwnProperty.call(this.activatedPlugins, extensionDescription.id)) { return TPromise.as(void 0); } - if (hasOwnProperty.call(this.activatingPlugins, pluginDescription.id)) { - return this.activatingPlugins[pluginDescription.id]; + if (hasOwnProperty.call(this.activatingPlugins, extensionDescription.id)) { + return this.activatingPlugins[extensionDescription.id]; } - this.activatingPlugins[pluginDescription.id] = this._actualActivatePlugin(pluginDescription).then(null, (err) => { - this._showMessage(Severity.Error, nls.localize('activationError', "Activating extension `{0}` failed: {1}.", pluginDescription.id, err.message)); - console.error('Activating extension `' + pluginDescription.id + '` failed: ', err.message); + this.activatingPlugins[extensionDescription.id] = this._actualActivatePlugin(extensionDescription).then(null, (err) => { + this._showMessage(Severity.Error, nls.localize('activationError', "Activating extension `{0}` failed: {1}.", extensionDescription.id, err.message)); + console.error('Activating extension `' + extensionDescription.id + '` failed: ', err.message); console.log('Here is the error stack: ', err.stack); // Treat the plugin as being empty return this._createFailedPlugin(); }).then((x: T) => { - this.activatedPlugins[pluginDescription.id] = x; - delete this.activatingPlugins[pluginDescription.id]; + this.activatedPlugins[extensionDescription.id] = x; + delete this.activatingPlugins[extensionDescription.id]; }); - return this.activatingPlugins[pluginDescription.id]; + return this.activatingPlugins[extensionDescription.id]; } protected abstract _createFailedPlugin(): T; - protected abstract _actualActivatePlugin(pluginDescription: IExtensionDescription): TPromise; + protected abstract _actualActivatePlugin(extensionDescription: IExtensionDescription): TPromise; } diff --git a/src/vs/platform/extensions/common/extensionsRegistry.ts b/src/vs/platform/extensions/common/extensionsRegistry.ts index 0c1a3e16086..d8e134b3e2b 100644 --- a/src/vs/platform/extensions/common/extensionsRegistry.ts +++ b/src/vs/platform/extensions/common/extensionsRegistry.ts @@ -19,18 +19,18 @@ export interface IExtensionMessageCollector { info(message: any): void; } -export interface IPluginsMessageCollector { +export interface IExtensionsMessageCollector { error(source: string, message: any): void; warn(source: string, message: any): void; info(source: string, message: any): void; scopeTo(source: string): IExtensionMessageCollector; } -class ScopedMessageCollector implements IExtensionMessageCollector { +class ExtensionMessageCollector implements IExtensionMessageCollector { private _scope: string; - private _actual: IPluginsMessageCollector; + private _actual: IExtensionsMessageCollector; - constructor(scope: string, actual: IPluginsMessageCollector) { + constructor(scope: string, actual: IExtensionsMessageCollector) { this._scope = scope; this._actual = actual; } @@ -48,15 +48,15 @@ class ScopedMessageCollector implements IExtensionMessageCollector { } } -export interface IMessageHandler { +export interface IExtensionsMessageHandler { (severity: Severity, source: string, message: string): void; } -class PluginsMessageForwarder implements IPluginsMessageCollector { +class ExtensionsMessageForwarder implements IExtensionsMessageCollector { - private _handler: IMessageHandler; + private _handler: IExtensionsMessageHandler; - constructor(handler: IMessageHandler) { + constructor(handler: IExtensionsMessageHandler) { this._handler = handler; } @@ -88,11 +88,11 @@ class PluginsMessageForwarder implements IPluginsMessageCollector { } public scopeTo(source: string): IExtensionMessageCollector { - return new ScopedMessageCollector(source, this); + return new ExtensionMessageCollector(source, this); } } -export class PluginsMessageCollector implements IPluginsMessageCollector { +export class ExtensionsMessageCollector implements IExtensionsMessageCollector { private _messages: IMessage[]; @@ -132,73 +132,73 @@ export class PluginsMessageCollector implements IPluginsMessageCollector { } public scopeTo(source: string): IExtensionMessageCollector { - return new ScopedMessageCollector(source, this); + return new ExtensionMessageCollector(source, this); } } -export function isValidPluginDescription(extensionFolderPath: string, pluginDescription: IExtensionDescription, notices: string[]): boolean { - if (!pluginDescription) { - notices.push(nls.localize('pluginDescription.empty', "Got empty extension description")); +export function isValidExtensionDescription(extensionFolderPath: string, extensionDescription: IExtensionDescription, notices: string[]): boolean { + if (!extensionDescription) { + notices.push(nls.localize('extensionDescription.empty', "Got empty extension description")); return false; } - if (typeof pluginDescription.publisher !== 'string') { - notices.push(nls.localize('pluginDescription.publisher', "property `{0}` is mandatory and must be of type `string`", 'publisher')); + if (typeof extensionDescription.publisher !== 'string') { + notices.push(nls.localize('extensionDescription.publisher', "property `{0}` is mandatory and must be of type `string`", 'publisher')); return false; } - if (typeof pluginDescription.name !== 'string') { - notices.push(nls.localize('pluginDescription.name', "property `{0}` is mandatory and must be of type `string`", 'name')); + if (typeof extensionDescription.name !== 'string') { + notices.push(nls.localize('extensionDescription.name', "property `{0}` is mandatory and must be of type `string`", 'name')); return false; } - if (typeof pluginDescription.version !== 'string') { - notices.push(nls.localize('pluginDescription.version', "property `{0}` is mandatory and must be of type `string`", 'version')); + if (typeof extensionDescription.version !== 'string') { + notices.push(nls.localize('extensionDescription.version', "property `{0}` is mandatory and must be of type `string`", 'version')); return false; } - if (!pluginDescription.engines) { - notices.push(nls.localize('pluginDescription.engines', "property `{0}` is mandatory and must be of type `object`", 'engines')); + if (!extensionDescription.engines) { + notices.push(nls.localize('extensionDescription.engines', "property `{0}` is mandatory and must be of type `object`", 'engines')); return false; } - if (typeof pluginDescription.engines.vscode !== 'string') { - notices.push(nls.localize('pluginDescription.engines.vscode', "property `{0}` is mandatory and must be of type `string`", 'engines.vscode')); + if (typeof extensionDescription.engines.vscode !== 'string') { + notices.push(nls.localize('extensionDescription.engines.vscode', "property `{0}` is mandatory and must be of type `string`", 'engines.vscode')); return false; } - if (typeof pluginDescription.extensionDependencies !== 'undefined') { - if (!_isStringArray(pluginDescription.extensionDependencies)) { - notices.push(nls.localize('pluginDescription.extensionDependencies', "property `{0}` can be omitted or must be of type `string[]`", 'extensionDependencies')); + if (typeof extensionDescription.extensionDependencies !== 'undefined') { + if (!_isStringArray(extensionDescription.extensionDependencies)) { + notices.push(nls.localize('extensionDescription.extensionDependencies', "property `{0}` can be omitted or must be of type `string[]`", 'extensionDependencies')); return false; } } - if (typeof pluginDescription.activationEvents !== 'undefined') { - if (!_isStringArray(pluginDescription.activationEvents)) { - notices.push(nls.localize('pluginDescription.activationEvents1', "property `{0}` can be omitted or must be of type `string[]`", 'activationEvents')); + if (typeof extensionDescription.activationEvents !== 'undefined') { + if (!_isStringArray(extensionDescription.activationEvents)) { + notices.push(nls.localize('extensionDescription.activationEvents1', "property `{0}` can be omitted or must be of type `string[]`", 'activationEvents')); return false; } - if (typeof pluginDescription.main === 'undefined') { - notices.push(nls.localize('pluginDescription.activationEvents2', "properties `{0}` and `{1}` must both be specified or must both be omitted", 'activationEvents', 'main')); + if (typeof extensionDescription.main === 'undefined') { + notices.push(nls.localize('extensionDescription.activationEvents2', "properties `{0}` and `{1}` must both be specified or must both be omitted", 'activationEvents', 'main')); return false; } } - if (typeof pluginDescription.main !== 'undefined') { - if (typeof pluginDescription.main !== 'string') { - notices.push(nls.localize('pluginDescription.main1', "property `{0}` can be omitted or must be of type `string`", 'main')); + if (typeof extensionDescription.main !== 'undefined') { + if (typeof extensionDescription.main !== 'string') { + notices.push(nls.localize('extensionDescription.main1', "property `{0}` can be omitted or must be of type `string`", 'main')); return false; } else { - let normalizedAbsolutePath = paths.normalize(paths.join(extensionFolderPath, pluginDescription.main)); + let normalizedAbsolutePath = paths.normalize(paths.join(extensionFolderPath, extensionDescription.main)); if (normalizedAbsolutePath.indexOf(extensionFolderPath)) { - notices.push(nls.localize('pluginDescription.main2', "Expected `main` ({0}) to be included inside extension's folder ({1}). This might make the extension non-portable.", normalizedAbsolutePath, extensionFolderPath)); + notices.push(nls.localize('extensionDescription.main2', "Expected `main` ({0}) to be included inside extension's folder ({1}). This might make the extension non-portable.", normalizedAbsolutePath, extensionFolderPath)); // not a failure case } } - if (typeof pluginDescription.activationEvents === 'undefined') { - notices.push(nls.localize('pluginDescription.main3', "properties `{0}` and `{1}` must both be specified or must both be omitted", 'activationEvents', 'main')); + if (typeof extensionDescription.activationEvents === 'undefined') { + notices.push(nls.localize('extensionDescription.main3', "properties `{0}` and `{1}` must both be specified or must both be omitted", 'activationEvents', 'main')); return false; } } return true; } -interface IPluginDescriptionMap { - [pluginId: string]: IExtensionDescription; +interface IExtensionDescriptionMap { + [extensionId: string]: IExtensionDescription; } const hasOwnProperty = Object.hasOwnProperty; let schemaRegistry = Registry.as(Extensions.JSONContribution); @@ -218,28 +218,28 @@ export interface IExtensionPoint { setHandler(handler: IExtensionPointHandler): void; } -export interface IPluginsRegistry { - registerPlugins(pluginDescriptions: IExtensionDescription[]): void; +export interface IExtensionsRegistry { + registerExtensions(extensionDescriptions: IExtensionDescription[]): void; - getPluginDescriptionsForActivationEvent(activationEvent: string): IExtensionDescription[]; - getAllPluginDescriptions(): IExtensionDescription[]; - getPluginDescription(pluginId: string): IExtensionDescription; + getExtensionDescriptionsForActivationEvent(activationEvent: string): IExtensionDescription[]; + getAllExtensionDescriptions(): IExtensionDescription[]; + getExtensionDescription(extensionId: string): IExtensionDescription; registerOneTimeActivationEventListener(activationEvent: string, listener: IActivationEventListener): void; triggerActivationEventListeners(activationEvent: string): void; registerExtensionPoint(extensionPoint: string, jsonSchema: IJSONSchema): IExtensionPoint; - handleExtensionPoints(messageHandler: IMessageHandler): void; + handleExtensionPoints(messageHandler: IExtensionsMessageHandler): void; } class ExtensionPoint implements IExtensionPoint { public name: string; - private _registry: PluginsRegistryImpl; + private _registry: ExtensionsRegistryImpl; private _handler: IExtensionPointHandler; - private _collector: IPluginsMessageCollector; + private _collector: IExtensionsMessageCollector; - constructor(name: string, registry: PluginsRegistryImpl) { + constructor(name: string, registry: ExtensionsRegistryImpl) { this.name = name; this._registry = registry; this._handler = null; @@ -254,7 +254,7 @@ class ExtensionPoint implements IExtensionPoint { this._handle(); } - handle(collector: IPluginsMessageCollector): void { + handle(collector: IExtensionsMessageCollector): void { this._collector = collector; this._handle(); } @@ -369,9 +369,9 @@ interface IPointListenerEntry { listener: IPointListener; } -class PluginsRegistryImpl implements IPluginsRegistry { +class ExtensionsRegistryImpl implements IExtensionsRegistry { - private _pluginsMap: IPluginDescriptionMap; + private _pluginsMap: IExtensionDescriptionMap; private _pluginsArr: IExtensionDescription[]; private _activationMap: { [activationEvent: string]: IExtensionDescription[]; }; private _pointListeners: IPointListenerEntry[]; @@ -393,7 +393,7 @@ class PluginsRegistryImpl implements IPluginsRegistry { listener: handler }; this._pointListeners.push(entry); - this._triggerPointListener(entry, PluginsRegistryImpl._filterWithExtPoint(this.getAllPluginDescriptions(), point)); + this._triggerPointListener(entry, ExtensionsRegistryImpl._filterWithExtPoint(this.getAllExtensionDescriptions(), point)); } public registerExtensionPoint(extensionPoint: string, jsonSchema: IJSONSchema): IExtensionPoint { @@ -409,8 +409,8 @@ class PluginsRegistryImpl implements IPluginsRegistry { return result; } - public handleExtensionPoints(messageHandler: IMessageHandler): void { - let collector = new PluginsMessageForwarder(messageHandler); + public handleExtensionPoints(messageHandler: IExtensionsMessageHandler): void { + let collector = new ExtensionsMessageForwarder(messageHandler); Object.keys(this._extensionPoints).forEach((extensionPointName) => { this._extensionPoints[extensionPointName].handle(collector); @@ -429,31 +429,31 @@ class PluginsRegistryImpl implements IPluginsRegistry { } } - public registerPlugins(pluginDescriptions: IExtensionDescription[]): void { - for (let i = 0, len = pluginDescriptions.length; i < len; i++) { - let pluginDescription = pluginDescriptions[i]; + public registerExtensions(extensionDescriptions: IExtensionDescription[]): void { + for (let i = 0, len = extensionDescriptions.length; i < len; i++) { + let extensionDescription = extensionDescriptions[i]; - if (hasOwnProperty.call(this._pluginsMap, pluginDescription.id)) { + if (hasOwnProperty.call(this._pluginsMap, extensionDescription.id)) { // No overwriting allowed! - console.error('Plugin `' + pluginDescription.id + '` is already registered'); + console.error('Plugin `' + extensionDescription.id + '` is already registered'); continue; } - this._pluginsMap[pluginDescription.id] = pluginDescription; - this._pluginsArr.push(pluginDescription); + this._pluginsMap[extensionDescription.id] = extensionDescription; + this._pluginsArr.push(extensionDescription); - if (Array.isArray(pluginDescription.activationEvents)) { - for (let j = 0, lenJ = pluginDescription.activationEvents.length; j < lenJ; j++) { - let activationEvent = pluginDescription.activationEvents[j]; + if (Array.isArray(extensionDescription.activationEvents)) { + for (let j = 0, lenJ = extensionDescription.activationEvents.length; j < lenJ; j++) { + let activationEvent = extensionDescription.activationEvents[j]; this._activationMap[activationEvent] = this._activationMap[activationEvent] || []; - this._activationMap[activationEvent].push(pluginDescription); + this._activationMap[activationEvent].push(extensionDescription); } } } for (let i = 0, len = this._pointListeners.length; i < len; i++) { let listenerEntry = this._pointListeners[i]; - let descriptions = PluginsRegistryImpl._filterWithExtPoint(pluginDescriptions, listenerEntry.extensionPoint); + let descriptions = ExtensionsRegistryImpl._filterWithExtPoint(extensionDescriptions, listenerEntry.extensionPoint); this._triggerPointListener(listenerEntry, descriptions); } } @@ -464,22 +464,22 @@ class PluginsRegistryImpl implements IPluginsRegistry { }); } - public getPluginDescriptionsForActivationEvent(activationEvent: string): IExtensionDescription[] { + public getExtensionDescriptionsForActivationEvent(activationEvent: string): IExtensionDescription[] { if (!hasOwnProperty.call(this._activationMap, activationEvent)) { return []; } return this._activationMap[activationEvent].slice(0); } - public getAllPluginDescriptions(): IExtensionDescription[] { + public getAllExtensionDescriptions(): IExtensionDescription[] { return this._pluginsArr.slice(0); } - public getPluginDescription(pluginId: string): IExtensionDescription { - if (!hasOwnProperty.call(this._pluginsMap, pluginId)) { + public getExtensionDescription(extensionId: string): IExtensionDescription { + if (!hasOwnProperty.call(this._pluginsMap, extensionId)) { return null; } - return this._pluginsMap[pluginId]; + return this._pluginsMap[extensionId]; } public registerOneTimeActivationEventListener(activationEvent: string, listener: IActivationEventListener): void { @@ -522,8 +522,8 @@ function _isStringArray(arr: string[]): boolean { const PRExtensions = { ExtensionsRegistry: 'ExtensionsRegistry' }; -Registry.add(PRExtensions.ExtensionsRegistry, new PluginsRegistryImpl()); -export const ExtensionsRegistry: IPluginsRegistry = Registry.as(PRExtensions.ExtensionsRegistry); +Registry.add(PRExtensions.ExtensionsRegistry, new ExtensionsRegistryImpl()); +export const ExtensionsRegistry: IExtensionsRegistry = Registry.as(PRExtensions.ExtensionsRegistry); schemaRegistry.registerSchema(schemaId, schema); schemaRegistry.addSchemaFileAssociation('/package.json', schemaId); \ No newline at end of file diff --git a/src/vs/platform/extensions/common/nativePluginService.ts b/src/vs/platform/extensions/common/nativePluginService.ts index 6752bf29e4f..8d82a25ccf5 100644 --- a/src/vs/platform/extensions/common/nativePluginService.ts +++ b/src/vs/platform/extensions/common/nativePluginService.ts @@ -119,16 +119,16 @@ export class MainProcessPluginService extends AbstractPluginService { - let event = this.getTelemetryActivationEvent(pluginDescription); + protected _actualActivatePlugin(extensionDescription: IExtensionDescription): TPromise { + let event = this.getTelemetryActivationEvent(extensionDescription); this._telemetryService.publicLog('activatePlugin', event); // redirect plugin activation to the plugin host - return this._proxy.$activatePluginInPluginHost(pluginDescription).then(_ => { + return this._proxy.$activatePluginInPluginHost(extensionDescription).then(_ => { // the plugin host calls $onPluginActivatedInPluginHost, where we write to `activatedPlugins` - return this.activatedPlugins[pluginDescription.id]; + return this.activatedPlugins[extensionDescription.id]; }); } // -- called by plugin host - public $onPluginHostReady(pluginDescriptions: IExtensionDescription[], messages: IMessage[]): void { - ExtensionsRegistry.registerPlugins(pluginDescriptions); + public $onPluginHostReady(extensionDescriptions: IExtensionDescription[], messages: IMessage[]): void { + ExtensionsRegistry.registerExtensions(extensionDescriptions); this.registrationDone(messages); } - public $onPluginActivatedInPluginHost(pluginId: string): void { - this.activatedPlugins[pluginId] = new MainProcessSuccessPlugin(); + public $onPluginActivatedInPluginHost(extensionId: string): void { + this.activatedPlugins[extensionId] = new MainProcessSuccessPlugin(); } - public $onPluginActivationFailedInPluginHost(pluginId: string): void { - this.activatedPlugins[pluginId] = new MainProcessFailedPlugin(); + public $onPluginActivationFailedInPluginHost(extensionId: string): void { + this.activatedPlugins[extensionId] = new MainProcessFailedPlugin(); } } @@ -293,15 +293,15 @@ export class PluginHostPluginService extends AbstractPluginService { - return loadCommonJSModule(pluginDescription.main); + protected _loadPluginModule(extensionDescription: IExtensionDescription): TPromise { + return loadCommonJSModule(extensionDescription.main); } - protected _loadPluginContext(pluginDescription: IExtensionDescription): TPromise { + protected _loadPluginContext(extensionDescription: IExtensionDescription): TPromise { - let globalState = new PluginMemento(pluginDescription.id, true, this._storage); - let workspaceState = new PluginMemento(pluginDescription.id, false, this._storage); + let globalState = new PluginMemento(extensionDescription.id, true, this._storage); + let workspaceState = new PluginMemento(extensionDescription.id, false, this._storage); return TPromise.join([globalState.whenReady, workspaceState.whenReady]).then(() => { return Object.freeze({ globalState, workspaceState, subscriptions: [], - get extensionPath() { return pluginDescription.extensionFolderPath; }, - asAbsolutePath: (relativePath: string) => { return paths.normalize(paths.join(pluginDescription.extensionFolderPath, relativePath), true); } + get extensionPath() { return extensionDescription.extensionFolderPath; }, + asAbsolutePath: (relativePath: string) => { return paths.normalize(paths.join(extensionDescription.extensionFolderPath, relativePath), true); } }); }); } - protected _actualActivatePlugin(pluginDescription: IExtensionDescription): TPromise { + protected _actualActivatePlugin(extensionDescription: IExtensionDescription): TPromise { - return this._superActualActivatePlugin(pluginDescription).then((activatedPlugin) => { - this._proxy.$onPluginActivatedInPluginHost(pluginDescription.id); + return this._superActualActivatePlugin(extensionDescription).then((activatedPlugin) => { + this._proxy.$onPluginActivatedInPluginHost(extensionDescription.id); return activatedPlugin; }, (err) => { - this._proxy.$onPluginActivationFailedInPluginHost(pluginDescription.id); + this._proxy.$onPluginActivationFailedInPluginHost(extensionDescription.id); throw err; }); } - private _superActualActivatePlugin(pluginDescription: IExtensionDescription): TPromise { + private _superActualActivatePlugin(extensionDescription: IExtensionDescription): TPromise { - if (!pluginDescription.main) { + if (!extensionDescription.main) { // Treat the plugin as being empty => NOT AN ERROR CASE return TPromise.as(new EmptyPlugin()); } - return this._loadPluginModule(pluginDescription).then((pluginModule) => { - return this._loadPluginContext(pluginDescription).then(context => { + return this._loadPluginModule(extensionDescription).then((pluginModule) => { + return this._loadPluginContext(extensionDescription).then(context => { return PluginHostPluginService._callActivate(pluginModule, context); }); }); @@ -406,8 +406,8 @@ export class PluginHostPluginService extends AbstractPluginService { - return this._activatePlugin(pluginDescription); + public $activatePluginInPluginHost(extensionDescription: IExtensionDescription): TPromise { + return this._activatePlugin(extensionDescription); } } diff --git a/src/vs/platform/extensions/node/pluginVersionValidator.ts b/src/vs/platform/extensions/node/pluginVersionValidator.ts index 8e963f46835..670333fba7c 100644 --- a/src/vs/platform/extensions/node/pluginVersionValidator.ts +++ b/src/vs/platform/extensions/node/pluginVersionValidator.ts @@ -6,7 +6,7 @@ import * as nls from 'vs/nls'; import {IExtensionDescription} from 'vs/platform/extensions/common/extensions'; -import {isValidPluginDescription as baseIsValidPluginDescription} from 'vs/platform/extensions/common/extensionsRegistry'; +import {isValidExtensionDescription as baseIsValidPluginDescription} from 'vs/platform/extensions/common/extensionsRegistry'; import {valid} from 'semver'; export interface IParsedVersion { @@ -203,16 +203,16 @@ export function isValidExtensionVersion(version: string, extensionDesc: IReduced return true; } -export function isValidPluginDescription(version: string, extensionFolderPath: string, pluginDescription: IExtensionDescription, notices: string[]): boolean { +export function isValidPluginDescription(version: string, extensionFolderPath: string, extensionDescription: IExtensionDescription, notices: string[]): boolean { - if (!baseIsValidPluginDescription(extensionFolderPath, pluginDescription, notices)) { + if (!baseIsValidPluginDescription(extensionFolderPath, extensionDescription, notices)) { return false; } - if (!valid(pluginDescription.version)) { + if (!valid(extensionDescription.version)) { notices.push(nls.localize('notSemver', "Extension version is not semver compatible.")); return false; } - return isValidExtensionVersion(version, pluginDescription, notices); + return isValidExtensionVersion(version, extensionDescription, notices); } \ No newline at end of file diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 95af5d8f0b1..7dff9cf39d5 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -372,13 +372,13 @@ export class ExtHostAPIImplementation { // this.extensions = { getExtension(extensionId: string):Extension { - let desc = ExtensionsRegistry.getPluginDescription(extensionId); + let desc = ExtensionsRegistry.getExtensionDescription(extensionId); if (desc) { return new Extension( extensionService, desc); } }, get all():Extension[] { - return ExtensionsRegistry.getAllPluginDescriptions().map((desc) => new Extension( extensionService, desc)); + return ExtensionsRegistry.getAllExtensionDescriptions().map((desc) => new Extension( extensionService, desc)); } }; diff --git a/src/vs/workbench/node/extensionPoints.ts b/src/vs/workbench/node/extensionPoints.ts index c64427d73bc..3873103ca8d 100644 --- a/src/vs/workbench/node/extensionPoints.ts +++ b/src/vs/workbench/node/extensionPoints.ts @@ -12,7 +12,7 @@ import {groupBy, values} from 'vs/base/common/collections'; import paths = require('vs/base/common/paths'); import json = require('vs/base/common/json'); import Types = require('vs/base/common/types'); -import {IPluginsMessageCollector, IExtensionMessageCollector} from 'vs/platform/extensions/common/extensionsRegistry'; +import {IExtensionsMessageCollector, IExtensionMessageCollector} from 'vs/platform/extensions/common/extensionsRegistry'; import {isValidPluginDescription} from 'vs/platform/extensions/node/pluginVersionValidator'; import * as semver from 'semver'; @@ -108,7 +108,7 @@ export class PluginScanner { */ public static scanPlugin( version: string, - collector: IPluginsMessageCollector, + collector: IExtensionsMessageCollector, absoluteFolderPath:string, isBuiltin:boolean ) : TPromise @@ -193,7 +193,7 @@ export class PluginScanner { */ public static scanPlugins( version: string, - collector: IPluginsMessageCollector, + collector: IExtensionsMessageCollector, absoluteFolderPath:string, isBuiltin:boolean ) : TPromise @@ -229,18 +229,18 @@ export class PluginScanner { */ public static scanOneOrMultiplePlugins( version: string, - collector: IPluginsMessageCollector, + collector: IExtensionsMessageCollector, absoluteFolderPath:string, isBuiltin:boolean ) : TPromise { return pfs.fileExists(paths.join(absoluteFolderPath, MANIFEST_FILE)).then((exists) => { if (exists) { - return this.scanPlugin(version, collector, absoluteFolderPath, isBuiltin).then((pluginDescription) => { - if (pluginDescription === null) { + return this.scanPlugin(version, collector, absoluteFolderPath, isBuiltin).then((extensionDescription) => { + if (extensionDescription === null) { return []; } - return [pluginDescription]; + return [extensionDescription]; }); } return this.scanPlugins(version, collector, absoluteFolderPath, isBuiltin); diff --git a/src/vs/workbench/node/pluginHostMain.ts b/src/vs/workbench/node/pluginHostMain.ts index 5c7e7e258ff..452fc13c5fb 100644 --- a/src/vs/workbench/node/pluginHostMain.ts +++ b/src/vs/workbench/node/pluginHostMain.ts @@ -14,7 +14,7 @@ import URI from 'vs/base/common/uri'; import {TPromise} from 'vs/base/common/winjs.base'; import paths = require('vs/base/common/paths'); import {IExtensionService, IExtensionDescription} from 'vs/platform/extensions/common/extensions'; -import {ExtensionsRegistry, PluginsMessageCollector, IPluginsMessageCollector} from 'vs/platform/extensions/common/extensionsRegistry'; +import {ExtensionsRegistry, ExtensionsMessageCollector, IExtensionsMessageCollector} from 'vs/platform/extensions/common/extensionsRegistry'; import {ExtHostAPIImplementation} from 'vs/workbench/api/node/extHost.api.impl'; import {IPluginsIPC} from 'vs/platform/extensions/common/ipcRemoteCom'; import {ExtHostModelService} from 'vs/workbench/api/node/extHostDocuments'; @@ -117,7 +117,7 @@ export class PluginHostMain { this._isTerminating = true; try { - let allExtensions = ExtensionsRegistry.getAllPluginDescriptions(); + let allExtensions = ExtensionsRegistry.getAllExtensionDescriptions(); let allExtensionsIds = allExtensions.map(ext => ext.id); let activatedExtensions = allExtensionsIds.filter(id => this._extensionService.isActivated(id)); @@ -135,7 +135,7 @@ export class PluginHostMain { } private readPlugins(): TPromise { - let collector = new PluginsMessageCollector(); + let collector = new ExtensionsMessageCollector(); let env = this._contextService.getConfiguration().env; return PluginHostMain.scanPlugins(collector, BUILTIN_PLUGINS_PATH, !env.disablePlugins ? env.userPluginsHome : void 0, !env.disablePlugins ? env.pluginDevelopmentPath : void 0, env.version) @@ -145,14 +145,14 @@ export class PluginHostMain { }) .then(extensions => { // Register & Signal done - ExtensionsRegistry.registerPlugins(extensions); + ExtensionsRegistry.registerExtensions(extensions); this._extensionService.registrationDone(collector.getMessages()); }) .then(() => this.handleEagerPlugins()) .then(() => this.handlePluginTests()); } - private static scanPlugins(collector: IPluginsMessageCollector, builtinPluginsPath: string, userInstallPath: string, pluginDevelopmentPath: string, version: string): TPromise { + private static scanPlugins(collector: IExtensionsMessageCollector, builtinPluginsPath: string, userInstallPath: string, pluginDevelopmentPath: string, version: string): TPromise { const builtinPlugins = PluginScanner.scanPlugins(version, collector, builtinPluginsPath, true); const userPlugins = !userInstallPath ? TPromise.as([]) : PluginScanner.scanPlugins(version, collector, userInstallPath, false); const developedPlugins = !pluginDevelopmentPath ? TPromise.as([]) : PluginScanner.scanOneOrMultiplePlugins(version, collector, pluginDevelopmentPath, false); @@ -204,7 +204,7 @@ export class PluginHostMain { [filename: string]: boolean; } = {}; - ExtensionsRegistry.getAllPluginDescriptions().forEach((desc) => { + ExtensionsRegistry.getAllExtensionDescriptions().forEach((desc) => { let activationEvents = desc.activationEvents; if (!activationEvents) { return;