Skip to content

Commit

Permalink
FIx #122448
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jun 22, 2021
1 parent ad59351 commit 82b4d9a
Show file tree
Hide file tree
Showing 7 changed files with 368 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2129,6 +2129,11 @@ export class SystemDisabledWarningAction extends ExtensionAction {
return;
}
}
if (this.extension.enablementState === EnablementState.DisabledByExtensionDependency) {
this.class = `${SystemDisabledWarningAction.WARNING_CLASS}`;
this.tooltip = localize('extension disabled because of dependency', "This extension has been disabled because it depends on an extension that is disabled.");
return;
}
if (this.extensionManagementServerService.localExtensionManagementServer && this.extensionManagementServerService.remoteExtensionManagementServer) {
if (isLanguagePackExtension(this.extension.local.manifest)) {
if (!this.extensionsWorkbenchService.installed.some(e => areSameExtensions(e.identifier, this.extension!.identifier) && e.server !== this.extension!.server)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ suite('ExtensionsWorkbenchServiceTest', () => {
}
});

instantiationService.stub(IExtensionManagementServerService, <IExtensionManagementServerService>{
localExtensionManagementServer: {
extensionManagementService: instantiationService.get(IExtensionManagementService)
}
});
instantiationService.stub(IExtensionManagementServerService, anExtensionManagementServerService({
id: 'local',
label: 'local',
extensionManagementService: instantiationService.get(IExtensionManagementService)
}, null, null));

instantiationService.stub(IWorkbenchExtensionEnablementService, new TestExtensionEnablementService(instantiationService));

Expand All @@ -121,7 +121,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', []);
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage());
instantiationService.stubPromise(INotificationService, 'prompt', 0);
await (<TestExtensionEnablementService>instantiationService.get(IWorkbenchExtensionEnablementService)).reset();
(<TestExtensionEnablementService>instantiationService.get(IWorkbenchExtensionEnablementService)).reset();
});

