提交 25200ef6 编写于 作者: S Sandeep Somavarapu

#48430 Change return type

上级 1005872b
...@@ -205,6 +205,7 @@ export enum LocalExtensionType { ...@@ -205,6 +205,7 @@ export enum LocalExtensionType {
export interface ILocalExtension { export interface ILocalExtension {
type: LocalExtensionType; type: LocalExtensionType;
identifier: IExtensionIdentifier; identifier: IExtensionIdentifier;
galleryIdentifier: IExtensionIdentifier;
manifest: IExtensionManifest; manifest: IExtensionManifest;
metadata: IGalleryMetadata; metadata: IGalleryMetadata;
location: URI; location: URI;
...@@ -303,10 +304,10 @@ export interface IExtensionManagementService { ...@@ -303,10 +304,10 @@ export interface IExtensionManagementService {
onUninstallExtension: Event<IExtensionIdentifier>; onUninstallExtension: Event<IExtensionIdentifier>;
onDidUninstallExtension: Event<DidUninstallExtensionEvent>; onDidUninstallExtension: Event<DidUninstallExtensionEvent>;
install(zipPath: string): TPromise<ILocalExtension>; install(zipPath: string): TPromise<void>;
installFromGallery(extension: IGalleryExtension): TPromise<ILocalExtension>; installFromGallery(extension: IGalleryExtension): TPromise<void>;
uninstall(extension: ILocalExtension, force?: boolean): TPromise<void>; uninstall(extension: ILocalExtension, force?: boolean): TPromise<void>;
reinstallFromGallery(extension: ILocalExtension): TPromise<ILocalExtension>; reinstallFromGallery(extension: ILocalExtension): TPromise<void>;
getInstalled(type?: LocalExtensionType): TPromise<ILocalExtension[]>; getInstalled(type?: LocalExtensionType): TPromise<ILocalExtension[]>;
getExtensionsReport(): TPromise<IReportedExtension[]>; getExtensionsReport(): TPromise<IReportedExtension[]>;
......
...@@ -17,10 +17,10 @@ export interface IExtensionManagementChannel extends IChannel { ...@@ -17,10 +17,10 @@ export interface IExtensionManagementChannel extends IChannel {
listen(event: 'onDidInstallExtension'): Event<DidInstallExtensionEvent>; listen(event: 'onDidInstallExtension'): Event<DidInstallExtensionEvent>;
listen(event: 'onUninstallExtension'): Event<IExtensionIdentifier>; listen(event: 'onUninstallExtension'): Event<IExtensionIdentifier>;
listen(event: 'onDidUninstallExtension'): Event<DidUninstallExtensionEvent>; listen(event: 'onDidUninstallExtension'): Event<DidUninstallExtensionEvent>;
call(command: 'install', args: [string]): TPromise<ILocalExtension>; call(command: 'install', args: [string]): TPromise<void>;
call(command: 'installFromGallery', args: [IGalleryExtension]): TPromise<ILocalExtension>; call(command: 'installFromGallery', args: [IGalleryExtension]): TPromise<void>;
call(command: 'uninstall', args: [ILocalExtension, boolean]): TPromise<void>; call(command: 'uninstall', args: [ILocalExtension, boolean]): TPromise<void>;
call(command: 'reinstallFromGallery', args: [ILocalExtension]): TPromise<ILocalExtension>; call(command: 'reinstallFromGallery', args: [ILocalExtension]): TPromise<void>;
call(command: 'getInstalled', args: [LocalExtensionType]): TPromise<ILocalExtension[]>; call(command: 'getInstalled', args: [LocalExtensionType]): TPromise<ILocalExtension[]>;
call(command: 'getExtensionsReport'): TPromise<IReportedExtension[]>; call(command: 'getExtensionsReport'): TPromise<IReportedExtension[]>;
call(command: 'updateMetadata', args: [ILocalExtension, IGalleryMetadata]): TPromise<ILocalExtension>; call(command: 'updateMetadata', args: [ILocalExtension, IGalleryMetadata]): TPromise<ILocalExtension>;
...@@ -81,23 +81,20 @@ export class ExtensionManagementChannelClient implements IExtensionManagementSer ...@@ -81,23 +81,20 @@ export class ExtensionManagementChannelClient implements IExtensionManagementSer
get onUninstallExtension(): Event<IExtensionIdentifier> { return this.channel.listen('onUninstallExtension'); } get onUninstallExtension(): Event<IExtensionIdentifier> { return this.channel.listen('onUninstallExtension'); }
get onDidUninstallExtension(): Event<DidUninstallExtensionEvent> { return this.channel.listen('onDidUninstallExtension'); } get onDidUninstallExtension(): Event<DidUninstallExtensionEvent> { return this.channel.listen('onDidUninstallExtension'); }
install(zipPath: string): TPromise<ILocalExtension> { install(zipPath: string): TPromise<void> {
return this.channel.call('install', [zipPath]) return this.channel.call('install', [zipPath]);
.then(extension => this._transform(extension));
} }
installFromGallery(extension: IGalleryExtension): TPromise<ILocalExtension> { installFromGallery(extension: IGalleryExtension): TPromise<void> {
return this.channel.call('installFromGallery', [extension]) return this.channel.call('installFromGallery', [extension]);
.then(extension => this._transform(extension));
} }
uninstall(extension: ILocalExtension, force = false): TPromise<void> { uninstall(extension: ILocalExtension, force = false): TPromise<void> {
return this.channel.call('uninstall', [extension, force]); return this.channel.call('uninstall', [extension, force]);
} }
reinstallFromGallery(extension: ILocalExtension): TPromise<ILocalExtension> { reinstallFromGallery(extension: ILocalExtension): TPromise<void> {
return this.channel.call('reinstallFromGallery', [extension]) return this.channel.call('reinstallFromGallery', [extension]);
.then(extension => this._transform(extension));
} }
getInstalled(type: LocalExtensionType = null): TPromise<ILocalExtension[]> { getInstalled(type: LocalExtensionType = null): TPromise<ILocalExtension[]> {
......
...@@ -41,7 +41,7 @@ export class MulitExtensionManagementService implements IExtensionManagementServ ...@@ -41,7 +41,7 @@ export class MulitExtensionManagementService implements IExtensionManagementServ
return this.getServer(extension).extensionManagementService.uninstall(extension, force); return this.getServer(extension).extensionManagementService.uninstall(extension, force);
} }
reinstallFromGallery(extension: ILocalExtension): TPromise<ILocalExtension> { reinstallFromGallery(extension: ILocalExtension): TPromise<void> {
return this.getServer(extension).extensionManagementService.reinstallFromGallery(extension); return this.getServer(extension).extensionManagementService.reinstallFromGallery(extension);
} }
...@@ -49,12 +49,12 @@ export class MulitExtensionManagementService implements IExtensionManagementServ ...@@ -49,12 +49,12 @@ export class MulitExtensionManagementService implements IExtensionManagementServ
return this.getServer(extension).extensionManagementService.updateMetadata(extension, metadata); return this.getServer(extension).extensionManagementService.updateMetadata(extension, metadata);
} }
install(zipPath: string): TPromise<ILocalExtension> { install(zipPath: string): TPromise<void> {
return this.servers[0].extensionManagementService.install(zipPath); return this.servers[0].extensionManagementService.install(zipPath);
} }
installFromGallery(extension: IGalleryExtension): TPromise<ILocalExtension> { installFromGallery(extension: IGalleryExtension): TPromise<void> {
return this.servers[0].extensionManagementService.installFromGallery(extension); return TPromise.join(this.servers.map(server => server.extensionManagementService.installFromGallery(extension))).then(() => null);
} }
getExtensionsReport(): TPromise<IReportedExtension[]> { getExtensionsReport(): TPromise<IReportedExtension[]> {
......
...@@ -152,14 +152,14 @@ export class ExtensionManagementService extends Disposable implements IExtension ...@@ -152,14 +152,14 @@ export class ExtensionManagementService extends Disposable implements IExtension
})); }));
} }
install(zipPath: string): TPromise<ILocalExtension> { install(zipPath: string): TPromise<void> {
zipPath = path.resolve(zipPath); zipPath = path.resolve(zipPath);
return validateLocalExtension(zipPath) return validateLocalExtension(zipPath)
.then(manifest => { .then(manifest => {
const identifier = { id: getLocalExtensionIdFromManifest(manifest) }; const identifier = { id: getLocalExtensionIdFromManifest(manifest) };
if (manifest.engines && manifest.engines.vscode && !isEngineValid(manifest.engines.vscode)) { if (manifest.engines && manifest.engines.vscode && !isEngineValid(manifest.engines.vscode)) {
return TPromise.wrapError<ILocalExtension>(new Error(nls.localize('incompatible', "Unable to install Extension '{0}' as it is not compatible with Code '{1}'.", identifier.id, pkg.version))); return TPromise.wrapError<void>(new Error(nls.localize('incompatible', "Unable to install Extension '{0}' as it is not compatible with Code '{1}'.", identifier.id, pkg.version)));
} }
return this.removeIfExists(identifier.id) return this.removeIfExists(identifier.id)
.then( .then(
...@@ -173,7 +173,7 @@ export class ExtensionManagementService extends Disposable implements IExtension ...@@ -173,7 +173,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
metadata => this.installFromZipPath(identifier, zipPath, metadata, manifest), metadata => this.installFromZipPath(identifier, zipPath, metadata, manifest),
error => this.installFromZipPath(identifier, zipPath, null, manifest)) error => this.installFromZipPath(identifier, zipPath, null, manifest))
.then( .then(
local => { this.logService.info('Successfully installed the extension:', identifier.id); return local; }, () => { this.logService.info('Successfully installed the extension:', identifier.id); },
e => { e => {
this.logService.error('Failed to install the extension:', identifier.id, e.message); this.logService.error('Failed to install the extension:', identifier.id, e.message);
return TPromise.wrapError(e); return TPromise.wrapError(e);
...@@ -240,7 +240,7 @@ export class ExtensionManagementService extends Disposable implements IExtension ...@@ -240,7 +240,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
})); }));
} }
installFromGallery(extension: IGalleryExtension): TPromise<ILocalExtension> { installFromGallery(extension: IGalleryExtension): TPromise<void> {
this.onInstallExtensions([extension]); this.onInstallExtensions([extension]);
return this.toNonCancellablePromise(this.getInstalled(LocalExtensionType.User) return this.toNonCancellablePromise(this.getInstalled(LocalExtensionType.User)
.then(installed => this.collectExtensionsToInstall(extension) .then(installed => this.collectExtensionsToInstall(extension)
...@@ -253,13 +253,13 @@ export class ExtensionManagementService extends Disposable implements IExtension ...@@ -253,13 +253,13 @@ export class ExtensionManagementService extends Disposable implements IExtension
return this.downloadAndInstallExtensions(extensionsToInstall, operataions) return this.downloadAndInstallExtensions(extensionsToInstall, operataions)
.then( .then(
locals => this.onDidInstallExtensions(extensionsToInstall, locals, operataions, []) locals => this.onDidInstallExtensions(extensionsToInstall, locals, operataions, [])
.then(() => locals.filter(l => areSameExtensions({ id: getGalleryExtensionIdFromLocal(l), uuid: l.identifier.uuid }, extension.identifier))[0]), .then(() => null),
errors => this.onDidInstallExtensions(extensionsToInstall, [], operataions, errors)); errors => this.onDidInstallExtensions(extensionsToInstall, [], operataions, errors));
}, },
error => this.onDidInstallExtensions([extension], [], [this.getOperation(extension.identifier, installed)], [error])))); error => this.onDidInstallExtensions([extension], [], [this.getOperation(extension.identifier, installed)], [error]))));
} }
reinstallFromGallery(extension: ILocalExtension): TPromise<ILocalExtension> { reinstallFromGallery(extension: ILocalExtension): TPromise<void> {
if (!this.galleryService.isEnabled()) { if (!this.galleryService.isEnabled()) {
return TPromise.wrapError(new Error(nls.localize('MarketPlaceDisabled', "Marketplace is not enabled"))); return TPromise.wrapError(new Error(nls.localize('MarketPlaceDisabled', "Marketplace is not enabled")));
} }
...@@ -762,7 +762,8 @@ export class ExtensionManagementService extends Disposable implements IExtension ...@@ -762,7 +762,8 @@ export class ExtensionManagementService extends Disposable implements IExtension
manifest.extensionDependencies = manifest.extensionDependencies.map(id => adoptToGalleryExtensionId(id)); manifest.extensionDependencies = manifest.extensionDependencies.map(id => adoptToGalleryExtensionId(id));
} }
const identifier = { id: type === LocalExtensionType.System ? folderName : getLocalExtensionIdFromManifest(manifest), uuid: metadata ? metadata.id : null }; const identifier = { id: type === LocalExtensionType.System ? folderName : getLocalExtensionIdFromManifest(manifest), uuid: metadata ? metadata.id : null };
return { type, identifier, manifest, metadata, location: URI.file(extensionPath), readmeUrl, changelogUrl }; const galleryIdentifier = { id: getGalleryExtensionId(manifest.publisher, manifest.name), uuid: identifier.uuid };
return { type, identifier, galleryIdentifier, manifest, metadata, location: URI.file(extensionPath), readmeUrl, changelogUrl };
})) }))
.then(null, () => null); .then(null, () => null);
} }
......
...@@ -655,7 +655,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService, ...@@ -655,7 +655,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
location: ProgressLocation.Extensions, location: ProgressLocation.Extensions,
title: nls.localize('installingMarketPlaceExtension', 'Installing extension from Marketplace....'), title: nls.localize('installingMarketPlaceExtension', 'Installing extension from Marketplace....'),
source: `${extension.id}` source: `${extension.id}`
}, () => this.extensionService.installFromGallery(gallery).then(() => null)); }, () => this.extensionService.installFromGallery(gallery));
} }
setEnablement(extensions: IExtension | IExtension[], enablementState: EnablementState): TPromise<void> { setEnablement(extensions: IExtension | IExtension[], enablementState: EnablementState): TPromise<void> {
......
...@@ -24,7 +24,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment' ...@@ -24,7 +24,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import { Schemas } from 'vs/base/common/network'; import { Schemas } from 'vs/base/common/network';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup'; import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { getInstalledExtensions, IExtensionStatus, onExtensionChanged, isKeymapExtension } from 'vs/workbench/parts/extensions/electron-browser/extensionsUtils'; import { getInstalledExtensions, IExtensionStatus, onExtensionChanged, isKeymapExtension } from 'vs/workbench/parts/extensions/electron-browser/extensionsUtils';
import { IExtensionEnablementService, IExtensionManagementService, IExtensionGalleryService, IExtensionTipsService, EnablementState } from 'vs/platform/extensionManagement/common/extensionManagement'; import { IExtensionEnablementService, IExtensionManagementService, IExtensionGalleryService, IExtensionTipsService, EnablementState, LocalExtensionType } from 'vs/platform/extensionManagement/common/extensionManagement';
import { used } from 'vs/workbench/parts/welcome/page/electron-browser/vs_code_welcome_page'; import { used } from 'vs/workbench/parts/welcome/page/electron-browser/vs_code_welcome_page';
import { ILifecycleService, StartupKind } from 'vs/platform/lifecycle/common/lifecycle'; import { ILifecycleService, StartupKind } from 'vs/platform/lifecycle/common/lifecycle';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose } from 'vs/base/common/lifecycle';
...@@ -39,6 +39,7 @@ import { IEditorInputFactory, EditorInput } from 'vs/workbench/common/editor'; ...@@ -39,6 +39,7 @@ import { IEditorInputFactory, EditorInput } from 'vs/workbench/common/editor';
import { getIdAndVersionFromLocalExtensionId } from 'vs/platform/extensionManagement/node/extensionManagementUtil'; import { getIdAndVersionFromLocalExtensionId } from 'vs/platform/extensionManagement/node/extensionManagementUtil';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { TimeoutTimer } from 'vs/base/common/async'; import { TimeoutTimer } from 'vs/base/common/async';
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
used(); used();
...@@ -420,7 +421,9 @@ class WelcomePage { ...@@ -420,7 +421,9 @@ class WelcomePage {
return null; return null;
} }
return this.extensionManagementService.installFromGallery(extension) return this.extensionManagementService.installFromGallery(extension)
.then(local => { .then(() => this.extensionManagementService.getInstalled(LocalExtensionType.User))
.then(installed => {
const local = installed.filter(i => areSameExtensions(extension.identifier, i.galleryIdentifier))[0];
// TODO: Do this as part of the install to avoid multiple events. // TODO: Do this as part of the install to avoid multiple events.
return this.extensionEnablementService.setEnablement(local, EnablementState.Disabled).then(() => local); return this.extensionEnablementService.setEnablement(local, EnablementState.Disabled).then(() => local);
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册