Path: blob/main/src/vs/workbench/test/browser/workbenchTestServices.ts
4778 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { IContextMenuDelegate } from '../../../base/browser/contextmenu.js';6import { IDimension } from '../../../base/browser/dom.js';7import { Direction, IViewSize } from '../../../base/browser/ui/grid/grid.js';8import { mainWindow } from '../../../base/browser/window.js';9import { timeout } from '../../../base/common/async.js';10import { VSBuffer, VSBufferReadable, VSBufferReadableStream } from '../../../base/common/buffer.js';11import { CancellationToken } from '../../../base/common/cancellation.js';12import { Codicon } from '../../../base/common/codicons.js';13import { Emitter, Event } from '../../../base/common/event.js';14import { isValidBasename } from '../../../base/common/extpath.js';15import { IMarkdownString } from '../../../base/common/htmlContent.js';16import { Disposable, DisposableStore, IDisposable } from '../../../base/common/lifecycle.js';17import { Schemas } from '../../../base/common/network.js';18import { posix, win32 } from '../../../base/common/path.js';19import { IProcessEnvironment, isWindows, OperatingSystem } from '../../../base/common/platform.js';20import { env } from '../../../base/common/process.js';21import { basename, isEqual } from '../../../base/common/resources.js';22import { newWriteableStream, ReadableStreamEvents } from '../../../base/common/stream.js';23import { ThemeIcon } from '../../../base/common/themables.js';24import { assertReturnsDefined, upcast } from '../../../base/common/types.js';25import { URI } from '../../../base/common/uri.js';26import { ICodeEditor } from '../../../editor/browser/editorBrowser.js';27import { ICodeEditorService } from '../../../editor/browser/services/codeEditorService.js';28import { Position as EditorPosition, IPosition } from '../../../editor/common/core/position.js';29import { Range } from '../../../editor/common/core/range.js';30import { Selection } from '../../../editor/common/core/selection.js';31import { IDiffEditor, IEditor } from '../../../editor/common/editorCommon.js';32import { ILanguageService } from '../../../editor/common/languages/language.js';33import { ILanguageConfigurationService } from '../../../editor/common/languages/languageConfigurationRegistry.js';34import { DefaultEndOfLine, EndOfLinePreference, ITextBufferFactory, ITextSnapshot } from '../../../editor/common/model.js';35import { createTextBufferFactoryFromStream } from '../../../editor/common/model/textModel.js';36import { IEditorWorkerService } from '../../../editor/common/services/editorWorker.js';37import { ILanguageFeatureDebounceService, LanguageFeatureDebounceService } from '../../../editor/common/services/languageFeatureDebounce.js';38import { ILanguageFeaturesService } from '../../../editor/common/services/languageFeatures.js';39import { LanguageFeaturesService } from '../../../editor/common/services/languageFeaturesService.js';40import { LanguageService } from '../../../editor/common/services/languageService.js';41import { IModelService } from '../../../editor/common/services/model.js';42import { ModelService } from '../../../editor/common/services/modelService.js';43import { ITextModelService } from '../../../editor/common/services/resolverService.js';44import { ITextResourceConfigurationService, ITextResourcePropertiesService } from '../../../editor/common/services/textResourceConfiguration.js';45import { ITreeSitterLibraryService } from '../../../editor/common/services/treeSitter/treeSitterLibraryService.js';46import { TestCodeEditor } from '../../../editor/test/browser/testCodeEditor.js';47import { TestLanguageConfigurationService } from '../../../editor/test/common/modes/testLanguageConfigurationService.js';48import { TestEditorWorkerService } from '../../../editor/test/common/services/testEditorWorkerService.js';49import { TestTreeSitterLibraryService } from '../../../editor/test/common/services/testTreeSitterLibraryService.js';50import { IAccessibilityService } from '../../../platform/accessibility/common/accessibility.js';51import { TestAccessibilityService } from '../../../platform/accessibility/test/common/testAccessibilityService.js';52import { IAccessibilitySignalService } from '../../../platform/accessibilitySignal/browser/accessibilitySignalService.js';53import { IActionViewItemService, NullActionViewItemService } from '../../../platform/actions/browser/actionViewItemService.js';54import { IMenu, IMenuActionOptions, IMenuChangeEvent, IMenuService, MenuId, MenuItemAction, SubmenuItemAction } from '../../../platform/actions/common/actions.js';55import { IFolderBackupInfo, IWorkspaceBackupInfo } from '../../../platform/backup/common/backup.js';56import { ConfigurationTarget, IConfigurationService, IConfigurationValue } from '../../../platform/configuration/common/configuration.js';57import { TestConfigurationService } from '../../../platform/configuration/test/common/testConfigurationService.js';58import { ContextKeyValue, IContextKeyService } from '../../../platform/contextkey/common/contextkey.js';59import { ContextMenuService } from '../../../platform/contextview/browser/contextMenuService.js';60import { IContextMenuMenuDelegate, IContextMenuService, IContextViewService } from '../../../platform/contextview/browser/contextView.js';61import { ContextViewService } from '../../../platform/contextview/browser/contextViewService.js';62import { IDiagnosticInfo, IDiagnosticInfoOptions } from '../../../platform/diagnostics/common/diagnostics.js';63import { ConfirmResult, IDialogService, IFileDialogService, IOpenDialogOptions, IPickAndOpenOptions, ISaveDialogOptions } from '../../../platform/dialogs/common/dialogs.js';64import { TestDialogService } from '../../../platform/dialogs/test/common/testDialogService.js';65import { IEditorOptions, IResourceEditorInput, IResourceEditorInputIdentifier, ITextEditorOptions, ITextResourceEditorInput } from '../../../platform/editor/common/editor.js';66import { IEnvironmentService } from '../../../platform/environment/common/environment.js';67import { IExtensionManagementParticipant, IExtensionsControlManifest, IGalleryExtension, IGalleryMetadata, ILocalExtension, InstallExtensionInfo, InstallExtensionResult, InstallExtensionSummary, InstallOptions, Metadata, UninstallExtensionInfo, UninstallOptions } from '../../../platform/extensionManagement/common/extensionManagement.js';68import { ExtensionType, IExtension, IExtensionDescription, IRelaxedExtensionManifest, TargetPlatform } from '../../../platform/extensions/common/extensions.js';69import { FileOperationError, FileSystemProviderCapabilities, FileType, IFileChange, IFileDeleteOptions, IFileOpenOptions, IFileOverwriteOptions, IFileReadStreamOptions, IFileService, IFileStatWithMetadata, IFileSystemProvider, IFileSystemProviderWithFileReadStreamCapability, IFileWriteOptions, IStat, IWatchOptions } from '../../../platform/files/common/files.js';70import { FileService } from '../../../platform/files/common/fileService.js';71import { InMemoryFileSystemProvider } from '../../../platform/files/common/inMemoryFilesystemProvider.js';72import { IHoverService } from '../../../platform/hover/browser/hover.js';73import { NullHoverService } from '../../../platform/hover/test/browser/nullHoverService.js';74import { SyncDescriptor } from '../../../platform/instantiation/common/descriptors.js';75import { IInstantiationService, ServiceIdentifier } from '../../../platform/instantiation/common/instantiation.js';76import { ServiceCollection } from '../../../platform/instantiation/common/serviceCollection.js';77import { TestInstantiationService } from '../../../platform/instantiation/test/common/instantiationServiceMock.js';78import { IKeybindingService } from '../../../platform/keybinding/common/keybinding.js';79import { MockContextKeyService, MockKeybindingService } from '../../../platform/keybinding/test/common/mockKeybindingService.js';80import { ILabelService } from '../../../platform/label/common/label.js';81import { ILayoutOffsetInfo } from '../../../platform/layout/browser/layoutService.js';82import { IListService } from '../../../platform/list/browser/listService.js';83import { ILoggerService, ILogService, NullLogService } from '../../../platform/log/common/log.js';84import { IMarkdownRendererService, MarkdownRendererService } from '../../../platform/markdown/browser/markdownRenderer.js';85import { IMarkerService } from '../../../platform/markers/common/markers.js';86import { INotificationService } from '../../../platform/notification/common/notification.js';87import { TestNotificationService } from '../../../platform/notification/test/common/testNotificationService.js';88import product from '../../../platform/product/common/product.js';89import { IProductService } from '../../../platform/product/common/productService.js';90import { IProgress, IProgressCompositeOptions, IProgressDialogOptions, IProgressIndicator, IProgressNotificationOptions, IProgressOptions, IProgressService, IProgressStep, IProgressWindowOptions, Progress } from '../../../platform/progress/common/progress.js';91import { IInputBox, IInputOptions, IPickOptions, IQuickInputButton, IQuickInputService, IQuickNavigateConfiguration, IQuickPick, IQuickPickItem, IQuickTree, IQuickTreeItem, IQuickWidget, QuickPickInput } from '../../../platform/quickinput/common/quickInput.js';92import { Registry } from '../../../platform/registry/common/platform.js';93import { IRemoteAgentEnvironment } from '../../../platform/remote/common/remoteAgentEnvironment.js';94import { IRemoteExtensionsScannerService } from '../../../platform/remote/common/remoteExtensionsScanner.js';95import { IRemoteSocketFactoryService, RemoteSocketFactoryService } from '../../../platform/remote/common/remoteSocketFactoryService.js';96import { IStorageService, StorageScope, StorageTarget } from '../../../platform/storage/common/storage.js';97import { ITelemetryData, ITelemetryService, TelemetryLevel } from '../../../platform/telemetry/common/telemetry.js';98import { NullTelemetryService } from '../../../platform/telemetry/common/telemetryUtils.js';99import { IExtensionTerminalProfile, IShellLaunchConfig, ITerminalBackend, ITerminalLogService, ITerminalProfile, TerminalIcon, TerminalLocation, TerminalShellType } from '../../../platform/terminal/common/terminal.js';100import { TerminalLogService } from '../../../platform/terminal/common/terminalLogService.js';101import { ColorScheme } from '../../../platform/theme/common/theme.js';102import { IThemeService } from '../../../platform/theme/common/themeService.js';103import { TestThemeService } from '../../../platform/theme/test/common/testThemeService.js';104import { IUndoRedoService } from '../../../platform/undoRedo/common/undoRedo.js';105import { UndoRedoService } from '../../../platform/undoRedo/common/undoRedoService.js';106import { IUriIdentityService } from '../../../platform/uriIdentity/common/uriIdentity.js';107import { UriIdentityService } from '../../../platform/uriIdentity/common/uriIdentityService.js';108import { IUserDataProfile, IUserDataProfilesService, UserDataProfilesService } from '../../../platform/userDataProfile/common/userDataProfile.js';109import { IOpenEmptyWindowOptions, IOpenWindowOptions, IRectangle, IWindowOpenable, MenuBarVisibility } from '../../../platform/window/common/window.js';110import { IWorkspaceContextService, IWorkspaceIdentifier } from '../../../platform/workspace/common/workspace.js';111import { IWorkspaceTrustManagementService, IWorkspaceTrustRequestService } from '../../../platform/workspace/common/workspaceTrust.js';112import { TestWorkspace } from '../../../platform/workspace/test/common/testWorkspace.js';113import { IEnterWorkspaceResult, IRecent, IRecentlyOpened, IWorkspaceFolderCreationData, IWorkspacesService } from '../../../platform/workspaces/common/workspaces.js';114import { EditorPaneDescriptor, IEditorPaneRegistry } from '../../browser/editor.js';115import { PaneComposite, PaneCompositeDescriptor } from '../../browser/panecomposite.js';116import { Part } from '../../browser/part.js';117import { DEFAULT_EDITOR_PART_OPTIONS, EditorServiceImpl, IEditorGroupsView, IEditorGroupTitleHeight, IEditorGroupView } from '../../browser/parts/editor/editor.js';118import { EditorPane } from '../../browser/parts/editor/editorPane.js';119import { MainEditorPart } from '../../browser/parts/editor/editorPart.js';120import { EditorParts } from '../../browser/parts/editor/editorParts.js';121import { SideBySideEditor } from '../../browser/parts/editor/sideBySideEditor.js';122import { TextEditorPaneSelection } from '../../browser/parts/editor/textEditor.js';123import { TextResourceEditor } from '../../browser/parts/editor/textResourceEditor.js';124import { IPaneCompositePart } from '../../browser/parts/paneCompositePart.js';125import { EditorExtensions, EditorInputCapabilities, EditorInputWithOptions, EditorPaneSelectionChangeReason, EditorsOrder, EditorExtensions as Extensions, GroupIdentifier, IActiveEditorChangeEvent, IEditorCloseEvent, IEditorFactoryRegistry, IEditorIdentifier, IEditorOpenContext, IEditorPane, IEditorPaneSelection, IEditorPartOptions, IEditorSerializer, IEditorWillMoveEvent, IEditorWillOpenEvent, IFileEditorInput, IMoveResult, IResourceDiffEditorInput, IRevertOptions, ISaveOptions, ITextDiffEditorPane, IToolbarActions, IUntitledTextResourceEditorInput, IUntypedEditorInput, IVisibleEditorPane } from '../../common/editor.js';126import { IGroupModelChangeEvent } from '../../common/editor/editorGroupModel.js';127import { EditorInput } from '../../common/editor/editorInput.js';128import { SideBySideEditorInput } from '../../common/editor/sideBySideEditorInput.js';129import { TextResourceEditorInput } from '../../common/editor/textResourceEditorInput.js';130import { IPaneComposite } from '../../common/panecomposite.js';131import { IView, IViewDescriptor, ViewContainer, ViewContainerLocation } from '../../common/views.js';132import { FileEditorInput } from '../../contrib/files/browser/editors/fileEditorInput.js';133import { TextFileEditor } from '../../contrib/files/browser/editors/textFileEditor.js';134import { FILE_EDITOR_INPUT_ID } from '../../contrib/files/common/files.js';135import { ICreateTerminalOptions, IDeserializedTerminalEditorInput, ITerminalConfigurationService, ITerminalEditorService, ITerminalGroup, ITerminalGroupService, ITerminalInstance, ITerminalInstanceService, TerminalEditorLocation } from '../../contrib/terminal/browser/terminal.js';136import { TerminalConfigurationService } from '../../contrib/terminal/browser/terminalConfigurationService.js';137import { TerminalEditorInput } from '../../contrib/terminal/browser/terminalEditorInput.js';138import { IEnvironmentVariableService } from '../../contrib/terminal/common/environmentVariable.js';139import { EnvironmentVariableService } from '../../contrib/terminal/common/environmentVariableService.js';140import { IRegisterContributedProfileArgs, IShellLaunchConfigResolveOptions, ITerminalProfileProvider, ITerminalProfileResolverService, ITerminalProfileService, type ITerminalConfiguration } from '../../contrib/terminal/common/terminal.js';141import { IChatEntitlementService } from '../../services/chat/common/chatEntitlementService.js';142import { IDecoration, IDecorationData, IDecorationsProvider, IDecorationsService, IResourceDecorationChangeEvent } from '../../services/decorations/common/decorations.js';143import { CodeEditorService } from '../../services/editor/browser/codeEditorService.js';144import { EditorPaneService } from '../../services/editor/browser/editorPaneService.js';145import { EditorResolverService } from '../../services/editor/browser/editorResolverService.js';146import { CustomEditorLabelService, ICustomEditorLabelService } from '../../services/editor/common/customEditorLabelService.js';147import { EditorGroupLayout, GroupDirection, GroupOrientation, GroupsArrangement, GroupsOrder, IAuxiliaryEditorPart, ICloseAllEditorsOptions, ICloseEditorOptions, ICloseEditorsFilter, IEditorDropTargetDelegate, IEditorGroup, IEditorGroupContextKeyProvider, IEditorGroupsContainer, IEditorGroupsService, IEditorPart, IEditorReplacement, IEditorWorkingSet, IEditorWorkingSetOptions, IFindGroupScope, IMergeGroupOptions } from '../../services/editor/common/editorGroupsService.js';148import { IEditorPaneService } from '../../services/editor/common/editorPaneService.js';149import { IEditorResolverService } from '../../services/editor/common/editorResolverService.js';150import { IEditorsChangeEvent, IEditorService, IRevertAllEditorsOptions, ISaveEditorsOptions, ISaveEditorsResult, PreferredGroup } from '../../services/editor/common/editorService.js';151import { BrowserWorkbenchEnvironmentService } from '../../services/environment/browser/environmentService.js';152import { IWorkbenchEnvironmentService } from '../../services/environment/common/environmentService.js';153import { EnablementState, IExtensionManagementServer, IResourceExtension, IScannedExtension, IWebExtensionsScannerService, IWorkbenchExtensionEnablementService, IWorkbenchExtensionManagementService } from '../../services/extensionManagement/common/extensionManagement.js';154import { IExtensionService } from '../../services/extensions/common/extensions.js';155import { BrowserElevatedFileService } from '../../services/files/browser/elevatedFileService.js';156import { IElevatedFileService } from '../../services/files/common/elevatedFileService.js';157import { FilesConfigurationService, IFilesConfigurationService } from '../../services/filesConfiguration/common/filesConfigurationService.js';158import { IHistoryService } from '../../services/history/common/history.js';159import { IHostService } from '../../services/host/browser/host.js';160import { LabelService } from '../../services/label/common/labelService.js';161import { ILanguageDetectionService } from '../../services/languageDetection/common/languageDetectionWorkerService.js';162import { IWorkbenchLayoutService, PanelAlignment, Position as PartPosition, Parts } from '../../services/layout/browser/layoutService.js';163import { ILifecycleService, InternalBeforeShutdownEvent, IWillShutdownEventJoiner, ShutdownReason, WillShutdownEvent } from '../../services/lifecycle/common/lifecycle.js';164import { IPaneCompositePartService } from '../../services/panecomposite/browser/panecomposite.js';165import { IPathService } from '../../services/path/common/pathService.js';166import { QuickInputService } from '../../services/quickinput/browser/quickInputService.js';167import { IExtensionHostExitInfo, IRemoteAgentConnection, IRemoteAgentService } from '../../services/remote/common/remoteAgentService.js';168import { BrowserTextFileService } from '../../services/textfile/browser/browserTextFileService.js';169import { EncodingOracle, IEncodingOverride } from '../../services/textfile/browser/textFileService.js';170import { UTF16be, UTF16le, UTF8_with_bom } from '../../services/textfile/common/encoding.js';171import { ITextEditorService, TextEditorService } from '../../services/textfile/common/textEditorService.js';172import { TextFileEditorModel } from '../../services/textfile/common/textFileEditorModel.js';173import { IReadTextFileOptions, ITextFileEditorModel, ITextFileEditorModelManager, ITextFileService, ITextFileStreamContent, IWriteTextFileOptions } from '../../services/textfile/common/textfiles.js';174import { TextModelResolverService } from '../../services/textmodelResolver/common/textModelResolverService.js';175import { UntitledTextEditorInput } from '../../services/untitled/common/untitledTextEditorInput.js';176import { IUntitledTextEditorModelManager, IUntitledTextEditorService, UntitledTextEditorService } from '../../services/untitled/common/untitledTextEditorService.js';177import { IUserDataProfileService } from '../../services/userDataProfile/common/userDataProfile.js';178import { UserDataProfileService } from '../../services/userDataProfile/common/userDataProfileService.js';179import { IViewsService } from '../../services/views/common/viewsService.js';180import { BrowserWorkingCopyBackupService } from '../../services/workingCopy/browser/workingCopyBackupService.js';181import { IWorkingCopy, IWorkingCopyBackupMeta, IWorkingCopyIdentifier } from '../../services/workingCopy/common/workingCopy.js';182import { IResolvedWorkingCopyBackup, IWorkingCopyBackupService } from '../../services/workingCopy/common/workingCopyBackup.js';183import { InMemoryWorkingCopyBackupService } from '../../services/workingCopy/common/workingCopyBackupService.js';184import { IWorkingCopyEditorService, WorkingCopyEditorService } from '../../services/workingCopy/common/workingCopyEditorService.js';185import { IWorkingCopyFileService, WorkingCopyFileService } from '../../services/workingCopy/common/workingCopyFileService.js';186import { IWorkingCopyService, WorkingCopyService } from '../../services/workingCopy/common/workingCopyService.js';187import { TestChatEntitlementService, TestContextService, TestExtensionService, TestFileService, TestHistoryService, TestLifecycleService, TestLoggerService, TestMarkerService, TestProductService, TestStorageService, TestTextResourcePropertiesService, TestWorkspaceTrustManagementService, TestWorkspaceTrustRequestService } from '../common/workbenchTestServices.js';188189// Backcompat export190export { TestFileService, TestLifecycleService };191192export function createFileEditorInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {193return instantiationService.createInstance(FileEditorInput, resource, undefined, undefined, undefined, undefined, undefined, undefined);194}195196Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerFileEditorFactory({197198typeId: FILE_EDITOR_INPUT_ID,199200createFileEditor: (resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents, instantiationService): IFileEditorInput => {201return instantiationService.createInstance(FileEditorInput, resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents);202},203204isFileEditor: (obj): obj is IFileEditorInput => {205return obj instanceof FileEditorInput;206}207});208209export class TestTextResourceEditor extends TextResourceEditor {210211protected override createEditorControl(parent: HTMLElement, configuration: any): void {212this.editorControl = this._register(this.instantiationService.createInstance(TestCodeEditor, parent, configuration, {}));213}214}215216export class TestTextFileEditor extends TextFileEditor {217218protected override createEditorControl(parent: HTMLElement, configuration: any): void {219this.editorControl = this._register(this.instantiationService.createInstance(TestCodeEditor, parent, configuration, { contributions: [] }));220}221222setSelection(selection: Selection | undefined, reason: EditorPaneSelectionChangeReason): void {223this._options = selection ? upcast<IEditorOptions, ITextEditorOptions>({ selection }) : undefined;224225this._onDidChangeSelection.fire({ reason });226}227228override getSelection(): IEditorPaneSelection | undefined {229const options = this.options;230if (!options) {231return undefined;232}233234const textSelection = (options as ITextEditorOptions).selection;235if (!textSelection) {236return undefined;237}238239return new TextEditorPaneSelection(new Selection(textSelection.startLineNumber, textSelection.startColumn, textSelection.endLineNumber ?? textSelection.startLineNumber, textSelection.endColumn ?? textSelection.startColumn));240}241}242243export interface ITestInstantiationService extends IInstantiationService {244stub<T>(service: ServiceIdentifier<T>, ctor: any): T;245}246247export class TestWorkingCopyService extends WorkingCopyService {248testUnregisterWorkingCopy(workingCopy: IWorkingCopy): void {249return super.unregisterWorkingCopy(workingCopy);250}251}252253export function workbenchInstantiationService(254overrides?: {255environmentService?: (instantiationService: IInstantiationService) => IEnvironmentService;256fileService?: (instantiationService: IInstantiationService) => IFileService;257workingCopyBackupService?: (instantiationService: IInstantiationService) => IWorkingCopyBackupService;258configurationService?: (instantiationService: IInstantiationService) => TestConfigurationService;259textFileService?: (instantiationService: IInstantiationService) => ITextFileService;260pathService?: (instantiationService: IInstantiationService) => IPathService;261editorService?: (instantiationService: IInstantiationService) => IEditorService;262contextKeyService?: (instantiationService: IInstantiationService) => IContextKeyService;263textEditorService?: (instantiationService: IInstantiationService) => ITextEditorService;264},265disposables: Pick<DisposableStore, 'add'> = new DisposableStore()266): TestInstantiationService {267const instantiationService = disposables.add(new TestInstantiationService(new ServiceCollection(268[ILifecycleService, disposables.add(new TestLifecycleService())],269[IActionViewItemService, new SyncDescriptor(NullActionViewItemService)],270)));271272instantiationService.stub(IProductService, TestProductService);273instantiationService.stub(IEditorWorkerService, new TestEditorWorkerService());274instantiationService.stub(IWorkingCopyService, disposables.add(new TestWorkingCopyService()));275const environmentService = overrides?.environmentService ? overrides.environmentService(instantiationService) : TestEnvironmentService;276instantiationService.stub(IEnvironmentService, environmentService);277instantiationService.stub(IWorkbenchEnvironmentService, environmentService);278instantiationService.stub(ILogService, new NullLogService());279const contextKeyService = overrides?.contextKeyService ? overrides.contextKeyService(instantiationService) : instantiationService.createInstance(MockContextKeyService);280instantiationService.stub(IContextKeyService, contextKeyService);281instantiationService.stub(IProgressService, new TestProgressService());282const workspaceContextService = new TestContextService(TestWorkspace);283instantiationService.stub(IWorkspaceContextService, workspaceContextService);284const configService = overrides?.configurationService ? overrides.configurationService(instantiationService) : new TestConfigurationService({285files: {286participants: {287timeout: 60000288}289}290});291instantiationService.stub(IConfigurationService, configService);292const textResourceConfigurationService = new TestTextResourceConfigurationService(configService);293instantiationService.stub(ITextResourceConfigurationService, textResourceConfigurationService);294instantiationService.stub(IUntitledTextEditorService, disposables.add(instantiationService.createInstance(UntitledTextEditorService)));295instantiationService.stub(IStorageService, disposables.add(new TestStorageService()));296instantiationService.stub(IRemoteAgentService, new TestRemoteAgentService());297instantiationService.stub(ILanguageDetectionService, new TestLanguageDetectionService());298instantiationService.stub(IPathService, overrides?.pathService ? overrides.pathService(instantiationService) : new TestPathService());299const layoutService = new TestLayoutService();300instantiationService.stub(IWorkbenchLayoutService, layoutService);301instantiationService.stub(IDialogService, new TestDialogService());302const accessibilityService = new TestAccessibilityService();303instantiationService.stub(IAccessibilityService, accessibilityService);304// eslint-disable-next-line local/code-no-any-casts305instantiationService.stub(IAccessibilitySignalService, {306playSignal: async () => { },307isSoundEnabled(signal: unknown) { return false; },308} as any);309instantiationService.stub(IFileDialogService, instantiationService.createInstance(TestFileDialogService));310instantiationService.stub(ILanguageService, disposables.add(instantiationService.createInstance(LanguageService)));311instantiationService.stub(ILanguageFeaturesService, new LanguageFeaturesService());312instantiationService.stub(ILanguageFeatureDebounceService, instantiationService.createInstance(LanguageFeatureDebounceService));313instantiationService.stub(IHistoryService, new TestHistoryService());314instantiationService.stub(ITextResourcePropertiesService, new TestTextResourcePropertiesService(configService));315instantiationService.stub(IUndoRedoService, instantiationService.createInstance(UndoRedoService));316const themeService = new TestThemeService();317instantiationService.stub(IThemeService, themeService);318instantiationService.stub(ILanguageConfigurationService, disposables.add(new TestLanguageConfigurationService()));319instantiationService.stub(ITreeSitterLibraryService, new TestTreeSitterLibraryService());320instantiationService.stub(IModelService, disposables.add(instantiationService.createInstance(ModelService)));321const fileService = overrides?.fileService ? overrides.fileService(instantiationService) : disposables.add(new TestFileService());322instantiationService.stub(IFileService, fileService);323instantiationService.stub(IUriIdentityService, disposables.add(new UriIdentityService(fileService)));324const markerService = new TestMarkerService();325instantiationService.stub(IMarkerService, markerService);326instantiationService.stub(IFilesConfigurationService, disposables.add(instantiationService.createInstance(TestFilesConfigurationService)));327const userDataProfilesService = instantiationService.stub(IUserDataProfilesService, disposables.add(instantiationService.createInstance(UserDataProfilesService)));328instantiationService.stub(IUserDataProfileService, disposables.add(new UserDataProfileService(userDataProfilesService.defaultProfile)));329instantiationService.stub(IWorkingCopyBackupService, overrides?.workingCopyBackupService ? overrides?.workingCopyBackupService(instantiationService) : disposables.add(new TestWorkingCopyBackupService()));330instantiationService.stub(ITelemetryService, NullTelemetryService);331instantiationService.stub(INotificationService, new TestNotificationService());332instantiationService.stub(IUntitledTextEditorService, disposables.add(instantiationService.createInstance(UntitledTextEditorService)));333instantiationService.stub(IMenuService, new TestMenuService());334const keybindingService = new MockKeybindingService();335instantiationService.stub(IKeybindingService, keybindingService);336instantiationService.stub(IDecorationsService, new TestDecorationsService());337instantiationService.stub(IExtensionService, new TestExtensionService());338instantiationService.stub(IWorkingCopyFileService, disposables.add(instantiationService.createInstance(WorkingCopyFileService)));339instantiationService.stub(ITextFileService, overrides?.textFileService ? overrides.textFileService(instantiationService) : disposables.add(<ITextFileService>instantiationService.createInstance(TestTextFileService)));340instantiationService.stub(IHostService, <IHostService>instantiationService.createInstance(TestHostService));341instantiationService.stub(ITextModelService, <ITextModelService>disposables.add(instantiationService.createInstance(TextModelResolverService)));342instantiationService.stub(ILoggerService, disposables.add(new TestLoggerService(TestEnvironmentService.logsHome)));343const editorGroupService = new TestEditorGroupsService([new TestEditorGroupView(0)]);344instantiationService.stub(IEditorGroupsService, editorGroupService);345instantiationService.stub(ILabelService, <ILabelService>disposables.add(instantiationService.createInstance(LabelService)));346const editorService = overrides?.editorService ? overrides.editorService(instantiationService) : disposables.add(new TestEditorService(editorGroupService));347instantiationService.stub(IEditorService, editorService);348instantiationService.stub(IEditorPaneService, new EditorPaneService());349instantiationService.stub(IWorkingCopyEditorService, disposables.add(instantiationService.createInstance(WorkingCopyEditorService)));350instantiationService.stub(IEditorResolverService, disposables.add(instantiationService.createInstance(EditorResolverService)));351const textEditorService = overrides?.textEditorService ? overrides.textEditorService(instantiationService) : disposables.add(instantiationService.createInstance(TextEditorService));352instantiationService.stub(ITextEditorService, textEditorService);353instantiationService.stub(ICodeEditorService, disposables.add(new CodeEditorService(editorService, themeService, configService)));354instantiationService.stub(IPaneCompositePartService, disposables.add(new TestPaneCompositeService()));355instantiationService.stub(IListService, new TestListService());356instantiationService.stub(IContextViewService, disposables.add(instantiationService.createInstance(ContextViewService)));357instantiationService.stub(IContextMenuService, disposables.add(instantiationService.createInstance(ContextMenuService)));358instantiationService.stub(IQuickInputService, disposables.add(new QuickInputService(configService, instantiationService, keybindingService, contextKeyService, themeService, layoutService)));359instantiationService.stub(IWorkspacesService, new TestWorkspacesService());360instantiationService.stub(IWorkspaceTrustManagementService, disposables.add(new TestWorkspaceTrustManagementService()));361instantiationService.stub(IWorkspaceTrustRequestService, disposables.add(new TestWorkspaceTrustRequestService(false)));362instantiationService.stub(ITerminalInstanceService, new TestTerminalInstanceService());363instantiationService.stub(ITerminalEditorService, new TestTerminalEditorService());364instantiationService.stub(ITerminalGroupService, new TestTerminalGroupService());365instantiationService.stub(ITerminalProfileService, new TestTerminalProfileService());366instantiationService.stub(ITerminalProfileResolverService, new TestTerminalProfileResolverService());367instantiationService.stub(ITerminalConfigurationService, disposables.add(instantiationService.createInstance(TestTerminalConfigurationService)));368instantiationService.stub(ITerminalLogService, disposables.add(instantiationService.createInstance(TerminalLogService)));369instantiationService.stub(IEnvironmentVariableService, disposables.add(instantiationService.createInstance(EnvironmentVariableService)));370instantiationService.stub(IElevatedFileService, new BrowserElevatedFileService());371instantiationService.stub(IRemoteSocketFactoryService, new RemoteSocketFactoryService());372instantiationService.stub(ICustomEditorLabelService, disposables.add(new CustomEditorLabelService(configService, workspaceContextService)));373instantiationService.stub(IHoverService, NullHoverService);374instantiationService.stub(IChatEntitlementService, new TestChatEntitlementService());375instantiationService.stub(IMarkdownRendererService, instantiationService.createInstance(MarkdownRendererService));376377return instantiationService;378}379380export class TestServiceAccessor {381constructor(382@ILifecycleService public lifecycleService: TestLifecycleService,383@ITextFileService public textFileService: TestTextFileService,384@ITextEditorService public textEditorService: ITextEditorService,385@IWorkingCopyFileService public workingCopyFileService: IWorkingCopyFileService,386@IFilesConfigurationService public filesConfigurationService: TestFilesConfigurationService,387@IWorkspaceContextService public contextService: TestContextService,388@IModelService public modelService: ModelService,389@IFileService public fileService: TestFileService,390@IFileDialogService public fileDialogService: TestFileDialogService,391@IDialogService public dialogService: TestDialogService,392@IWorkingCopyService public workingCopyService: TestWorkingCopyService,393@IEditorService public editorService: TestEditorService,394@IEditorPaneService public editorPaneService: IEditorPaneService,395@IWorkbenchEnvironmentService public environmentService: IWorkbenchEnvironmentService,396@IPathService public pathService: IPathService,397@IEditorGroupsService public editorGroupService: IEditorGroupsService,398@IEditorResolverService public editorResolverService: IEditorResolverService,399@ILanguageService public languageService: ILanguageService,400@ITextModelService public textModelResolverService: ITextModelService,401@IUntitledTextEditorService public untitledTextEditorService: UntitledTextEditorService,402@IConfigurationService public testConfigurationService: TestConfigurationService,403@IWorkingCopyBackupService public workingCopyBackupService: TestWorkingCopyBackupService,404@IHostService public hostService: TestHostService,405@IQuickInputService public quickInputService: IQuickInputService,406@ILabelService public labelService: ILabelService,407@ILogService public logService: ILogService,408@IUriIdentityService public uriIdentityService: IUriIdentityService,409@IInstantiationService public instantitionService: IInstantiationService,410@INotificationService public notificationService: INotificationService,411@IWorkingCopyEditorService public workingCopyEditorService: IWorkingCopyEditorService,412@IInstantiationService public instantiationService: IInstantiationService,413@IElevatedFileService public elevatedFileService: IElevatedFileService,414@IWorkspaceTrustRequestService public workspaceTrustRequestService: TestWorkspaceTrustRequestService,415@IDecorationsService public decorationsService: IDecorationsService,416@IProgressService public progressService: IProgressService,417) { }418}419420export class TestTextFileService extends BrowserTextFileService {421private readStreamError: FileOperationError | undefined = undefined;422private writeError: FileOperationError | undefined = undefined;423424constructor(425@IFileService fileService: IFileService,426@IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorModelManager,427@ILifecycleService lifecycleService: ILifecycleService,428@IInstantiationService instantiationService: IInstantiationService,429@IModelService modelService: IModelService,430@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,431@IDialogService dialogService: IDialogService,432@IFileDialogService fileDialogService: IFileDialogService,433@ITextResourceConfigurationService textResourceConfigurationService: ITextResourceConfigurationService,434@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService,435@ICodeEditorService codeEditorService: ICodeEditorService,436@IPathService pathService: IPathService,437@IWorkingCopyFileService workingCopyFileService: IWorkingCopyFileService,438@IUriIdentityService uriIdentityService: IUriIdentityService,439@ILanguageService languageService: ILanguageService,440@ILogService logService: ILogService,441@IElevatedFileService elevatedFileService: IElevatedFileService,442@IDecorationsService decorationsService: IDecorationsService443) {444super(445fileService,446untitledTextEditorService,447lifecycleService,448instantiationService,449modelService,450environmentService,451dialogService,452fileDialogService,453textResourceConfigurationService,454filesConfigurationService,455codeEditorService,456pathService,457workingCopyFileService,458uriIdentityService,459languageService,460elevatedFileService,461logService,462decorationsService463);464}465466setReadStreamErrorOnce(error: FileOperationError): void {467this.readStreamError = error;468}469470override async readStream(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileStreamContent> {471if (this.readStreamError) {472const error = this.readStreamError;473this.readStreamError = undefined;474475throw error;476}477478const content = await this.fileService.readFileStream(resource, options);479return {480resource: content.resource,481name: content.name,482mtime: content.mtime,483ctime: content.ctime,484etag: content.etag,485encoding: 'utf8',486value: await createTextBufferFactoryFromStream(content.value),487size: 10,488readonly: false,489locked: false,490executable: false491};492}493494setWriteErrorOnce(error: FileOperationError): void {495this.writeError = error;496}497498override async write(resource: URI, value: string | ITextSnapshot, options?: IWriteTextFileOptions): Promise<IFileStatWithMetadata> {499if (this.writeError) {500const error = this.writeError;501this.writeError = undefined;502503throw error;504}505506return super.write(resource, value, options);507}508}509510export class TestBrowserTextFileServiceWithEncodingOverrides extends BrowserTextFileService {511512private _testEncoding: TestEncodingOracle | undefined;513override get encoding(): TestEncodingOracle {514if (!this._testEncoding) {515this._testEncoding = this._register(this.instantiationService.createInstance(TestEncodingOracle));516}517518return this._testEncoding;519}520}521522export class TestEncodingOracle extends EncodingOracle {523524protected override get encodingOverrides(): IEncodingOverride[] {525return [526{ extension: 'utf16le', encoding: UTF16le },527{ extension: 'utf16be', encoding: UTF16be },528{ extension: 'utf8bom', encoding: UTF8_with_bom }529];530}531532protected override set encodingOverrides(overrides: IEncodingOverride[]) { }533}534535class TestEnvironmentServiceWithArgs extends BrowserWorkbenchEnvironmentService {536args = [];537}538539export const TestEnvironmentService = new TestEnvironmentServiceWithArgs('', URI.file('tests').with({ scheme: 'vscode-tests' }), Object.create(null), TestProductService);540541export class TestProgressService implements IProgressService {542543declare readonly _serviceBrand: undefined;544545withProgress(546options: IProgressOptions | IProgressDialogOptions | IProgressWindowOptions | IProgressNotificationOptions | IProgressCompositeOptions,547task: (progress: IProgress<IProgressStep>) => Promise<any>,548onDidCancel?: ((choice?: number | undefined) => void) | undefined549): Promise<any> {550return task(Progress.None);551}552}553554export class TestDecorationsService implements IDecorationsService {555556declare readonly _serviceBrand: undefined;557558readonly onDidChangeDecorations: Event<IResourceDecorationChangeEvent> = Event.None;559560registerDecorationsProvider(_provider: IDecorationsProvider): IDisposable { return Disposable.None; }561getDecoration(_uri: URI, _includeChildren: boolean, _overwrite?: IDecorationData): IDecoration | undefined { return undefined; }562}563564export class TestMenuService implements IMenuService {565566declare readonly _serviceBrand: undefined;567568createMenu(_id: MenuId, _scopedKeybindingService: IContextKeyService): IMenu {569return {570onDidChange: Event.None,571dispose: () => undefined,572getActions: () => []573};574}575576getMenuActions(id: MenuId, contextKeyService: IContextKeyService, options?: IMenuActionOptions): [string, Array<MenuItemAction | SubmenuItemAction>][] {577throw new Error('Method not implemented.');578}579580getMenuContexts(id: MenuId): ReadonlySet<string> {581throw new Error('Method not implemented.');582}583584resetHiddenStates(): void {585// nothing586}587}588589export class TestFileDialogService implements IFileDialogService {590591declare readonly _serviceBrand: undefined;592593private confirmResult!: ConfirmResult;594595constructor(596@IPathService private readonly pathService: IPathService597) { }598async defaultFilePath(_schemeFilter?: string): Promise<URI> { return this.pathService.userHome(); }599async defaultFolderPath(_schemeFilter?: string): Promise<URI> { return this.pathService.userHome(); }600async defaultWorkspacePath(_schemeFilter?: string): Promise<URI> { return this.pathService.userHome(); }601async preferredHome(_schemeFilter?: string): Promise<URI> { return this.pathService.userHome(); }602pickFileFolderAndOpen(_options: IPickAndOpenOptions): Promise<any> { return Promise.resolve(0); }603pickFileAndOpen(_options: IPickAndOpenOptions): Promise<any> { return Promise.resolve(0); }604pickFolderAndOpen(_options: IPickAndOpenOptions): Promise<any> { return Promise.resolve(0); }605pickWorkspaceAndOpen(_options: IPickAndOpenOptions): Promise<any> { return Promise.resolve(0); }606607private fileToSave!: URI;608setPickFileToSave(path: URI): void { this.fileToSave = path; }609pickFileToSave(defaultUri: URI, availableFileSystems?: string[]): Promise<URI | undefined> { return Promise.resolve(this.fileToSave); }610611showSaveDialog(_options: ISaveDialogOptions): Promise<URI | undefined> { return Promise.resolve(undefined); }612showOpenDialog(_options: IOpenDialogOptions): Promise<URI[] | undefined> { return Promise.resolve(undefined); }613614setConfirmResult(result: ConfirmResult): void { this.confirmResult = result; }615showSaveConfirm(fileNamesOrResources: (string | URI)[]): Promise<ConfirmResult> { return Promise.resolve(this.confirmResult); }616}617618export class TestLayoutService implements IWorkbenchLayoutService {619620declare readonly _serviceBrand: undefined;621622openedDefaultEditors = false;623624mainContainerDimension: IDimension = { width: 800, height: 600 };625activeContainerDimension: IDimension = { width: 800, height: 600 };626mainContainerOffset: ILayoutOffsetInfo = { top: 0, quickPickTop: 0 };627activeContainerOffset: ILayoutOffsetInfo = { top: 0, quickPickTop: 0 };628629mainContainer: HTMLElement = mainWindow.document.body;630containers = [mainWindow.document.body];631activeContainer: HTMLElement = mainWindow.document.body;632633readonly onDidChangeZenMode: Event<boolean> = Event.None;634readonly onDidChangeMainEditorCenteredLayout: Event<boolean> = Event.None;635readonly onDidChangeWindowMaximized: Event<{ windowId: number; maximized: boolean }> = Event.None;636readonly onDidChangePanelPosition: Event<string> = Event.None;637readonly onDidChangePanelAlignment: Event<PanelAlignment> = Event.None;638readonly onDidChangePartVisibility: Event<void> = Event.None;639onDidLayoutMainContainer = Event.None;640onDidLayoutActiveContainer = Event.None;641onDidLayoutContainer = Event.None;642onDidChangeNotificationsVisibility = Event.None;643onDidAddContainer = Event.None;644onDidChangeActiveContainer = Event.None;645onDidChangeAuxiliaryBarMaximized = Event.None;646647layout(): void { }648isRestored(): boolean { return true; }649whenReady: Promise<void> = Promise.resolve(undefined);650whenRestored: Promise<void> = Promise.resolve(undefined);651hasFocus(_part: Parts): boolean { return false; }652focusPart(_part: Parts): void { }653hasMainWindowBorder(): boolean { return false; }654getMainWindowBorderRadius(): string | undefined { return undefined; }655isVisible(_part: Parts): boolean { return true; }656getContainer(): HTMLElement { return mainWindow.document.body; }657whenContainerStylesLoaded() { return undefined; }658isTitleBarHidden(): boolean { return false; }659isStatusBarHidden(): boolean { return false; }660isActivityBarHidden(): boolean { return false; }661setActivityBarHidden(_hidden: boolean): void { }662setBannerHidden(_hidden: boolean): void { }663isSideBarHidden(): boolean { return false; }664async setEditorHidden(_hidden: boolean): Promise<void> { }665async setSideBarHidden(_hidden: boolean): Promise<void> { }666async setAuxiliaryBarHidden(_hidden: boolean): Promise<void> { }667async setPartHidden(_hidden: boolean, part: Parts): Promise<void> { }668isPanelHidden(): boolean { return false; }669async setPanelHidden(_hidden: boolean): Promise<void> { }670toggleMaximizedPanel(): void { }671isPanelMaximized(): boolean { return false; }672toggleMaximizedAuxiliaryBar(): void { }673setAuxiliaryBarMaximized(maximized: boolean): boolean { return false; }674isAuxiliaryBarMaximized(): boolean { return false; }675getMenubarVisibility(): MenuBarVisibility { throw new Error('not implemented'); }676toggleMenuBar(): void { }677getSideBarPosition() { return 0; }678getPanelPosition() { return 0; }679getPanelAlignment(): PanelAlignment { return 'center'; }680async setPanelPosition(_position: PartPosition): Promise<void> { }681async setPanelAlignment(_alignment: PanelAlignment): Promise<void> { }682addClass(_clazz: string): void { }683removeClass(_clazz: string): void { }684getMaximumEditorDimensions(): IDimension { throw new Error('not implemented'); }685toggleZenMode(): void { }686isMainEditorLayoutCentered(): boolean { return false; }687centerMainEditorLayout(_active: boolean): void { }688resizePart(_part: Parts, _sizeChangeWidth: number, _sizeChangeHeight: number): void { }689getSize(part: Parts): IViewSize { throw new Error('Method not implemented.'); }690setSize(part: Parts, size: IViewSize): void { throw new Error('Method not implemented.'); }691registerPart(part: Part): IDisposable { return Disposable.None; }692isWindowMaximized(targetWindow: Window) { return false; }693updateWindowMaximizedState(targetWindow: Window, maximized: boolean): void { }694getVisibleNeighborPart(part: Parts, direction: Direction): Parts | undefined { return undefined; }695focus() { }696}697698// eslint-disable-next-line local/code-no-any-casts699const activeViewlet: PaneComposite = {} as any;700701export class TestPaneCompositeService extends Disposable implements IPaneCompositePartService {702declare readonly _serviceBrand: undefined;703704readonly onDidPaneCompositeOpen: Event<{ composite: IPaneComposite; viewContainerLocation: ViewContainerLocation }>;705readonly onDidPaneCompositeClose: Event<{ composite: IPaneComposite; viewContainerLocation: ViewContainerLocation }>;706707private parts = new Map<ViewContainerLocation, IPaneCompositePart>();708709constructor() {710super();711712this.parts.set(ViewContainerLocation.Panel, new TestPanelPart());713this.parts.set(ViewContainerLocation.Sidebar, new TestSideBarPart());714715this.onDidPaneCompositeOpen = Event.any(...([ViewContainerLocation.Panel, ViewContainerLocation.Sidebar].map(loc => Event.map(this.parts.get(loc)!.onDidPaneCompositeOpen, composite => { return { composite, viewContainerLocation: loc }; }))));716this.onDidPaneCompositeClose = Event.any(...([ViewContainerLocation.Panel, ViewContainerLocation.Sidebar].map(loc => Event.map(this.parts.get(loc)!.onDidPaneCompositeClose, composite => { return { composite, viewContainerLocation: loc }; }))));717}718719openPaneComposite(id: string | undefined, viewContainerLocation: ViewContainerLocation, focus?: boolean): Promise<IPaneComposite | undefined> {720return this.getPartByLocation(viewContainerLocation).openPaneComposite(id, focus);721}722getActivePaneComposite(viewContainerLocation: ViewContainerLocation): IPaneComposite | undefined {723return this.getPartByLocation(viewContainerLocation).getActivePaneComposite();724}725getPaneComposite(id: string, viewContainerLocation: ViewContainerLocation): PaneCompositeDescriptor | undefined {726return this.getPartByLocation(viewContainerLocation).getPaneComposite(id);727}728getPaneComposites(viewContainerLocation: ViewContainerLocation): PaneCompositeDescriptor[] {729return this.getPartByLocation(viewContainerLocation).getPaneComposites();730}731getProgressIndicator(id: string, viewContainerLocation: ViewContainerLocation): IProgressIndicator | undefined {732return this.getPartByLocation(viewContainerLocation).getProgressIndicator(id);733}734hideActivePaneComposite(viewContainerLocation: ViewContainerLocation): void {735this.getPartByLocation(viewContainerLocation).hideActivePaneComposite();736}737getLastActivePaneCompositeId(viewContainerLocation: ViewContainerLocation): string {738return this.getPartByLocation(viewContainerLocation).getLastActivePaneCompositeId();739}740741getPinnedPaneCompositeIds(viewContainerLocation: ViewContainerLocation): string[] {742throw new Error('Method not implemented.');743}744745getVisiblePaneCompositeIds(viewContainerLocation: ViewContainerLocation): string[] {746throw new Error('Method not implemented.');747}748749getPaneCompositeIds(viewContainerLocation: ViewContainerLocation): string[] {750throw new Error('Method not implemented.');751}752753getPartByLocation(viewContainerLocation: ViewContainerLocation): IPaneCompositePart {754return assertReturnsDefined(this.parts.get(viewContainerLocation));755}756}757758export class TestSideBarPart implements IPaneCompositePart {759declare readonly _serviceBrand: undefined;760761onDidViewletRegisterEmitter = new Emitter<PaneCompositeDescriptor>();762onDidViewletDeregisterEmitter = new Emitter<PaneCompositeDescriptor>();763onDidViewletOpenEmitter = new Emitter<IPaneComposite>();764onDidViewletCloseEmitter = new Emitter<IPaneComposite>();765766readonly partId = Parts.SIDEBAR_PART;767element: HTMLElement = undefined!;768minimumWidth = 0;769maximumWidth = 0;770minimumHeight = 0;771maximumHeight = 0;772onDidChange = Event.None;773onDidPaneCompositeOpen = this.onDidViewletOpenEmitter.event;774onDidPaneCompositeClose = this.onDidViewletCloseEmitter.event;775776openPaneComposite(id: string, focus?: boolean): Promise<IPaneComposite | undefined> { return Promise.resolve(undefined); }777getPaneComposites(): PaneCompositeDescriptor[] { return []; }778getAllViewlets(): PaneCompositeDescriptor[] { return []; }779getActivePaneComposite(): IPaneComposite { return activeViewlet; }780getDefaultViewletId(): string { return 'workbench.view.explorer'; }781getPaneComposite(id: string): PaneCompositeDescriptor | undefined { return undefined; }782getProgressIndicator(id: string) { return undefined; }783hideActivePaneComposite(): void { }784getLastActivePaneCompositeId(): string { return undefined!; }785dispose() { }786getPinnedPaneCompositeIds() { return []; }787getVisiblePaneCompositeIds() { return []; }788getPaneCompositeIds() { return []; }789layout(width: number, height: number, top: number, left: number): void { }790}791792export class TestPanelPart implements IPaneCompositePart {793declare readonly _serviceBrand: undefined;794795element: HTMLElement = undefined!;796minimumWidth = 0;797maximumWidth = 0;798minimumHeight = 0;799maximumHeight = 0;800onDidChange = Event.None;801onDidPaneCompositeOpen = new Emitter<IPaneComposite>().event;802onDidPaneCompositeClose = new Emitter<IPaneComposite>().event;803readonly partId = Parts.AUXILIARYBAR_PART;804805async openPaneComposite(id?: string, focus?: boolean): Promise<undefined> { return undefined; }806getPaneComposite(id: string): any { return activeViewlet; }807getPaneComposites() { return []; }808getPinnedPaneCompositeIds() { return []; }809getVisiblePaneCompositeIds() { return []; }810getPaneCompositeIds() { return []; }811getActivePaneComposite(): IPaneComposite { return activeViewlet; }812setPanelEnablement(id: string, enabled: boolean): void { }813dispose() { }814getProgressIndicator(id: string) { return null!; }815hideActivePaneComposite(): void { }816getLastActivePaneCompositeId(): string { return undefined!; }817layout(width: number, height: number, top: number, left: number): void { }818}819820export class TestViewsService implements IViewsService {821declare readonly _serviceBrand: undefined;822823824onDidChangeViewContainerVisibility = new Emitter<{ id: string; visible: boolean; location: ViewContainerLocation }>().event;825isViewContainerVisible(id: string): boolean { return true; }826isViewContainerActive(id: string): boolean { return true; }827getVisibleViewContainer(): ViewContainer | null { return null; }828openViewContainer(id: string, focus?: boolean): Promise<IPaneComposite | null> { return Promise.resolve(null); }829closeViewContainer(id: string): void { }830831onDidChangeViewVisibilityEmitter = new Emitter<{ id: string; visible: boolean }>();832onDidChangeViewVisibility = this.onDidChangeViewVisibilityEmitter.event;833onDidChangeFocusedViewEmitter = new Emitter<void>();834onDidChangeFocusedView = this.onDidChangeFocusedViewEmitter.event;835isViewVisible(id: string): boolean { return true; }836getActiveViewWithId<T extends IView>(id: string): T | null { return null; }837getViewWithId<T extends IView>(id: string): T | null { return null; }838openView<T extends IView>(id: string, focus?: boolean | undefined): Promise<T | null> { return Promise.resolve(null); }839closeView(id: string): void { }840getViewProgressIndicator(id: string) { return null!; }841getActiveViewPaneContainerWithId(id: string) { return null; }842getFocusedViewName(): string { return ''; }843getFocusedView(): IViewDescriptor | null { return null; }844}845846export class TestEditorGroupsService implements IEditorGroupsService {847848declare readonly _serviceBrand: undefined;849850constructor(public groups: TestEditorGroupView[] = []) { }851852readonly parts: readonly IEditorPart[] = [this];853854windowId = mainWindow.vscodeWindowId;855856readonly onDidCreateAuxiliaryEditorPart: Event<IAuxiliaryEditorPart> = Event.None;857readonly onDidChangeActiveGroup: Event<IEditorGroup> = Event.None;858readonly onDidActivateGroup: Event<IEditorGroup> = Event.None;859readonly onDidAddGroup: Event<IEditorGroup> = Event.None;860readonly onDidRemoveGroup: Event<IEditorGroup> = Event.None;861readonly onDidMoveGroup: Event<IEditorGroup> = Event.None;862readonly onDidChangeGroupIndex: Event<IEditorGroup> = Event.None;863readonly onDidChangeGroupLabel: Event<IEditorGroup> = Event.None;864readonly onDidChangeGroupLocked: Event<IEditorGroup> = Event.None;865readonly onDidChangeGroupMaximized: Event<boolean> = Event.None;866readonly onDidLayout: Event<IDimension> = Event.None;867onDidChangeEditorPartOptions = Event.None;868onDidScroll = Event.None;869onWillDispose = Event.None;870871orientation = GroupOrientation.HORIZONTAL;872isReady = true;873whenReady: Promise<void> = Promise.resolve(undefined);874whenRestored: Promise<void> = Promise.resolve(undefined);875hasRestorableState = false;876877contentDimension = { width: 800, height: 600 };878879get activeGroup(): IEditorGroup { return this.groups[0]; }880get sideGroup(): IEditorGroup { return this.groups[0]; }881get count(): number { return this.groups.length; }882883getPart(group: number | IEditorGroup): IEditorPart { return this; }884saveWorkingSet(name: string): IEditorWorkingSet { throw new Error('Method not implemented.'); }885getWorkingSets(): IEditorWorkingSet[] { throw new Error('Method not implemented.'); }886applyWorkingSet(workingSet: IEditorWorkingSet | 'empty', options?: IEditorWorkingSetOptions): Promise<boolean> { throw new Error('Method not implemented.'); }887deleteWorkingSet(workingSet: IEditorWorkingSet): Promise<boolean> { throw new Error('Method not implemented.'); }888getGroups(_order?: GroupsOrder): readonly IEditorGroup[] { return this.groups; }889getGroup(identifier: number): IEditorGroup | undefined { return this.groups.find(group => group.id === identifier); }890getLabel(_identifier: number): string { return 'Group 1'; }891findGroup(_scope: IFindGroupScope, _source?: number | IEditorGroup, _wrap?: boolean): IEditorGroup { throw new Error('not implemented'); }892activateGroup(_group: number | IEditorGroup): IEditorGroup { throw new Error('not implemented'); }893restoreGroup(_group: number | IEditorGroup): IEditorGroup { throw new Error('not implemented'); }894getSize(_group: number | IEditorGroup): { width: number; height: number } { return { width: 100, height: 100 }; }895setSize(_group: number | IEditorGroup, _size: { width: number; height: number }): void { }896arrangeGroups(_arrangement: GroupsArrangement): void { }897toggleMaximizeGroup(): void { }898hasMaximizedGroup(): boolean { throw new Error('not implemented'); }899toggleExpandGroup(): void { }900applyLayout(_layout: EditorGroupLayout): void { }901getLayout(): EditorGroupLayout { throw new Error('not implemented'); }902setGroupOrientation(_orientation: GroupOrientation): void { }903addGroup(_location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup { throw new Error('not implemented'); }904removeGroup(_group: number | IEditorGroup): void { }905moveGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup { throw new Error('not implemented'); }906mergeGroup(_group: number | IEditorGroup, _target: number | IEditorGroup, _options?: IMergeGroupOptions): boolean { throw new Error('not implemented'); }907mergeAllGroups(_group: number | IEditorGroup, _options?: IMergeGroupOptions): boolean { throw new Error('not implemented'); }908copyGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup { throw new Error('not implemented'); }909centerLayout(active: boolean): void { }910isLayoutCentered(): boolean { return false; }911createEditorDropTarget(container: HTMLElement, delegate: IEditorDropTargetDelegate): IDisposable { return Disposable.None; }912registerContextKeyProvider<T extends ContextKeyValue>(_provider: IEditorGroupContextKeyProvider<T>): IDisposable { throw new Error('not implemented'); }913getScopedInstantiationService(part: IEditorPart): IInstantiationService { throw new Error('Method not implemented.'); }914915partOptions!: IEditorPartOptions;916enforcePartOptions(options: IEditorPartOptions): IDisposable { return Disposable.None; }917918readonly mainPart = this;919registerEditorPart(part: any): IDisposable { return Disposable.None; }920createAuxiliaryEditorPart(): Promise<IAuxiliaryEditorPart> { throw new Error('Method not implemented.'); }921}922923export class TestEditorGroupView implements IEditorGroupView {924925constructor(public id: number) { }926927windowId = mainWindow.vscodeWindowId;928groupsView: IEditorGroupsView = undefined!;929activeEditorPane!: IVisibleEditorPane;930activeEditor!: EditorInput;931selectedEditors: EditorInput[] = [];932previewEditor!: EditorInput;933count!: number;934stickyCount!: number;935disposed!: boolean;936editors: readonly EditorInput[] = [];937label!: string;938isLocked!: boolean;939ariaLabel!: string;940index!: number;941whenRestored: Promise<void> = Promise.resolve(undefined);942element!: HTMLElement;943minimumWidth!: number;944maximumWidth!: number;945minimumHeight!: number;946maximumHeight!: number;947948titleHeight!: IEditorGroupTitleHeight;949950isEmpty = true;951952readonly onWillDispose: Event<void> = Event.None;953readonly onDidModelChange: Event<IGroupModelChangeEvent> = Event.None;954readonly onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;955readonly onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;956readonly onDidOpenEditorFail: Event<EditorInput> = Event.None;957readonly onDidFocus: Event<void> = Event.None;958readonly onDidChange: Event<{ width: number; height: number }> = Event.None;959readonly onWillMoveEditor: Event<IEditorWillMoveEvent> = Event.None;960readonly onWillOpenEditor: Event<IEditorWillOpenEvent> = Event.None;961readonly onDidActiveEditorChange: Event<IActiveEditorChangeEvent> = Event.None;962963getEditors(_order?: EditorsOrder): readonly EditorInput[] { return []; }964findEditors(_resource: URI): readonly EditorInput[] { return []; }965getEditorByIndex(_index: number): EditorInput { throw new Error('not implemented'); }966getIndexOfEditor(_editor: EditorInput): number { return -1; }967isFirst(editor: EditorInput): boolean { return false; }968isLast(editor: EditorInput): boolean { return false; }969openEditor(_editor: EditorInput, _options?: IEditorOptions): Promise<IEditorPane> { throw new Error('not implemented'); }970openEditors(_editors: EditorInputWithOptions[]): Promise<IEditorPane> { throw new Error('not implemented'); }971isPinned(_editor: EditorInput): boolean { return false; }972isSticky(_editor: EditorInput): boolean { return false; }973isTransient(_editor: EditorInput): boolean { return false; }974isActive(_editor: EditorInput | IUntypedEditorInput): boolean { return false; }975setSelection(_activeSelectedEditor: EditorInput, _inactiveSelectedEditors: EditorInput[]): Promise<void> { throw new Error('not implemented'); }976isSelected(_editor: EditorInput): boolean { return false; }977contains(candidate: EditorInput | IUntypedEditorInput): boolean { return false; }978moveEditor(_editor: EditorInput, _target: IEditorGroup, _options?: IEditorOptions): boolean { return true; }979moveEditors(_editors: EditorInputWithOptions[], _target: IEditorGroup): boolean { return true; }980copyEditor(_editor: EditorInput, _target: IEditorGroup, _options?: IEditorOptions): void { }981copyEditors(_editors: EditorInputWithOptions[], _target: IEditorGroup): void { }982async closeEditor(_editor?: EditorInput, options?: ICloseEditorOptions): Promise<boolean> { return true; }983async closeEditors(_editors: EditorInput[] | ICloseEditorsFilter, options?: ICloseEditorOptions): Promise<boolean> { return true; }984closeAllEditors(options?: ICloseAllEditorsOptions): any { return true; }985async replaceEditors(_editors: IEditorReplacement[]): Promise<void> { }986pinEditor(_editor?: EditorInput): void { }987stickEditor(editor?: EditorInput | undefined): void { }988unstickEditor(editor?: EditorInput | undefined): void { }989lock(locked: boolean): void { }990focus(): void { }991get scopedContextKeyService(): IContextKeyService { throw new Error('not implemented'); }992setActive(_isActive: boolean): void { }993notifyIndexChanged(_index: number): void { }994notifyLabelChanged(_label: string): void { }995dispose(): void { }996toJSON(): object { return Object.create(null); }997layout(_width: number, _height: number): void { }998relayout() { }999createEditorActions(_menuDisposable: IDisposable): { actions: IToolbarActions; onDidChange: Event<IMenuChangeEvent> } { throw new Error('not implemented'); }1000}10011002export class TestEditorGroupAccessor implements IEditorGroupsView {10031004label: string = '';1005windowId = mainWindow.vscodeWindowId;10061007groups: IEditorGroupView[] = [];1008activeGroup!: IEditorGroupView;10091010partOptions: IEditorPartOptions = { ...DEFAULT_EDITOR_PART_OPTIONS };10111012onDidChangeEditorPartOptions = Event.None;1013onDidVisibilityChange = Event.None;10141015getGroup(identifier: number): IEditorGroupView | undefined { throw new Error('Method not implemented.'); }1016getGroups(order: GroupsOrder): IEditorGroupView[] { throw new Error('Method not implemented.'); }1017activateGroup(identifier: number | IEditorGroupView): IEditorGroupView { throw new Error('Method not implemented.'); }1018restoreGroup(identifier: number | IEditorGroupView): IEditorGroupView { throw new Error('Method not implemented.'); }1019addGroup(location: number | IEditorGroupView, direction: GroupDirection): IEditorGroupView { throw new Error('Method not implemented.'); }1020mergeGroup(group: number | IEditorGroupView, target: number | IEditorGroupView, options?: IMergeGroupOptions | undefined): boolean { throw new Error('Method not implemented.'); }1021moveGroup(group: number | IEditorGroupView, location: number | IEditorGroupView, direction: GroupDirection): IEditorGroupView { throw new Error('Method not implemented.'); }1022copyGroup(group: number | IEditorGroupView, location: number | IEditorGroupView, direction: GroupDirection): IEditorGroupView { throw new Error('Method not implemented.'); }1023removeGroup(group: number | IEditorGroupView): void { throw new Error('Method not implemented.'); }1024arrangeGroups(arrangement: GroupsArrangement, target?: number | IEditorGroupView | undefined): void { throw new Error('Method not implemented.'); }1025toggleMaximizeGroup(group: number | IEditorGroupView): void { throw new Error('Method not implemented.'); }1026toggleExpandGroup(group: number | IEditorGroupView): void { throw new Error('Method not implemented.'); }1027}10281029export class TestEditorService extends Disposable implements EditorServiceImpl {10301031declare readonly _serviceBrand: undefined;10321033readonly onDidActiveEditorChange: Event<void> = Event.None;1034readonly onDidVisibleEditorsChange: Event<void> = Event.None;1035readonly onDidEditorsChange: Event<IEditorsChangeEvent> = Event.None;1036readonly onWillOpenEditor: Event<IEditorWillOpenEvent> = Event.None;1037readonly onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;1038readonly onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;1039readonly onDidMostRecentlyActiveEditorsChange: Event<void> = Event.None;10401041private _activeTextEditorControl: ICodeEditor | IDiffEditor | undefined;1042public get activeTextEditorControl(): ICodeEditor | IDiffEditor | undefined { return this._activeTextEditorControl; }1043public set activeTextEditorControl(value: ICodeEditor | IDiffEditor | undefined) { this._activeTextEditorControl = value; }10441045activeEditorPane: IVisibleEditorPane | undefined;1046activeTextEditorLanguageId: string | undefined;10471048private _activeEditor: EditorInput | undefined;1049public get activeEditor(): EditorInput | undefined { return this._activeEditor; }1050public set activeEditor(value: EditorInput | undefined) { this._activeEditor = value; }10511052editors: readonly EditorInput[] = [];1053mostRecentlyActiveEditors: readonly IEditorIdentifier[] = [];1054visibleEditorPanes: readonly IVisibleEditorPane[] = [];1055visibleTextEditorControls = [];1056getVisibleTextEditorControls(order: EditorsOrder): readonly (IEditor | IDiffEditor)[] { return this.visibleTextEditorControls; }1057visibleEditors: readonly EditorInput[] = [];1058count = this.editors.length;10591060constructor(private editorGroupService?: IEditorGroupsService) {1061super();1062}1063createScoped(editorGroupsContainer: IEditorGroupsContainer): IEditorService { return this; }1064getEditors() { return []; }1065// eslint-disable-next-line local/code-no-any-casts1066findEditors() { return [] as any; }1067openEditor(editor: EditorInput, options?: IEditorOptions, group?: PreferredGroup): Promise<IEditorPane | undefined>;1068openEditor(editor: IResourceEditorInput | IUntitledTextResourceEditorInput, group?: PreferredGroup): Promise<IEditorPane | undefined>;1069openEditor(editor: IResourceDiffEditorInput, group?: PreferredGroup): Promise<ITextDiffEditorPane | undefined>;1070async openEditor(editor: EditorInput | IUntypedEditorInput, optionsOrGroup?: IEditorOptions | PreferredGroup, group?: PreferredGroup): Promise<IEditorPane | undefined> {1071// openEditor takes ownership of the input, register it to the TestEditorService1072// so it's not marked as leaked during tests.1073if ('dispose' in editor) {1074this._register(editor);1075}1076return undefined;1077}1078async closeEditor(editor: IEditorIdentifier, options?: ICloseEditorOptions): Promise<void> { }1079async closeEditors(editors: IEditorIdentifier[], options?: ICloseEditorOptions): Promise<void> { }1080doResolveEditorOpenRequest(editor: EditorInput | IUntypedEditorInput): [IEditorGroup, EditorInput, IEditorOptions | undefined] | undefined {1081if (!this.editorGroupService) {1082return undefined;1083}10841085return [this.editorGroupService.activeGroup, editor as EditorInput, undefined];1086}1087openEditors(_editors: any, _group?: any): Promise<IEditorPane[]> { throw new Error('not implemented'); }1088isOpened(_editor: IResourceEditorInputIdentifier): boolean { return false; }1089isVisible(_editor: EditorInput): boolean { return false; }1090replaceEditors(_editors: any, _group: any) { return Promise.resolve(undefined); }1091save(editors: IEditorIdentifier[], options?: ISaveEditorsOptions): Promise<ISaveEditorsResult> { throw new Error('Method not implemented.'); }1092saveAll(options?: ISaveEditorsOptions): Promise<ISaveEditorsResult> { throw new Error('Method not implemented.'); }1093revert(editors: IEditorIdentifier[], options?: IRevertOptions): Promise<boolean> { throw new Error('Method not implemented.'); }1094revertAll(options?: IRevertAllEditorsOptions): Promise<boolean> { throw new Error('Method not implemented.'); }1095}10961097export class TestWorkingCopyBackupService extends InMemoryWorkingCopyBackupService {10981099readonly resolved: Set<IWorkingCopyIdentifier> = new Set();11001101constructor() {1102super();1103}11041105parseBackupContent(textBufferFactory: ITextBufferFactory): string {1106const textBuffer = textBufferFactory.create(DefaultEndOfLine.LF).textBuffer;1107const lineCount = textBuffer.getLineCount();1108const range = new Range(1, 1, lineCount, textBuffer.getLineLength(lineCount) + 1);11091110return textBuffer.getValueInRange(range, EndOfLinePreference.TextDefined);1111}11121113override async resolve<T extends IWorkingCopyBackupMeta>(identifier: IWorkingCopyIdentifier): Promise<IResolvedWorkingCopyBackup<T> | undefined> {1114this.resolved.add(identifier);11151116return super.resolve(identifier);1117}1118}11191120export function toUntypedWorkingCopyId(resource: URI): IWorkingCopyIdentifier {1121return toTypedWorkingCopyId(resource, '');1122}11231124export function toTypedWorkingCopyId(resource: URI, typeId = 'testBackupTypeId'): IWorkingCopyIdentifier {1125return { typeId, resource };1126}11271128export class InMemoryTestWorkingCopyBackupService extends BrowserWorkingCopyBackupService {11291130private backupResourceJoiners: Function[];1131private discardBackupJoiners: Function[];11321133discardedBackups: IWorkingCopyIdentifier[];11341135constructor() {1136const disposables = new DisposableStore();1137const environmentService = TestEnvironmentService;1138const logService = new NullLogService();1139const fileService = disposables.add(new FileService(logService));1140disposables.add(fileService.registerProvider(Schemas.file, disposables.add(new InMemoryFileSystemProvider())));1141disposables.add(fileService.registerProvider(Schemas.vscodeUserData, disposables.add(new InMemoryFileSystemProvider())));11421143super(new TestContextService(TestWorkspace), environmentService, fileService, logService);11441145this.backupResourceJoiners = [];1146this.discardBackupJoiners = [];1147this.discardedBackups = [];11481149this._register(disposables);1150}11511152testGetFileService(): IFileService {1153return this.fileService;1154}11551156joinBackupResource(): Promise<void> {1157return new Promise(resolve => this.backupResourceJoiners.push(resolve));1158}11591160joinDiscardBackup(): Promise<void> {1161return new Promise(resolve => this.discardBackupJoiners.push(resolve));1162}11631164override async backup(identifier: IWorkingCopyIdentifier, content?: VSBufferReadableStream | VSBufferReadable, versionId?: number, meta?: any, token?: CancellationToken): Promise<void> {1165await super.backup(identifier, content, versionId, meta, token);11661167while (this.backupResourceJoiners.length) {1168this.backupResourceJoiners.pop()!();1169}1170}11711172override async discardBackup(identifier: IWorkingCopyIdentifier): Promise<void> {1173await super.discardBackup(identifier);1174this.discardedBackups.push(identifier);11751176while (this.discardBackupJoiners.length) {1177this.discardBackupJoiners.pop()!();1178}1179}11801181async getBackupContents(identifier: IWorkingCopyIdentifier): Promise<string> {1182const backupResource = this.toBackupResource(identifier);11831184const fileContents = await this.fileService.readFile(backupResource);11851186return fileContents.value.toString();1187}1188}11891190export class TestBeforeShutdownEvent implements InternalBeforeShutdownEvent {11911192value: boolean | Promise<boolean> | undefined;1193finalValue: (() => boolean | Promise<boolean>) | undefined;1194reason = ShutdownReason.CLOSE;11951196veto(value: boolean | Promise<boolean>): void {1197this.value = value;1198}11991200finalVeto(vetoFn: () => boolean | Promise<boolean>): void {1201this.value = vetoFn();1202this.finalValue = vetoFn;1203}1204}12051206export class TestWillShutdownEvent implements WillShutdownEvent {12071208value: Promise<void>[] = [];1209joiners = () => [];1210reason = ShutdownReason.CLOSE;1211token = CancellationToken.None;12121213join(promise: Promise<void> | (() => Promise<void>), joiner: IWillShutdownEventJoiner): void {1214this.value.push(typeof promise === 'function' ? promise() : promise);1215}12161217force() { /* No-Op in tests */ }1218}12191220export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {12211222declare readonly _serviceBrand: undefined;12231224constructor(private configurationService = new TestConfigurationService()) { }12251226onDidChangeConfiguration() {1227return { dispose() { } };1228}12291230getValue<T>(resource: URI, arg2?: any, arg3?: any): T {1231const position: IPosition | null = EditorPosition.isIPosition(arg2) ? arg2 : null;1232const section: string | undefined = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);1233return this.configurationService.getValue(section, { resource }) as T;1234}12351236inspect<T>(resource: URI | undefined, position: IPosition | null, section: string): IConfigurationValue<Readonly<T>> {1237return this.configurationService.inspect<T>(section, { resource });1238}12391240updateValue(resource: URI, key: string, value: any, configurationTarget?: ConfigurationTarget): Promise<void> {1241return this.configurationService.updateValue(key, value);1242}1243}12441245export class RemoteFileSystemProvider implements IFileSystemProvider {12461247constructor(private readonly wrappedFsp: IFileSystemProvider, private readonly remoteAuthority: string) {1248this.capabilities = this.wrappedFsp.capabilities;1249this.onDidChangeCapabilities = this.wrappedFsp.onDidChangeCapabilities;1250this.onDidChangeFile = Event.map(this.wrappedFsp.onDidChangeFile, changes => changes.map(c => {1251return {1252type: c.type,1253resource: c.resource.with({ scheme: Schemas.vscodeRemote, authority: this.remoteAuthority }),1254};1255}));1256}12571258readonly capabilities: FileSystemProviderCapabilities;1259readonly onDidChangeCapabilities: Event<void>;12601261readonly onDidChangeFile: Event<readonly IFileChange[]>;1262watch(resource: URI, opts: IWatchOptions): IDisposable { return this.wrappedFsp.watch(this.toFileResource(resource), opts); }12631264stat(resource: URI): Promise<IStat> { return this.wrappedFsp.stat(this.toFileResource(resource)); }1265mkdir(resource: URI): Promise<void> { return this.wrappedFsp.mkdir(this.toFileResource(resource)); }1266readdir(resource: URI): Promise<[string, FileType][]> { return this.wrappedFsp.readdir(this.toFileResource(resource)); }1267delete(resource: URI, opts: IFileDeleteOptions): Promise<void> { return this.wrappedFsp.delete(this.toFileResource(resource), opts); }12681269rename(from: URI, to: URI, opts: IFileOverwriteOptions): Promise<void> { return this.wrappedFsp.rename(this.toFileResource(from), this.toFileResource(to), opts); }1270copy(from: URI, to: URI, opts: IFileOverwriteOptions): Promise<void> { return this.wrappedFsp.copy!(this.toFileResource(from), this.toFileResource(to), opts); }12711272readFile(resource: URI): Promise<Uint8Array> { return this.wrappedFsp.readFile!(this.toFileResource(resource)); }1273writeFile(resource: URI, content: Uint8Array, opts: IFileWriteOptions): Promise<void> { return this.wrappedFsp.writeFile!(this.toFileResource(resource), content, opts); }12741275open(resource: URI, opts: IFileOpenOptions): Promise<number> { return this.wrappedFsp.open!(this.toFileResource(resource), opts); }1276close(fd: number): Promise<void> { return this.wrappedFsp.close!(fd); }1277read(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return this.wrappedFsp.read!(fd, pos, data, offset, length); }1278write(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return this.wrappedFsp.write!(fd, pos, data, offset, length); }12791280readFileStream(resource: URI, opts: IFileReadStreamOptions, token: CancellationToken): ReadableStreamEvents<Uint8Array> { return this.wrappedFsp.readFileStream!(this.toFileResource(resource), opts, token); }12811282private toFileResource(resource: URI): URI { return resource.with({ scheme: Schemas.file, authority: '' }); }1283}12841285export class TestInMemoryFileSystemProvider extends InMemoryFileSystemProvider implements IFileSystemProviderWithFileReadStreamCapability {1286override get capabilities(): FileSystemProviderCapabilities {1287return FileSystemProviderCapabilities.FileReadWrite1288| FileSystemProviderCapabilities.PathCaseSensitive1289| FileSystemProviderCapabilities.FileReadStream;1290}12911292override readFileStream(resource: URI): ReadableStreamEvents<Uint8Array> {1293const BUFFER_SIZE = 64 * 1024;1294const stream = newWriteableStream<Uint8Array>(data => VSBuffer.concat(data.map(data => VSBuffer.wrap(data))).buffer);12951296(async () => {1297try {1298const data = await this.readFile(resource);12991300let offset = 0;1301while (offset < data.length) {1302await timeout(0);1303await stream.write(data.subarray(offset, offset + BUFFER_SIZE));1304offset += BUFFER_SIZE;1305}13061307await timeout(0);1308stream.end();1309} catch (error) {1310stream.end(error);1311}1312})();13131314return stream;1315}1316}13171318export const productService: IProductService = { _serviceBrand: undefined, ...product };13191320export class TestHostService implements IHostService {13211322declare readonly _serviceBrand: undefined;13231324private _hasFocus = true;1325get hasFocus() { return this._hasFocus; }1326async hadLastFocus(): Promise<boolean> { return this._hasFocus; }13271328private _onDidChangeFocus = new Emitter<boolean>();1329readonly onDidChangeFocus = this._onDidChangeFocus.event;13301331private _onDidChangeWindow = new Emitter<number>();1332readonly onDidChangeActiveWindow = this._onDidChangeWindow.event;13331334readonly onDidChangeFullScreen: Event<{ windowId: number; fullscreen: boolean }> = Event.None;13351336setFocus(focus: boolean) {1337this._hasFocus = focus;1338this._onDidChangeFocus.fire(this._hasFocus);1339}13401341async restart(): Promise<void> { }1342async reload(): Promise<void> { }1343async close(): Promise<void> { }1344async withExpectedShutdown<T>(expectedShutdownTask: () => Promise<T>): Promise<T> {1345return await expectedShutdownTask();1346}13471348async focus(): Promise<void> { }1349async moveTop(): Promise<void> { }1350async getCursorScreenPoint(): Promise<undefined> { return undefined; }13511352async getWindows(options: unknown) { return []; }13531354async openWindow(arg1?: IOpenEmptyWindowOptions | IWindowOpenable[], arg2?: IOpenWindowOptions): Promise<void> { }13551356async toggleFullScreen(): Promise<void> { }13571358async getScreenshot(rect?: IRectangle): Promise<VSBuffer | undefined> { return undefined; }13591360async getNativeWindowHandle(_windowId: number): Promise<VSBuffer | undefined> { return undefined; }13611362readonly colorScheme = ColorScheme.DARK;1363onDidChangeColorScheme = Event.None;1364}13651366export class TestFilesConfigurationService extends FilesConfigurationService {13671368testOnFilesConfigurationChange(configuration: any): void {1369super.onFilesConfigurationChange(configuration, true);1370}1371}13721373export class TestReadonlyTextFileEditorModel extends TextFileEditorModel {13741375override isReadonly(): boolean {1376return true;1377}1378}13791380export class TestEditorInput extends EditorInput {13811382constructor(public resource: URI, private readonly _typeId: string) {1383super();1384}13851386override get typeId(): string {1387return this._typeId;1388}13891390override get editorId(): string {1391return this._typeId;1392}13931394override resolve(): Promise<IDisposable | null> {1395return Promise.resolve(null);1396}1397}13981399export function registerTestEditor(id: string, inputs: SyncDescriptor<EditorInput>[], serializerInputId?: string): IDisposable {1400const disposables = new DisposableStore();14011402class TestEditor extends EditorPane {14031404private _scopedContextKeyService: IContextKeyService;14051406constructor(group: IEditorGroup) {1407super(id, group, NullTelemetryService, new TestThemeService(), disposables.add(new TestStorageService()));1408this._scopedContextKeyService = new MockContextKeyService();1409}14101411override async setInput(input: EditorInput, options: IEditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void> {1412super.setInput(input, options, context, token);14131414await input.resolve();1415}14161417override getId(): string { return id; }1418layout(): void { }1419protected createEditor(): void { }14201421override get scopedContextKeyService() {1422return this._scopedContextKeyService;1423}1424}14251426disposables.add(Registry.as<IEditorPaneRegistry>(Extensions.EditorPane).registerEditorPane(EditorPaneDescriptor.create(TestEditor, id, 'Test Editor Control'), inputs));14271428if (serializerInputId) {14291430interface ISerializedTestInput {1431resource: string;1432}14331434class EditorsObserverTestEditorInputSerializer implements IEditorSerializer {14351436canSerialize(editorInput: EditorInput): boolean {1437return true;1438}14391440serialize(editorInput: EditorInput): string {1441const testEditorInput = <TestFileEditorInput>editorInput;1442const testInput: ISerializedTestInput = {1443resource: testEditorInput.resource.toString()1444};14451446return JSON.stringify(testInput);1447}14481449deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): EditorInput {1450const testInput: ISerializedTestInput = JSON.parse(serializedEditorInput);14511452return new TestFileEditorInput(URI.parse(testInput.resource), serializerInputId!);1453}1454}14551456disposables.add(Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerEditorSerializer(serializerInputId, EditorsObserverTestEditorInputSerializer));1457}14581459return disposables;1460}14611462export function registerTestFileEditor(): IDisposable {1463const disposables = new DisposableStore();14641465disposables.add(Registry.as<IEditorPaneRegistry>(Extensions.EditorPane).registerEditorPane(1466EditorPaneDescriptor.create(1467TestTextFileEditor,1468TestTextFileEditor.ID,1469'Text File Editor'1470),1471[new SyncDescriptor(FileEditorInput)]1472));14731474return disposables;1475}14761477export function registerTestResourceEditor(): IDisposable {1478const disposables = new DisposableStore();14791480disposables.add(Registry.as<IEditorPaneRegistry>(Extensions.EditorPane).registerEditorPane(1481EditorPaneDescriptor.create(1482TestTextResourceEditor,1483TestTextResourceEditor.ID,1484'Text Editor'1485),1486[1487new SyncDescriptor(UntitledTextEditorInput),1488new SyncDescriptor(TextResourceEditorInput)1489]1490));14911492return disposables;1493}14941495export function registerTestSideBySideEditor(): IDisposable {1496const disposables = new DisposableStore();14971498disposables.add(Registry.as<IEditorPaneRegistry>(Extensions.EditorPane).registerEditorPane(1499EditorPaneDescriptor.create(1500SideBySideEditor,1501SideBySideEditor.ID,1502'Text Editor'1503),1504[1505new SyncDescriptor(SideBySideEditorInput)1506]1507));15081509return disposables;1510}15111512export class TestFileEditorInput extends EditorInput implements IFileEditorInput {15131514readonly preferredResource;15151516gotDisposed = false;1517gotSaved = false;1518gotSavedAs = false;1519gotReverted = false;1520dirty = false;1521modified: boolean | undefined;1522private fails = false;15231524disableToUntyped = false;15251526constructor(1527public resource: URI,1528private _typeId: string1529) {1530super();15311532this.preferredResource = this.resource;1533}15341535override get typeId() { return this._typeId; }1536override get editorId() { return this._typeId; }15371538private _capabilities: EditorInputCapabilities = EditorInputCapabilities.None;1539override get capabilities(): EditorInputCapabilities { return this._capabilities; }1540override set capabilities(capabilities: EditorInputCapabilities) {1541if (this._capabilities !== capabilities) {1542this._capabilities = capabilities;1543this._onDidChangeCapabilities.fire();1544}1545}15461547override resolve(): Promise<IDisposable | null> { return !this.fails ? Promise.resolve(null) : Promise.reject(new Error('fails')); }1548override matches(other: EditorInput | IResourceEditorInput | ITextResourceEditorInput | IUntitledTextResourceEditorInput): boolean {1549if (super.matches(other)) {1550return true;1551}1552if (other instanceof EditorInput) {1553return !!(other?.resource && this.resource.toString() === other.resource.toString() && other instanceof TestFileEditorInput && other.typeId === this.typeId);1554}1555return isEqual(this.resource, other.resource) && (this.editorId === other.options?.override || other.options?.override === undefined);1556}1557setPreferredResource(resource: URI): void { }1558async setEncoding(encoding: string) { }1559getEncoding() { return undefined; }1560setPreferredName(name: string): void { }1561setPreferredDescription(description: string): void { }1562setPreferredEncoding(encoding: string) { }1563setPreferredContents(contents: string): void { }1564setLanguageId(languageId: string, source?: string) { }1565setPreferredLanguageId(languageId: string) { }1566setForceOpenAsBinary(): void { }1567setFailToOpen(): void {1568this.fails = true;1569}1570override async save(groupId: GroupIdentifier, options?: ISaveOptions): Promise<EditorInput | undefined> {1571this.gotSaved = true;1572this.dirty = false;1573return this;1574}1575override async saveAs(groupId: GroupIdentifier, options?: ISaveOptions): Promise<EditorInput | undefined> {1576this.gotSavedAs = true;1577return this;1578}1579override async revert(group: GroupIdentifier, options?: IRevertOptions): Promise<void> {1580this.gotReverted = true;1581this.gotSaved = false;1582this.gotSavedAs = false;1583this.dirty = false;1584}1585override toUntyped(): IUntypedEditorInput | undefined {1586if (this.disableToUntyped) {1587return undefined;1588}1589return { resource: this.resource };1590}1591setModified(): void { this.modified = true; }1592override isModified(): boolean {1593return this.modified === undefined ? this.dirty : this.modified;1594}1595setDirty(): void { this.dirty = true; }1596override isDirty(): boolean {1597return this.dirty;1598}1599isResolved(): boolean { return false; }1600override dispose(): void {1601super.dispose();1602this.gotDisposed = true;1603}1604movedEditor: IMoveResult | undefined = undefined;1605override async rename(): Promise<IMoveResult | undefined> { return this.movedEditor; }16061607private moveDisabledReason: string | undefined = undefined;1608setMoveDisabled(reason: string): void {1609this.moveDisabledReason = reason;1610}16111612override canMove(sourceGroup: GroupIdentifier, targetGroup: GroupIdentifier): string | true {1613if (typeof this.moveDisabledReason === 'string') {1614return this.moveDisabledReason;1615}1616return super.canMove(sourceGroup, targetGroup);1617}1618}16191620export class TestSingletonFileEditorInput extends TestFileEditorInput {16211622override get capabilities(): EditorInputCapabilities { return EditorInputCapabilities.Singleton; }1623}16241625export class TestEditorPart extends MainEditorPart implements IEditorGroupsService {16261627declare readonly _serviceBrand: undefined;16281629readonly mainPart = this;1630readonly parts: readonly IEditorPart[] = [this];16311632readonly onDidCreateAuxiliaryEditorPart: Event<IAuxiliaryEditorPart> = Event.None;16331634testSaveState(): void {1635return super.saveState();1636}16371638clearState(): void {1639const workspaceMemento = this.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE) as Record<string, unknown>;1640for (const key of Object.keys(workspaceMemento)) {1641delete workspaceMemento[key];1642}16431644const profileMemento = this.getMemento(StorageScope.PROFILE, StorageTarget.MACHINE) as Record<string, unknown>;1645for (const key of Object.keys(profileMemento)) {1646delete profileMemento[key];1647}1648}16491650registerEditorPart(part: IEditorPart): IDisposable {1651return Disposable.None;1652}16531654createAuxiliaryEditorPart(): Promise<IAuxiliaryEditorPart> {1655throw new Error('Method not implemented.');1656}16571658getScopedInstantiationService(part: IEditorPart): IInstantiationService {1659throw new Error('Method not implemented.');1660}16611662getPart(group: number | IEditorGroup): IEditorPart { return this; }16631664saveWorkingSet(name: string): IEditorWorkingSet { throw new Error('Method not implemented.'); }1665getWorkingSets(): IEditorWorkingSet[] { throw new Error('Method not implemented.'); }1666applyWorkingSet(workingSet: IEditorWorkingSet | 'empty', options?: IEditorWorkingSetOptions): Promise<boolean> { throw new Error('Method not implemented.'); }1667deleteWorkingSet(workingSet: IEditorWorkingSet): Promise<boolean> { throw new Error('Method not implemented.'); }16681669registerContextKeyProvider<T extends ContextKeyValue>(provider: IEditorGroupContextKeyProvider<T>): IDisposable { throw new Error('Method not implemented.'); }1670}16711672export class TestEditorParts extends EditorParts {1673testMainPart!: TestEditorPart;16741675protected override createMainEditorPart(): MainEditorPart {1676this.testMainPart = this.instantiationService.createInstance(TestEditorPart, this);16771678return this.testMainPart;1679}1680}16811682export async function createEditorParts(instantiationService: IInstantiationService, disposables: DisposableStore): Promise<TestEditorParts> {1683const parts = instantiationService.createInstance(TestEditorParts);1684const part = disposables.add(parts).testMainPart;1685part.create(document.createElement('div'));1686part.layout(1080, 800, 0, 0);16871688await parts.whenReady;16891690return parts;1691}16921693export async function createEditorPart(instantiationService: IInstantiationService, disposables: DisposableStore): Promise<TestEditorPart> {1694return (await createEditorParts(instantiationService, disposables)).testMainPart;1695}16961697export class TestListService implements IListService {1698declare readonly _serviceBrand: undefined;16991700lastFocusedList: any | undefined = undefined;17011702register(): IDisposable {1703return Disposable.None;1704}1705}17061707export class TestPathService implements IPathService {17081709declare readonly _serviceBrand: undefined;17101711constructor(private readonly fallbackUserHome: URI = URI.from({ scheme: Schemas.file, path: '/' }), public defaultUriScheme = Schemas.file) { }17121713hasValidBasename(resource: URI, basename?: string): Promise<boolean>;1714hasValidBasename(resource: URI, os: OperatingSystem, basename?: string): boolean;1715hasValidBasename(resource: URI, arg2?: string | OperatingSystem, name?: string): boolean | Promise<boolean> {1716if (typeof arg2 === 'string' || typeof arg2 === 'undefined') {1717return isValidBasename(arg2 ?? basename(resource));1718}17191720return isValidBasename(name ?? basename(resource));1721}17221723get path() { return Promise.resolve(isWindows ? win32 : posix); }17241725userHome(options?: { preferLocal: boolean }): Promise<URI>;1726userHome(options: { preferLocal: true }): URI;1727userHome(options?: { preferLocal: boolean }): Promise<URI> | URI {1728return options?.preferLocal ? this.fallbackUserHome : Promise.resolve(this.fallbackUserHome);1729}17301731get resolvedUserHome() { return this.fallbackUserHome; }17321733async fileURI(path: string): Promise<URI> {1734return URI.file(path);1735}1736}17371738export interface ITestTextFileEditorModelManager extends ITextFileEditorModelManager, IDisposable {1739add(resource: URI, model: TextFileEditorModel): void;1740remove(resource: URI): void;1741}17421743interface ITestTextFileEditorModel extends ITextFileEditorModel {1744readonly lastResolvedFileStat: IFileStatWithMetadata | undefined;1745}17461747export function getLastResolvedFileStat(model: unknown): IFileStatWithMetadata | undefined {1748const candidate = model as ITestTextFileEditorModel | undefined;17491750return candidate?.lastResolvedFileStat;1751}17521753export class TestWorkspacesService implements IWorkspacesService {1754_serviceBrand: undefined;17551756onDidChangeRecentlyOpened = Event.None;17571758async createUntitledWorkspace(folders?: IWorkspaceFolderCreationData[], remoteAuthority?: string): Promise<IWorkspaceIdentifier> { throw new Error('Method not implemented.'); }1759async deleteUntitledWorkspace(workspace: IWorkspaceIdentifier): Promise<void> { }1760async addRecentlyOpened(recents: IRecent[]): Promise<void> { }1761async removeRecentlyOpened(workspaces: URI[]): Promise<void> { }1762async clearRecentlyOpened(): Promise<void> { }1763async getRecentlyOpened(): Promise<IRecentlyOpened> { return { files: [], workspaces: [] }; }1764async getDirtyWorkspaces(): Promise<(IFolderBackupInfo | IWorkspaceBackupInfo)[]> { return []; }1765async enterWorkspace(path: URI): Promise<IEnterWorkspaceResult | undefined> { throw new Error('Method not implemented.'); }1766async getWorkspaceIdentifier(workspacePath: URI): Promise<IWorkspaceIdentifier> { throw new Error('Method not implemented.'); }1767}17681769export class TestTerminalInstanceService implements ITerminalInstanceService {1770onDidCreateInstance = Event.None;1771onDidRegisterBackend = Event.None;1772declare readonly _serviceBrand: undefined;17731774convertProfileToShellLaunchConfig(shellLaunchConfigOrProfile?: IShellLaunchConfig | ITerminalProfile, cwd?: string | URI): IShellLaunchConfig { throw new Error('Method not implemented.'); }1775preparePathForTerminalAsync(path: string, executable: string | undefined, title: string, shellType: TerminalShellType, remoteAuthority: string | undefined): Promise<string> { throw new Error('Method not implemented.'); }1776createInstance(options: ICreateTerminalOptions, target: TerminalLocation): ITerminalInstance { throw new Error('Method not implemented.'); }1777async getBackend(remoteAuthority?: string): Promise<ITerminalBackend | undefined> { throw new Error('Method not implemented.'); }1778didRegisterBackend(backend: ITerminalBackend): void { throw new Error('Method not implemented.'); }1779getRegisteredBackends(): IterableIterator<ITerminalBackend> { throw new Error('Method not implemented.'); }1780}17811782export class TestTerminalEditorService implements ITerminalEditorService {1783_serviceBrand: undefined;1784activeInstance: ITerminalInstance | undefined;1785instances: readonly ITerminalInstance[] = [];1786onDidDisposeInstance = Event.None;1787onDidFocusInstance = Event.None;1788onDidChangeInstanceCapability = Event.None;1789onDidChangeActiveInstance = Event.None;1790onDidChangeInstances = Event.None;1791openEditor(instance: ITerminalInstance, editorOptions?: TerminalEditorLocation): Promise<void> { throw new Error('Method not implemented.'); }1792detachInstance(instance: ITerminalInstance): void { throw new Error('Method not implemented.'); }1793splitInstance(instanceToSplit: ITerminalInstance, shellLaunchConfig?: IShellLaunchConfig): ITerminalInstance { throw new Error('Method not implemented.'); }1794revealActiveEditor(preserveFocus?: boolean): Promise<void> { throw new Error('Method not implemented.'); }1795resolveResource(instance: ITerminalInstance): URI { throw new Error('Method not implemented.'); }1796reviveInput(deserializedInput: IDeserializedTerminalEditorInput): TerminalEditorInput { throw new Error('Method not implemented.'); }1797getInputFromResource(resource: URI): TerminalEditorInput { throw new Error('Method not implemented.'); }1798setActiveInstance(instance: ITerminalInstance): void { throw new Error('Method not implemented.'); }1799focusActiveInstance(): Promise<void> { throw new Error('Method not implemented.'); }1800async focusInstance(instance: ITerminalInstance): Promise<void> { throw new Error('Method not implemented.'); }1801getInstanceFromResource(resource: URI | undefined): ITerminalInstance | undefined { throw new Error('Method not implemented.'); }1802focusFindWidget(): void { throw new Error('Method not implemented.'); }1803hideFindWidget(): void { throw new Error('Method not implemented.'); }1804findNext(): void { throw new Error('Method not implemented.'); }1805findPrevious(): void { throw new Error('Method not implemented.'); }1806}18071808export class TestTerminalGroupService implements ITerminalGroupService {1809_serviceBrand: undefined;1810activeInstance: ITerminalInstance | undefined;1811instances: readonly ITerminalInstance[] = [];1812groups: readonly ITerminalGroup[] = [];1813activeGroup: ITerminalGroup | undefined;1814activeGroupIndex: number = 0;1815lastAccessedMenu: 'inline-tab' | 'tab-list' = 'inline-tab';1816onDidChangeActiveGroup = Event.None;1817onDidDisposeGroup = Event.None;1818onDidShow = Event.None;1819onDidChangeGroups = Event.None;1820onDidChangePanelOrientation = Event.None;1821onDidDisposeInstance = Event.None;1822onDidFocusInstance = Event.None;1823onDidChangeInstanceCapability = Event.None;1824onDidChangeActiveInstance = Event.None;1825onDidChangeInstances = Event.None;1826createGroup(instance?: any): ITerminalGroup { throw new Error('Method not implemented.'); }1827getGroupForInstance(instance: ITerminalInstance): ITerminalGroup | undefined { throw new Error('Method not implemented.'); }1828moveGroup(source: ITerminalInstance | ITerminalInstance[], target: ITerminalInstance): void { throw new Error('Method not implemented.'); }1829moveGroupToEnd(source: ITerminalInstance | ITerminalInstance[]): void { throw new Error('Method not implemented.'); }1830moveInstance(source: ITerminalInstance, target: ITerminalInstance, side: 'before' | 'after'): void { throw new Error('Method not implemented.'); }1831unsplitInstance(instance: ITerminalInstance): void { throw new Error('Method not implemented.'); }1832joinInstances(instances: ITerminalInstance[]): void { throw new Error('Method not implemented.'); }1833instanceIsSplit(instance: ITerminalInstance): boolean { throw new Error('Method not implemented.'); }1834getGroupLabels(): string[] { throw new Error('Method not implemented.'); }1835setActiveGroupByIndex(index: number): void { throw new Error('Method not implemented.'); }1836setActiveGroupToNext(): void { throw new Error('Method not implemented.'); }1837setActiveGroupToPrevious(): void { throw new Error('Method not implemented.'); }1838setActiveInstanceByIndex(terminalIndex: number): void { throw new Error('Method not implemented.'); }1839setContainer(container: HTMLElement): void { throw new Error('Method not implemented.'); }1840showPanel(focus?: boolean): Promise<void> { throw new Error('Method not implemented.'); }1841hidePanel(): void { throw new Error('Method not implemented.'); }1842focusTabs(): void { throw new Error('Method not implemented.'); }1843focusHover(): void { throw new Error('Method not implemented.'); }1844setActiveInstance(instance: ITerminalInstance): void { throw new Error('Method not implemented.'); }1845focusActiveInstance(): Promise<void> { throw new Error('Method not implemented.'); }1846async focusInstance(instance: ITerminalInstance): Promise<void> { throw new Error('Method not implemented.'); }1847getInstanceFromResource(resource: URI | undefined): ITerminalInstance | undefined { throw new Error('Method not implemented.'); }1848focusFindWidget(): void { throw new Error('Method not implemented.'); }1849hideFindWidget(): void { throw new Error('Method not implemented.'); }1850findNext(): void { throw new Error('Method not implemented.'); }1851findPrevious(): void { throw new Error('Method not implemented.'); }1852updateVisibility(): void { throw new Error('Method not implemented.'); }1853}18541855export class TestTerminalProfileService implements ITerminalProfileService {1856_serviceBrand: undefined;1857availableProfiles: ITerminalProfile[] = [];1858contributedProfiles: IExtensionTerminalProfile[] = [];1859profilesReady: Promise<void> = Promise.resolve();1860onDidChangeAvailableProfiles = Event.None;1861getPlatformKey(): Promise<string> { throw new Error('Method not implemented.'); }1862refreshAvailableProfiles(): void { throw new Error('Method not implemented.'); }1863getDefaultProfileName(): string | undefined { throw new Error('Method not implemented.'); }1864getDefaultProfile(): ITerminalProfile | undefined { throw new Error('Method not implemented.'); }1865getContributedDefaultProfile(shellLaunchConfig: IShellLaunchConfig): Promise<IExtensionTerminalProfile | undefined> { throw new Error('Method not implemented.'); }1866registerContributedProfile(args: IRegisterContributedProfileArgs): Promise<void> { throw new Error('Method not implemented.'); }1867getContributedProfileProvider(extensionIdentifier: string, id: string): ITerminalProfileProvider | undefined { throw new Error('Method not implemented.'); }1868registerTerminalProfileProvider(extensionIdentifier: string, id: string, profileProvider: ITerminalProfileProvider): IDisposable { throw new Error('Method not implemented.'); }1869}18701871export class TestTerminalProfileResolverService implements ITerminalProfileResolverService {1872_serviceBrand: undefined;1873defaultProfileName = '';1874resolveIcon(shellLaunchConfig: IShellLaunchConfig): void { }1875async resolveShellLaunchConfig(shellLaunchConfig: IShellLaunchConfig, options: IShellLaunchConfigResolveOptions): Promise<void> { }1876async getDefaultProfile(options: IShellLaunchConfigResolveOptions): Promise<ITerminalProfile> { return { path: '/default', profileName: 'Default', isDefault: true }; }1877async getDefaultShell(options: IShellLaunchConfigResolveOptions): Promise<string> { return '/default'; }1878async getDefaultShellArgs(options: IShellLaunchConfigResolveOptions): Promise<string | string[]> { return []; }1879getDefaultIcon(): TerminalIcon & ThemeIcon { return Codicon.terminal; }1880async getEnvironment(): Promise<IProcessEnvironment> { return env; }1881getSafeConfigValue(key: string, os: OperatingSystem): unknown | undefined { return undefined; }1882getSafeConfigValueFullKey(key: string): unknown | undefined { return undefined; }1883createProfileFromShellAndShellArgs(shell?: unknown, shellArgs?: unknown): Promise<string | ITerminalProfile> { throw new Error('Method not implemented.'); }1884}18851886export class TestTerminalConfigurationService extends TerminalConfigurationService {1887get fontMetrics() { return this._fontMetrics; }1888// eslint-disable-next-line local/code-no-any-casts1889setConfig(config: Partial<ITerminalConfiguration>) { this._config = config as any; }1890}18911892export class TestQuickInputService implements IQuickInputService {1893declare readonly _serviceBrand: undefined;18941895readonly onShow = Event.None;1896readonly onHide = Event.None;18971898readonly currentQuickInput = undefined;1899readonly quickAccess = undefined!;1900backButton!: IQuickInputButton;19011902pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: IPickOptions<T> & { canPickMany: true }, token?: CancellationToken): Promise<T[]>;1903pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: IPickOptions<T> & { canPickMany: false }, token?: CancellationToken): Promise<T>;1904async pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: Omit<IPickOptions<T>, 'canPickMany'>, token?: CancellationToken): Promise<T | undefined> {1905if (Array.isArray(picks)) {1906// eslint-disable-next-line local/code-no-any-casts1907return <any>{ label: 'selectedPick', description: 'pick description', value: 'selectedPick' };1908} else {1909return undefined;1910}1911}19121913async input(options?: IInputOptions, token?: CancellationToken): Promise<string> { return options ? 'resolved' + options.prompt : 'resolved'; }19141915createQuickPick<T extends IQuickPickItem>(): IQuickPick<T, { useSeparators: boolean }> { throw new Error('not implemented.'); }1916createInputBox(): IInputBox { throw new Error('not implemented.'); }1917createQuickWidget(): IQuickWidget { throw new Error('Method not implemented.'); }1918createQuickTree<T extends IQuickTreeItem>(): IQuickTree<T> { throw new Error('not implemented.'); }1919focus(): void { throw new Error('not implemented.'); }1920toggle(): void { throw new Error('not implemented.'); }1921navigate(next: boolean, quickNavigate?: IQuickNavigateConfiguration): void { throw new Error('not implemented.'); }1922accept(): Promise<void> { throw new Error('not implemented.'); }1923back(): Promise<void> { throw new Error('not implemented.'); }1924cancel(): Promise<void> { throw new Error('not implemented.'); }1925setAlignment(alignment: 'top' | 'center' | { top: number; left: number }): void { throw new Error('not implemented.'); }1926toggleHover(): void { throw new Error('not implemented.'); }1927}19281929class TestLanguageDetectionService implements ILanguageDetectionService {19301931declare readonly _serviceBrand: undefined;19321933isEnabledForLanguage(languageId: string): boolean { return false; }1934async detectLanguage(resource: URI, supportedLangs?: string[] | undefined): Promise<string | undefined> { return undefined; }1935}19361937export class TestRemoteAgentService implements IRemoteAgentService {19381939declare readonly _serviceBrand: undefined;19401941getConnection(): IRemoteAgentConnection | null { return null; }1942async getEnvironment(): Promise<IRemoteAgentEnvironment | null> { return null; }1943async getRawEnvironment(): Promise<IRemoteAgentEnvironment | null> { return null; }1944async getExtensionHostExitInfo(reconnectionToken: string): Promise<IExtensionHostExitInfo | null> { return null; }1945async getDiagnosticInfo(options: IDiagnosticInfoOptions): Promise<IDiagnosticInfo | undefined> { return undefined; }1946async updateTelemetryLevel(telemetryLevel: TelemetryLevel): Promise<void> { }1947async logTelemetry(eventName: string, data?: ITelemetryData): Promise<void> { }1948async flushTelemetry(): Promise<void> { }1949async getRoundTripTime(): Promise<number | undefined> { return undefined; }1950async endConnection(): Promise<void> { }1951}19521953export class TestRemoteExtensionsScannerService implements IRemoteExtensionsScannerService {1954declare readonly _serviceBrand: undefined;1955async whenExtensionsReady(): Promise<InstallExtensionSummary> { return { failed: [] }; }1956scanExtensions(): Promise<IExtensionDescription[]> { throw new Error('Method not implemented.'); }1957}19581959export class TestWorkbenchExtensionEnablementService implements IWorkbenchExtensionEnablementService {1960_serviceBrand: undefined;1961onEnablementChanged = Event.None;1962getEnablementState(extension: IExtension): EnablementState { return EnablementState.EnabledGlobally; }1963getEnablementStates(extensions: IExtension[], workspaceTypeOverrides?: { trusted?: boolean | undefined } | undefined): EnablementState[] { return []; }1964getDependenciesEnablementStates(extension: IExtension): [IExtension, EnablementState][] { return []; }1965canChangeEnablement(extension: IExtension): boolean { return true; }1966canChangeWorkspaceEnablement(extension: IExtension): boolean { return true; }1967isEnabled(extension: IExtension): boolean { return true; }1968isEnabledEnablementState(enablementState: EnablementState): boolean { return true; }1969isDisabledGlobally(extension: IExtension): boolean { return false; }1970async setEnablement(extensions: IExtension[], state: EnablementState): Promise<boolean[]> { return []; }1971async updateExtensionsEnablementsWhenWorkspaceTrustChanges(): Promise<void> { }1972}19731974export class TestWorkbenchExtensionManagementService implements IWorkbenchExtensionManagementService {1975_serviceBrand: undefined;1976onInstallExtension = Event.None;1977onDidInstallExtensions = Event.None;1978onUninstallExtension = Event.None;1979onDidUninstallExtension = Event.None;1980onDidUpdateExtensionMetadata = Event.None;1981onProfileAwareInstallExtension = Event.None;1982onProfileAwareDidInstallExtensions = Event.None;1983onProfileAwareUninstallExtension = Event.None;1984onProfileAwareDidUninstallExtension = Event.None;1985onDidProfileAwareUninstallExtensions = Event.None;1986onProfileAwareDidUpdateExtensionMetadata = Event.None;1987onDidChangeProfile = Event.None;1988onDidEnableExtensions = Event.None;1989preferPreReleases = true;1990installVSIX(location: URI, manifest: Readonly<IRelaxedExtensionManifest>, installOptions?: InstallOptions | undefined): Promise<ILocalExtension> {1991throw new Error('Method not implemented.');1992}1993installFromLocation(location: URI): Promise<ILocalExtension> {1994throw new Error('Method not implemented.');1995}1996installGalleryExtensions(extensions: InstallExtensionInfo[]): Promise<InstallExtensionResult[]> {1997throw new Error('Method not implemented.');1998}1999async updateFromGallery(gallery: IGalleryExtension, extension: ILocalExtension, installOptions?: InstallOptions | undefined): Promise<ILocalExtension> { return extension; }2000zip(extension: ILocalExtension): Promise<URI> {2001throw new Error('Method not implemented.');2002}2003getManifest(vsix: URI): Promise<Readonly<IRelaxedExtensionManifest>> {2004throw new Error('Method not implemented.');2005}2006install(vsix: URI, options?: InstallOptions | undefined): Promise<ILocalExtension> {2007throw new Error('Method not implemented.');2008}2009isAllowed(): true | IMarkdownString { return true; }2010async canInstall(extension: IGalleryExtension): Promise<true> { return true; }2011installFromGallery(extension: IGalleryExtension, options?: InstallOptions | undefined): Promise<ILocalExtension> {2012throw new Error('Method not implemented.');2013}2014uninstall(extension: ILocalExtension, options?: UninstallOptions | undefined): Promise<void> {2015throw new Error('Method not implemented.');2016}2017uninstallExtensions(extensions: UninstallExtensionInfo[]): Promise<void> {2018throw new Error('Method not implemented.');2019}2020async getInstalled(type?: ExtensionType | undefined): Promise<ILocalExtension[]> { return []; }2021getExtensionsControlManifest(): Promise<IExtensionsControlManifest> {2022throw new Error('Method not implemented.');2023}2024async updateMetadata(local: ILocalExtension, metadata: Partial<Metadata>): Promise<ILocalExtension> { return local; }2025registerParticipant(pariticipant: IExtensionManagementParticipant): void { }2026async getTargetPlatform(): Promise<TargetPlatform> { return TargetPlatform.UNDEFINED; }2027async cleanUp(): Promise<void> { }2028download(): Promise<URI> {2029throw new Error('Method not implemented.');2030}2031copyExtensions(): Promise<void> { throw new Error('Not Supported'); }2032toggleApplicationScope(): Promise<ILocalExtension> { throw new Error('Not Supported'); }2033installExtensionsFromProfile(): Promise<ILocalExtension[]> { throw new Error('Not Supported'); }2034whenProfileChanged(from: IUserDataProfile, to: IUserDataProfile): Promise<void> { throw new Error('Not Supported'); }2035getInstalledWorkspaceExtensionLocations(): URI[] { throw new Error('Method not implemented.'); }2036getInstalledWorkspaceExtensions(): Promise<ILocalExtension[]> { throw new Error('Method not implemented.'); }2037installResourceExtension(): Promise<ILocalExtension> { throw new Error('Method not implemented.'); }2038getExtensions(): Promise<IResourceExtension[]> { throw new Error('Method not implemented.'); }2039resetPinnedStateForAllUserExtensions(pinned: boolean): Promise<void> { throw new Error('Method not implemented.'); }2040getInstallableServers(extension: IGalleryExtension): Promise<IExtensionManagementServer[]> { throw new Error('Method not implemented.'); }2041isPublisherTrusted(extension: IGalleryExtension): boolean { return false; }2042getTrustedPublishers() { return []; }2043trustPublishers(): void { }2044untrustPublishers(): void { }2045async requestPublisherTrust(extensions: InstallExtensionInfo[]): Promise<void> { }2046}2047204820492050export class TestWebExtensionsScannerService implements IWebExtensionsScannerService {2051_serviceBrand: undefined;2052onDidChangeProfile = Event.None;2053async scanSystemExtensions(): Promise<IExtension[]> { return []; }2054async scanUserExtensions(): Promise<IScannedExtension[]> { return []; }2055async scanExtensionsUnderDevelopment(): Promise<IExtension[]> { return []; }2056async copyExtensions(): Promise<void> {2057throw new Error('Method not implemented.');2058}2059scanExistingExtension(extensionLocation: URI, extensionType: ExtensionType): Promise<IScannedExtension | null> {2060throw new Error('Method not implemented.');2061}2062addExtension(location: URI, metadata?: Partial<IGalleryMetadata & { isApplicationScoped: boolean; isMachineScoped: boolean; isBuiltin: boolean; isSystem: boolean; updated: boolean; preRelease: boolean; installedTimestamp: number }> | undefined): Promise<IExtension> {2063throw new Error('Method not implemented.');2064}2065addExtensionFromGallery(galleryExtension: IGalleryExtension, metadata?: Partial<IGalleryMetadata & { isApplicationScoped: boolean; isMachineScoped: boolean; isBuiltin: boolean; isSystem: boolean; updated: boolean; preRelease: boolean; installedTimestamp: number }> | undefined): Promise<IExtension> {2066throw new Error('Method not implemented.');2067}2068removeExtension(): Promise<void> {2069throw new Error('Method not implemented.');2070}2071updateMetadata(extension: IScannedExtension, metaData: Partial<Metadata>, profileLocation: URI): Promise<IScannedExtension> {2072throw new Error('Method not implemented.');2073}2074scanExtensionManifest(extensionLocation: URI): Promise<Readonly<IRelaxedExtensionManifest> | null> {2075throw new Error('Method not implemented.');2076}2077}20782079export async function workbenchTeardown(instantiationService: IInstantiationService): Promise<void> {2080return instantiationService.invokeFunction(async accessor => {2081const workingCopyService = accessor.get(IWorkingCopyService);2082const editorGroupService = accessor.get(IEditorGroupsService);20832084for (const workingCopy of workingCopyService.workingCopies) {2085await workingCopy.revert();2086}20872088for (const group of editorGroupService.groups) {2089await group.closeAllEditors();2090}20912092for (const group of editorGroupService.groups) {2093editorGroupService.removeGroup(group);2094}2095});2096}20972098export class TestContextMenuService implements IContextMenuService {20992100_serviceBrand: undefined;21012102readonly onDidShowContextMenu = Event.None;2103readonly onDidHideContextMenu = Event.None;21042105showContextMenu(delegate: IContextMenuDelegate | IContextMenuMenuDelegate): void {2106throw new Error('Method not implemented.');2107}2108}210921102111