Fixed 项目创建后,帮助菜单缺少插件依赖管理器和离线插件管理器菜单项

This commit is contained in:
chriswang521 2023-05-30 16:46:43 +08:00
parent e98641595c
commit f5ee416cc7
2 changed files with 19 additions and 23 deletions

View File

@ -14,7 +14,7 @@ import { Context as SuggestContext } from 'vs/editor/contrib/suggest/browser/sug
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import { Action2, MenuId, MenuRegistry, registerAction2 } from 'vs/platform/actions/common/actions'; import { Action2, MenuId, MenuRegistry, registerAction2 } from 'vs/platform/actions/common/actions';
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands'; import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
import { ContextKeyExpr, IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { InputFocusedContext, IsMacNativeContext } from 'vs/platform/contextkey/common/contextkeys'; import { InputFocusedContext, IsMacNativeContext } from 'vs/platform/contextkey/common/contextkeys';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
@ -60,9 +60,6 @@ const SETTINGS_EDITOR_COMMAND_FILTER_UNTRUSTED = 'settings.filterUntrusted';
const SETTINGS_COMMAND_OPEN_SETTINGS = 'workbench.action.openSettings'; const SETTINGS_COMMAND_OPEN_SETTINGS = 'workbench.action.openSettings';
const HasInstalledExtDependencyExtensionContext = new RawContextKey<boolean>('hasExtDependency', false); //by wpl
const HasInstalledOfflineExtManagerExtensionContext = new RawContextKey<boolean>('hasOfflineExtManager', false); //by wpl
Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane( Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(
EditorPaneDescriptor.create( EditorPaneDescriptor.create(
@ -141,16 +138,12 @@ function sanitizeOpenSettingsArgs(args: any): IOpenSettingsActionOptions {
class PreferencesActionsContribution extends Disposable implements IWorkbenchContribution { class PreferencesActionsContribution extends Disposable implements IWorkbenchContribution {
private HasInstalledExtDependencyExtensionContextKey: IContextKey<boolean>;
private HasInstalledOfflineExtManagerExtensionContextKey: IContextKey<boolean>;
constructor( constructor(
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService, @IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IPreferencesService private readonly preferencesService: IPreferencesService, @IPreferencesService private readonly preferencesService: IPreferencesService,
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService, @IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
@ILabelService private readonly labelService: ILabelService, @ILabelService private readonly labelService: ILabelService,
@IExtensionService private readonly extensionService: IExtensionService, @IExtensionService private readonly extensionService: IExtensionService,
@IContextKeyService contextKeyService: IContextKeyService,
) { ) {
super(); super();
@ -161,21 +154,6 @@ class PreferencesActionsContribution extends Disposable implements IWorkbenchCon
this._register(workspaceContextService.onDidChangeWorkbenchState(() => this.updatePreferencesEditorMenuItem())); this._register(workspaceContextService.onDidChangeWorkbenchState(() => this.updatePreferencesEditorMenuItem()));
this._register(workspaceContextService.onDidChangeWorkspaceFolders(() => this.updatePreferencesEditorMenuItemForWorkspaceFolders())); this._register(workspaceContextService.onDidChangeWorkspaceFolders(() => this.updatePreferencesEditorMenuItemForWorkspaceFolders()));
this.HasInstalledExtDependencyExtensionContextKey = HasInstalledExtDependencyExtensionContext.bindTo(contextKeyService);
this.HasInstalledOfflineExtManagerExtensionContextKey = HasInstalledOfflineExtManagerExtensionContext.bindTo(contextKeyService);
this.checkallextension();
}
//check extension
private async checkallextension() {
const runningExtensions = await this.extensionService.getExtensions();
for (let extension of runningExtensions) {
if (extension.identifier.value === 'KylinIDETeam.extension-dependency') {
this.HasInstalledExtDependencyExtensionContextKey.set(true);
} else if (extension.identifier.value === 'KylinIDETeam.offline-extensions-manager') {
this.HasInstalledOfflineExtManagerExtensionContextKey.set(true);
}
}
} }
private registerSettingsActions() { private registerSettingsActions() {

View File

@ -15,23 +15,34 @@ import { localize } from 'vs/nls';
import { INotificationService } from 'vs/platform/notification/common/notification'; import { INotificationService } from 'vs/platform/notification/common/notification';
import { IHostService } from 'vs/workbench/services/host/browser/host'; import { IHostService } from 'vs/workbench/services/host/browser/host';
import { timeout } from 'vs/base/common/async'; import { timeout } from 'vs/base/common/async';
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
const HasInstalledExtDependencyExtensionContext = new RawContextKey<boolean>('hasExtDependency', false);
const HasInstalledOfflineExtManagerExtensionContext = new RawContextKey<boolean>('hasOfflineExtManager', false);
export class CachedExtensionScanner { export class CachedExtensionScanner {
public readonly scannedExtensions: Promise<IExtensionDescription[]>; public readonly scannedExtensions: Promise<IExtensionDescription[]>;
private _scannedExtensionsResolve!: (result: IExtensionDescription[]) => void; private _scannedExtensionsResolve!: (result: IExtensionDescription[]) => void;
private _scannedExtensionsReject!: (err: any) => void; private _scannedExtensionsReject!: (err: any) => void;
private HasInstalledExtDependencyExtensionContextKey: IContextKey<boolean>;
private HasInstalledOfflineExtManagerExtensionContextKey: IContextKey<boolean>;
constructor( constructor(
@INotificationService private readonly _notificationService: INotificationService, @INotificationService private readonly _notificationService: INotificationService,
@IHostService private readonly _hostService: IHostService, @IHostService private readonly _hostService: IHostService,
@IExtensionsScannerService private readonly _extensionsScannerService: IExtensionsScannerService, @IExtensionsScannerService private readonly _extensionsScannerService: IExtensionsScannerService,
@ILogService private readonly _logService: ILogService, @ILogService private readonly _logService: ILogService,
@IContextKeyService contextKeyService: IContextKeyService,
) { ) {
this.scannedExtensions = new Promise<IExtensionDescription[]>((resolve, reject) => { this.scannedExtensions = new Promise<IExtensionDescription[]>((resolve, reject) => {
this._scannedExtensionsResolve = resolve; this._scannedExtensionsResolve = resolve;
this._scannedExtensionsReject = reject; this._scannedExtensionsReject = reject;
}); });
this.HasInstalledExtDependencyExtensionContextKey = HasInstalledExtDependencyExtensionContext.bindTo(contextKeyService);
this.HasInstalledOfflineExtManagerExtensionContextKey = HasInstalledOfflineExtManagerExtensionContext.bindTo(contextKeyService);
} }
public async scanSingleExtension(extensionPath: string, isBuiltin: boolean): Promise<IExtensionDescription | null> { public async scanSingleExtension(extensionPath: string, isBuiltin: boolean): Promise<IExtensionDescription | null> {
@ -43,6 +54,13 @@ export class CachedExtensionScanner {
try { try {
const { system, user, development } = await this._scanInstalledExtensions(); const { system, user, development } = await this._scanInstalledExtensions();
const r = dedupExtensions(system, user, development, this._logService); const r = dedupExtensions(system, user, development, this._logService);
for (let extension of r) {
if (extension.identifier.value === 'KylinIDETeam.extension-dependency') {
this.HasInstalledExtDependencyExtensionContextKey.set(true);
} else if (extension.identifier.value === 'KylinIDETeam.offline-extensions-manager') {
this.HasInstalledOfflineExtManagerExtensionContextKey.set(true);
}
}
this._scannedExtensionsResolve(r); this._scannedExtensionsResolve(r);
} catch (err) { } catch (err) {
this._scannedExtensionsReject(err); this._scannedExtensionsReject(err);