提交 6f80511a 编写于 作者: S Sandeep Somavarapu

Fix #45122

上级 8f6c4465
......@@ -271,10 +271,10 @@ export interface IExtensionManagementService {
onUninstallExtension: Event<IExtensionIdentifier>;
onDidUninstallExtension: Event<DidUninstallExtensionEvent>;
install(zipPath: string): TPromise<void>;
installFromGallery(extension: IGalleryExtension): TPromise<void>;
install(zipPath: string): TPromise<ILocalExtension>;
installFromGallery(extension: IGalleryExtension): TPromise<ILocalExtension>;
uninstall(extension: ILocalExtension, force?: boolean): TPromise<void>;
reinstall(extension: ILocalExtension): TPromise<void>;
reinstall(extension: ILocalExtension): TPromise<ILocalExtension>;
getInstalled(type?: LocalExtensionType): TPromise<ILocalExtension[]>;
getExtensionsReport(): TPromise<IReportedExtension[]>;
......@@ -330,10 +330,6 @@ export interface IExtensionEnablementService {
* Throws error if enablement is requested for workspace and there is no workspace
*/
setEnablement(extension: ILocalExtension, state: EnablementState): TPromise<boolean>;
/**
* TODO: @Sandy. Use setEnablement(extension: ILocalExtension, state: EnablementState): TPromise<boolean>. Use one model for extension management and runtime
*/
setEnablement(identifier: IExtensionIdentifier, state: EnablementState): TPromise<boolean>;
}
export const IExtensionTipsService = createDecorator<IExtensionTipsService>('extensionTipsService');
......
......@@ -15,9 +15,10 @@ export interface IExtensionManagementChannel extends IChannel {
call(command: 'event:onDidInstallExtension'): TPromise<void>;
call(command: 'event:onUninstallExtension'): TPromise<void>;
call(command: 'event:onDidUninstallExtension'): TPromise<void>;
call(command: 'install', path: string): TPromise<void>;
call(command: 'installFromGallery', extension: IGalleryExtension): TPromise<void>;
call(command: 'install', path: string): TPromise<ILocalExtension>;
call(command: 'installFromGallery', extension: IGalleryExtension): TPromise<ILocalExtension>;
call(command: 'uninstall', args: [ILocalExtension, boolean]): TPromise<void>;
call(command: 'reinstall', args: [ILocalExtension]): TPromise<ILocalExtension>;
call(command: 'getInstalled'): TPromise<ILocalExtension[]>;
call(command: 'getExtensionsReport'): TPromise<IReportedExtension[]>;
call(command: string, arg?: any): TPromise<any>;
......@@ -73,11 +74,11 @@ export class ExtensionManagementChannelClient implements IExtensionManagementSer
private _onDidUninstallExtension = eventFromCall<DidUninstallExtensionEvent>(this.channel, 'event:onDidUninstallExtension');
get onDidUninstallExtension(): Event<DidUninstallExtensionEvent> { return this._onDidUninstallExtension; }
install(zipPath: string): TPromise<void> {
install(zipPath: string): TPromise<ILocalExtension> {
return this.channel.call('install', zipPath);
}
installFromGallery(extension: IGalleryExtension): TPromise<void> {
installFromGallery(extension: IGalleryExtension): TPromise<ILocalExtension> {
return this.channel.call('installFromGallery', [extension]);
}
......@@ -85,7 +86,7 @@ export class ExtensionManagementChannelClient implements IExtensionManagementSer
return this.channel.call('uninstall', [extension, force]);
}
reinstall(extension: ILocalExtension): TPromise<void> {
reinstall(extension: ILocalExtension): TPromise<ILocalExtension> {
return this.channel.call('reinstall', [extension]);
}
......
......@@ -141,7 +141,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
this.extensionLifecycle = this._register(new ExtensionsLifecycle(this.logService));
}
install(zipPath: string): TPromise<void> {
install(zipPath: string): TPromise<ILocalExtension> {
zipPath = path.resolve(zipPath);
return validateLocalExtension(zipPath)
......@@ -159,7 +159,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
metadata => this.installFromZipPath(identifier, zipPath, metadata, manifest),
error => this.installFromZipPath(identifier, zipPath, null, manifest))
.then(
() => this.logService.info('Successfully installed the extension:', identifier.id),
local => { this.logService.info('Successfully installed the extension:', identifier.id); return local; },
e => {
this.logService.error('Failed to install the extension:', identifier.id, e.message);
return TPromise.wrapError(e);
......@@ -208,7 +208,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
});
}
private installFromZipPath(identifier: IExtensionIdentifier, zipPath: string, metadata: IGalleryMetadata, manifest: IExtensionManifest): TPromise<void> {
private installFromZipPath(identifier: IExtensionIdentifier, zipPath: string, metadata: IGalleryMetadata, manifest: IExtensionManifest): TPromise<ILocalExtension> {
return this.installExtension({ zipPath, id: identifier.id, metadata })
.then(local => {
if (this.galleryService.isEnabled() && local.manifest.extensionDependencies && local.manifest.extensionDependencies.length) {
......@@ -222,12 +222,12 @@ export class ExtensionManagementService extends Disposable implements IExtension
return local;
})
.then(
local => this._onDidInstallExtension.fire({ identifier, zipPath, local }),
local => { this._onDidInstallExtension.fire({ identifier, zipPath, local }); return local; },
error => { this._onDidInstallExtension.fire({ identifier, zipPath, error }); return TPromise.wrapError(error); }
);
}
installFromGallery(extension: IGalleryExtension): TPromise<void> {
installFromGallery(extension: IGalleryExtension): TPromise<ILocalExtension> {
this.onInstallExtensions([extension]);
return this.collectExtensionsToInstall(extension)
.then(
......@@ -237,13 +237,14 @@ export class ExtensionManagementService extends Disposable implements IExtension
}
return this.downloadAndInstallExtensions(extensionsToInstall)
.then(
locals => this.onDidInstallExtensions(extensionsToInstall, locals, []),
locals => this.onDidInstallExtensions(extensionsToInstall, locals, [])
.then(() => locals.filter(l => areSameExtensions({ id: getGalleryExtensionIdFromLocal(l), uuid: l.identifier.uuid }, extension.identifier)[0])),
errors => this.onDidInstallExtensions(extensionsToInstall, [], errors));
},
error => this.onDidInstallExtensions([extension], [], [error]));
}
reinstall(extension: ILocalExtension): TPromise<void> {
reinstall(extension: ILocalExtension): TPromise<ILocalExtension> {
if (!this.galleryService.isEnabled()) {
return TPromise.wrapError(new Error(nls.localize('MarketPlaceDisabled', "Marketplace is not enabled")));
}
......
......@@ -589,7 +589,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService {
location: ProgressLocation.Extensions,
title: nls.localize('installingVSIXExtension', 'Installing extension from VSIX...'),
tooltip: `${extension}`
}, () => this.extensionService.install(extension));
}, () => this.extensionService.install(extension).then(() => null));
}
if (!(extension instanceof Extension)) {
......@@ -611,7 +611,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService {
location: ProgressLocation.Extensions,
title: nls.localize('installingMarketPlaceExtension', 'Installing extension from Marketplace....'),
tooltip: `${extension.id}`
}, () => this.extensionService.installFromGallery(gallery));
}, () => this.extensionService.installFromGallery(gallery).then(() => null));
}
setEnablement(extension: IExtension, enablementState: EnablementState): TPromise<void> {
......@@ -670,7 +670,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService {
return this.progressService.withProgress({
location: ProgressLocation.Extensions,
tooltip: `${local.identifier.id}`
}, () => this.extensionService.reinstall(local));
}, () => this.extensionService.reinstall(local).then(() => null));
}
private promptAndSetEnablement(extension: IExtension, enablementState: EnablementState, enable: boolean): TPromise<any> {
......
......@@ -416,18 +416,16 @@ class WelcomePage {
this.notificationService.info(strings.alreadyInstalled.replace('{0}', extensionSuggestion.name));
return;
}
const foundAndInstalled = installedExtension ? TPromise.as(installedExtension.identifier) : this.extensionGalleryService.query({ names: [extensionSuggestion.id], source: telemetryFrom })
const foundAndInstalled = installedExtension ? TPromise.as(installedExtension.local) : this.extensionGalleryService.query({ names: [extensionSuggestion.id], source: telemetryFrom })
.then(result => {
const [extension] = result.firstPage;
if (!extension) {
return null;
}
return this.extensionManagementService.installFromGallery(extension)
.then(() => {
.then(local => {
// TODO: Do this as part of the install to avoid multiple events.
return this.extensionEnablementService.setEnablement(extension.identifier, EnablementState.Disabled);
}).then(() => {
return extension.identifier;
return this.extensionEnablementService.setEnablement(local, EnablementState.Disabled).then(() => local);
});
});
......@@ -440,7 +438,7 @@ class WelcomePage {
});
TPromise.join(extensionSuggestion.isKeymap ? extensions.filter(extension => isKeymapExtension(this.tipsService, extension) && extension.globallyEnabled)
.map(extension => {
return this.extensionEnablementService.setEnablement(extension.identifier, EnablementState.Disabled);
return this.extensionEnablementService.setEnablement(extension.local, EnablementState.Disabled);
}) : []).then(() => {
return foundAndInstalled.then(foundExtension => {
messageDelay.cancel();
......
......@@ -17,8 +17,8 @@ import * as platform from 'vs/base/common/platform';
import { ExtensionDescriptionRegistry } from 'vs/workbench/services/extensions/node/extensionDescriptionRegistry';
import { IMessage, IExtensionDescription, IExtensionsStatus, IExtensionService, ExtensionPointContribution, ActivationTimes, ProfileSession } from 'vs/workbench/services/extensions/common/extensions';
import { USER_MANIFEST_CACHE_FILE, BUILTIN_MANIFEST_CACHE_FILE, MANIFEST_CACHE_FOLDER } from 'vs/platform/extensions/common/extensions';
import { IExtensionEnablementService, IExtensionIdentifier, EnablementState } from 'vs/platform/extensionManagement/common/extensionManagement';
import { areSameExtensions, BetterMergeId, BetterMergeDisabledNowKey } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { IExtensionEnablementService, IExtensionIdentifier, EnablementState, IExtensionManagementService, LocalExtensionType } from 'vs/platform/extensionManagement/common/extensionManagement';
import { areSameExtensions, BetterMergeId, BetterMergeDisabledNowKey, getGalleryExtensionIdFromLocal } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { ExtensionsRegistry, ExtensionPoint, IExtensionPointUser, ExtensionMessageCollector, IExtensionPoint } from 'vs/workbench/services/extensions/common/extensionsRegistry';
import { ExtensionScanner, ILog, ExtensionScannerInput, IExtensionResolver, IExtensionReference, Translations } from 'vs/workbench/services/extensions/node/extensionPoints';
import { ProxyIdentifier } from 'vs/workbench/services/extensions/node/proxyIdentifier';
......@@ -150,7 +150,8 @@ export class ExtensionService extends Disposable implements IExtensionService {
@IExtensionEnablementService private readonly _extensionEnablementService: IExtensionEnablementService,
@IStorageService private readonly _storageService: IStorageService,
@IWindowService private readonly _windowService: IWindowService,
@ILifecycleService lifecycleService: ILifecycleService
@ILifecycleService lifecycleService: ILifecycleService,
@IExtensionManagementService private extensionManagementService: IExtensionManagementService
) {
super();
this._registry = null;
......@@ -500,7 +501,11 @@ export class ExtensionService extends Disposable implements IExtensionService {
});
if (extensionsToDisable.length) {
return TPromise.join(extensionsToDisable.map(e => this._extensionEnablementService.setEnablement(e, EnablementState.Disabled)))
return this.extensionManagementService.getInstalled(LocalExtensionType.User)
.then(installed => {
const toDisable = installed.filter(i => extensionsToDisable.some(e => areSameExtensions({ id: getGalleryExtensionIdFromLocal(i) }, e)));
return TPromise.join(toDisable.map(e => this._extensionEnablementService.setEnablement(e, EnablementState.Disabled)));
})
.then(() => {
this._storageService.store(BetterMergeDisabledNowKey, true);
return runtimeExtensions;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册