feat: IDE server模式下添加三个插件的ExtensionContextkey监听.

This commit is contained in:
chriswang521 2024-06-21 14:52:12 +08:00 committed by wangpenglong
parent 118a10dd93
commit 1a9a004205
1 changed files with 22 additions and 3 deletions

View File

@ -41,9 +41,16 @@ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteA
import { IRemoteExplorerService } from 'vs/workbench/services/remote/common/remoteExplorerService';
import { IUserDataInitializationService } from 'vs/workbench/services/userData/browser/userDataInit';
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
const HasInstalledExtDependencyExtensionContext = new RawContextKey<boolean>('hasExtDependency', false);
const HasInstalledOfflineExtManagerExtensionContext = new RawContextKey<boolean>('hasOfflineExtManager', false);
const HasInstalledProjectManagerExtensionContext = new RawContextKey<boolean>('hasProjectManager', false);
export class ExtensionService extends AbstractExtensionService implements IExtensionService {
private HasInstalledExtDependencyExtensionContextKey: IContextKey<boolean>;
private HasInstalledOfflineExtManagerExtensionContextKey: IContextKey<boolean>;
private HasInstalledProjectManagerExtensionContextKey: IContextKey<boolean>;
constructor(
@IInstantiationService instantiationService: IInstantiationService,
@INotificationService notificationService: INotificationService,
@ -67,6 +74,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
@IWorkspaceTrustManagementService private readonly _workspaceTrustManagementService: IWorkspaceTrustManagementService,
@IRemoteExplorerService private readonly _remoteExplorerService: IRemoteExplorerService,
@IDialogService dialogService: IDialogService,
@IContextKeyService contextKeyService: IContextKeyService,
) {
const extensionsProposedApi = instantiationService.createInstance(ExtensionsProposedApi);
const extensionHostFactory = new BrowserExtensionHostFactory(
@ -79,6 +87,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
extensionEnablementService,
logService
);
super(
extensionsProposedApi,
extensionHostFactory,
@ -101,7 +110,9 @@ export class ExtensionService extends AbstractExtensionService implements IExten
remoteAuthorityResolverService,
dialogService
);
this.HasInstalledExtDependencyExtensionContextKey = HasInstalledExtDependencyExtensionContext.bindTo(contextKeyService);
this.HasInstalledOfflineExtManagerExtensionContextKey = HasInstalledOfflineExtManagerExtensionContext.bindTo(contextKeyService);
this.HasInstalledProjectManagerExtensionContextKey = HasInstalledProjectManagerExtensionContext.bindTo(contextKeyService);
// Initialize installed extensions first and do it only after workbench is ready
lifecycleService.when(LifecyclePhase.Ready).then(async () => {
await this._userDataInitializationService.initializeInstalledExtensions(this._instantiationService);
@ -149,7 +160,15 @@ export class ExtensionService extends AbstractExtensionService implements IExten
this._scanWebExtensions(),
this._remoteExtensionsScannerService.scanExtensions()
]);
remoteExtensions.forEach(extension => {
if (extension.identifier.value === 'KylinIDETeam.extension-dependency') {
this.HasInstalledExtDependencyExtensionContextKey.set(true);
} else if (extension.identifier.value === 'KylinIDETeam.offline-extensions-manager') {
this.HasInstalledOfflineExtManagerExtensionContextKey.set(true);
} else if (extension.identifier.value === 'KylinIDETeam.project-manager') {
this.HasInstalledProjectManagerExtensionContextKey.set(true);
}
});
return new ResolvedExtensions(localExtensions, remoteExtensions, /*hasLocalProcess*/false, /*allowRemoteExtensionsInLocalWebWorker*/true);
}