-
Notifications
You must be signed in to change notification settings - Fork 31k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sandbox - more lifting of extensions related management contributions
- Loading branch information
Showing
6 changed files
with
168 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
src/vs/workbench/contrib/extensions/electron-sandbox/extensions.contribution.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { localize } from 'vs/nls'; | ||
import { Registry } from 'vs/platform/registry/common/platform'; | ||
import { MenuRegistry, MenuId, registerAction2 } from 'vs/platform/actions/common/actions'; | ||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, IWorkbenchContribution } from 'vs/workbench/common/contributions'; | ||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; | ||
import { CommandsRegistry } from 'vs/platform/commands/common/commands'; | ||
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; | ||
import { EditorDescriptor, IEditorRegistry } from 'vs/workbench/browser/editor'; | ||
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; | ||
import { RuntimeExtensionsEditor, StartExtensionHostProfileAction, StopExtensionHostProfileAction, CONTEXT_PROFILE_SESSION_STATE, CONTEXT_EXTENSION_HOST_PROFILE_RECORDED, SaveExtensionHostProfileAction } from 'vs/workbench/contrib/extensions/electron-sandbox/runtimeExtensionsEditor'; | ||
import { DebugExtensionHostAction } from 'vs/workbench/contrib/extensions/electron-sandbox/debugExtensionHostAction'; | ||
import { EditorInput, IEditorInputSerializer, IEditorInputFactoryRegistry, ActiveEditorContext, EditorExtensions } from 'vs/workbench/common/editor'; | ||
import { RuntimeExtensionsInput } from 'vs/workbench/contrib/extensions/common/runtimeExtensionsInput'; | ||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; | ||
import { OpenExtensionsFolderAction } from 'vs/workbench/contrib/extensions/electron-sandbox/extensionsActions'; | ||
import { IExtensionRecommendationNotificationService } from 'vs/platform/extensionRecommendations/common/extensionRecommendations'; | ||
import { ISharedProcessService } from 'vs/platform/ipc/electron-sandbox/services'; | ||
import { ExtensionRecommendationNotificationServiceChannel } from 'vs/platform/extensionRecommendations/electron-sandbox/extensionRecommendationsIpc'; | ||
import { Codicon } from 'vs/base/common/codicons'; | ||
|
||
// Running Extensions Editor | ||
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor( | ||
EditorDescriptor.create(RuntimeExtensionsEditor, RuntimeExtensionsEditor.ID, localize('runtimeExtension', "Running Extensions")), | ||
[new SyncDescriptor(RuntimeExtensionsInput)] | ||
); | ||
|
||
class RuntimeExtensionsInputSerializer implements IEditorInputSerializer { | ||
canSerialize(editorInput: EditorInput): boolean { | ||
return true; | ||
} | ||
serialize(editorInput: EditorInput): string { | ||
return ''; | ||
} | ||
deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): EditorInput { | ||
return RuntimeExtensionsInput.instance; | ||
} | ||
} | ||
|
||
Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).registerEditorInputSerializer(RuntimeExtensionsInput.ID, RuntimeExtensionsInputSerializer); | ||
|
||
|
||
// Global actions | ||
|
||
class ExtensionsContributions implements IWorkbenchContribution { | ||
|
||
constructor( | ||
@IExtensionRecommendationNotificationService extensionRecommendationNotificationService: IExtensionRecommendationNotificationService, | ||
@ISharedProcessService sharedProcessService: ISharedProcessService, | ||
) { | ||
sharedProcessService.registerChannel('extensionRecommendationNotification', new ExtensionRecommendationNotificationServiceChannel(extensionRecommendationNotificationService)); | ||
registerAction2(OpenExtensionsFolderAction); | ||
} | ||
} | ||
|
||
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench); | ||
workbenchRegistry.registerWorkbenchContribution(ExtensionsContributions, LifecyclePhase.Starting); | ||
|
||
// Register Commands | ||
|
||
CommandsRegistry.registerCommand(DebugExtensionHostAction.ID, (accessor: ServicesAccessor) => { | ||
const instantiationService = accessor.get(IInstantiationService); | ||
instantiationService.createInstance(DebugExtensionHostAction).run(); | ||
}); | ||
|
||
CommandsRegistry.registerCommand(StartExtensionHostProfileAction.ID, (accessor: ServicesAccessor) => { | ||
const instantiationService = accessor.get(IInstantiationService); | ||
instantiationService.createInstance(StartExtensionHostProfileAction, StartExtensionHostProfileAction.ID, StartExtensionHostProfileAction.LABEL).run(); | ||
}); | ||
|
||
CommandsRegistry.registerCommand(StopExtensionHostProfileAction.ID, (accessor: ServicesAccessor) => { | ||
const instantiationService = accessor.get(IInstantiationService); | ||
instantiationService.createInstance(StopExtensionHostProfileAction, StopExtensionHostProfileAction.ID, StopExtensionHostProfileAction.LABEL).run(); | ||
}); | ||
|
||
CommandsRegistry.registerCommand(SaveExtensionHostProfileAction.ID, (accessor: ServicesAccessor) => { | ||
const instantiationService = accessor.get(IInstantiationService); | ||
instantiationService.createInstance(SaveExtensionHostProfileAction, SaveExtensionHostProfileAction.ID, SaveExtensionHostProfileAction.LABEL).run(); | ||
}); | ||
|
||
// Running extensions | ||
|
||
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { | ||
command: { | ||
id: DebugExtensionHostAction.ID, | ||
title: DebugExtensionHostAction.LABEL, | ||
icon: Codicon.debugStart | ||
}, | ||
group: 'navigation', | ||
when: ActiveEditorContext.isEqualTo(RuntimeExtensionsEditor.ID) | ||
}); | ||
|
||
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { | ||
command: { | ||
id: StartExtensionHostProfileAction.ID, | ||
title: StartExtensionHostProfileAction.LABEL, | ||
icon: Codicon.circleFilled | ||
}, | ||
group: 'navigation', | ||
when: ContextKeyExpr.and(ActiveEditorContext.isEqualTo(RuntimeExtensionsEditor.ID), CONTEXT_PROFILE_SESSION_STATE.notEqualsTo('running')) | ||
}); | ||
|
||
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { | ||
command: { | ||
id: StopExtensionHostProfileAction.ID, | ||
title: StopExtensionHostProfileAction.LABEL, | ||
icon: Codicon.debugStop | ||
}, | ||
group: 'navigation', | ||
when: ContextKeyExpr.and(ActiveEditorContext.isEqualTo(RuntimeExtensionsEditor.ID), CONTEXT_PROFILE_SESSION_STATE.isEqualTo('running')) | ||
}); | ||
|
||
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { | ||
command: { | ||
id: SaveExtensionHostProfileAction.ID, | ||
title: SaveExtensionHostProfileAction.LABEL, | ||
icon: Codicon.saveAll, | ||
precondition: CONTEXT_EXTENSION_HOST_PROFILE_RECORDED | ||
}, | ||
group: 'navigation', | ||
when: ContextKeyExpr.and(ActiveEditorContext.isEqualTo(RuntimeExtensionsEditor.ID)) | ||
}); |
Oops, something went wrong.