teardown(() => {
Expand Down Expand Up @@ -1449,6 +1449,24 @@ suite('ExtensionsWorkbenchServiceTest', () => {
});
}

function anExtensionManagementServerService(localExtensionManagementServer: IExtensionManagementServer | null, remoteExtensionManagementServer: IExtensionManagementServer | null, webExtensionManagementServer: IExtensionManagementServer | null): IExtensionManagementServerService {
return {
_serviceBrand: undefined,
localExtensionManagementServer,
remoteExtensionManagementServer,
webExtensionManagementServer,
getExtensionManagementServer: (extension: IExtension) => {
if (extension.location.scheme === Schemas.file) {
return localExtensionManagementServer;
}
if (extension.location.scheme === Schemas.vscodeRemote) {
return remoteExtensionManagementServer;
}
return webExtensionManagementServer;
}
};
}

function aMultiExtensionManagementServerService(instantiationService: TestInstantiationService, localExtensionManagementService?: IExtensionManagementService, remoteExtensionManagementService?: IExtensionManagementService): IExtensionManagementServerService {
const localExtensionManagementServer: IExtensionManagementServer = {
id: 'vscode-local',
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { Event } from 'vs/base/common/event';
import { createDecorator, refineServiceDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IExtension, ExtensionType, IExtensionManifest } from 'vs/platform/extensions/common/extensions';
import { IExtensionManagementService, IGalleryExtension, IExtensionIdentifier, ILocalExtension, InstallOptions } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IExtensionManagementService, IGalleryExtension, IExtensionIdentifier, ILocalExtension, InstallOptions, InstallExtensionEvent, DidInstallExtensionEvent, DidUninstallExtensionEvent } from 'vs/platform/extensionManagement/common/extensionManagement';
import { URI } from 'vs/base/common/uri';

export interface IExtensionManagementServer {
Expand All @@ -24,9 +24,20 @@ export interface IExtensionManagementServerService {
getExtensionManagementServer(extension: IExtension): IExtensionManagementServer | null;
}

export type InstallExtensionOnServerEvent = InstallExtensionEvent & { server: IExtensionManagementServer };
export type DidInstallExtensionOnServerEvent = DidInstallExtensionEvent & { server: IExtensionManagementServer };
export type UninstallExtensionOnServerEvent = IExtensionIdentifier & { server: IExtensionManagementServer };
export type DidUninstallExtensionOnServerEvent = DidUninstallExtensionEvent & { server: IExtensionManagementServer };

export const IWorkbenchExtensionManagementService = refineServiceDecorator<IExtensionManagementService, IWorkbenchExtensionManagementService>(IExtensionManagementService);
export interface IWorkbenchExtensionManagementService extends IExtensionManagementService {
readonly _serviceBrand: undefined;

onInstallExtension: Event<InstallExtensionOnServerEvent>;
onDidInstallExtension: Event<DidInstallExtensionOnServerEvent>;
onUninstallExtension: Event<UninstallExtensionOnServerEvent>;
onDidUninstallExtension: Event<DidUninstallExtensionOnServerEvent>;

installWebExtension(location: URI): Promise<ILocalExtension>;
installExtensions(extensions: IGalleryExtension[], installOptions?: InstallOptions): Promise<ILocalExtension[]>;
updateFromGallery(gallery: IGalleryExtension, extension: ILocalExtension): Promise<ILocalExtension>;
Expand All @@ -38,6 +49,7 @@ export const enum EnablementState {
DisabledByExtensionKind,
DisabledByEnvironment,
DisabledByVirtualWorkspace,
DisabledByExtensionDependency,
DisabledGlobally,
DisabledWorkspace,
EnabledGlobally,
Expand All @@ -59,6 +71,12 @@ export interface IWorkbenchExtensionEnablementService {
*/
getEnablementState(extension: IExtension): EnablementState;

/**
* Returns the enablement states for the given extensions
* @param extensions list of extensions
*/
getEnablementStates(extensions: IExtension[]): EnablementState[];

/**
* Returns `true` if the enablement can be changed.
*/
Expand All @@ -82,12 +100,6 @@ export interface IWorkbenchExtensionEnablementService {
*/
isDisabledGlobally(extension: IExtension): boolean;

/**
* Returns `true` if the given extension identifier is enabled by the user but it it
* disabled due to the fact that the current window/folder/workspace is not trusted.
*/
isDisabledByWorkspaceTrust(extension: IExtension): boolean;

/**
* Enable or disable the given extension.
* if `workspace` is `true` then enablement is done for workspace, otherwise globally.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import { Event, EventMultiplexer } from 'vs/base/common/event';
import {
ILocalExtension, IGalleryExtension, InstallExtensionEvent, DidInstallExtensionEvent, IExtensionIdentifier, DidUninstallExtensionEvent, IReportedExtension, IGalleryMetadata, IExtensionGalleryService, InstallOptions, UninstallOptions, INSTALL_ERROR_NOT_SUPPORTED, InstallVSIXOptions
ILocalExtension, IGalleryExtension, IExtensionIdentifier, IReportedExtension, IGalleryMetadata, IExtensionGalleryService, InstallOptions, UninstallOptions, INSTALL_ERROR_NOT_SUPPORTED, InstallVSIXOptions
} from 'vs/platform/extensionManagement/common/extensionManagement';
import { IExtensionManagementServer, IExtensionManagementServerService, IWorkbenchExtensionManagementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
import { DidInstallExtensionOnServerEvent, DidUninstallExtensionOnServerEvent, IExtensionManagementServer, IExtensionManagementServerService, InstallExtensionOnServerEvent, IWorkbenchExtensionManagementService, UninstallExtensionOnServerEvent } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
import { ExtensionType, isLanguagePackExtension, IExtensionManifest } from 'vs/platform/extensions/common/extensions';
import { URI } from 'vs/base/common/uri';
import { Disposable } from 'vs/base/common/lifecycle';
Expand All @@ -31,10 +31,10 @@ export class ExtensionManagementService extends Disposable implements IWorkbench

declare readonly _serviceBrand: undefined;

readonly onInstallExtension: Event<InstallExtensionEvent>;
readonly onDidInstallExtension: Event<DidInstallExtensionEvent>;
readonly onUninstallExtension: Event<IExtensionIdentifier>;
readonly onDidUninstallExtension: Event<DidUninstallExtensionEvent>;
readonly onInstallExtension: Event<InstallExtensionOnServerEvent>;
readonly onDidInstallExtension: Event<DidInstallExtensionOnServerEvent>;
readonly onUninstallExtension: Event<UninstallExtensionOnServerEvent>;
readonly onDidUninstallExtension: Event<DidUninstallExtensionOnServerEvent>;

protected readonly servers: IExtensionManagementServer[] = [];

Expand All @@ -61,10 +61,10 @@ export class ExtensionManagementService extends Disposable implements IWorkbench
this.servers.push(this.extensionManagementServerService.webExtensionManagementServer);
}

this.onInstallExtension = this._register(this.servers.reduce((emitter: EventMultiplexer<InstallExtensionEvent>, server) => { emitter.add(server.extensionManagementService.onInstallExtension); return emitter; }, new EventMultiplexer<InstallExtensionEvent>())).event;
this.onDidInstallExtension = this._register(this.servers.reduce((emitter: EventMultiplexer<DidInstallExtensionEvent>, server) => { emitter.add(server.extensionManagementService.onDidInstallExtension); return emitter; }, new EventMultiplexer<DidInstallExtensionEvent>())).event;
this.onUninstallExtension = this._register(this.servers.reduce((emitter: EventMultiplexer<IExtensionIdentifier>, server) => { emitter.add(server.extensionManagementService.onUninstallExtension); return emitter; }, new EventMultiplexer<IExtensionIdentifier>())).event;
this.onDidUninstallExtension = this._register(this.servers.reduce((emitter: EventMultiplexer<DidUninstallExtensionEvent>, server) => { emitter.add(server.extensionManagementService.onDidUninstallExtension); return emitter; }, new EventMultiplexer<DidUninstallExtensionEvent>())).event;
this.onInstallExtension = this._register(this.servers.reduce((emitter: EventMultiplexer<InstallExtensionOnServerEvent>, server) => { emitter.add(Event.map(server.extensionManagementService.onInstallExtension, e => ({ ...e, server }))); return emitter; }, new EventMultiplexer<InstallExtensionOnServerEvent>())).event;
this.onDidInstallExtension = this._register(this.servers.reduce((emitter: EventMultiplexer<DidInstallExtensionOnServerEvent>, server) => { emitter.add(Event.map(server.extensionManagementService.onDidInstallExtension, e => ({ ...e, server }))); return emitter; }, new EventMultiplexer<DidInstallExtensionOnServerEvent>())).event;
this.onUninstallExtension = this._register(this.servers.reduce((emitter: EventMultiplexer<UninstallExtensionOnServerEvent>, server) => { emitter.add(Event.map(server.extensionManagementService.onUninstallExtension, e => ({ ...e, server }))); return emitter; }, new EventMultiplexer<UninstallExtensionOnServerEvent>())).event;
this.onDidUninstallExtension = this._register(this.servers.reduce((emitter: EventMultiplexer<DidUninstallExtensionOnServerEvent>, server) => { emitter.add(Event.map(server.extensionManagementService.onDidUninstallExtension, e => ({ ...e, server }))); return emitter; }, new EventMultiplexer<DidUninstallExtensionOnServerEvent>())).event;
}

async getInstalled(type?: ExtensionType): Promise<ILocalExtension[]> {
Expand Down
Loading

0 comments on commit 82b4d9a

Please sign in to comment.