Path: blob/main/src/vs/workbench/test/browser/workbenchTestServices.ts
5222 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 { IDefaultAccountService } from '../../../platform/defaultAccount/common/defaultAccount.js';60import { ContextMenuService } from '../../../platform/contextview/browser/contextMenuService.js';61import { IContextMenuMenuDelegate, IContextMenuService, IContextViewService } from '../../../platform/contextview/browser/contextView.js';62import { ContextViewService } from '../../../platform/contextview/browser/contextViewService.js';63import { IDiagnosticInfo, IDiagnosticInfoOptions } from '../../../platform/diagnostics/common/diagnostics.js';64import { ConfirmResult, IDialogService, IFileDialogService, IOpenDialogOptions, IPickAndOpenOptions, ISaveDialogOptions } from '../../../platform/dialogs/common/dialogs.js';65import { TestDialogService } from '../../../platform/dialogs/test/common/testDialogService.js';66import { IEditorOptions, IResourceEditorInput, IResourceEditorInputIdentifier, ITextEditorOptions, ITextResourceEditorInput } from '../../../platform/editor/common/editor.js';67import { IEnvironmentService } from '../../../platform/environment/common/environment.js';68import { IExtensionManagementParticipant, IExtensionsControlManifest, IGalleryExtension, IGalleryMetadata, ILocalExtension, InstallExtensionInfo, InstallExtensionResult, InstallExtensionSummary, InstallOptions, Metadata, UninstallExtensionInfo, UninstallOptions } from '../../../platform/extensionManagement/common/extensionManagement.js';69import { ExtensionType, IExtension, IExtensionDescription, IRelaxedExtensionManifest, TargetPlatform } from '../../../platform/extensions/common/extensions.js';70import { FileOperationError, FileSystemProviderCapabilities, FileType, IFileChange, IFileDeleteOptions, IFileOpenOptions, IFileOverwriteOptions, IFileReadStreamOptions, IFileService, IFileStatWithMetadata, IFileSystemProvider, IFileSystemProviderWithFileReadStreamCapability, IFileWriteOptions, IStat, IWatchOptions } from '../../../platform/files/common/files.js';71import { FileService } from '../../../platform/files/common/fileService.js';72import { InMemoryFileSystemProvider } from '../../../platform/files/common/inMemoryFilesystemProvider.js';73import { IHoverService } from '../../../platform/hover/browser/hover.js';74import { NullHoverService } from '../../../platform/hover/test/browser/nullHoverService.js';75import { SyncDescriptor } from '../../../platform/instantiation/common/descriptors.js';76import { IInstantiationService, ServiceIdentifier } from '../../../platform/instantiation/common/instantiation.js';77import { ServiceCollection } from '../../../platform/instantiation/common/serviceCollection.js';78import { TestInstantiationService } from '../../../platform/instantiation/test/common/instantiationServiceMock.js';79import { IKeybindingService } from '../../../platform/keybinding/common/keybinding.js';80import { MockContextKeyService, MockKeybindingService } from '../../../platform/keybinding/test/common/mockKeybindingService.js';81import { ILabelService } from '../../../platform/label/common/label.js';82import { ILayoutOffsetInfo } from '../../../platform/layout/browser/layoutService.js';83import { IListService } from '../../../platform/list/browser/listService.js';84import { ILoggerService, ILogService, NullLogService } from '../../../platform/log/common/log.js';85import { IMarkdownRendererService, MarkdownRendererService } from '../../../platform/markdown/browser/markdownRenderer.js';86import { IMarkerService } from '../../../platform/markers/common/markers.js';87import { INotificationService } from '../../../platform/notification/common/notification.js';88import { TestNotificationService } from '../../../platform/notification/test/common/testNotificationService.js';89import product from '../../../platform/product/common/product.js';90import { IProductService } from '../../../platform/product/common/productService.js';91import { IProgress, IProgressCompositeOptions, IProgressDialogOptions, IProgressIndicator, IProgressNotificationOptions, IProgressOptions, IProgressService, IProgressStep, IProgressWindowOptions, Progress } from '../../../platform/progress/common/progress.js';92import { IInputBox, IInputOptions, IPickOptions, IQuickInputButton, IQuickInputService, IQuickNavigateConfiguration, IQuickPick, IQuickPickItem, IQuickTree, IQuickTreeItem, IQuickWidget, QuickPickInput } from '../../../platform/quickinput/common/quickInput.js';93import { Registry } from '../../../platform/registry/common/platform.js';94import { IRemoteAgentEnvironment } from '../../../platform/remote/common/remoteAgentEnvironment.js';95import { IRemoteExtensionsScannerService } from '../../../platform/remote/common/remoteExtensionsScanner.js';96import { IRemoteSocketFactoryService, RemoteSocketFactoryService } from '../../../platform/remote/common/remoteSocketFactoryService.js';97import { IStorageService, StorageScope, StorageTarget } from '../../../platform/storage/common/storage.js';98import { ITelemetryData, ITelemetryService, TelemetryLevel } from '../../../platform/telemetry/common/telemetry.js';99import { NullTelemetryService } from '../../../platform/telemetry/common/telemetryUtils.js';100import { IExtensionTerminalProfile, IShellLaunchConfig, ITerminalBackend, ITerminalLogService, ITerminalProfile, TerminalIcon, TerminalLocation, TerminalShellType } from '../../../platform/terminal/common/terminal.js';101import { TerminalLogService } from '../../../platform/terminal/common/terminalLogService.js';102import { ColorScheme } from '../../../platform/theme/common/theme.js';103import { IThemeService } from '../../../platform/theme/common/themeService.js';104import { TestThemeService } from '../../../platform/theme/test/common/testThemeService.js';105import { IUndoRedoService } from '../../../platform/undoRedo/common/undoRedo.js';106import { UndoRedoService } from '../../../platform/undoRedo/common/undoRedoService.js';107import { IUriIdentityService } from '../../../platform/uriIdentity/common/uriIdentity.js';108import { UriIdentityService } from '../../../platform/uriIdentity/common/uriIdentityService.js';109import { IUserDataProfile, IUserDataProfilesService, UserDataProfilesService } from '../../../platform/userDataProfile/common/userDataProfile.js';110import { IOpenEmptyWindowOptions, IOpenWindowOptions, IRectangle, IWindowOpenable, MenuBarVisibility } from '../../../platform/window/common/window.js';111import { IWorkspaceContextService, IWorkspaceIdentifier } from '../../../platform/workspace/common/workspace.js';112import { IWorkspaceTrustManagementService, IWorkspaceTrustRequestService } from '../../../platform/workspace/common/workspaceTrust.js';113import { TestWorkspace } from '../../../platform/workspace/test/common/testWorkspace.js';114import { IEnterWorkspaceResult, IRecent, IRecentlyOpened, IWorkspaceFolderCreationData, IWorkspacesService } from '../../../platform/workspaces/common/workspaces.js';115import { EditorPaneDescriptor, IEditorPaneRegistry } from '../../browser/editor.js';116import { PaneComposite, PaneCompositeDescriptor } from '../../browser/panecomposite.js';117import { Part } from '../../browser/part.js';118import { DEFAULT_EDITOR_PART_OPTIONS, EditorServiceImpl, IEditorGroupsView, IEditorGroupTitleHeight, IEditorGroupView } from '../../browser/parts/editor/editor.js';119import { EditorPane } from '../../browser/parts/editor/editorPane.js';120import { MainEditorPart } from '../../browser/parts/editor/editorPart.js';121import { EditorParts } from '../../browser/parts/editor/editorParts.js';122import { SideBySideEditor } from '../../browser/parts/editor/sideBySideEditor.js';123import { TextEditorPaneSelection } from '../../browser/parts/editor/textEditor.js';124import { TextResourceEditor } from '../../browser/parts/editor/textResourceEditor.js';125import { IPaneCompositePart } from '../../browser/parts/paneCompositePart.js';126import { 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';127import { IGroupModelChangeEvent } from '../../common/editor/editorGroupModel.js';128import { EditorInput } from '../../common/editor/editorInput.js';129import { SideBySideEditorInput } from '../../common/editor/sideBySideEditorInput.js';130import { TextResourceEditorInput } from '../../common/editor/textResourceEditorInput.js';131import { IPaneComposite } from '../../common/panecomposite.js';132import { IView, IViewDescriptor, ViewContainer, ViewContainerLocation } from '../../common/views.js';133import { IChatWidget, IChatWidgetService } from '../../contrib/chat/browser/chat.js';134import { IChatEditorOptions } from '../../contrib/chat/browser/widgetHosts/editor/chatEditor.js';135import { ChatAgentLocation } from '../../contrib/chat/common/constants.js';136import { FileEditorInput } from '../../contrib/files/browser/editors/fileEditorInput.js';137import { TextFileEditor } from '../../contrib/files/browser/editors/textFileEditor.js';138import { FILE_EDITOR_INPUT_ID } from '../../contrib/files/common/files.js';139import { ICreateTerminalOptions, IDeserializedTerminalEditorInput, ITerminalConfigurationService, ITerminalEditorService, ITerminalGroup, ITerminalGroupService, ITerminalInstance, ITerminalInstanceService, TerminalEditorLocation } from '../../contrib/terminal/browser/terminal.js';140import { TerminalConfigurationService } from '../../contrib/terminal/browser/terminalConfigurationService.js';141import { TerminalEditorInput } from '../../contrib/terminal/browser/terminalEditorInput.js';142import { IEnvironmentVariableService } from '../../contrib/terminal/common/environmentVariable.js';143import { EnvironmentVariableService } from '../../contrib/terminal/common/environmentVariableService.js';144import { IRegisterContributedProfileArgs, IShellLaunchConfigResolveOptions, ITerminalProfileProvider, ITerminalProfileResolverService, ITerminalProfileService, type ITerminalConfiguration } from '../../contrib/terminal/common/terminal.js';145import { IChatEntitlementService } from '../../services/chat/common/chatEntitlementService.js';146import { IDecoration, IDecorationData, IDecorationsProvider, IDecorationsService, IResourceDecorationChangeEvent } from '../../services/decorations/common/decorations.js';147import { CodeEditorService } from '../../services/editor/browser/codeEditorService.js';148import { EditorPaneService } from '../../services/editor/browser/editorPaneService.js';149import { EditorResolverService } from '../../services/editor/browser/editorResolverService.js';150import { CustomEditorLabelService, ICustomEditorLabelService } from '../../services/editor/common/customEditorLabelService.js';151import { EditorGroupLayout, GroupDirection, GroupOrientation, GroupsArrangement, GroupsOrder, IAuxiliaryEditorPart, ICloseAllEditorsOptions, ICloseEditorOptions, ICloseEditorsFilter, IEditorDropTargetDelegate, IEditorGroup, IEditorGroupContextKeyProvider, IEditorGroupsContainer, IEditorGroupsService, IEditorPart, IEditorReplacement, IEditorWorkingSet, IEditorWorkingSetOptions, IFindGroupScope, IMergeGroupOptions, IModalEditorPart } from '../../services/editor/common/editorGroupsService.js';152import { IEditorPaneService } from '../../services/editor/common/editorPaneService.js';153import { IEditorResolverService } from '../../services/editor/common/editorResolverService.js';154import { IEditorsChangeEvent, IEditorService, IRevertAllEditorsOptions, ISaveEditorsOptions, ISaveEditorsResult, PreferredGroup } from '../../services/editor/common/editorService.js';155import { BrowserWorkbenchEnvironmentService } from '../../services/environment/browser/environmentService.js';156import { IWorkbenchEnvironmentService } from '../../services/environment/common/environmentService.js';157import { EnablementState, IExtensionManagementServer, IResourceExtension, IScannedExtension, IWebExtensionsScannerService, IWorkbenchExtensionEnablementService, IWorkbenchExtensionManagementService } from '../../services/extensionManagement/common/extensionManagement.js';158import { IExtensionService } from '../../services/extensions/common/extensions.js';159import { BrowserElevatedFileService } from '../../services/files/browser/elevatedFileService.js';160import { IElevatedFileService } from '../../services/files/common/elevatedFileService.js';161import { FilesConfigurationService, IFilesConfigurationService } from '../../services/filesConfiguration/common/filesConfigurationService.js';162import { IHistoryService } from '../../services/history/common/history.js';163import { IHostService, IToastOptions, IToastResult } from '../../services/host/browser/host.js';164import { LabelService } from '../../services/label/common/labelService.js';165import { ILanguageDetectionService } from '../../services/languageDetection/common/languageDetectionWorkerService.js';166import { IPartVisibilityChangeEvent, IWorkbenchLayoutService, PanelAlignment, Position as PartPosition, Parts } from '../../services/layout/browser/layoutService.js';167import { ILifecycleService, InternalBeforeShutdownEvent, IWillShutdownEventJoiner, ShutdownReason, WillShutdownEvent } from '../../services/lifecycle/common/lifecycle.js';168import { IPaneCompositePartService } from '../../services/panecomposite/browser/panecomposite.js';169import { IPathService } from '../../services/path/common/pathService.js';170import { QuickInputService } from '../../services/quickinput/browser/quickInputService.js';171import { IExtensionHostExitInfo, IRemoteAgentConnection, IRemoteAgentService } from '../../services/remote/common/remoteAgentService.js';172import { BrowserTextFileService } from '../../services/textfile/browser/browserTextFileService.js';173import { EncodingOracle, IEncodingOverride } from '../../services/textfile/browser/textFileService.js';174import { UTF16be, UTF16le, UTF8_with_bom } from '../../services/textfile/common/encoding.js';175import { ITextEditorService, TextEditorService } from '../../services/textfile/common/textEditorService.js';176import { TextFileEditorModel } from '../../services/textfile/common/textFileEditorModel.js';177import { IReadTextFileOptions, ITextFileEditorModel, ITextFileEditorModelManager, ITextFileService, ITextFileStreamContent, IWriteTextFileOptions } from '../../services/textfile/common/textfiles.js';178import { TextModelResolverService } from '../../services/textmodelResolver/common/textModelResolverService.js';179import { UntitledTextEditorInput } from '../../services/untitled/common/untitledTextEditorInput.js';180import { IUntitledTextEditorModelManager, IUntitledTextEditorService, UntitledTextEditorService } from '../../services/untitled/common/untitledTextEditorService.js';181import { IUserDataProfileService } from '../../services/userDataProfile/common/userDataProfile.js';182import { UserDataProfileService } from '../../services/userDataProfile/common/userDataProfileService.js';183import { IViewsService } from '../../services/views/common/viewsService.js';184import { BrowserWorkingCopyBackupService } from '../../services/workingCopy/browser/workingCopyBackupService.js';185import { IWorkingCopy, IWorkingCopyBackupMeta, IWorkingCopyIdentifier } from '../../services/workingCopy/common/workingCopy.js';186import { IResolvedWorkingCopyBackup, IWorkingCopyBackupService } from '../../services/workingCopy/common/workingCopyBackup.js';187import { InMemoryWorkingCopyBackupService } from '../../services/workingCopy/common/workingCopyBackupService.js';188import { IWorkingCopyEditorService, WorkingCopyEditorService } from '../../services/workingCopy/common/workingCopyEditorService.js';189import { IWorkingCopyFileService, WorkingCopyFileService } from '../../services/workingCopy/common/workingCopyFileService.js';190import { IWorkingCopyService, WorkingCopyService } from '../../services/workingCopy/common/workingCopyService.js';191import { TestChatEntitlementService, TestContextService, TestExtensionService, TestFileService, TestHistoryService, TestLifecycleService, TestLoggerService, TestMarkerService, TestProductService, TestStorageService, TestTextResourcePropertiesService, TestWorkspaceTrustManagementService, TestWorkspaceTrustRequestService } from '../common/workbenchTestServices.js';192import { DefaultAccountService } from '../../services/accounts/browser/defaultAccount.js';193194// Backcompat export195export { TestFileService, TestLifecycleService };196197export function createFileEditorInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {198return instantiationService.createInstance(FileEditorInput, resource, undefined, undefined, undefined, undefined, undefined, undefined);199}200201Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerFileEditorFactory({202203typeId: FILE_EDITOR_INPUT_ID,204205createFileEditor: (resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents, instantiationService): IFileEditorInput => {206return instantiationService.createInstance(FileEditorInput, resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents);207},208209isFileEditor: (obj): obj is IFileEditorInput => {210return obj instanceof FileEditorInput;211}212});213214export class TestTextResourceEditor extends TextResourceEditor {215216protected override createEditorControl(parent: HTMLElement, configuration: any): void {217this.editorControl = this._register(this.instantiationService.createInstance(TestCodeEditor, parent, configuration, {}));218}219}220221export class TestTextFileEditor extends TextFileEditor {222223protected override createEditorControl(parent: HTMLElement, configuration: any): void {224this.editorControl = this._register(this.instantiationService.createInstance(TestCodeEditor, parent, configuration, { contributions: [] }));225}226227setSelection(selection: Selection | undefined, reason: EditorPaneSelectionChangeReason): void {228this._options = selection ? upcast<IEditorOptions, ITextEditorOptions>({ selection }) : undefined;229230this._onDidChangeSelection.fire({ reason });231}232233override getSelection(): IEditorPaneSelection | undefined {234const options = this.options;235if (!options) {236return undefined;237}238239const textSelection = (options as ITextEditorOptions).selection;240if (!textSelection) {241return undefined;242}243244return new TextEditorPaneSelection(new Selection(textSelection.startLineNumber, textSelection.startColumn, textSelection.endLineNumber ?? textSelection.startLineNumber, textSelection.endColumn ?? textSelection.startColumn));245}246}247248export interface ITestInstantiationService extends IInstantiationService {249stub<T>(service: ServiceIdentifier<T>, ctor: any): T;250}251252export class TestWorkingCopyService extends WorkingCopyService {253testUnregisterWorkingCopy(workingCopy: IWorkingCopy): void {254return super.unregisterWorkingCopy(workingCopy);255}256}257258export function workbenchInstantiationService(259overrides?: {260environmentService?: (instantiationService: IInstantiationService) => IEnvironmentService;261fileService?: (instantiationService: IInstantiationService) => IFileService;262workingCopyBackupService?: (instantiationService: IInstantiationService) => IWorkingCopyBackupService;263configurationService?: (instantiationService: IInstantiationService) => TestConfigurationService;264textFileService?: (instantiationService: IInstantiationService) => ITextFileService;265pathService?: (instantiationService: IInstantiationService) => IPathService;266editorService?: (instantiationService: IInstantiationService) => IEditorService;267contextKeyService?: (instantiationService: IInstantiationService) => IContextKeyService;268textEditorService?: (instantiationService: IInstantiationService) => ITextEditorService;269},270disposables: Pick<DisposableStore, 'add'> = new DisposableStore()271): TestInstantiationService {272const instantiationService = disposables.add(new TestInstantiationService(new ServiceCollection(273[ILifecycleService, disposables.add(new TestLifecycleService())],274[IActionViewItemService, new SyncDescriptor(NullActionViewItemService)],275)));276277instantiationService.stub(IProductService, TestProductService);278instantiationService.stub(IEditorWorkerService, new TestEditorWorkerService());279instantiationService.stub(IWorkingCopyService, disposables.add(new TestWorkingCopyService()));280const environmentService = overrides?.environmentService ? overrides.environmentService(instantiationService) : TestEnvironmentService;281instantiationService.stub(IEnvironmentService, environmentService);282instantiationService.stub(IWorkbenchEnvironmentService, environmentService);283instantiationService.stub(ILogService, new NullLogService());284const contextKeyService = overrides?.contextKeyService ? overrides.contextKeyService(instantiationService) : instantiationService.createInstance(MockContextKeyService);285instantiationService.stub(IContextKeyService, contextKeyService);286instantiationService.stub(IProgressService, new TestProgressService());287const workspaceContextService = new TestContextService(TestWorkspace);288instantiationService.stub(IWorkspaceContextService, workspaceContextService);289const configService = overrides?.configurationService ? overrides.configurationService(instantiationService) : new TestConfigurationService({290files: {291participants: {292timeout: 60000293}294}295});296instantiationService.stub(IConfigurationService, configService);297const textResourceConfigurationService = new TestTextResourceConfigurationService(configService);298instantiationService.stub(ITextResourceConfigurationService, textResourceConfigurationService);299instantiationService.stub(IUntitledTextEditorService, disposables.add(instantiationService.createInstance(UntitledTextEditorService)));300instantiationService.stub(IStorageService, disposables.add(new TestStorageService()));301instantiationService.stub(IRemoteAgentService, new TestRemoteAgentService());302instantiationService.stub(ILanguageDetectionService, new TestLanguageDetectionService());303instantiationService.stub(IPathService, overrides?.pathService ? overrides.pathService(instantiationService) : new TestPathService());304const layoutService = new TestLayoutService();305instantiationService.stub(IWorkbenchLayoutService, layoutService);306instantiationService.stub(IDialogService, new TestDialogService());307const accessibilityService = new TestAccessibilityService();308instantiationService.stub(IAccessibilityService, accessibilityService);309// eslint-disable-next-line local/code-no-any-casts310instantiationService.stub(IAccessibilitySignalService, {311playSignal: async () => { },312isSoundEnabled(signal: unknown) { return false; },313} as any);314instantiationService.stub(IFileDialogService, instantiationService.createInstance(TestFileDialogService));315instantiationService.stub(ILanguageService, disposables.add(instantiationService.createInstance(LanguageService)));316instantiationService.stub(ILanguageFeaturesService, new LanguageFeaturesService());317instantiationService.stub(ILanguageFeatureDebounceService, instantiationService.createInstance(LanguageFeatureDebounceService));318instantiationService.stub(IHistoryService, new TestHistoryService());319instantiationService.stub(ITextResourcePropertiesService, new TestTextResourcePropertiesService(configService));320instantiationService.stub(IUndoRedoService, instantiationService.createInstance(UndoRedoService));321const themeService = new TestThemeService();322instantiationService.stub(IThemeService, themeService);323instantiationService.stub(ILanguageConfigurationService, disposables.add(new TestLanguageConfigurationService()));324instantiationService.stub(ITreeSitterLibraryService, new TestTreeSitterLibraryService());325instantiationService.stub(IModelService, disposables.add(instantiationService.createInstance(ModelService)));326const fileService = overrides?.fileService ? overrides.fileService(instantiationService) : disposables.add(new TestFileService());327instantiationService.stub(IFileService, fileService);328instantiationService.stub(IUriIdentityService, disposables.add(new UriIdentityService(fileService)));329const markerService = new TestMarkerService();330instantiationService.stub(IMarkerService, markerService);331instantiationService.stub(IFilesConfigurationService, disposables.add(instantiationService.createInstance(TestFilesConfigurationService)));332const userDataProfilesService = instantiationService.stub(IUserDataProfilesService, disposables.add(instantiationService.createInstance(UserDataProfilesService)));333instantiationService.stub(IUserDataProfileService, disposables.add(new UserDataProfileService(userDataProfilesService.defaultProfile)));334instantiationService.stub(IWorkingCopyBackupService, overrides?.workingCopyBackupService ? overrides?.workingCopyBackupService(instantiationService) : disposables.add(new TestWorkingCopyBackupService()));335instantiationService.stub(ITelemetryService, NullTelemetryService);336instantiationService.stub(INotificationService, new TestNotificationService());337instantiationService.stub(IUntitledTextEditorService, disposables.add(instantiationService.createInstance(UntitledTextEditorService)));338instantiationService.stub(IMenuService, new TestMenuService());339const keybindingService = new MockKeybindingService();340instantiationService.stub(IKeybindingService, keybindingService);341instantiationService.stub(IDecorationsService, new TestDecorationsService());342instantiationService.stub(IExtensionService, new TestExtensionService());343instantiationService.stub(IWorkingCopyFileService, disposables.add(instantiationService.createInstance(WorkingCopyFileService)));344instantiationService.stub(ITextFileService, overrides?.textFileService ? overrides.textFileService(instantiationService) : disposables.add(<ITextFileService>instantiationService.createInstance(TestTextFileService)));345instantiationService.stub(IHostService, <IHostService>instantiationService.createInstance(TestHostService));346instantiationService.stub(ITextModelService, <ITextModelService>disposables.add(instantiationService.createInstance(TextModelResolverService)));347instantiationService.stub(ILoggerService, disposables.add(new TestLoggerService(TestEnvironmentService.logsHome)));348const editorGroupService = new TestEditorGroupsService([new TestEditorGroupView(0)]);349instantiationService.stub(IEditorGroupsService, editorGroupService);350instantiationService.stub(ILabelService, <ILabelService>disposables.add(instantiationService.createInstance(LabelService)));351const editorService = overrides?.editorService ? overrides.editorService(instantiationService) : disposables.add(new TestEditorService(editorGroupService));352instantiationService.stub(IEditorService, editorService);353instantiationService.stub(IEditorPaneService, new EditorPaneService());354instantiationService.stub(IWorkingCopyEditorService, disposables.add(instantiationService.createInstance(WorkingCopyEditorService)));355instantiationService.stub(IEditorResolverService, disposables.add(instantiationService.createInstance(EditorResolverService)));356const textEditorService = overrides?.textEditorService ? overrides.textEditorService(instantiationService) : disposables.add(instantiationService.createInstance(TextEditorService));357instantiationService.stub(ITextEditorService, textEditorService);358instantiationService.stub(ICodeEditorService, disposables.add(new CodeEditorService(editorService, themeService, configService)));359instantiationService.stub(IPaneCompositePartService, disposables.add(new TestPaneCompositeService()));360instantiationService.stub(IListService, new TestListService());361instantiationService.stub(IContextViewService, disposables.add(instantiationService.createInstance(ContextViewService)));362instantiationService.stub(IContextMenuService, disposables.add(instantiationService.createInstance(ContextMenuService)));363instantiationService.stub(IQuickInputService, disposables.add(new QuickInputService(configService, instantiationService, keybindingService, contextKeyService, themeService, layoutService)));364instantiationService.stub(IWorkspacesService, new TestWorkspacesService());365instantiationService.stub(IWorkspaceTrustManagementService, disposables.add(new TestWorkspaceTrustManagementService()));366instantiationService.stub(IWorkspaceTrustRequestService, disposables.add(new TestWorkspaceTrustRequestService(false)));367instantiationService.stub(ITerminalInstanceService, new TestTerminalInstanceService());368instantiationService.stub(ITerminalEditorService, new TestTerminalEditorService());369instantiationService.stub(ITerminalGroupService, new TestTerminalGroupService());370instantiationService.stub(ITerminalProfileService, new TestTerminalProfileService());371instantiationService.stub(ITerminalProfileResolverService, new TestTerminalProfileResolverService());372instantiationService.stub(ITerminalConfigurationService, disposables.add(instantiationService.createInstance(TestTerminalConfigurationService)));373instantiationService.stub(ITerminalLogService, disposables.add(instantiationService.createInstance(TerminalLogService)));374instantiationService.stub(IEnvironmentVariableService, disposables.add(instantiationService.createInstance(EnvironmentVariableService)));375instantiationService.stub(IElevatedFileService, new BrowserElevatedFileService());376instantiationService.stub(IRemoteSocketFactoryService, new RemoteSocketFactoryService());377instantiationService.stub(ICustomEditorLabelService, disposables.add(new CustomEditorLabelService(configService, workspaceContextService)));378instantiationService.stub(IHoverService, NullHoverService);379instantiationService.stub(IChatEntitlementService, new TestChatEntitlementService());380instantiationService.stub(IMarkdownRendererService, instantiationService.createInstance(MarkdownRendererService));381instantiationService.stub(IChatWidgetService, instantiationService.createInstance(TestChatWidgetService));382instantiationService.stub(IDefaultAccountService, DefaultAccountService);383384return instantiationService;385}386387export class TestServiceAccessor {388constructor(389@ILifecycleService public lifecycleService: TestLifecycleService,390@ITextFileService public textFileService: TestTextFileService,391@ITextEditorService public textEditorService: ITextEditorService,392@IWorkingCopyFileService public workingCopyFileService: IWorkingCopyFileService,393@IFilesConfigurationService public filesConfigurationService: TestFilesConfigurationService,394@IWorkspaceContextService public contextService: TestContextService,395@IModelService public modelService: ModelService,396@IFileService public fileService: TestFileService,397@IFileDialogService public fileDialogService: TestFileDialogService,398@IDialogService public dialogService: TestDialogService,399@IWorkingCopyService public workingCopyService: TestWorkingCopyService,400@IEditorService public editorService: TestEditorService,401@IEditorPaneService public editorPaneService: IEditorPaneService,402@IWorkbenchEnvironmentService public environmentService: IWorkbenchEnvironmentService,403@IPathService public pathService: IPathService,404@IEditorGroupsService public editorGroupService: IEditorGroupsService,405@IEditorResolverService public editorResolverService: IEditorResolverService,406@ILanguageService public languageService: ILanguageService,407@ITextModelService public textModelResolverService: ITextModelService,408@IUntitledTextEditorService public untitledTextEditorService: UntitledTextEditorService,409@IConfigurationService public testConfigurationService: TestConfigurationService,410@IWorkingCopyBackupService public workingCopyBackupService: TestWorkingCopyBackupService,411@IHostService public hostService: TestHostService,412@IQuickInputService public quickInputService: IQuickInputService,413@ILabelService public labelService: ILabelService,414@ILogService public logService: ILogService,415@IUriIdentityService public uriIdentityService: IUriIdentityService,416@IInstantiationService public instantitionService: IInstantiationService,417@INotificationService public notificationService: INotificationService,418@IWorkingCopyEditorService public workingCopyEditorService: IWorkingCopyEditorService,419@IInstantiationService public instantiationService: IInstantiationService,420@IElevatedFileService public elevatedFileService: IElevatedFileService,421@IWorkspaceTrustRequestService public workspaceTrustRequestService: TestWorkspaceTrustRequestService,422@IDecorationsService public decorationsService: IDecorationsService,423@IProgressService public progressService: IProgressService,424) { }425}426427export class TestTextFileService extends BrowserTextFileService {428private readStreamError: FileOperationError | undefined = undefined;429private writeError: FileOperationError | undefined = undefined;430431constructor(432@IFileService fileService: IFileService,433@IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorModelManager,434@ILifecycleService lifecycleService: ILifecycleService,435@IInstantiationService instantiationService: IInstantiationService,436@IModelService modelService: IModelService,437@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,438@IDialogService dialogService: IDialogService,439@IFileDialogService fileDialogService: IFileDialogService,440@ITextResourceConfigurationService textResourceConfigurationService: ITextResourceConfigurationService,441@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService,442@ICodeEditorService codeEditorService: ICodeEditorService,443@IPathService pathService: IPathService,444@IWorkingCopyFileService workingCopyFileService: IWorkingCopyFileService,445@IUriIdentityService uriIdentityService: IUriIdentityService,446@ILanguageService languageService: ILanguageService,447@ILogService logService: ILogService,448@IElevatedFileService elevatedFileService: IElevatedFileService,449@IDecorationsService decorationsService: IDecorationsService450) {451super(452fileService,453untitledTextEditorService,454lifecycleService,455instantiationService,456modelService,457environmentService,458dialogService,459fileDialogService,460textResourceConfigurationService,461filesConfigurationService,462codeEditorService,463pathService,464workingCopyFileService,465uriIdentityService,466languageService,467elevatedFileService,468logService,469decorationsService470);471}472473setReadStreamErrorOnce(error: FileOperationError): void {474this.readStreamError = error;475}476477override async readStream(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileStreamContent> {478if (this.readStreamError) {479const error = this.readStreamError;480this.readStreamError = undefined;481482throw error;483}484485const content = await this.fileService.readFileStream(resource, options);486return {487resource: content.resource,488name: content.name,489mtime: content.mtime,490ctime: content.ctime,491etag: content.etag,492encoding: 'utf8',493value: await createTextBufferFactoryFromStream(content.value),494size: 10,495readonly: false,496locked: false,497executable: false498};499}500501setWriteErrorOnce(error: FileOperationError): void {502this.writeError = error;503}504505override async write(resource: URI, value: string | ITextSnapshot, options?: IWriteTextFileOptions): Promise<IFileStatWithMetadata> {506if (this.writeError) {507const error = this.writeError;508this.writeError = undefined;509510throw error;511}512513return super.write(resource, value, options);514}515}516517export class TestBrowserTextFileServiceWithEncodingOverrides extends BrowserTextFileService {518519private _testEncoding: TestEncodingOracle | undefined;520override get encoding(): TestEncodingOracle {521if (!this._testEncoding) {522this._testEncoding = this._register(this.instantiationService.createInstance(TestEncodingOracle));523}524525return this._testEncoding;526}527}528529export class TestEncodingOracle extends EncodingOracle {530531protected override get encodingOverrides(): IEncodingOverride[] {532return [533{ extension: 'utf16le', encoding: UTF16le },534{ extension: 'utf16be', encoding: UTF16be },535{ extension: 'utf8bom', encoding: UTF8_with_bom }536];537}538539protected override set encodingOverrides(overrides: IEncodingOverride[]) { }540}541542class TestEnvironmentServiceWithArgs extends BrowserWorkbenchEnvironmentService {543args = [];544}545546export const TestEnvironmentService = new TestEnvironmentServiceWithArgs('', URI.file('tests').with({ scheme: 'vscode-tests' }), Object.create(null), TestProductService);547548export class TestProgressService implements IProgressService {549550declare readonly _serviceBrand: undefined;551552withProgress(553options: IProgressOptions | IProgressDialogOptions | IProgressWindowOptions | IProgressNotificationOptions | IProgressCompositeOptions,554task: (progress: IProgress<IProgressStep>) => Promise<any>,555onDidCancel?: ((choice?: number | undefined) => void) | undefined556): Promise<any> {557return task(Progress.None);558}559}560561export class TestDecorationsService implements IDecorationsService {562563declare readonly _serviceBrand: undefined;564565readonly onDidChangeDecorations: Event<IResourceDecorationChangeEvent> = Event.None;566567registerDecorationsProvider(_provider: IDecorationsProvider): IDisposable { return Disposable.None; }568getDecoration(_uri: URI, _includeChildren: boolean, _overwrite?: IDecorationData): IDecoration | undefined { return undefined; }569}570571export class TestMenuService implements IMenuService {572573declare readonly _serviceBrand: undefined;574575createMenu(_id: MenuId, _scopedKeybindingService: IContextKeyService): IMenu {576return {577onDidChange: Event.None,578dispose: () => undefined,579getActions: () => []580};581}582583getMenuActions(id: MenuId, contextKeyService: IContextKeyService, options?: IMenuActionOptions): [string, Array<MenuItemAction | SubmenuItemAction>][] {584throw new Error('Method not implemented.');585}586587getMenuContexts(id: MenuId): ReadonlySet<string> {588throw new Error('Method not implemented.');589}590591resetHiddenStates(): void {592// nothing593}594}595596export class TestFileDialogService implements IFileDialogService {597598declare readonly _serviceBrand: undefined;599600private confirmResult!: ConfirmResult;601602constructor(603@IPathService private readonly pathService: IPathService604) { }605async defaultFilePath(_schemeFilter?: string): Promise<URI> { return this.pathService.userHome(); }606async defaultFolderPath(_schemeFilter?: string): Promise<URI> { return this.pathService.userHome(); }607async defaultWorkspacePath(_schemeFilter?: string): Promise<URI> { return this.pathService.userHome(); }608async preferredHome(_schemeFilter?: string): Promise<URI> { return this.pathService.userHome(); }609pickFileFolderAndOpen(_options: IPickAndOpenOptions): Promise<any> { return Promise.resolve(0); }610pickFileAndOpen(_options: IPickAndOpenOptions): Promise<any> { return Promise.resolve(0); }611pickFolderAndOpen(_options: IPickAndOpenOptions): Promise<any> { return Promise.resolve(0); }612pickWorkspaceAndOpen(_options: IPickAndOpenOptions): Promise<any> { return Promise.resolve(0); }613614private fileToSave!: URI;615setPickFileToSave(path: URI): void { this.fileToSave = path; }616pickFileToSave(defaultUri: URI, availableFileSystems?: string[]): Promise<URI | undefined> { return Promise.resolve(this.fileToSave); }617618showSaveDialog(_options: ISaveDialogOptions): Promise<URI | undefined> { return Promise.resolve(undefined); }619showOpenDialog(_options: IOpenDialogOptions): Promise<URI[] | undefined> { return Promise.resolve(undefined); }620621setConfirmResult(result: ConfirmResult): void { this.confirmResult = result; }622showSaveConfirm(fileNamesOrResources: (string | URI)[]): Promise<ConfirmResult> { return Promise.resolve(this.confirmResult); }623}624625export class TestLayoutService implements IWorkbenchLayoutService {626627declare readonly _serviceBrand: undefined;628629openedDefaultEditors = false;630631mainContainerDimension: IDimension = { width: 800, height: 600 };632activeContainerDimension: IDimension = { width: 800, height: 600 };633mainContainerOffset: ILayoutOffsetInfo = { top: 0, quickPickTop: 0 };634activeContainerOffset: ILayoutOffsetInfo = { top: 0, quickPickTop: 0 };635636mainContainer: HTMLElement = mainWindow.document.body;637containers = [mainWindow.document.body];638activeContainer: HTMLElement = mainWindow.document.body;639640readonly onDidChangeZenMode: Event<boolean> = Event.None;641readonly onDidChangeMainEditorCenteredLayout: Event<boolean> = Event.None;642readonly onDidChangeWindowMaximized: Event<{ windowId: number; maximized: boolean }> = Event.None;643readonly onDidChangePanelPosition: Event<string> = Event.None;644readonly onDidChangePanelAlignment: Event<PanelAlignment> = Event.None;645readonly onDidChangePartVisibility: Event<IPartVisibilityChangeEvent> = Event.None;646onDidLayoutMainContainer = Event.None;647onDidLayoutActiveContainer = Event.None;648onDidLayoutContainer = Event.None;649onDidChangeNotificationsVisibility = Event.None;650onDidAddContainer = Event.None;651onDidChangeActiveContainer = Event.None;652onDidChangeAuxiliaryBarMaximized = Event.None;653654layout(): void { }655isRestored(): boolean { return true; }656whenReady: Promise<void> = Promise.resolve(undefined);657whenRestored: Promise<void> = Promise.resolve(undefined);658hasFocus(_part: Parts): boolean { return false; }659focusPart(_part: Parts): void { }660hasMainWindowBorder(): boolean { return false; }661getMainWindowBorderRadius(): string | undefined { return undefined; }662isVisible(_part: Parts): boolean { return true; }663getContainer(): HTMLElement { return mainWindow.document.body; }664whenContainerStylesLoaded() { return undefined; }665isTitleBarHidden(): boolean { return false; }666isStatusBarHidden(): boolean { return false; }667isActivityBarHidden(): boolean { return false; }668setActivityBarHidden(_hidden: boolean): void { }669setBannerHidden(_hidden: boolean): void { }670isSideBarHidden(): boolean { return false; }671async setEditorHidden(_hidden: boolean): Promise<void> { }672async setSideBarHidden(_hidden: boolean): Promise<void> { }673async setAuxiliaryBarHidden(_hidden: boolean): Promise<void> { }674async setPartHidden(_hidden: boolean, part: Parts): Promise<void> { }675isPanelHidden(): boolean { return false; }676async setPanelHidden(_hidden: boolean): Promise<void> { }677toggleMaximizedPanel(): void { }678isPanelMaximized(): boolean { return false; }679toggleMaximizedAuxiliaryBar(): void { }680setAuxiliaryBarMaximized(maximized: boolean): boolean { return false; }681isAuxiliaryBarMaximized(): boolean { return false; }682getMenubarVisibility(): MenuBarVisibility { throw new Error('not implemented'); }683toggleMenuBar(): void { }684getSideBarPosition() { return 0; }685getPanelPosition() { return 0; }686getPanelAlignment(): PanelAlignment { return 'center'; }687async setPanelPosition(_position: PartPosition): Promise<void> { }688async setPanelAlignment(_alignment: PanelAlignment): Promise<void> { }689addClass(_clazz: string): void { }690removeClass(_clazz: string): void { }691getMaximumEditorDimensions(): IDimension { throw new Error('not implemented'); }692toggleZenMode(): void { }693isMainEditorLayoutCentered(): boolean { return false; }694centerMainEditorLayout(_active: boolean): void { }695resizePart(_part: Parts, _sizeChangeWidth: number, _sizeChangeHeight: number): void { }696getSize(part: Parts): IViewSize { throw new Error('Method not implemented.'); }697setSize(part: Parts, size: IViewSize): void { throw new Error('Method not implemented.'); }698registerPart(part: Part): IDisposable { return Disposable.None; }699isWindowMaximized(targetWindow: Window) { return false; }700updateWindowMaximizedState(targetWindow: Window, maximized: boolean): void { }701getVisibleNeighborPart(part: Parts, direction: Direction): Parts | undefined { return undefined; }702focus() { }703}704705// eslint-disable-next-line local/code-no-any-casts706const activeViewlet: PaneComposite = {} as any;707708export class TestPaneCompositeService extends Disposable implements IPaneCompositePartService {709declare readonly _serviceBrand: undefined;710711readonly onDidPaneCompositeOpen: Event<{ composite: IPaneComposite; viewContainerLocation: ViewContainerLocation }>;712readonly onDidPaneCompositeClose: Event<{ composite: IPaneComposite; viewContainerLocation: ViewContainerLocation }>;713714private parts = new Map<ViewContainerLocation, IPaneCompositePart>();715716constructor() {717super();718719this.parts.set(ViewContainerLocation.Panel, new TestPanelPart());720this.parts.set(ViewContainerLocation.Sidebar, new TestSideBarPart());721722this.onDidPaneCompositeOpen = Event.any(...([ViewContainerLocation.Panel, ViewContainerLocation.Sidebar].map(loc => Event.map(this.parts.get(loc)!.onDidPaneCompositeOpen, composite => { return { composite, viewContainerLocation: loc }; }))));723this.onDidPaneCompositeClose = Event.any(...([ViewContainerLocation.Panel, ViewContainerLocation.Sidebar].map(loc => Event.map(this.parts.get(loc)!.onDidPaneCompositeClose, composite => { return { composite, viewContainerLocation: loc }; }))));724}725726openPaneComposite(id: string | undefined, viewContainerLocation: ViewContainerLocation, focus?: boolean): Promise<IPaneComposite | undefined> {727return this.getPartByLocation(viewContainerLocation).openPaneComposite(id, focus);728}729getActivePaneComposite(viewContainerLocation: ViewContainerLocation): IPaneComposite | undefined {730return this.getPartByLocation(viewContainerLocation).getActivePaneComposite();731}732getPaneComposite(id: string, viewContainerLocation: ViewContainerLocation): PaneCompositeDescriptor | undefined {733return this.getPartByLocation(viewContainerLocation).getPaneComposite(id);734}735getPaneComposites(viewContainerLocation: ViewContainerLocation): PaneCompositeDescriptor[] {736return this.getPartByLocation(viewContainerLocation).getPaneComposites();737}738getProgressIndicator(id: string, viewContainerLocation: ViewContainerLocation): IProgressIndicator | undefined {739return this.getPartByLocation(viewContainerLocation).getProgressIndicator(id);740}741hideActivePaneComposite(viewContainerLocation: ViewContainerLocation): void {742this.getPartByLocation(viewContainerLocation).hideActivePaneComposite();743}744getLastActivePaneCompositeId(viewContainerLocation: ViewContainerLocation): string {745return this.getPartByLocation(viewContainerLocation).getLastActivePaneCompositeId();746}747748getPinnedPaneCompositeIds(viewContainerLocation: ViewContainerLocation): string[] {749throw new Error('Method not implemented.');750}751752getVisiblePaneCompositeIds(viewContainerLocation: ViewContainerLocation): string[] {753throw new Error('Method not implemented.');754}755756getPaneCompositeIds(viewContainerLocation: ViewContainerLocation): string[] {757throw new Error('Method not implemented.');758}759760getPartByLocation(viewContainerLocation: ViewContainerLocation): IPaneCompositePart {761return assertReturnsDefined(this.parts.get(viewContainerLocation));762}763}764765export class TestSideBarPart implements IPaneCompositePart {766declare readonly _serviceBrand: undefined;767768onDidViewletRegisterEmitter = new Emitter<PaneCompositeDescriptor>();769onDidViewletDeregisterEmitter = new Emitter<PaneCompositeDescriptor>();770onDidViewletOpenEmitter = new Emitter<IPaneComposite>();771onDidViewletCloseEmitter = new Emitter<IPaneComposite>();772773readonly partId = Parts.SIDEBAR_PART;774element: HTMLElement = undefined!;775minimumWidth = 0;776maximumWidth = 0;777minimumHeight = 0;778maximumHeight = 0;779onDidChange = Event.None;780onDidPaneCompositeOpen = this.onDidViewletOpenEmitter.event;781onDidPaneCompositeClose = this.onDidViewletCloseEmitter.event;782783openPaneComposite(id: string, focus?: boolean): Promise<IPaneComposite | undefined> { return Promise.resolve(undefined); }784getPaneComposites(): PaneCompositeDescriptor[] { return []; }785getAllViewlets(): PaneCompositeDescriptor[] { return []; }786getActivePaneComposite(): IPaneComposite { return activeViewlet; }787getDefaultViewletId(): string { return 'workbench.view.explorer'; }788getPaneComposite(id: string): PaneCompositeDescriptor | undefined { return undefined; }789getProgressIndicator(id: string) { return undefined; }790hideActivePaneComposite(): void { }791getLastActivePaneCompositeId(): string { return undefined!; }792dispose() { }793getPinnedPaneCompositeIds() { return []; }794getVisiblePaneCompositeIds() { return []; }795getPaneCompositeIds() { return []; }796layout(width: number, height: number, top: number, left: number): void { }797}798799export class TestPanelPart implements IPaneCompositePart {800declare readonly _serviceBrand: undefined;801802element: HTMLElement = undefined!;803minimumWidth = 0;804maximumWidth = 0;805minimumHeight = 0;806maximumHeight = 0;807onDidChange = Event.None;808onDidPaneCompositeOpen = new Emitter<IPaneComposite>().event;809onDidPaneCompositeClose = new Emitter<IPaneComposite>().event;810readonly partId = Parts.AUXILIARYBAR_PART;811812async openPaneComposite(id?: string, focus?: boolean): Promise<undefined> { return undefined; }813getPaneComposite(id: string): any { return activeViewlet; }814getPaneComposites() { return []; }815getPinnedPaneCompositeIds() { return []; }816getVisiblePaneCompositeIds() { return []; }817getPaneCompositeIds() { return []; }818getActivePaneComposite(): IPaneComposite { return activeViewlet; }819setPanelEnablement(id: string, enabled: boolean): void { }820dispose() { }821getProgressIndicator(id: string) { return null!; }822hideActivePaneComposite(): void { }823getLastActivePaneCompositeId(): string { return undefined!; }824layout(width: number, height: number, top: number, left: number): void { }825}826827export class TestViewsService implements IViewsService {828declare readonly _serviceBrand: undefined;829830831onDidChangeViewContainerVisibility = new Emitter<{ id: string; visible: boolean; location: ViewContainerLocation }>().event;832isViewContainerVisible(id: string): boolean { return true; }833isViewContainerActive(id: string): boolean { return true; }834getVisibleViewContainer(): ViewContainer | null { return null; }835openViewContainer(id: string, focus?: boolean): Promise<IPaneComposite | null> { return Promise.resolve(null); }836closeViewContainer(id: string): void { }837838onDidChangeViewVisibilityEmitter = new Emitter<{ id: string; visible: boolean }>();839onDidChangeViewVisibility = this.onDidChangeViewVisibilityEmitter.event;840onDidChangeFocusedViewEmitter = new Emitter<void>();841onDidChangeFocusedView = this.onDidChangeFocusedViewEmitter.event;842isViewVisible(id: string): boolean { return true; }843getActiveViewWithId<T extends IView>(id: string): T | null { return null; }844getViewWithId<T extends IView>(id: string): T | null { return null; }845openView<T extends IView>(id: string, focus?: boolean | undefined): Promise<T | null> { return Promise.resolve(null); }846closeView(id: string): void { }847getViewProgressIndicator(id: string) { return null!; }848getActiveViewPaneContainerWithId(id: string) { return null; }849getFocusedViewName(): string { return ''; }850getFocusedView(): IViewDescriptor | null { return null; }851}852853export class TestEditorGroupsService implements IEditorGroupsService {854855declare readonly _serviceBrand: undefined;856857constructor(public groups: TestEditorGroupView[] = []) { }858859readonly parts: readonly IEditorPart[] = [this];860861windowId = mainWindow.vscodeWindowId;862863readonly onDidCreateAuxiliaryEditorPart: Event<IAuxiliaryEditorPart> = Event.None;864readonly onDidChangeActiveGroup: Event<IEditorGroup> = Event.None;865readonly onDidActivateGroup: Event<IEditorGroup> = Event.None;866readonly onDidAddGroup: Event<IEditorGroup> = Event.None;867readonly onDidRemoveGroup: Event<IEditorGroup> = Event.None;868readonly onDidMoveGroup: Event<IEditorGroup> = Event.None;869readonly onDidChangeGroupIndex: Event<IEditorGroup> = Event.None;870readonly onDidChangeGroupLabel: Event<IEditorGroup> = Event.None;871readonly onDidChangeGroupLocked: Event<IEditorGroup> = Event.None;872readonly onDidChangeGroupMaximized: Event<boolean> = Event.None;873readonly onDidLayout: Event<IDimension> = Event.None;874onDidChangeEditorPartOptions = Event.None;875onDidScroll = Event.None;876onWillDispose = Event.None;877878orientation = GroupOrientation.HORIZONTAL;879isReady = true;880whenReady: Promise<void> = Promise.resolve(undefined);881whenRestored: Promise<void> = Promise.resolve(undefined);882hasRestorableState = false;883884contentDimension = { width: 800, height: 600 };885886get activeGroup(): IEditorGroup { return this.groups[0]; }887get sideGroup(): IEditorGroup { return this.groups[0]; }888get count(): number { return this.groups.length; }889890getPart(group: number | IEditorGroup): IEditorPart { return this; }891saveWorkingSet(name: string): IEditorWorkingSet { throw new Error('Method not implemented.'); }892getWorkingSets(): IEditorWorkingSet[] { throw new Error('Method not implemented.'); }893applyWorkingSet(workingSet: IEditorWorkingSet | 'empty', options?: IEditorWorkingSetOptions): Promise<boolean> { throw new Error('Method not implemented.'); }894deleteWorkingSet(workingSet: IEditorWorkingSet): Promise<boolean> { throw new Error('Method not implemented.'); }895getGroups(_order?: GroupsOrder): readonly IEditorGroup[] { return this.groups; }896getGroup(identifier: number): IEditorGroup | undefined { return this.groups.find(group => group.id === identifier); }897getLabel(_identifier: number): string { return 'Group 1'; }898findGroup(_scope: IFindGroupScope, _source?: number | IEditorGroup, _wrap?: boolean): IEditorGroup { throw new Error('not implemented'); }899activateGroup(_group: number | IEditorGroup): IEditorGroup { throw new Error('not implemented'); }900restoreGroup(_group: number | IEditorGroup): IEditorGroup { throw new Error('not implemented'); }901getSize(_group: number | IEditorGroup): { width: number; height: number } { return { width: 100, height: 100 }; }902setSize(_group: number | IEditorGroup, _size: { width: number; height: number }): void { }903arrangeGroups(_arrangement: GroupsArrangement): void { }904toggleMaximizeGroup(): void { }905hasMaximizedGroup(): boolean { throw new Error('not implemented'); }906toggleExpandGroup(): void { }907applyLayout(_layout: EditorGroupLayout): void { }908getLayout(): EditorGroupLayout { throw new Error('not implemented'); }909setGroupOrientation(_orientation: GroupOrientation): void { }910addGroup(_location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup { throw new Error('not implemented'); }911removeGroup(_group: number | IEditorGroup): void { }912moveGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup { throw new Error('not implemented'); }913mergeGroup(_group: number | IEditorGroup, _target: number | IEditorGroup, _options?: IMergeGroupOptions): boolean { throw new Error('not implemented'); }914mergeAllGroups(_group: number | IEditorGroup, _options?: IMergeGroupOptions): boolean { throw new Error('not implemented'); }915copyGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup { throw new Error('not implemented'); }916centerLayout(active: boolean): void { }917isLayoutCentered(): boolean { return false; }918createEditorDropTarget(container: HTMLElement, delegate: IEditorDropTargetDelegate): IDisposable { return Disposable.None; }919registerContextKeyProvider<T extends ContextKeyValue>(_provider: IEditorGroupContextKeyProvider<T>): IDisposable { throw new Error('not implemented'); }920getScopedInstantiationService(part: IEditorPart): IInstantiationService { throw new Error('Method not implemented.'); }921922partOptions!: IEditorPartOptions;923enforcePartOptions(options: IEditorPartOptions): IDisposable { return Disposable.None; }924925readonly mainPart = this;926registerEditorPart(part: any): IDisposable { return Disposable.None; }927createAuxiliaryEditorPart(): Promise<IAuxiliaryEditorPart> { throw new Error('Method not implemented.'); }928createModalEditorPart(): Promise<IModalEditorPart> { throw new Error('Method not implemented.'); }929}930931export class TestEditorGroupView implements IEditorGroupView {932933constructor(public id: number) { }934935windowId = mainWindow.vscodeWindowId;936groupsView: IEditorGroupsView = undefined!;937activeEditorPane!: IVisibleEditorPane;938activeEditor!: EditorInput;939selectedEditors: EditorInput[] = [];940previewEditor!: EditorInput;941count!: number;942stickyCount!: number;943disposed!: boolean;944editors: readonly EditorInput[] = [];945label!: string;946isLocked!: boolean;947ariaLabel!: string;948index!: number;949whenRestored: Promise<void> = Promise.resolve(undefined);950element!: HTMLElement;951minimumWidth!: number;952maximumWidth!: number;953minimumHeight!: number;954maximumHeight!: number;955956titleHeight!: IEditorGroupTitleHeight;957958isEmpty = true;959960readonly onWillDispose: Event<void> = Event.None;961readonly onDidModelChange: Event<IGroupModelChangeEvent> = Event.None;962readonly onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;963readonly onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;964readonly onDidOpenEditorFail: Event<EditorInput> = Event.None;965readonly onDidFocus: Event<void> = Event.None;966readonly onDidChange: Event<{ width: number; height: number }> = Event.None;967readonly onWillMoveEditor: Event<IEditorWillMoveEvent> = Event.None;968readonly onWillOpenEditor: Event<IEditorWillOpenEvent> = Event.None;969readonly onDidActiveEditorChange: Event<IActiveEditorChangeEvent> = Event.None;970971getEditors(_order?: EditorsOrder): readonly EditorInput[] { return []; }972findEditors(_resource: URI): readonly EditorInput[] { return []; }973getEditorByIndex(_index: number): EditorInput { throw new Error('not implemented'); }974getIndexOfEditor(_editor: EditorInput): number { return -1; }975isFirst(editor: EditorInput): boolean { return false; }976isLast(editor: EditorInput): boolean { return false; }977openEditor(_editor: EditorInput, _options?: IEditorOptions): Promise<IEditorPane> { throw new Error('not implemented'); }978openEditors(_editors: EditorInputWithOptions[]): Promise<IEditorPane> { throw new Error('not implemented'); }979isPinned(_editor: EditorInput): boolean { return false; }980isSticky(_editor: EditorInput): boolean { return false; }981isTransient(_editor: EditorInput): boolean { return false; }982isActive(_editor: EditorInput | IUntypedEditorInput): boolean { return false; }983setSelection(_activeSelectedEditor: EditorInput, _inactiveSelectedEditors: EditorInput[]): Promise<void> { throw new Error('not implemented'); }984isSelected(_editor: EditorInput): boolean { return false; }985contains(candidate: EditorInput | IUntypedEditorInput): boolean { return false; }986moveEditor(_editor: EditorInput, _target: IEditorGroup, _options?: IEditorOptions): boolean { return true; }987moveEditors(_editors: EditorInputWithOptions[], _target: IEditorGroup): boolean { return true; }988copyEditor(_editor: EditorInput, _target: IEditorGroup, _options?: IEditorOptions): void { }989copyEditors(_editors: EditorInputWithOptions[], _target: IEditorGroup): void { }990async closeEditor(_editor?: EditorInput, options?: ICloseEditorOptions): Promise<boolean> { return true; }991async closeEditors(_editors: EditorInput[] | ICloseEditorsFilter, options?: ICloseEditorOptions): Promise<boolean> { return true; }992closeAllEditors(options?: ICloseAllEditorsOptions): any { return true; }993async replaceEditors(_editors: IEditorReplacement[]): Promise<void> { }994pinEditor(_editor?: EditorInput): void { }995stickEditor(editor?: EditorInput | undefined): void { }996unstickEditor(editor?: EditorInput | undefined): void { }997lock(locked: boolean): void { }998focus(): void { }999get scopedContextKeyService(): IContextKeyService { throw new Error('not implemented'); }1000setActive(_isActive: boolean): void { }1001notifyIndexChanged(_index: number): void { }1002notifyLabelChanged(_label: string): void { }1003dispose(): void { }1004toJSON(): object { return Object.create(null); }1005layout(_width: number, _height: number): void { }1006relayout() { }1007createEditorActions(_menuDisposable: IDisposable): { actions: IToolbarActions; onDidChange: Event<IMenuChangeEvent> } { throw new Error('not implemented'); }1008}10091010export class TestEditorGroupAccessor implements IEditorGroupsView {10111012label: string = '';1013windowId = mainWindow.vscodeWindowId;10141015groups: IEditorGroupView[] = [];1016activeGroup!: IEditorGroupView;10171018partOptions: IEditorPartOptions = { ...DEFAULT_EDITOR_PART_OPTIONS };10191020onDidChangeEditorPartOptions = Event.None;1021onDidVisibilityChange = Event.None;10221023getGroup(identifier: number): IEditorGroupView | undefined { throw new Error('Method not implemented.'); }1024getGroups(order: GroupsOrder): IEditorGroupView[] { throw new Error('Method not implemented.'); }1025activateGroup(identifier: number | IEditorGroupView): IEditorGroupView { throw new Error('Method not implemented.'); }1026restoreGroup(identifier: number | IEditorGroupView): IEditorGroupView { throw new Error('Method not implemented.'); }1027addGroup(location: number | IEditorGroupView, direction: GroupDirection): IEditorGroupView { throw new Error('Method not implemented.'); }1028mergeGroup(group: number | IEditorGroupView, target: number | IEditorGroupView, options?: IMergeGroupOptions | undefined): boolean { throw new Error('Method not implemented.'); }1029moveGroup(group: number | IEditorGroupView, location: number | IEditorGroupView, direction: GroupDirection): IEditorGroupView { throw new Error('Method not implemented.'); }1030copyGroup(group: number | IEditorGroupView, location: number | IEditorGroupView, direction: GroupDirection): IEditorGroupView { throw new Error('Method not implemented.'); }1031removeGroup(group: number | IEditorGroupView): void { throw new Error('Method not implemented.'); }1032arrangeGroups(arrangement: GroupsArrangement, target?: number | IEditorGroupView | undefined): void { throw new Error('Method not implemented.'); }1033toggleMaximizeGroup(group: number | IEditorGroupView): void { throw new Error('Method not implemented.'); }1034toggleExpandGroup(group: number | IEditorGroupView): void { throw new Error('Method not implemented.'); }1035}10361037export class TestEditorService extends Disposable implements EditorServiceImpl {10381039declare readonly _serviceBrand: undefined;10401041readonly onDidActiveEditorChange: Event<void> = Event.None;1042readonly onDidVisibleEditorsChange: Event<void> = Event.None;1043readonly onDidEditorsChange: Event<IEditorsChangeEvent> = Event.None;1044readonly onWillOpenEditor: Event<IEditorWillOpenEvent> = Event.None;1045readonly onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;1046readonly onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;1047readonly onDidMostRecentlyActiveEditorsChange: Event<void> = Event.None;10481049private _activeTextEditorControl: ICodeEditor | IDiffEditor | undefined;1050public get activeTextEditorControl(): ICodeEditor | IDiffEditor | undefined { return this._activeTextEditorControl; }1051public set activeTextEditorControl(value: ICodeEditor | IDiffEditor | undefined) { this._activeTextEditorControl = value; }10521053activeEditorPane: IVisibleEditorPane | undefined;1054activeTextEditorLanguageId: string | undefined;10551056private _activeEditor: EditorInput | undefined;1057public get activeEditor(): EditorInput | undefined { return this._activeEditor; }1058public set activeEditor(value: EditorInput | undefined) { this._activeEditor = value; }10591060editors: readonly EditorInput[] = [];1061mostRecentlyActiveEditors: readonly IEditorIdentifier[] = [];1062visibleEditorPanes: readonly IVisibleEditorPane[] = [];1063visibleTextEditorControls = [];1064getVisibleTextEditorControls(order: EditorsOrder): readonly (IEditor | IDiffEditor)[] { return this.visibleTextEditorControls; }1065visibleEditors: readonly EditorInput[] = [];1066count = this.editors.length;10671068constructor(private editorGroupService?: IEditorGroupsService) {1069super();1070}1071createScoped(editorGroupsContainer: IEditorGroupsContainer): IEditorService { return this; }1072getEditors() { return []; }1073// eslint-disable-next-line local/code-no-any-casts1074findEditors() { return [] as any; }1075openEditor(editor: EditorInput, options?: IEditorOptions, group?: PreferredGroup): Promise<IEditorPane | undefined>;1076openEditor(editor: IResourceEditorInput | IUntitledTextResourceEditorInput, group?: PreferredGroup): Promise<IEditorPane | undefined>;1077openEditor(editor: IResourceDiffEditorInput, group?: PreferredGroup): Promise<ITextDiffEditorPane | undefined>;1078async openEditor(editor: EditorInput | IUntypedEditorInput, optionsOrGroup?: IEditorOptions | PreferredGroup, group?: PreferredGroup): Promise<IEditorPane | undefined> {1079// openEditor takes ownership of the input, register it to the TestEditorService1080// so it's not marked as leaked during tests.1081if ('dispose' in editor) {1082this._register(editor);1083}1084return undefined;1085}1086async closeEditor(editor: IEditorIdentifier, options?: ICloseEditorOptions): Promise<void> { }1087async closeEditors(editors: IEditorIdentifier[], options?: ICloseEditorOptions): Promise<void> { }1088doResolveEditorOpenRequest(editor: EditorInput | IUntypedEditorInput): [IEditorGroup, EditorInput, IEditorOptions | undefined] | undefined {1089if (!this.editorGroupService) {1090return undefined;1091}10921093return [this.editorGroupService.activeGroup, editor as EditorInput, undefined];1094}1095openEditors(_editors: any, _group?: any): Promise<IEditorPane[]> { throw new Error('not implemented'); }1096isOpened(_editor: IResourceEditorInputIdentifier): boolean { return false; }1097isVisible(_editor: EditorInput): boolean { return false; }1098replaceEditors(_editors: any, _group: any) { return Promise.resolve(undefined); }1099save(editors: IEditorIdentifier[], options?: ISaveEditorsOptions): Promise<ISaveEditorsResult> { throw new Error('Method not implemented.'); }1100saveAll(options?: ISaveEditorsOptions): Promise<ISaveEditorsResult> { throw new Error('Method not implemented.'); }1101revert(editors: IEditorIdentifier[], options?: IRevertOptions): Promise<boolean> { throw new Error('Method not implemented.'); }1102revertAll(options?: IRevertAllEditorsOptions): Promise<boolean> { throw new Error('Method not implemented.'); }1103}11041105export class TestWorkingCopyBackupService extends InMemoryWorkingCopyBackupService {11061107readonly resolved: Set<IWorkingCopyIdentifier> = new Set();11081109constructor() {1110super();1111}11121113parseBackupContent(textBufferFactory: ITextBufferFactory): string {1114const textBuffer = textBufferFactory.create(DefaultEndOfLine.LF).textBuffer;1115const lineCount = textBuffer.getLineCount();1116const range = new Range(1, 1, lineCount, textBuffer.getLineLength(lineCount) + 1);11171118return textBuffer.getValueInRange(range, EndOfLinePreference.TextDefined);1119}11201121override async resolve<T extends IWorkingCopyBackupMeta>(identifier: IWorkingCopyIdentifier): Promise<IResolvedWorkingCopyBackup<T> | undefined> {1122this.resolved.add(identifier);11231124return super.resolve(identifier);1125}1126}11271128export function toUntypedWorkingCopyId(resource: URI): IWorkingCopyIdentifier {1129return toTypedWorkingCopyId(resource, '');1130}11311132export function toTypedWorkingCopyId(resource: URI, typeId = 'testBackupTypeId'): IWorkingCopyIdentifier {1133return { typeId, resource };1134}11351136export class InMemoryTestWorkingCopyBackupService extends BrowserWorkingCopyBackupService {11371138private backupResourceJoiners: Function[];1139private discardBackupJoiners: Function[];11401141discardedBackups: IWorkingCopyIdentifier[];11421143constructor() {1144const disposables = new DisposableStore();1145const environmentService = TestEnvironmentService;1146const logService = new NullLogService();1147const fileService = disposables.add(new FileService(logService));1148disposables.add(fileService.registerProvider(Schemas.file, disposables.add(new InMemoryFileSystemProvider())));1149disposables.add(fileService.registerProvider(Schemas.vscodeUserData, disposables.add(new InMemoryFileSystemProvider())));11501151super(new TestContextService(TestWorkspace), environmentService, fileService, logService);11521153this.backupResourceJoiners = [];1154this.discardBackupJoiners = [];1155this.discardedBackups = [];11561157this._register(disposables);1158}11591160testGetFileService(): IFileService {1161return this.fileService;1162}11631164joinBackupResource(): Promise<void> {1165return new Promise(resolve => this.backupResourceJoiners.push(resolve));1166}11671168joinDiscardBackup(): Promise<void> {1169return new Promise(resolve => this.discardBackupJoiners.push(resolve));1170}11711172override async backup(identifier: IWorkingCopyIdentifier, content?: VSBufferReadableStream | VSBufferReadable, versionId?: number, meta?: any, token?: CancellationToken): Promise<void> {1173await super.backup(identifier, content, versionId, meta, token);11741175while (this.backupResourceJoiners.length) {1176this.backupResourceJoiners.pop()!();1177}1178}11791180override async discardBackup(identifier: IWorkingCopyIdentifier): Promise<void> {1181await super.discardBackup(identifier);1182this.discardedBackups.push(identifier);11831184while (this.discardBackupJoiners.length) {1185this.discardBackupJoiners.pop()!();1186}1187}11881189async getBackupContents(identifier: IWorkingCopyIdentifier): Promise<string> {1190const backupResource = this.toBackupResource(identifier);11911192const fileContents = await this.fileService.readFile(backupResource);11931194return fileContents.value.toString();1195}1196}11971198export class TestBeforeShutdownEvent implements InternalBeforeShutdownEvent {11991200value: boolean | Promise<boolean> | undefined;1201finalValue: (() => boolean | Promise<boolean>) | undefined;1202reason = ShutdownReason.CLOSE;12031204veto(value: boolean | Promise<boolean>): void {1205this.value = value;1206}12071208finalVeto(vetoFn: () => boolean | Promise<boolean>): void {1209this.value = vetoFn();1210this.finalValue = vetoFn;1211}1212}12131214export class TestWillShutdownEvent implements WillShutdownEvent {12151216value: Promise<void>[] = [];1217joiners = () => [];1218reason = ShutdownReason.CLOSE;1219token = CancellationToken.None;12201221join(promise: Promise<void> | (() => Promise<void>), joiner: IWillShutdownEventJoiner): void {1222this.value.push(typeof promise === 'function' ? promise() : promise);1223}12241225force() { /* No-Op in tests */ }1226}12271228export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {12291230declare readonly _serviceBrand: undefined;12311232constructor(private configurationService = new TestConfigurationService()) { }12331234onDidChangeConfiguration() {1235return { dispose() { } };1236}12371238getValue<T>(resource: URI, arg2?: any, arg3?: any): T {1239const position: IPosition | null = EditorPosition.isIPosition(arg2) ? arg2 : null;1240const section: string | undefined = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);1241return this.configurationService.getValue(section, { resource }) as T;1242}12431244inspect<T>(resource: URI | undefined, position: IPosition | null, section: string): IConfigurationValue<Readonly<T>> {1245return this.configurationService.inspect<T>(section, { resource });1246}12471248updateValue(resource: URI, key: string, value: any, configurationTarget?: ConfigurationTarget): Promise<void> {1249return this.configurationService.updateValue(key, value);1250}1251}12521253export class RemoteFileSystemProvider implements IFileSystemProvider {12541255constructor(private readonly wrappedFsp: IFileSystemProvider, private readonly remoteAuthority: string) {1256this.capabilities = this.wrappedFsp.capabilities;1257this.onDidChangeCapabilities = this.wrappedFsp.onDidChangeCapabilities;1258this.onDidChangeFile = Event.map(this.wrappedFsp.onDidChangeFile, changes => changes.map(c => {1259return {1260type: c.type,1261resource: c.resource.with({ scheme: Schemas.vscodeRemote, authority: this.remoteAuthority }),1262};1263}));1264}12651266readonly capabilities: FileSystemProviderCapabilities;1267readonly onDidChangeCapabilities: Event<void>;12681269readonly onDidChangeFile: Event<readonly IFileChange[]>;1270watch(resource: URI, opts: IWatchOptions): IDisposable { return this.wrappedFsp.watch(this.toFileResource(resource), opts); }12711272stat(resource: URI): Promise<IStat> { return this.wrappedFsp.stat(this.toFileResource(resource)); }1273mkdir(resource: URI): Promise<void> { return this.wrappedFsp.mkdir(this.toFileResource(resource)); }1274readdir(resource: URI): Promise<[string, FileType][]> { return this.wrappedFsp.readdir(this.toFileResource(resource)); }1275delete(resource: URI, opts: IFileDeleteOptions): Promise<void> { return this.wrappedFsp.delete(this.toFileResource(resource), opts); }12761277rename(from: URI, to: URI, opts: IFileOverwriteOptions): Promise<void> { return this.wrappedFsp.rename(this.toFileResource(from), this.toFileResource(to), opts); }1278copy(from: URI, to: URI, opts: IFileOverwriteOptions): Promise<void> { return this.wrappedFsp.copy!(this.toFileResource(from), this.toFileResource(to), opts); }12791280readFile(resource: URI): Promise<Uint8Array> { return this.wrappedFsp.readFile!(this.toFileResource(resource)); }1281writeFile(resource: URI, content: Uint8Array, opts: IFileWriteOptions): Promise<void> { return this.wrappedFsp.writeFile!(this.toFileResource(resource), content, opts); }12821283open(resource: URI, opts: IFileOpenOptions): Promise<number> { return this.wrappedFsp.open!(this.toFileResource(resource), opts); }1284close(fd: number): Promise<void> { return this.wrappedFsp.close!(fd); }1285read(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return this.wrappedFsp.read!(fd, pos, data, offset, length); }1286write(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return this.wrappedFsp.write!(fd, pos, data, offset, length); }12871288readFileStream(resource: URI, opts: IFileReadStreamOptions, token: CancellationToken): ReadableStreamEvents<Uint8Array> { return this.wrappedFsp.readFileStream!(this.toFileResource(resource), opts, token); }12891290private toFileResource(resource: URI): URI { return resource.with({ scheme: Schemas.file, authority: '' }); }1291}12921293export class TestInMemoryFileSystemProvider extends InMemoryFileSystemProvider implements IFileSystemProviderWithFileReadStreamCapability {1294override get capabilities(): FileSystemProviderCapabilities {1295return FileSystemProviderCapabilities.FileReadWrite1296| FileSystemProviderCapabilities.PathCaseSensitive1297| FileSystemProviderCapabilities.FileReadStream;1298}12991300override readFileStream(resource: URI): ReadableStreamEvents<Uint8Array> {1301const BUFFER_SIZE = 64 * 1024;1302const stream = newWriteableStream<Uint8Array>(data => VSBuffer.concat(data.map(data => VSBuffer.wrap(data))).buffer);13031304(async () => {1305try {1306const data = await this.readFile(resource);13071308let offset = 0;1309while (offset < data.length) {1310await timeout(0);1311await stream.write(data.subarray(offset, offset + BUFFER_SIZE));1312offset += BUFFER_SIZE;1313}13141315await timeout(0);1316stream.end();1317} catch (error) {1318stream.end(error);1319}1320})();13211322return stream;1323}1324}13251326export const productService: IProductService = { _serviceBrand: undefined, ...product };13271328export class TestHostService implements IHostService {13291330declare readonly _serviceBrand: undefined;13311332private _hasFocus = true;1333get hasFocus() { return this._hasFocus; }1334async hadLastFocus(): Promise<boolean> { return this._hasFocus; }13351336private _onDidChangeFocus = new Emitter<boolean>();1337readonly onDidChangeFocus = this._onDidChangeFocus.event;13381339private _onDidChangeWindow = new Emitter<number>();1340readonly onDidChangeActiveWindow = this._onDidChangeWindow.event;13411342readonly onDidChangeFullScreen: Event<{ windowId: number; fullscreen: boolean }> = Event.None;13431344setFocus(focus: boolean) {1345this._hasFocus = focus;1346this._onDidChangeFocus.fire(this._hasFocus);1347}13481349async restart(): Promise<void> { }1350async reload(): Promise<void> { }1351async close(): Promise<void> { }1352async withExpectedShutdown<T>(expectedShutdownTask: () => Promise<T>): Promise<T> {1353return await expectedShutdownTask();1354}13551356async focus(): Promise<void> { }1357async moveTop(): Promise<void> { }1358async getCursorScreenPoint(): Promise<undefined> { return undefined; }13591360async getWindows(options: unknown) { return []; }13611362async openWindow(arg1?: IOpenEmptyWindowOptions | IWindowOpenable[], arg2?: IOpenWindowOptions): Promise<void> { }13631364async toggleFullScreen(): Promise<void> { }13651366async getScreenshot(rect?: IRectangle): Promise<VSBuffer | undefined> { return undefined; }13671368async getNativeWindowHandle(_windowId: number): Promise<VSBuffer | undefined> { return undefined; }13691370async showToast(_options: IToastOptions, token: CancellationToken): Promise<IToastResult> { return { supported: false, clicked: false }; }13711372readonly colorScheme = ColorScheme.DARK;1373onDidChangeColorScheme = Event.None;1374}13751376export class TestFilesConfigurationService extends FilesConfigurationService {13771378testOnFilesConfigurationChange(configuration: any): void {1379super.onFilesConfigurationChange(configuration, true);1380}1381}13821383export class TestReadonlyTextFileEditorModel extends TextFileEditorModel {13841385override isReadonly(): boolean {1386return true;1387}1388}13891390export class TestEditorInput extends EditorInput {13911392constructor(public resource: URI, private readonly _typeId: string) {1393super();1394}13951396override get typeId(): string {1397return this._typeId;1398}13991400override get editorId(): string {1401return this._typeId;1402}14031404override resolve(): Promise<IDisposable | null> {1405return Promise.resolve(null);1406}1407}14081409export function registerTestEditor(id: string, inputs: SyncDescriptor<EditorInput>[], serializerInputId?: string): IDisposable {1410const disposables = new DisposableStore();14111412class TestEditor extends EditorPane {14131414private _scopedContextKeyService: IContextKeyService;14151416constructor(group: IEditorGroup) {1417super(id, group, NullTelemetryService, new TestThemeService(), disposables.add(new TestStorageService()));1418this._scopedContextKeyService = new MockContextKeyService();1419}14201421override async setInput(input: EditorInput, options: IEditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void> {1422super.setInput(input, options, context, token);14231424await input.resolve();1425}14261427override getId(): string { return id; }1428layout(): void { }1429protected createEditor(): void { }14301431override get scopedContextKeyService() {1432return this._scopedContextKeyService;1433}1434}14351436disposables.add(Registry.as<IEditorPaneRegistry>(Extensions.EditorPane).registerEditorPane(EditorPaneDescriptor.create(TestEditor, id, 'Test Editor Control'), inputs));14371438if (serializerInputId) {14391440interface ISerializedTestInput {1441resource: string;1442}14431444class EditorsObserverTestEditorInputSerializer implements IEditorSerializer {14451446canSerialize(editorInput: EditorInput): boolean {1447return true;1448}14491450serialize(editorInput: EditorInput): string {1451const testEditorInput = <TestFileEditorInput>editorInput;1452const testInput: ISerializedTestInput = {1453resource: testEditorInput.resource.toString()1454};14551456return JSON.stringify(testInput);1457}14581459deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): EditorInput {1460const testInput: ISerializedTestInput = JSON.parse(serializedEditorInput);14611462return new TestFileEditorInput(URI.parse(testInput.resource), serializerInputId!);1463}1464}14651466disposables.add(Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerEditorSerializer(serializerInputId, EditorsObserverTestEditorInputSerializer));1467}14681469return disposables;1470}14711472export function registerTestFileEditor(): IDisposable {1473const disposables = new DisposableStore();14741475disposables.add(Registry.as<IEditorPaneRegistry>(Extensions.EditorPane).registerEditorPane(1476EditorPaneDescriptor.create(1477TestTextFileEditor,1478TestTextFileEditor.ID,1479'Text File Editor'1480),1481[new SyncDescriptor(FileEditorInput)]1482));14831484return disposables;1485}14861487export function registerTestResourceEditor(): IDisposable {1488const disposables = new DisposableStore();14891490disposables.add(Registry.as<IEditorPaneRegistry>(Extensions.EditorPane).registerEditorPane(1491EditorPaneDescriptor.create(1492TestTextResourceEditor,1493TestTextResourceEditor.ID,1494'Text Editor'1495),1496[1497new SyncDescriptor(UntitledTextEditorInput),1498new SyncDescriptor(TextResourceEditorInput)1499]1500));15011502return disposables;1503}15041505export function registerTestSideBySideEditor(): IDisposable {1506const disposables = new DisposableStore();15071508disposables.add(Registry.as<IEditorPaneRegistry>(Extensions.EditorPane).registerEditorPane(1509EditorPaneDescriptor.create(1510SideBySideEditor,1511SideBySideEditor.ID,1512'Text Editor'1513),1514[1515new SyncDescriptor(SideBySideEditorInput)1516]1517));15181519return disposables;1520}15211522export class TestFileEditorInput extends EditorInput implements IFileEditorInput {15231524readonly preferredResource;15251526gotDisposed = false;1527gotSaved = false;1528gotSavedAs = false;1529gotReverted = false;1530dirty = false;1531modified: boolean | undefined;1532private fails = false;15331534disableToUntyped = false;15351536constructor(1537public resource: URI,1538private _typeId: string1539) {1540super();15411542this.preferredResource = this.resource;1543}15441545override get typeId() { return this._typeId; }1546override get editorId() { return this._typeId; }15471548private _capabilities: EditorInputCapabilities = EditorInputCapabilities.None;1549override get capabilities(): EditorInputCapabilities { return this._capabilities; }1550override set capabilities(capabilities: EditorInputCapabilities) {1551if (this._capabilities !== capabilities) {1552this._capabilities = capabilities;1553this._onDidChangeCapabilities.fire();1554}1555}15561557override resolve(): Promise<IDisposable | null> { return !this.fails ? Promise.resolve(null) : Promise.reject(new Error('fails')); }1558override matches(other: EditorInput | IResourceEditorInput | ITextResourceEditorInput | IUntitledTextResourceEditorInput): boolean {1559if (super.matches(other)) {1560return true;1561}1562if (other instanceof EditorInput) {1563return !!(other?.resource && this.resource.toString() === other.resource.toString() && other instanceof TestFileEditorInput && other.typeId === this.typeId);1564}1565return isEqual(this.resource, other.resource) && (this.editorId === other.options?.override || other.options?.override === undefined);1566}1567setPreferredResource(resource: URI): void { }1568async setEncoding(encoding: string) { }1569getEncoding() { return undefined; }1570setPreferredName(name: string): void { }1571setPreferredDescription(description: string): void { }1572setPreferredEncoding(encoding: string) { }1573setPreferredContents(contents: string): void { }1574setLanguageId(languageId: string, source?: string) { }1575setPreferredLanguageId(languageId: string) { }1576setForceOpenAsBinary(): void { }1577setFailToOpen(): void {1578this.fails = true;1579}1580override async save(groupId: GroupIdentifier, options?: ISaveOptions): Promise<EditorInput | undefined> {1581this.gotSaved = true;1582this.dirty = false;1583return this;1584}1585override async saveAs(groupId: GroupIdentifier, options?: ISaveOptions): Promise<EditorInput | undefined> {1586this.gotSavedAs = true;1587return this;1588}1589override async revert(group: GroupIdentifier, options?: IRevertOptions): Promise<void> {1590this.gotReverted = true;1591this.gotSaved = false;1592this.gotSavedAs = false;1593this.dirty = false;1594}1595override toUntyped(): IUntypedEditorInput | undefined {1596if (this.disableToUntyped) {1597return undefined;1598}1599return { resource: this.resource };1600}1601setModified(): void { this.modified = true; }1602override isModified(): boolean {1603return this.modified === undefined ? this.dirty : this.modified;1604}1605setDirty(): void { this.dirty = true; }1606override isDirty(): boolean {1607return this.dirty;1608}1609isResolved(): boolean { return false; }1610override dispose(): void {1611super.dispose();1612this.gotDisposed = true;1613}1614movedEditor: IMoveResult | undefined = undefined;1615override async rename(): Promise<IMoveResult | undefined> { return this.movedEditor; }16161617private moveDisabledReason: string | undefined = undefined;1618setMoveDisabled(reason: string): void {1619this.moveDisabledReason = reason;1620}16211622override canMove(sourceGroup: GroupIdentifier, targetGroup: GroupIdentifier): string | true {1623if (typeof this.moveDisabledReason === 'string') {1624return this.moveDisabledReason;1625}1626return super.canMove(sourceGroup, targetGroup);1627}1628}16291630export class TestSingletonFileEditorInput extends TestFileEditorInput {16311632override get capabilities(): EditorInputCapabilities { return EditorInputCapabilities.Singleton; }1633}16341635export class TestEditorPart extends MainEditorPart implements IEditorGroupsService {16361637declare readonly _serviceBrand: undefined;16381639readonly mainPart = this;1640readonly parts: readonly IEditorPart[] = [this];16411642readonly onDidCreateAuxiliaryEditorPart: Event<IAuxiliaryEditorPart> = Event.None;16431644testSaveState(): void {1645return super.saveState();1646}16471648clearState(): void {1649const workspaceMemento = this.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE) as Record<string, unknown>;1650for (const key of Object.keys(workspaceMemento)) {1651delete workspaceMemento[key];1652}16531654const profileMemento = this.getMemento(StorageScope.PROFILE, StorageTarget.MACHINE) as Record<string, unknown>;1655for (const key of Object.keys(profileMemento)) {1656delete profileMemento[key];1657}1658}16591660registerEditorPart(part: IEditorPart): IDisposable {1661return Disposable.None;1662}16631664createAuxiliaryEditorPart(): Promise<IAuxiliaryEditorPart> {1665throw new Error('Method not implemented.');1666}16671668createModalEditorPart(): Promise<IModalEditorPart> {1669throw new Error('Method not implemented.');1670}16711672getScopedInstantiationService(part: IEditorPart): IInstantiationService {1673throw new Error('Method not implemented.');1674}16751676getPart(group: number | IEditorGroup): IEditorPart { return this; }16771678saveWorkingSet(name: string): IEditorWorkingSet { throw new Error('Method not implemented.'); }1679getWorkingSets(): IEditorWorkingSet[] { throw new Error('Method not implemented.'); }1680applyWorkingSet(workingSet: IEditorWorkingSet | 'empty', options?: IEditorWorkingSetOptions): Promise<boolean> { throw new Error('Method not implemented.'); }1681deleteWorkingSet(workingSet: IEditorWorkingSet): Promise<boolean> { throw new Error('Method not implemented.'); }16821683registerContextKeyProvider<T extends ContextKeyValue>(provider: IEditorGroupContextKeyProvider<T>): IDisposable { throw new Error('Method not implemented.'); }1684}16851686export class TestEditorParts extends EditorParts {1687testMainPart!: TestEditorPart;16881689protected override createMainEditorPart(): MainEditorPart {1690this.testMainPart = this.instantiationService.createInstance(TestEditorPart, this);16911692return this.testMainPart;1693}1694}16951696export async function createEditorParts(instantiationService: IInstantiationService, disposables: DisposableStore): Promise<TestEditorParts> {1697const parts = instantiationService.createInstance(TestEditorParts);1698const part = disposables.add(parts).testMainPart;1699part.create(document.createElement('div'));1700part.layout(1080, 800, 0, 0);17011702await parts.whenReady;17031704return parts;1705}17061707export async function createEditorPart(instantiationService: IInstantiationService, disposables: DisposableStore): Promise<TestEditorPart> {1708return (await createEditorParts(instantiationService, disposables)).testMainPart;1709}17101711export class TestListService implements IListService {1712declare readonly _serviceBrand: undefined;17131714lastFocusedList: any | undefined = undefined;17151716register(): IDisposable {1717return Disposable.None;1718}1719}17201721export class TestPathService implements IPathService {17221723declare readonly _serviceBrand: undefined;17241725constructor(private readonly fallbackUserHome: URI = URI.from({ scheme: Schemas.file, path: '/' }), public defaultUriScheme = Schemas.file) { }17261727hasValidBasename(resource: URI, basename?: string): Promise<boolean>;1728hasValidBasename(resource: URI, os: OperatingSystem, basename?: string): boolean;1729hasValidBasename(resource: URI, arg2?: string | OperatingSystem, name?: string): boolean | Promise<boolean> {1730if (typeof arg2 === 'string' || typeof arg2 === 'undefined') {1731return isValidBasename(arg2 ?? basename(resource));1732}17331734return isValidBasename(name ?? basename(resource));1735}17361737get path() { return Promise.resolve(isWindows ? win32 : posix); }17381739userHome(options?: { preferLocal: boolean }): Promise<URI>;1740userHome(options: { preferLocal: true }): URI;1741userHome(options?: { preferLocal: boolean }): Promise<URI> | URI {1742return options?.preferLocal ? this.fallbackUserHome : Promise.resolve(this.fallbackUserHome);1743}17441745get resolvedUserHome() { return this.fallbackUserHome; }17461747async fileURI(path: string): Promise<URI> {1748return URI.file(path);1749}1750}17511752export interface ITestTextFileEditorModelManager extends ITextFileEditorModelManager, IDisposable {1753add(resource: URI, model: TextFileEditorModel): void;1754remove(resource: URI): void;1755}17561757interface ITestTextFileEditorModel extends ITextFileEditorModel {1758readonly lastResolvedFileStat: IFileStatWithMetadata | undefined;1759}17601761export function getLastResolvedFileStat(model: unknown): IFileStatWithMetadata | undefined {1762const candidate = model as ITestTextFileEditorModel | undefined;17631764return candidate?.lastResolvedFileStat;1765}17661767export class TestWorkspacesService implements IWorkspacesService {1768_serviceBrand: undefined;17691770onDidChangeRecentlyOpened = Event.None;17711772async createUntitledWorkspace(folders?: IWorkspaceFolderCreationData[], remoteAuthority?: string): Promise<IWorkspaceIdentifier> { throw new Error('Method not implemented.'); }1773async deleteUntitledWorkspace(workspace: IWorkspaceIdentifier): Promise<void> { }1774async addRecentlyOpened(recents: IRecent[]): Promise<void> { }1775async removeRecentlyOpened(workspaces: URI[]): Promise<void> { }1776async clearRecentlyOpened(): Promise<void> { }1777async getRecentlyOpened(): Promise<IRecentlyOpened> { return { files: [], workspaces: [] }; }1778async getDirtyWorkspaces(): Promise<(IFolderBackupInfo | IWorkspaceBackupInfo)[]> { return []; }1779async enterWorkspace(path: URI): Promise<IEnterWorkspaceResult | undefined> { throw new Error('Method not implemented.'); }1780async getWorkspaceIdentifier(workspacePath: URI): Promise<IWorkspaceIdentifier> { throw new Error('Method not implemented.'); }1781}17821783export class TestTerminalInstanceService implements ITerminalInstanceService {1784onDidCreateInstance = Event.None;1785onDidRegisterBackend = Event.None;1786declare readonly _serviceBrand: undefined;17871788convertProfileToShellLaunchConfig(shellLaunchConfigOrProfile?: IShellLaunchConfig | ITerminalProfile, cwd?: string | URI): IShellLaunchConfig { throw new Error('Method not implemented.'); }1789preparePathForTerminalAsync(path: string, executable: string | undefined, title: string, shellType: TerminalShellType, remoteAuthority: string | undefined): Promise<string> { throw new Error('Method not implemented.'); }1790createInstance(options: ICreateTerminalOptions, target: TerminalLocation): ITerminalInstance { throw new Error('Method not implemented.'); }1791async getBackend(remoteAuthority?: string): Promise<ITerminalBackend | undefined> { throw new Error('Method not implemented.'); }1792didRegisterBackend(backend: ITerminalBackend): void { throw new Error('Method not implemented.'); }1793getRegisteredBackends(): IterableIterator<ITerminalBackend> { throw new Error('Method not implemented.'); }1794}17951796export class TestTerminalEditorService implements ITerminalEditorService {1797_serviceBrand: undefined;1798activeInstance: ITerminalInstance | undefined;1799instances: readonly ITerminalInstance[] = [];1800onDidDisposeInstance = Event.None;1801onDidFocusInstance = Event.None;1802onDidChangeInstanceCapability = Event.None;1803onDidChangeActiveInstance = Event.None;1804onDidChangeInstances = Event.None;1805openEditor(instance: ITerminalInstance, editorOptions?: TerminalEditorLocation): Promise<void> { throw new Error('Method not implemented.'); }1806detachInstance(instance: ITerminalInstance): void { throw new Error('Method not implemented.'); }1807splitInstance(instanceToSplit: ITerminalInstance, shellLaunchConfig?: IShellLaunchConfig): ITerminalInstance { throw new Error('Method not implemented.'); }1808revealActiveEditor(preserveFocus?: boolean): Promise<void> { throw new Error('Method not implemented.'); }1809resolveResource(instance: ITerminalInstance): URI { throw new Error('Method not implemented.'); }1810reviveInput(deserializedInput: IDeserializedTerminalEditorInput): TerminalEditorInput { throw new Error('Method not implemented.'); }1811getInputFromResource(resource: URI): TerminalEditorInput { throw new Error('Method not implemented.'); }1812setActiveInstance(instance: ITerminalInstance): void { throw new Error('Method not implemented.'); }1813focusActiveInstance(): Promise<void> { throw new Error('Method not implemented.'); }1814async focusInstance(instance: ITerminalInstance): Promise<void> { throw new Error('Method not implemented.'); }1815getInstanceFromResource(resource: URI | undefined): ITerminalInstance | undefined { throw new Error('Method not implemented.'); }1816focusFindWidget(): void { throw new Error('Method not implemented.'); }1817hideFindWidget(): void { throw new Error('Method not implemented.'); }1818findNext(): void { throw new Error('Method not implemented.'); }1819findPrevious(): void { throw new Error('Method not implemented.'); }1820}18211822export class TestTerminalGroupService implements ITerminalGroupService {1823_serviceBrand: undefined;1824activeInstance: ITerminalInstance | undefined;1825instances: readonly ITerminalInstance[] = [];1826groups: readonly ITerminalGroup[] = [];1827activeGroup: ITerminalGroup | undefined;1828activeGroupIndex: number = 0;1829lastAccessedMenu: 'inline-tab' | 'tab-list' = 'inline-tab';1830onDidChangeActiveGroup = Event.None;1831onDidDisposeGroup = Event.None;1832onDidShow = Event.None;1833onDidChangeGroups = Event.None;1834onDidChangePanelOrientation = Event.None;1835onDidDisposeInstance = Event.None;1836onDidFocusInstance = Event.None;1837onDidChangeInstanceCapability = Event.None;1838onDidChangeActiveInstance = Event.None;1839onDidChangeInstances = Event.None;1840createGroup(instance?: any): ITerminalGroup { throw new Error('Method not implemented.'); }1841getGroupForInstance(instance: ITerminalInstance): ITerminalGroup | undefined { throw new Error('Method not implemented.'); }1842moveGroup(source: ITerminalInstance | ITerminalInstance[], target: ITerminalInstance): void { throw new Error('Method not implemented.'); }1843moveGroupToEnd(source: ITerminalInstance | ITerminalInstance[]): void { throw new Error('Method not implemented.'); }1844moveInstance(source: ITerminalInstance, target: ITerminalInstance, side: 'before' | 'after'): void { throw new Error('Method not implemented.'); }1845unsplitInstance(instance: ITerminalInstance): void { throw new Error('Method not implemented.'); }1846joinInstances(instances: ITerminalInstance[]): void { throw new Error('Method not implemented.'); }1847instanceIsSplit(instance: ITerminalInstance): boolean { throw new Error('Method not implemented.'); }1848getGroupLabels(): string[] { throw new Error('Method not implemented.'); }1849setActiveGroupByIndex(index: number): void { throw new Error('Method not implemented.'); }1850setActiveGroupToNext(): void { throw new Error('Method not implemented.'); }1851setActiveGroupToPrevious(): void { throw new Error('Method not implemented.'); }1852setActiveInstanceByIndex(terminalIndex: number): void { throw new Error('Method not implemented.'); }1853setContainer(container: HTMLElement): void { throw new Error('Method not implemented.'); }1854showPanel(focus?: boolean): Promise<void> { throw new Error('Method not implemented.'); }1855hidePanel(): void { throw new Error('Method not implemented.'); }1856focusTabs(): void { throw new Error('Method not implemented.'); }1857focusHover(): void { throw new Error('Method not implemented.'); }1858setActiveInstance(instance: ITerminalInstance): void { throw new Error('Method not implemented.'); }1859focusActiveInstance(): Promise<void> { throw new Error('Method not implemented.'); }1860async focusInstance(instance: ITerminalInstance): Promise<void> { throw new Error('Method not implemented.'); }1861getInstanceFromResource(resource: URI | undefined): ITerminalInstance | undefined { throw new Error('Method not implemented.'); }1862focusFindWidget(): void { throw new Error('Method not implemented.'); }1863hideFindWidget(): void { throw new Error('Method not implemented.'); }1864findNext(): void { throw new Error('Method not implemented.'); }1865findPrevious(): void { throw new Error('Method not implemented.'); }1866updateVisibility(): void { throw new Error('Method not implemented.'); }1867}18681869export class TestTerminalProfileService implements ITerminalProfileService {1870_serviceBrand: undefined;1871availableProfiles: ITerminalProfile[] = [];1872contributedProfiles: IExtensionTerminalProfile[] = [];1873profilesReady: Promise<void> = Promise.resolve();1874onDidChangeAvailableProfiles = Event.None;1875getPlatformKey(): Promise<string> { throw new Error('Method not implemented.'); }1876refreshAvailableProfiles(): void { throw new Error('Method not implemented.'); }1877getDefaultProfileName(): string | undefined { throw new Error('Method not implemented.'); }1878getDefaultProfile(): ITerminalProfile | undefined { throw new Error('Method not implemented.'); }1879getContributedDefaultProfile(shellLaunchConfig: IShellLaunchConfig): Promise<IExtensionTerminalProfile | undefined> { throw new Error('Method not implemented.'); }1880registerContributedProfile(args: IRegisterContributedProfileArgs): Promise<void> { throw new Error('Method not implemented.'); }1881getContributedProfileProvider(extensionIdentifier: string, id: string): ITerminalProfileProvider | undefined { throw new Error('Method not implemented.'); }1882registerTerminalProfileProvider(extensionIdentifier: string, id: string, profileProvider: ITerminalProfileProvider): IDisposable { throw new Error('Method not implemented.'); }1883}18841885export class TestTerminalProfileResolverService implements ITerminalProfileResolverService {1886_serviceBrand: undefined;1887defaultProfileName = '';1888resolveIcon(shellLaunchConfig: IShellLaunchConfig): void { }1889async resolveShellLaunchConfig(shellLaunchConfig: IShellLaunchConfig, options: IShellLaunchConfigResolveOptions): Promise<void> { }1890async getDefaultProfile(options: IShellLaunchConfigResolveOptions): Promise<ITerminalProfile> { return { path: '/default', profileName: 'Default', isDefault: true }; }1891async getDefaultShell(options: IShellLaunchConfigResolveOptions): Promise<string> { return '/default'; }1892async getDefaultShellArgs(options: IShellLaunchConfigResolveOptions): Promise<string | string[]> { return []; }1893getDefaultIcon(): TerminalIcon & ThemeIcon { return Codicon.terminal; }1894async getEnvironment(): Promise<IProcessEnvironment> { return env; }1895getSafeConfigValue(key: string, os: OperatingSystem): unknown | undefined { return undefined; }1896getSafeConfigValueFullKey(key: string): unknown | undefined { return undefined; }1897createProfileFromShellAndShellArgs(shell?: unknown, shellArgs?: unknown): Promise<string | ITerminalProfile> { throw new Error('Method not implemented.'); }1898}18991900export class TestTerminalConfigurationService extends TerminalConfigurationService {1901get fontMetrics() { return this._fontMetrics; }1902// eslint-disable-next-line local/code-no-any-casts1903setConfig(config: Partial<ITerminalConfiguration>) { this._config = config as any; }1904}19051906export class TestQuickInputService implements IQuickInputService {1907declare readonly _serviceBrand: undefined;19081909readonly onShow = Event.None;1910readonly onHide = Event.None;19111912readonly currentQuickInput = undefined;1913readonly quickAccess = undefined!;1914backButton!: IQuickInputButton;19151916pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: IPickOptions<T> & { canPickMany: true }, token?: CancellationToken): Promise<T[]>;1917pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: IPickOptions<T> & { canPickMany: false }, token?: CancellationToken): Promise<T>;1918async pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: Omit<IPickOptions<T>, 'canPickMany'>, token?: CancellationToken): Promise<T | undefined> {1919if (Array.isArray(picks)) {1920// eslint-disable-next-line local/code-no-any-casts1921return <any>{ label: 'selectedPick', description: 'pick description', value: 'selectedPick' };1922} else {1923return undefined;1924}1925}19261927async input(options?: IInputOptions, token?: CancellationToken): Promise<string> { return options ? 'resolved' + options.prompt : 'resolved'; }19281929createQuickPick<T extends IQuickPickItem>(): IQuickPick<T, { useSeparators: boolean }> { throw new Error('not implemented.'); }1930createInputBox(): IInputBox { throw new Error('not implemented.'); }1931createQuickWidget(): IQuickWidget { throw new Error('Method not implemented.'); }1932createQuickTree<T extends IQuickTreeItem>(): IQuickTree<T> { throw new Error('not implemented.'); }1933focus(): void { throw new Error('not implemented.'); }1934toggle(): void { throw new Error('not implemented.'); }1935navigate(next: boolean, quickNavigate?: IQuickNavigateConfiguration): void { throw new Error('not implemented.'); }1936accept(): Promise<void> { throw new Error('not implemented.'); }1937back(): Promise<void> { throw new Error('not implemented.'); }1938cancel(): Promise<void> { throw new Error('not implemented.'); }1939setAlignment(alignment: 'top' | 'center' | { top: number; left: number }): void { throw new Error('not implemented.'); }1940toggleHover(): void { throw new Error('not implemented.'); }1941}19421943class TestLanguageDetectionService implements ILanguageDetectionService {19441945declare readonly _serviceBrand: undefined;19461947isEnabledForLanguage(languageId: string): boolean { return false; }1948async detectLanguage(resource: URI, supportedLangs?: string[] | undefined): Promise<string | undefined> { return undefined; }1949}19501951export class TestRemoteAgentService implements IRemoteAgentService {19521953declare readonly _serviceBrand: undefined;19541955getConnection(): IRemoteAgentConnection | null { return null; }1956async getEnvironment(): Promise<IRemoteAgentEnvironment | null> { return null; }1957async getRawEnvironment(): Promise<IRemoteAgentEnvironment | null> { return null; }1958async getExtensionHostExitInfo(reconnectionToken: string): Promise<IExtensionHostExitInfo | null> { return null; }1959async getDiagnosticInfo(options: IDiagnosticInfoOptions): Promise<IDiagnosticInfo | undefined> { return undefined; }1960async updateTelemetryLevel(telemetryLevel: TelemetryLevel): Promise<void> { }1961async logTelemetry(eventName: string, data?: ITelemetryData): Promise<void> { }1962async flushTelemetry(): Promise<void> { }1963async getRoundTripTime(): Promise<number | undefined> { return undefined; }1964async endConnection(): Promise<void> { }1965}19661967export class TestRemoteExtensionsScannerService implements IRemoteExtensionsScannerService {1968declare readonly _serviceBrand: undefined;1969async whenExtensionsReady(): Promise<InstallExtensionSummary> { return { failed: [] }; }1970scanExtensions(): Promise<IExtensionDescription[]> { throw new Error('Method not implemented.'); }1971}19721973export class TestWorkbenchExtensionEnablementService implements IWorkbenchExtensionEnablementService {1974_serviceBrand: undefined;1975onEnablementChanged = Event.None;1976getEnablementState(extension: IExtension): EnablementState { return EnablementState.EnabledGlobally; }1977getEnablementStates(extensions: IExtension[], workspaceTypeOverrides?: { trusted?: boolean | undefined } | undefined): EnablementState[] { return []; }1978getDependenciesEnablementStates(extension: IExtension): [IExtension, EnablementState][] { return []; }1979canChangeEnablement(extension: IExtension): boolean { return true; }1980canChangeWorkspaceEnablement(extension: IExtension): boolean { return true; }1981isEnabled(extension: IExtension): boolean { return true; }1982isEnabledEnablementState(enablementState: EnablementState): boolean { return true; }1983isDisabledGlobally(extension: IExtension): boolean { return false; }1984async setEnablement(extensions: IExtension[], state: EnablementState): Promise<boolean[]> { return []; }1985async updateExtensionsEnablementsWhenWorkspaceTrustChanges(): Promise<void> { }1986}19871988export class TestWorkbenchExtensionManagementService implements IWorkbenchExtensionManagementService {1989_serviceBrand: undefined;1990onInstallExtension = Event.None;1991onDidInstallExtensions = Event.None;1992onUninstallExtension = Event.None;1993onDidUninstallExtension = Event.None;1994onDidUpdateExtensionMetadata = Event.None;1995onProfileAwareInstallExtension = Event.None;1996onProfileAwareDidInstallExtensions = Event.None;1997onProfileAwareUninstallExtension = Event.None;1998onProfileAwareDidUninstallExtension = Event.None;1999onDidProfileAwareUninstallExtensions = Event.None;2000onProfileAwareDidUpdateExtensionMetadata = Event.None;2001onDidChangeProfile = Event.None;2002onDidEnableExtensions = Event.None;2003preferPreReleases = true;2004installVSIX(location: URI, manifest: Readonly<IRelaxedExtensionManifest>, installOptions?: InstallOptions | undefined): Promise<ILocalExtension> {2005throw new Error('Method not implemented.');2006}2007installFromLocation(location: URI): Promise<ILocalExtension> {2008throw new Error('Method not implemented.');2009}2010installGalleryExtensions(extensions: InstallExtensionInfo[]): Promise<InstallExtensionResult[]> {2011throw new Error('Method not implemented.');2012}2013async updateFromGallery(gallery: IGalleryExtension, extension: ILocalExtension, installOptions?: InstallOptions | undefined): Promise<ILocalExtension> { return extension; }2014zip(extension: ILocalExtension): Promise<URI> {2015throw new Error('Method not implemented.');2016}2017getManifest(vsix: URI): Promise<Readonly<IRelaxedExtensionManifest>> {2018throw new Error('Method not implemented.');2019}2020install(vsix: URI, options?: InstallOptions | undefined): Promise<ILocalExtension> {2021throw new Error('Method not implemented.');2022}2023isAllowed(): true | IMarkdownString { return true; }2024async canInstall(extension: IGalleryExtension): Promise<true> { return true; }2025installFromGallery(extension: IGalleryExtension, options?: InstallOptions | undefined): Promise<ILocalExtension> {2026throw new Error('Method not implemented.');2027}2028uninstall(extension: ILocalExtension, options?: UninstallOptions | undefined): Promise<void> {2029throw new Error('Method not implemented.');2030}2031uninstallExtensions(extensions: UninstallExtensionInfo[]): Promise<void> {2032throw new Error('Method not implemented.');2033}2034async getInstalled(type?: ExtensionType | undefined): Promise<ILocalExtension[]> { return []; }2035getExtensionsControlManifest(): Promise<IExtensionsControlManifest> {2036throw new Error('Method not implemented.');2037}2038async updateMetadata(local: ILocalExtension, metadata: Partial<Metadata>): Promise<ILocalExtension> { return local; }2039registerParticipant(pariticipant: IExtensionManagementParticipant): void { }2040async getTargetPlatform(): Promise<TargetPlatform> { return TargetPlatform.UNDEFINED; }2041async cleanUp(): Promise<void> { }2042download(): Promise<URI> {2043throw new Error('Method not implemented.');2044}2045copyExtensions(): Promise<void> { throw new Error('Not Supported'); }2046toggleApplicationScope(): Promise<ILocalExtension> { throw new Error('Not Supported'); }2047installExtensionsFromProfile(): Promise<ILocalExtension[]> { throw new Error('Not Supported'); }2048whenProfileChanged(from: IUserDataProfile, to: IUserDataProfile): Promise<void> { throw new Error('Not Supported'); }2049getInstalledWorkspaceExtensionLocations(): URI[] { throw new Error('Method not implemented.'); }2050getInstalledWorkspaceExtensions(): Promise<ILocalExtension[]> { throw new Error('Method not implemented.'); }2051installResourceExtension(): Promise<ILocalExtension> { throw new Error('Method not implemented.'); }2052getExtensions(): Promise<IResourceExtension[]> { throw new Error('Method not implemented.'); }2053resetPinnedStateForAllUserExtensions(pinned: boolean): Promise<void> { throw new Error('Method not implemented.'); }2054getInstallableServers(extension: IGalleryExtension): Promise<IExtensionManagementServer[]> { throw new Error('Method not implemented.'); }2055isPublisherTrusted(extension: IGalleryExtension): boolean { return false; }2056getTrustedPublishers() { return []; }2057trustPublishers(): void { }2058untrustPublishers(): void { }2059async requestPublisherTrust(extensions: InstallExtensionInfo[]): Promise<void> { }2060}2061206220632064export class TestWebExtensionsScannerService implements IWebExtensionsScannerService {2065_serviceBrand: undefined;2066onDidChangeProfile = Event.None;2067async scanSystemExtensions(): Promise<IExtension[]> { return []; }2068async scanUserExtensions(): Promise<IScannedExtension[]> { return []; }2069async scanExtensionsUnderDevelopment(): Promise<IExtension[]> { return []; }2070async copyExtensions(): Promise<void> {2071throw new Error('Method not implemented.');2072}2073scanExistingExtension(extensionLocation: URI, extensionType: ExtensionType): Promise<IScannedExtension | null> {2074throw new Error('Method not implemented.');2075}2076addExtension(location: URI, metadata?: Partial<IGalleryMetadata & { isApplicationScoped: boolean; isMachineScoped: boolean; isBuiltin: boolean; isSystem: boolean; updated: boolean; preRelease: boolean; installedTimestamp: number }> | undefined): Promise<IExtension> {2077throw new Error('Method not implemented.');2078}2079addExtensionFromGallery(galleryExtension: IGalleryExtension, metadata?: Partial<IGalleryMetadata & { isApplicationScoped: boolean; isMachineScoped: boolean; isBuiltin: boolean; isSystem: boolean; updated: boolean; preRelease: boolean; installedTimestamp: number }> | undefined): Promise<IExtension> {2080throw new Error('Method not implemented.');2081}2082removeExtension(): Promise<void> {2083throw new Error('Method not implemented.');2084}2085updateMetadata(extension: IScannedExtension, metaData: Partial<Metadata>, profileLocation: URI): Promise<IScannedExtension> {2086throw new Error('Method not implemented.');2087}2088scanExtensionManifest(extensionLocation: URI): Promise<Readonly<IRelaxedExtensionManifest> | null> {2089throw new Error('Method not implemented.');2090}2091}20922093export async function workbenchTeardown(instantiationService: IInstantiationService): Promise<void> {2094return instantiationService.invokeFunction(async accessor => {2095const workingCopyService = accessor.get(IWorkingCopyService);2096const editorGroupService = accessor.get(IEditorGroupsService);20972098for (const workingCopy of workingCopyService.workingCopies) {2099await workingCopy.revert();2100}21012102for (const group of editorGroupService.groups) {2103await group.closeAllEditors();2104}21052106for (const group of editorGroupService.groups) {2107editorGroupService.removeGroup(group);2108}2109});2110}21112112export class TestContextMenuService implements IContextMenuService {21132114_serviceBrand: undefined;21152116readonly onDidShowContextMenu = Event.None;2117readonly onDidHideContextMenu = Event.None;21182119showContextMenu(delegate: IContextMenuDelegate | IContextMenuMenuDelegate): void {2120throw new Error('Method not implemented.');2121}2122}21232124export class TestChatWidgetService implements IChatWidgetService {21252126_serviceBrand: undefined;21272128lastFocusedWidget: IChatWidget | undefined;21292130onDidAddWidget = Event.None;2131onDidBackgroundSession = Event.None;21322133async reveal(widget: IChatWidget, preserveFocus?: boolean): Promise<boolean> { return false; }2134async revealWidget(preserveFocus?: boolean): Promise<IChatWidget | undefined> { return undefined; }2135getAllWidgets(): ReadonlyArray<IChatWidget> { return []; }2136getWidgetByInputUri(uri: URI): IChatWidget | undefined { return undefined; }2137openSession(sessionResource: URI): Promise<IChatWidget | undefined>;2138openSession(sessionResource: URI, target?: PreferredGroup, options?: IChatEditorOptions): Promise<IChatWidget | undefined>;2139async openSession(sessionResource: unknown, target?: unknown, options?: unknown): Promise<IChatWidget | undefined> { return undefined; }2140getWidgetBySessionResource(sessionResource: URI): IChatWidget | undefined { return undefined; }2141getWidgetsByLocations(location: ChatAgentLocation): ReadonlyArray<IChatWidget> { return []; }2142register(newWidget: IChatWidget): IDisposable { return Disposable.None; }2143}214421452146