提交 0e5f4af1 编写于 作者: S Sandeep Somavarapu

#66397 Use `galleryIdentifier` instead of `identfier` in `ILocalExtension`

上级 9031a4f3
......@@ -35,7 +35,7 @@ import { StateService } from 'vs/platform/state/node/stateService';
import { createSpdLogService } from 'vs/platform/log/node/spdlogService';
import { ILogService, getLogLevel } from 'vs/platform/log/common/log';
import { isPromiseCanceledError } from 'vs/base/common/errors';
import { areSameExtensions, getGalleryExtensionIdFromLocal, adoptToGalleryExtensionId, getGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { areSameExtensions, adoptToGalleryExtensionId, getGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { URI } from 'vs/base/common/uri';
import { getManifest } from 'vs/platform/extensionManagement/node/extensionManagementUtil';
import { IExtensionManifest, ExtensionType } from 'vs/platform/extensions/common/extensions';
......@@ -153,7 +153,7 @@ class Main {
return Promise.reject(new Error(`${notFound(version ? `${id}@${version}` : id)}\n${useId}`));
}
const [installedExtension] = installed.filter(e => areSameExtensions({ id: getGalleryExtensionIdFromLocal(e) }, { id }));
const [installedExtension] = installed.filter(e => areSameExtensions(e.galleryIdentifier, { id }));
if (installedExtension) {
if (extension.version !== installedExtension.manifest.version) {
if (version || force) {
......@@ -186,7 +186,7 @@ class Main {
const extensionIdentifier = { id: getGalleryExtensionId(manifest.publisher, manifest.name) };
const installedExtensions = await this.extensionManagementService.getInstalled(ExtensionType.User);
const newer = installedExtensions.filter(local => areSameExtensions(extensionIdentifier, { id: getGalleryExtensionIdFromLocal(local) }) && semver.gt(local.manifest.version, manifest.version))[0];
const newer = installedExtensions.filter(local => areSameExtensions(extensionIdentifier, local.galleryIdentifier) && semver.gt(local.manifest.version, manifest.version))[0];
if (newer && !force) {
console.log(localize('forceDowngrade', "A newer version of this extension '{0}' v{1} is already installed. Use '--force' option to downgrade to older version.", newer.galleryIdentifier.id, newer.manifest.version, manifest.version));
......@@ -225,7 +225,7 @@ class Main {
return sequence(extensions.map(extension => () => {
return getExtensionId(extension).then(id => {
return this.extensionManagementService.getInstalled(ExtensionType.User).then(installed => {
const [extension] = installed.filter(e => areSameExtensions({ id: getGalleryExtensionIdFromLocal(e) }, { id }));
const [extension] = installed.filter(e => areSameExtensions(e.galleryIdentifier, { id }));
if (!extension) {
return Promise.reject(new Error(`${notInstalled(id)}\n${useId}`));
......
......@@ -91,7 +91,7 @@ export interface IGalleryMetadata {
}
export interface ILocalExtension extends IExtension {
manifest: IExtensionManifest; /** TODO:@sandy081 - remove the readonly relaxment */
readonly manifest: IExtensionManifest;
metadata: IGalleryMetadata;
readmeUrl: URI | null;
changelogUrl: URI | null;
......
......@@ -25,10 +25,6 @@ export function getGalleryExtensionId(publisher: string, name: string): string {
return `${publisher.toLocaleLowerCase()}.${name.toLocaleLowerCase()}`;
}
export function getGalleryExtensionIdFromLocal(local: ILocalExtension): string {
return local.manifest ? getGalleryExtensionId(local.manifest.publisher, local.manifest.name) : local.identifier.id;
}
export const LOCAL_EXTENSION_ID_REGEX = /^([^.]+\..+)-(\d+\.\d+\.\d+(-.*)?)$/;
export function getIdFromLocalExtensionId(localExtensionId: string): string {
......@@ -74,7 +70,7 @@ export function groupByExtension<T>(extensions: T[], getExtensionIdentifier: (t:
export function getLocalExtensionTelemetryData(extension: ILocalExtension): any {
return {
id: getGalleryExtensionIdFromLocal(extension),
id: extension.galleryIdentifier.id,
name: extension.manifest.name,
galleryId: null,
publisherId: extension.metadata ? extension.metadata.publisherId : null,
......
......@@ -21,11 +21,9 @@ function transformOutgoingURI(uri: URI, transformer: IURITransformer | null): UR
function transformIncomingExtension(extension: ILocalExtension, transformer: IURITransformer | null): ILocalExtension {
transformer = transformer ? transformer : DefaultURITransformer;
const manfiest = extension.manifest;
delete extension.manifest;
extension = transformAndReviveIncomingURIs(extension, transformer);
extension.manifest = manfiest;
return extension;
const manifest = extension.manifest;
const transformed = transformAndReviveIncomingURIs({ ...extension, ...{ manifest: undefined } }, transformer);
return { ...transformed, ...{ manifest } };
}
function transformOutgoingExtension(extension: ILocalExtension, transformer: IURITransformer | null): ILocalExtension {
......
......@@ -21,7 +21,7 @@ import {
INSTALL_ERROR_MALICIOUS,
INSTALL_ERROR_INCOMPATIBLE
} from 'vs/platform/extensionManagement/common/extensionManagement';
import { getGalleryExtensionIdFromLocal, adoptToGalleryExtensionId, areSameExtensions, getGalleryExtensionId, groupByExtension, getMaliciousExtensionsSet, getLocalExtensionId, getGalleryExtensionTelemetryData, getLocalExtensionTelemetryData, getIdFromLocalExtensionId, getLocalExtensionIdFromManifest, getLocalExtensionIdFromGallery } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { adoptToGalleryExtensionId, areSameExtensions, getGalleryExtensionId, groupByExtension, getMaliciousExtensionsSet, getLocalExtensionId, getGalleryExtensionTelemetryData, getLocalExtensionTelemetryData, getIdFromLocalExtensionId, getLocalExtensionIdFromManifest, getLocalExtensionIdFromGallery } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { localizeManifest } from '../common/extensionNls';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { Limiter, always, createCancelablePromise, CancelablePromise, Queue } from 'vs/base/common/async';
......@@ -150,7 +150,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
}
zip(extension: ILocalExtension): Promise<URI> {
this.logService.trace('ExtensionManagementService#zip', extension.identifier.id);
this.logService.trace('ExtensionManagementService#zip', extension.galleryIdentifier.id);
return this.collectFiles(extension)
.then(files => zip(path.join(tmpdir(), generateUuid()), files))
.then(path => URI.file(path));
......@@ -204,7 +204,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
const extensionIdentifier = { id: getGalleryExtensionId(manifest.publisher, manifest.name) };
return this.getInstalled(ExtensionType.User)
.then(installedExtensions => {
const newer = installedExtensions.filter(local => areSameExtensions(extensionIdentifier, { id: getGalleryExtensionIdFromLocal(local) }) && semver.gt(local.manifest.version, manifest.version))[0];
const newer = installedExtensions.filter(local => areSameExtensions(extensionIdentifier, local.galleryIdentifier) && semver.gt(local.manifest.version, manifest.version))[0];
return newer ? this.uninstall(newer, true) : undefined;
})
.then(() => {
......@@ -349,7 +349,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
}
reinstallFromGallery(extension: ILocalExtension): Promise<void> {
this.logService.trace('ExtensionManagementService#reinstallFromGallery', extension.identifier.id);
this.logService.trace('ExtensionManagementService#reinstallFromGallery', extension.galleryIdentifier.id);
if (!this.galleryService.isEnabled()) {
return Promise.reject(new Error(nls.localize('MarketPlaceDisabled', "Marketplace is not enabled")));
}
......@@ -367,7 +367,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
}
private getOperation(extensionToInstall: IExtensionIdentifier, installed: ILocalExtension[]): InstallOperation {
return installed.some(i => areSameExtensions({ id: getGalleryExtensionIdFromLocal(i), uuid: i.identifier.uuid }, extensionToInstall)) ? InstallOperation.Update : InstallOperation.Install;
return installed.some(i => areSameExtensions(i.galleryIdentifier, extensionToInstall)) ? InstallOperation.Update : InstallOperation.Install;
}
private getTelemetryEvent(operation: InstallOperation): string {
......@@ -530,7 +530,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
}
uninstall(extension: ILocalExtension, force = false): Promise<void> {
this.logService.trace('ExtensionManagementService#uninstall', extension.identifier.id);
this.logService.trace('ExtensionManagementService#uninstall', extension.galleryIdentifier.id);
return this.toNonCancellablePromise(this.getInstalled(ExtensionType.User)
.then(installed => {
const extensionsToUninstall = installed
......@@ -545,7 +545,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
}
updateMetadata(local: ILocalExtension, metadata: IGalleryMetadata): Promise<ILocalExtension> {
this.logService.trace('ExtensionManagementService#updateMetadata', local.identifier.id);
this.logService.trace('ExtensionManagementService#updateMetadata', local.galleryIdentifier.id);
local.metadata = metadata;
return this.saveMetadataForLocalExtension(local)
.then(localExtension => {
......@@ -572,11 +572,11 @@ export class ExtensionManagementService extends Disposable implements IExtension
}
private findGalleryExtension(local: ILocalExtension): Promise<IGalleryExtension> {
if (local.identifier.uuid) {
return this.findGalleryExtensionById(local.identifier.uuid)
.then(galleryExtension => galleryExtension ? galleryExtension : this.findGalleryExtensionByName(getGalleryExtensionIdFromLocal(local)));
if (local.galleryIdentifier.uuid) {
return this.findGalleryExtensionById(local.galleryIdentifier.uuid)
.then(galleryExtension => galleryExtension ? galleryExtension : this.findGalleryExtensionByName(local.galleryIdentifier.id));
}
return this.findGalleryExtensionByName(getGalleryExtensionIdFromLocal(local));
return this.findGalleryExtensionByName(local.galleryIdentifier.id);
}
private findGalleryExtensionById(uuid: string): Promise<IGalleryExtension> {
......@@ -672,31 +672,30 @@ export class ExtensionManagementService extends Disposable implements IExtension
return Promise.resolve(pfs.exists(extension.location.fsPath))
.then(exists => exists ? null : Promise.reject(new Error(nls.localize('notExists', "Could not find extension"))))
.then(() => {
this.logService.info('Uninstalling extension:', extension.identifier.id);
this.logService.info('Uninstalling extension:', extension.galleryIdentifier.id);
this._onUninstallExtension.fire(extension.identifier);
});
}
private uninstallExtension(local: ILocalExtension): Promise<void> {
const id = getGalleryExtensionIdFromLocal(local);
let promise = this.uninstallingExtensions.get(id);
let promise = this.uninstallingExtensions.get(local.galleryIdentifier.id);
if (!promise) {
// Set all versions of the extension as uninstalled
promise = createCancelablePromise(token => this.scanUserExtensions(false)
.then(userExtensions => this.setUninstalled(...userExtensions.filter(u => areSameExtensions({ id: getGalleryExtensionIdFromLocal(u), uuid: u.identifier.uuid }, { id, uuid: local.identifier.uuid }))))
.then(() => { this.uninstallingExtensions.delete(id); }));
this.uninstallingExtensions.set(id, promise);
.then(userExtensions => this.setUninstalled(...userExtensions.filter(u => areSameExtensions(u.galleryIdentifier, local.galleryIdentifier))))
.then(() => { this.uninstallingExtensions.delete(local.galleryIdentifier.id); }));
this.uninstallingExtensions.set(local.galleryIdentifier.id, promise);
}
return promise;
}
private async postUninstallExtension(extension: ILocalExtension, error?: Error): Promise<void> {
if (error) {
this.logService.error('Failed to uninstall extension:', extension.identifier.id, error.message);
this.logService.error('Failed to uninstall extension:', extension.galleryIdentifier.id, error.message);
} else {
this.logService.info('Successfully uninstalled extension:', extension.identifier.id);
this.logService.info('Successfully uninstalled extension:', extension.galleryIdentifier.id);
// only report if extension has a mapped gallery extension. UUID identifies the gallery extension.
if (extension.identifier.uuid) {
if (extension.galleryIdentifier.uuid) {
await this.galleryService.reportStatistic(extension.manifest.publisher, extension.manifest.name, extension.manifest.version, StatisticType.Uninstall);
}
}
......@@ -753,7 +752,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
.then(([uninstalled, extensions]) => {
extensions = extensions.filter(e => !uninstalled[e.identifier.id]);
if (excludeOutdated) {
const byExtension: ILocalExtension[][] = groupByExtension(extensions, e => ({ id: getGalleryExtensionIdFromLocal(e), uuid: e.identifier.uuid }));
const byExtension: ILocalExtension[][] = groupByExtension(extensions, e => e.galleryIdentifier);
extensions = byExtension.map(p => p.sort((a, b) => semver.rcompare(a.manifest.version, b.manifest.version))[0]);
}
this.logService.info('Scanned user extensions:', extensions.length);
......@@ -808,7 +807,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
const toRemove: ILocalExtension[] = [];
// Outdated extensions
const byExtension: ILocalExtension[][] = groupByExtension(extensions, e => ({ id: getGalleryExtensionIdFromLocal(e), uuid: e.identifier.uuid }));
const byExtension: ILocalExtension[][] = groupByExtension(extensions, e => e.galleryIdentifier);
toRemove.push(...flatten(byExtension.map(p => p.sort((a, b) => semver.rcompare(a.manifest.version, b.manifest.version)).slice(1))));
return Promise.all(toRemove.map(extension => this.removeExtension(extension, 'outdated')));
......@@ -822,8 +821,8 @@ export class ExtensionManagementService extends Disposable implements IExtension
}
private removeExtension(extension: ILocalExtension, type: string): Promise<void> {
this.logService.trace(`Deleting ${type} extension from disk`, extension.identifier.id);
return pfs.rimraf(extension.location.fsPath).then(() => this.logService.info('Deleted from disk', extension.identifier.id));
this.logService.trace(`Deleting ${type} extension from disk`, extension.galleryIdentifier.id, extension.location.fsPath);
return pfs.rimraf(extension.location.fsPath).then(() => this.logService.info('Deleted from disk', extension.galleryIdentifier.id, extension.location.fsPath));
}
private isUninstalled(id: string): Promise<boolean> {
......
......@@ -9,7 +9,7 @@ import { IExtensionManagementService, ILocalExtension, IExtensionIdentifier } fr
import { Disposable } from 'vs/base/common/lifecycle';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { Queue } from 'vs/base/common/async';
import { areSameExtensions, getGalleryExtensionIdFromLocal, getIdFromLocalExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { areSameExtensions, getIdFromLocalExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { ILogService } from 'vs/platform/log/common/log';
import { isValidLocalization, ILocalizationsService, LanguageType } from 'vs/platform/localizations/common/localizations';
import product from 'vs/platform/node/product';
......@@ -68,7 +68,7 @@ export class LocalizationsService extends Disposable implements ILocalizationsSe
private onDidInstallExtension(extension: ILocalExtension | undefined): void {
if (extension && extension.manifest && extension.manifest.contributes && extension.manifest.contributes.localizations && extension.manifest.contributes.localizations.length) {
this.logService.debug('Adding language packs from the extension', extension.identifier.id);
this.logService.debug('Adding language packs from the extension', extension.galleryIdentifier.id);
this.update();
}
}
......@@ -136,7 +136,7 @@ class LanguagePacksCache extends Disposable {
}
private createLanguagePacksFromExtension(languagePacks: { [language: string]: ILanguagePack }, extension: ILocalExtension): void {
const extensionIdentifier = { id: getGalleryExtensionIdFromLocal(extension), uuid: extension.identifier.uuid };
const extensionIdentifier = extension.galleryIdentifier;
const localizations = extension.manifest.contributes && extension.manifest.contributes.localizations ? extension.manifest.contributes.localizations : [];
for (const localizationContribution of localizations) {
if (extension.location.scheme === Schemas.file && isValidLocalization(localizationContribution)) {
......
......@@ -40,7 +40,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
import { Emitter, Event } from 'vs/base/common/event';
import { assign } from 'vs/base/common/objects';
import { URI } from 'vs/base/common/uri';
import { areSameExtensions, getGalleryExtensionIdFromLocal } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { IExperimentService, ExperimentActionType, ExperimentState } from 'vs/workbench/parts/experiments/node/experimentService';
import { CancellationToken } from 'vs/base/common/cancellation';
import { getKeywordsForExtension } from 'vs/workbench/parts/extensions/electron-browser/extensionsUtils';
......@@ -421,7 +421,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
}
this.extensionsService.getInstalled(ExtensionType.User).then(local => {
const recommendations = filteredRecs.filter(({ extensionId }) => local.every(local => !areSameExtensions({ id: extensionId }, { id: getGalleryExtensionIdFromLocal(local) })));
const recommendations = filteredRecs.filter(({ extensionId }) => local.every(local => !areSameExtensions({ id: extensionId }, local.galleryIdentifier)));
if (!recommendations.length) {
return Promise.resolve(undefined);
......
......@@ -13,7 +13,7 @@ import { IExtensionManagementService, ILocalExtension, IExtensionEnablementServi
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { areSameExtensions, adoptToGalleryExtensionId, getGalleryExtensionIdFromLocal } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { getIdAndVersionFromLocalExtensionId } from 'vs/platform/extensionManagement/node/extensionManagementUtil';
import { Severity, INotificationService } from 'vs/platform/notification/common/notification';
import product from 'vs/platform/node/product';
......@@ -126,9 +126,9 @@ export function getInstalledExtensions(accessor: ServicesAccessor): Promise<IExt
.then(disabledExtensions => {
return extensions.map(extension => {
return {
identifier: { id: adoptToGalleryExtensionId(stripVersion(extension.identifier.id)), uuid: extension.identifier.uuid },
identifier: extension.galleryIdentifier,
local: extension,
globallyEnabled: disabledExtensions.every(disabled => !areSameExtensions(disabled, extension.identifier))
globallyEnabled: disabledExtensions.every(disabled => !areSameExtensions(disabled, extension.galleryIdentifier))
};
});
});
......@@ -137,7 +137,7 @@ export function getInstalledExtensions(accessor: ServicesAccessor): Promise<IExt
export function isKeymapExtension(tipsService: IExtensionTipsService, extension: IExtensionStatus): boolean {
const cats = extension.local.manifest.categories;
return cats && cats.indexOf('Keymaps') !== -1 || tipsService.getKeymapRecommendations().some(({ extensionId }) => areSameExtensions({ id: extensionId }, { id: getGalleryExtensionIdFromLocal(extension.local) }));
return cats && cats.indexOf('Keymaps') !== -1 || tipsService.getKeymapRecommendations().some(({ extensionId }) => areSameExtensions({ id: extensionId }, extension.local.galleryIdentifier));
}
function stripVersion(id: string): string {
......
......@@ -40,7 +40,7 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IContextKeyService, ContextKeyExpr, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { getGalleryExtensionIdFromLocal, getMaliciousExtensionsSet } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { getMaliciousExtensionsSet } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { ILogService } from 'vs/platform/log/common/log';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IWindowService } from 'vs/platform/windows/common/windows';
......@@ -635,13 +635,13 @@ export class MaliciousExtensionChecker implements IWorkbenchContribution {
return this.extensionsManagementService.getInstalled(ExtensionType.User).then(installed => {
const maliciousExtensions = installed
.filter(e => maliciousSet.has(getGalleryExtensionIdFromLocal(e)));
.filter(e => maliciousSet.has(e.galleryIdentifier.id));
if (maliciousExtensions.length) {
return Promise.all(maliciousExtensions.map(e => this.extensionsManagementService.uninstall(e, true).then(() => {
this.notificationService.prompt(
Severity.Warning,
localize('malicious warning', "We have uninstalled '{0}' which was reported to be problematic.", getGalleryExtensionIdFromLocal(e)),
localize('malicious warning', "We have uninstalled '{0}' which was reported to be problematic.", e.galleryIdentifier.id),
[{
label: localize('reloadNow', "Reload Now"),
run: () => this.windowService.reloadWindow()
......
......@@ -232,7 +232,7 @@ export class ExtensionsListView extends ViewletPanel {
&& e.local.manifest.contributes
&& Array.isArray(e.local.manifest.contributes.grammars)
&& e.local.manifest.contributes.grammars.length
&& e.local.identifier.id !== 'git';
&& e.local.galleryIdentifier.id !== 'vscode.git';
});
return this.getPagedModel(this.sortExtensions(basics, options));
}
......@@ -240,7 +240,7 @@ export class ExtensionsListView extends ViewletPanel {
const others = result.filter(e => {
return e.local.manifest
&& e.local.manifest.contributes
&& (!Array.isArray(e.local.manifest.contributes.grammars) || e.local.identifier.id === 'git')
&& (!Array.isArray(e.local.manifest.contributes.grammars) || e.local.galleryIdentifier.id === 'vscode.git')
&& !Array.isArray(e.local.manifest.contributes.themes);
});
return this.getPagedModel(this.sortExtensions(others, options));
......
......@@ -16,7 +16,7 @@ import {
IExtensionManagementService, IExtensionGalleryService, ILocalExtension, IGalleryExtension, IQueryOptions,
InstallExtensionEvent, DidInstallExtensionEvent, DidUninstallExtensionEvent, IExtensionEnablementService, IExtensionIdentifier, EnablementState, IExtensionManagementServerService
} from 'vs/platform/extensionManagement/common/extensionManagement';
import { getGalleryExtensionIdFromLocal, getGalleryExtensionTelemetryData, getLocalExtensionTelemetryData, areSameExtensions, getMaliciousExtensionsSet, getLocalExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { getGalleryExtensionTelemetryData, getLocalExtensionTelemetryData, areSameExtensions, getMaliciousExtensionsSet, getLocalExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWindowService } from 'vs/platform/windows/common/windows';
......@@ -78,11 +78,11 @@ class Extension implements IExtension {
if (this.gallery) {
return this.gallery.identifier;
}
return { id: getGalleryExtensionIdFromLocal(this.local), uuid: this.local.identifier.uuid };
return this.local.galleryIdentifier;
}
get uuid(): string | undefined {
return this.gallery ? this.gallery.identifier.uuid : this.local.identifier.uuid;
return this.gallery ? this.gallery.identifier.uuid : this.local.galleryIdentifier.uuid;
}
get publisher(): string {
......@@ -432,13 +432,13 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
return this.extensionService.getInstalled()
.then(installed => this.getDistinctInstalledExtensions(installed)
.then(distinctInstalled => {
const installedById = index(this.installed, e => e.local.identifier.id);
const groupById = groupBy(installed, i => getGalleryExtensionIdFromLocal(i));
const installedById = index(this.installed, e => e.identifier.id);
const groupById = groupBy(installed, i => i.galleryIdentifier.id);
this.installed = distinctInstalled.map(local => {
const locals = groupById[getGalleryExtensionIdFromLocal(local)];
const locals = groupById[local.galleryIdentifier.id];
locals.splice(locals.indexOf(local), 1);
locals.splice(0, 0, local);
const extension = installedById[local.identifier.id] || new Extension(this.galleryService, this.stateProvider, locals, undefined, this.telemetryService, this.logService, this.fileService);
const extension = installedById[local.galleryIdentifier.id] || new Extension(this.galleryService, this.stateProvider, locals, undefined, this.telemetryService, this.logService, this.fileService);
extension.locals = locals;
extension.enablementState = this.extensionEnablementService.getEnablementState(local);
return extension;
......@@ -498,7 +498,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
return Promise.all([this.runtimeExtensionService.getExtensions(), this.extensionEnablementService.getDisabledExtensions()])
.then(([runtimeExtensions, disabledExtensionIdentifiers]) => {
const groups = groupBy(allInstalled, (extension: ILocalExtension) => {
const isDisabled = disabledExtensionIdentifiers.some(identifier => areSameExtensions(identifier, { id: getGalleryExtensionIdFromLocal(extension), uuid: extension.identifier.uuid }));
const isDisabled = disabledExtensionIdentifiers.some(identifier => areSameExtensions(identifier, extension.galleryIdentifier));
if (isDisabled) {
return extension.location.scheme === Schemas.file ? 'disabled:primary' : 'disabled:secondary';
} else {
......@@ -511,21 +511,20 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
for (const extension of (groups['enabled'] || [])) {
if (runtimeExtensions.some(r => r.extensionLocation.toString() === extension.location.toString())) {
enabled.push(extension);
seenExtensions[getGalleryExtensionIdFromLocal(extension)] = true;
seenExtensions[extension.galleryIdentifier.id] = true;
} else {
notRunningExtensions.push(extension);
}
}
for (const extension of notRunningExtensions) {
if (!seenExtensions[getGalleryExtensionIdFromLocal(extension)]) {
if (!seenExtensions[extension.galleryIdentifier.id]) {
enabled.push(extension);
seenExtensions[getGalleryExtensionIdFromLocal(extension)] = true;
seenExtensions[extension.galleryIdentifier.id] = true;
}
}
const primaryDisabled = groups['disabled:primary'] || [];
const secondaryDisabled = (groups['disabled:secondary'] || []).filter(disabled => {
const identifier: IExtensionIdentifier = { id: getGalleryExtensionIdFromLocal(disabled), uuid: disabled.identifier.uuid };
return primaryDisabled.every(p => !areSameExtensions({ id: getGalleryExtensionIdFromLocal(p), uuid: p.identifier.uuid }, identifier));
return primaryDisabled.every(p => !areSameExtensions(p.galleryIdentifier, disabled.galleryIdentifier));
});
return [...enabled, ...primaryDisabled, ...secondaryDisabled];
});
......@@ -534,11 +533,10 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
private hasDuplicates(extensions: ILocalExtension[]): boolean {
const seen: { [key: string]: boolean; } = Object.create(null);
for (const i of extensions) {
const key = getGalleryExtensionIdFromLocal(i);
if (seen[key]) {
if (seen[i.galleryIdentifier.id]) {
return true;
}
seen[key] = true;
seen[i.galleryIdentifier.id] = true;
}
return false;
}
......@@ -711,7 +709,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
return this.progressService.withProgress({
location: ProgressLocation.Extensions,
title: nls.localize('uninstallingExtension', 'Uninstalling extension....'),
source: `${toUninstall[0].identifier.id}`
source: `${toUninstall[0].galleryIdentifier.id}`
}, () => Promise.all(toUninstall.map(local => this.extensionService.uninstall(local))).then(() => undefined));
}
......@@ -754,7 +752,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
return this.progressService.withProgress({
location: ProgressLocation.Extensions,
source: `${toReinstall[0].identifier.id}`
source: `${toReinstall[0].galleryIdentifier.id}`
}, () => Promise.all(toReinstall.map(local => this.extensionService.reinstallFromGallery(local))).then(() => undefined));
}
......@@ -767,7 +765,7 @@ export class ExtensionsWorkbenchService implements IExtensionsWorkbenchService,
}
private checkAndEnableDisabledDependencies(extensionIdentifier: IExtensionIdentifier): Promise<void> {
const extension = this.local.filter(e => (e.local || e.gallery) && areSameExtensions(extensionIdentifier, e.local ? e.local.identifier : e.gallery!.identifier))[0];
const extension = this.local.filter(e => (e.local || e.gallery) && areSameExtensions(extensionIdentifier, e.identifier))[0];
if (extension) {
const disabledDepencies = this.getExtensionsRecursively([extension], this.local, EnablementState.Enabled, { dependencies: true, pack: false });
if (disabledDepencies.length) {
......
......@@ -49,7 +49,7 @@ export class PreferencesSearchService extends Disposable implements IPreferences
return exts
.filter(ext => this.extensionEnablementService.isEnabled(ext))
.filter(ext => ext.manifest && ext.manifest.contributes && ext.manifest.contributes.configuration)
.filter(ext => !!ext.identifier.uuid);
.filter(ext => !!ext.galleryIdentifier.uuid);
});
}
......@@ -393,7 +393,7 @@ class RemoteSearchProvider implements ISearchProvider {
}
private getExtensionFilter(ext: ILocalExtension): string {
const uuid = ext.identifier.uuid;
const uuid = ext.galleryIdentifier.uuid;
const versionString = ext.manifest.version
.split('.')
.map(versionPart => strings.pad(<any>versionPart, 10))
......
......@@ -14,7 +14,7 @@ import { isEqualOrParent } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { EnablementState, IExtensionEnablementService, IExtensionIdentifier, IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { BetterMergeId, areSameExtensions, getGalleryExtensionIdFromLocal } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { BetterMergeId, areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import pkg from 'vs/platform/node/package';
......@@ -494,7 +494,7 @@ export class ExtensionService extends Disposable implements IExtensionService {
if (extensionsToDisable.length) {
return this._extensionManagementService.getInstalled(ExtensionType.User)
.then(installed => {
const toDisable = installed.filter(i => extensionsToDisable.some(e => areSameExtensions({ id: getGalleryExtensionIdFromLocal(i) }, e)));
const toDisable = installed.filter(i => extensionsToDisable.some(e => areSameExtensions(i.galleryIdentifier, e)));
return Promise.all(toDisable.map(e => this._extensionEnablementService.setEnablement(e, EnablementState.Disabled)));
})
.then(() => {
......
......@@ -40,7 +40,7 @@ export class WorkbenchIssueService implements IWorkbenchIssueService {
repositoryUrl: manifest.repository && manifest.repository.url,
bugsUrl: manifest.bugs && manifest.bugs.url,
displayName: manifest.displayName,
id: extension.identifier.id,
id: extension.galleryIdentifier.id,
isTheme: isTheme
};
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册