Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/test/browser/workbenchTestServices.ts
4778 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { IContextMenuDelegate } from '../../../base/browser/contextmenu.js';
7
import { IDimension } from '../../../base/browser/dom.js';
8
import { Direction, IViewSize } from '../../../base/browser/ui/grid/grid.js';
9
import { mainWindow } from '../../../base/browser/window.js';
10
import { timeout } from '../../../base/common/async.js';
11
import { VSBuffer, VSBufferReadable, VSBufferReadableStream } from '../../../base/common/buffer.js';
12
import { CancellationToken } from '../../../base/common/cancellation.js';
13
import { Codicon } from '../../../base/common/codicons.js';
14
import { Emitter, Event } from '../../../base/common/event.js';
15
import { isValidBasename } from '../../../base/common/extpath.js';
16
import { IMarkdownString } from '../../../base/common/htmlContent.js';
17
import { Disposable, DisposableStore, IDisposable } from '../../../base/common/lifecycle.js';
18
import { Schemas } from '../../../base/common/network.js';
19
import { posix, win32 } from '../../../base/common/path.js';
20
import { IProcessEnvironment, isWindows, OperatingSystem } from '../../../base/common/platform.js';
21
import { env } from '../../../base/common/process.js';
22
import { basename, isEqual } from '../../../base/common/resources.js';
23
import { newWriteableStream, ReadableStreamEvents } from '../../../base/common/stream.js';
24
import { ThemeIcon } from '../../../base/common/themables.js';
25
import { assertReturnsDefined, upcast } from '../../../base/common/types.js';
26
import { URI } from '../../../base/common/uri.js';
27
import { ICodeEditor } from '../../../editor/browser/editorBrowser.js';
28
import { ICodeEditorService } from '../../../editor/browser/services/codeEditorService.js';
29
import { Position as EditorPosition, IPosition } from '../../../editor/common/core/position.js';
30
import { Range } from '../../../editor/common/core/range.js';
31
import { Selection } from '../../../editor/common/core/selection.js';
32
import { IDiffEditor, IEditor } from '../../../editor/common/editorCommon.js';
33
import { ILanguageService } from '../../../editor/common/languages/language.js';
34
import { ILanguageConfigurationService } from '../../../editor/common/languages/languageConfigurationRegistry.js';
35
import { DefaultEndOfLine, EndOfLinePreference, ITextBufferFactory, ITextSnapshot } from '../../../editor/common/model.js';
36
import { createTextBufferFactoryFromStream } from '../../../editor/common/model/textModel.js';
37
import { IEditorWorkerService } from '../../../editor/common/services/editorWorker.js';
38
import { ILanguageFeatureDebounceService, LanguageFeatureDebounceService } from '../../../editor/common/services/languageFeatureDebounce.js';
39
import { ILanguageFeaturesService } from '../../../editor/common/services/languageFeatures.js';
40
import { LanguageFeaturesService } from '../../../editor/common/services/languageFeaturesService.js';
41
import { LanguageService } from '../../../editor/common/services/languageService.js';
42
import { IModelService } from '../../../editor/common/services/model.js';
43
import { ModelService } from '../../../editor/common/services/modelService.js';
44
import { ITextModelService } from '../../../editor/common/services/resolverService.js';
45
import { ITextResourceConfigurationService, ITextResourcePropertiesService } from '../../../editor/common/services/textResourceConfiguration.js';
46
import { ITreeSitterLibraryService } from '../../../editor/common/services/treeSitter/treeSitterLibraryService.js';
47
import { TestCodeEditor } from '../../../editor/test/browser/testCodeEditor.js';
48
import { TestLanguageConfigurationService } from '../../../editor/test/common/modes/testLanguageConfigurationService.js';
49
import { TestEditorWorkerService } from '../../../editor/test/common/services/testEditorWorkerService.js';
50
import { TestTreeSitterLibraryService } from '../../../editor/test/common/services/testTreeSitterLibraryService.js';
51
import { IAccessibilityService } from '../../../platform/accessibility/common/accessibility.js';
52
import { TestAccessibilityService } from '../../../platform/accessibility/test/common/testAccessibilityService.js';
53
import { IAccessibilitySignalService } from '../../../platform/accessibilitySignal/browser/accessibilitySignalService.js';
54
import { IActionViewItemService, NullActionViewItemService } from '../../../platform/actions/browser/actionViewItemService.js';
55
import { IMenu, IMenuActionOptions, IMenuChangeEvent, IMenuService, MenuId, MenuItemAction, SubmenuItemAction } from '../../../platform/actions/common/actions.js';
56
import { IFolderBackupInfo, IWorkspaceBackupInfo } from '../../../platform/backup/common/backup.js';
57
import { ConfigurationTarget, IConfigurationService, IConfigurationValue } from '../../../platform/configuration/common/configuration.js';
58
import { TestConfigurationService } from '../../../platform/configuration/test/common/testConfigurationService.js';
59
import { ContextKeyValue, IContextKeyService } from '../../../platform/contextkey/common/contextkey.js';
60
import { ContextMenuService } from '../../../platform/contextview/browser/contextMenuService.js';
61
import { IContextMenuMenuDelegate, IContextMenuService, IContextViewService } from '../../../platform/contextview/browser/contextView.js';
62
import { ContextViewService } from '../../../platform/contextview/browser/contextViewService.js';
63
import { IDiagnosticInfo, IDiagnosticInfoOptions } from '../../../platform/diagnostics/common/diagnostics.js';
64
import { ConfirmResult, IDialogService, IFileDialogService, IOpenDialogOptions, IPickAndOpenOptions, ISaveDialogOptions } from '../../../platform/dialogs/common/dialogs.js';
65
import { TestDialogService } from '../../../platform/dialogs/test/common/testDialogService.js';
66
import { IEditorOptions, IResourceEditorInput, IResourceEditorInputIdentifier, ITextEditorOptions, ITextResourceEditorInput } from '../../../platform/editor/common/editor.js';
67
import { IEnvironmentService } from '../../../platform/environment/common/environment.js';
68
import { IExtensionManagementParticipant, IExtensionsControlManifest, IGalleryExtension, IGalleryMetadata, ILocalExtension, InstallExtensionInfo, InstallExtensionResult, InstallExtensionSummary, InstallOptions, Metadata, UninstallExtensionInfo, UninstallOptions } from '../../../platform/extensionManagement/common/extensionManagement.js';
69
import { ExtensionType, IExtension, IExtensionDescription, IRelaxedExtensionManifest, TargetPlatform } from '../../../platform/extensions/common/extensions.js';
70
import { FileOperationError, FileSystemProviderCapabilities, FileType, IFileChange, IFileDeleteOptions, IFileOpenOptions, IFileOverwriteOptions, IFileReadStreamOptions, IFileService, IFileStatWithMetadata, IFileSystemProvider, IFileSystemProviderWithFileReadStreamCapability, IFileWriteOptions, IStat, IWatchOptions } from '../../../platform/files/common/files.js';
71
import { FileService } from '../../../platform/files/common/fileService.js';
72
import { InMemoryFileSystemProvider } from '../../../platform/files/common/inMemoryFilesystemProvider.js';
73
import { IHoverService } from '../../../platform/hover/browser/hover.js';
74
import { NullHoverService } from '../../../platform/hover/test/browser/nullHoverService.js';
75
import { SyncDescriptor } from '../../../platform/instantiation/common/descriptors.js';
76
import { IInstantiationService, ServiceIdentifier } from '../../../platform/instantiation/common/instantiation.js';
77
import { ServiceCollection } from '../../../platform/instantiation/common/serviceCollection.js';
78
import { TestInstantiationService } from '../../../platform/instantiation/test/common/instantiationServiceMock.js';
79
import { IKeybindingService } from '../../../platform/keybinding/common/keybinding.js';
80
import { MockContextKeyService, MockKeybindingService } from '../../../platform/keybinding/test/common/mockKeybindingService.js';
81
import { ILabelService } from '../../../platform/label/common/label.js';
82
import { ILayoutOffsetInfo } from '../../../platform/layout/browser/layoutService.js';
83
import { IListService } from '../../../platform/list/browser/listService.js';
84
import { ILoggerService, ILogService, NullLogService } from '../../../platform/log/common/log.js';
85
import { IMarkdownRendererService, MarkdownRendererService } from '../../../platform/markdown/browser/markdownRenderer.js';
86
import { IMarkerService } from '../../../platform/markers/common/markers.js';
87
import { INotificationService } from '../../../platform/notification/common/notification.js';
88
import { TestNotificationService } from '../../../platform/notification/test/common/testNotificationService.js';
89
import product from '../../../platform/product/common/product.js';
90
import { IProductService } from '../../../platform/product/common/productService.js';
91
import { IProgress, IProgressCompositeOptions, IProgressDialogOptions, IProgressIndicator, IProgressNotificationOptions, IProgressOptions, IProgressService, IProgressStep, IProgressWindowOptions, Progress } from '../../../platform/progress/common/progress.js';
92
import { IInputBox, IInputOptions, IPickOptions, IQuickInputButton, IQuickInputService, IQuickNavigateConfiguration, IQuickPick, IQuickPickItem, IQuickTree, IQuickTreeItem, IQuickWidget, QuickPickInput } from '../../../platform/quickinput/common/quickInput.js';
93
import { Registry } from '../../../platform/registry/common/platform.js';
94
import { IRemoteAgentEnvironment } from '../../../platform/remote/common/remoteAgentEnvironment.js';
95
import { IRemoteExtensionsScannerService } from '../../../platform/remote/common/remoteExtensionsScanner.js';
96
import { IRemoteSocketFactoryService, RemoteSocketFactoryService } from '../../../platform/remote/common/remoteSocketFactoryService.js';
97
import { IStorageService, StorageScope, StorageTarget } from '../../../platform/storage/common/storage.js';
98
import { ITelemetryData, ITelemetryService, TelemetryLevel } from '../../../platform/telemetry/common/telemetry.js';
99
import { NullTelemetryService } from '../../../platform/telemetry/common/telemetryUtils.js';
100
import { IExtensionTerminalProfile, IShellLaunchConfig, ITerminalBackend, ITerminalLogService, ITerminalProfile, TerminalIcon, TerminalLocation, TerminalShellType } from '../../../platform/terminal/common/terminal.js';
101
import { TerminalLogService } from '../../../platform/terminal/common/terminalLogService.js';
102
import { ColorScheme } from '../../../platform/theme/common/theme.js';
103
import { IThemeService } from '../../../platform/theme/common/themeService.js';
104
import { TestThemeService } from '../../../platform/theme/test/common/testThemeService.js';
105
import { IUndoRedoService } from '../../../platform/undoRedo/common/undoRedo.js';
106
import { UndoRedoService } from '../../../platform/undoRedo/common/undoRedoService.js';
107
import { IUriIdentityService } from '../../../platform/uriIdentity/common/uriIdentity.js';
108
import { UriIdentityService } from '../../../platform/uriIdentity/common/uriIdentityService.js';
109
import { IUserDataProfile, IUserDataProfilesService, UserDataProfilesService } from '../../../platform/userDataProfile/common/userDataProfile.js';
110
import { IOpenEmptyWindowOptions, IOpenWindowOptions, IRectangle, IWindowOpenable, MenuBarVisibility } from '../../../platform/window/common/window.js';
111
import { IWorkspaceContextService, IWorkspaceIdentifier } from '../../../platform/workspace/common/workspace.js';
112
import { IWorkspaceTrustManagementService, IWorkspaceTrustRequestService } from '../../../platform/workspace/common/workspaceTrust.js';
113
import { TestWorkspace } from '../../../platform/workspace/test/common/testWorkspace.js';
114
import { IEnterWorkspaceResult, IRecent, IRecentlyOpened, IWorkspaceFolderCreationData, IWorkspacesService } from '../../../platform/workspaces/common/workspaces.js';
115
import { EditorPaneDescriptor, IEditorPaneRegistry } from '../../browser/editor.js';
116
import { PaneComposite, PaneCompositeDescriptor } from '../../browser/panecomposite.js';
117
import { Part } from '../../browser/part.js';
118
import { DEFAULT_EDITOR_PART_OPTIONS, EditorServiceImpl, IEditorGroupsView, IEditorGroupTitleHeight, IEditorGroupView } from '../../browser/parts/editor/editor.js';
119
import { EditorPane } from '../../browser/parts/editor/editorPane.js';
120
import { MainEditorPart } from '../../browser/parts/editor/editorPart.js';
121
import { EditorParts } from '../../browser/parts/editor/editorParts.js';
122
import { SideBySideEditor } from '../../browser/parts/editor/sideBySideEditor.js';
123
import { TextEditorPaneSelection } from '../../browser/parts/editor/textEditor.js';
124
import { TextResourceEditor } from '../../browser/parts/editor/textResourceEditor.js';
125
import { IPaneCompositePart } from '../../browser/parts/paneCompositePart.js';
126
import { 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';
127
import { IGroupModelChangeEvent } from '../../common/editor/editorGroupModel.js';
128
import { EditorInput } from '../../common/editor/editorInput.js';
129
import { SideBySideEditorInput } from '../../common/editor/sideBySideEditorInput.js';
130
import { TextResourceEditorInput } from '../../common/editor/textResourceEditorInput.js';
131
import { IPaneComposite } from '../../common/panecomposite.js';
132
import { IView, IViewDescriptor, ViewContainer, ViewContainerLocation } from '../../common/views.js';
133
import { FileEditorInput } from '../../contrib/files/browser/editors/fileEditorInput.js';
134
import { TextFileEditor } from '../../contrib/files/browser/editors/textFileEditor.js';
135
import { FILE_EDITOR_INPUT_ID } from '../../contrib/files/common/files.js';
136
import { ICreateTerminalOptions, IDeserializedTerminalEditorInput, ITerminalConfigurationService, ITerminalEditorService, ITerminalGroup, ITerminalGroupService, ITerminalInstance, ITerminalInstanceService, TerminalEditorLocation } from '../../contrib/terminal/browser/terminal.js';
137
import { TerminalConfigurationService } from '../../contrib/terminal/browser/terminalConfigurationService.js';
138
import { TerminalEditorInput } from '../../contrib/terminal/browser/terminalEditorInput.js';
139
import { IEnvironmentVariableService } from '../../contrib/terminal/common/environmentVariable.js';
140
import { EnvironmentVariableService } from '../../contrib/terminal/common/environmentVariableService.js';
141
import { IRegisterContributedProfileArgs, IShellLaunchConfigResolveOptions, ITerminalProfileProvider, ITerminalProfileResolverService, ITerminalProfileService, type ITerminalConfiguration } from '../../contrib/terminal/common/terminal.js';
142
import { IChatEntitlementService } from '../../services/chat/common/chatEntitlementService.js';
143
import { IDecoration, IDecorationData, IDecorationsProvider, IDecorationsService, IResourceDecorationChangeEvent } from '../../services/decorations/common/decorations.js';
144
import { CodeEditorService } from '../../services/editor/browser/codeEditorService.js';
145
import { EditorPaneService } from '../../services/editor/browser/editorPaneService.js';
146
import { EditorResolverService } from '../../services/editor/browser/editorResolverService.js';
147
import { CustomEditorLabelService, ICustomEditorLabelService } from '../../services/editor/common/customEditorLabelService.js';
148
import { EditorGroupLayout, GroupDirection, GroupOrientation, GroupsArrangement, GroupsOrder, IAuxiliaryEditorPart, ICloseAllEditorsOptions, ICloseEditorOptions, ICloseEditorsFilter, IEditorDropTargetDelegate, IEditorGroup, IEditorGroupContextKeyProvider, IEditorGroupsContainer, IEditorGroupsService, IEditorPart, IEditorReplacement, IEditorWorkingSet, IEditorWorkingSetOptions, IFindGroupScope, IMergeGroupOptions } from '../../services/editor/common/editorGroupsService.js';
149
import { IEditorPaneService } from '../../services/editor/common/editorPaneService.js';
150
import { IEditorResolverService } from '../../services/editor/common/editorResolverService.js';
151
import { IEditorsChangeEvent, IEditorService, IRevertAllEditorsOptions, ISaveEditorsOptions, ISaveEditorsResult, PreferredGroup } from '../../services/editor/common/editorService.js';
152
import { BrowserWorkbenchEnvironmentService } from '../../services/environment/browser/environmentService.js';
153
import { IWorkbenchEnvironmentService } from '../../services/environment/common/environmentService.js';
154
import { EnablementState, IExtensionManagementServer, IResourceExtension, IScannedExtension, IWebExtensionsScannerService, IWorkbenchExtensionEnablementService, IWorkbenchExtensionManagementService } from '../../services/extensionManagement/common/extensionManagement.js';
155
import { IExtensionService } from '../../services/extensions/common/extensions.js';
156
import { BrowserElevatedFileService } from '../../services/files/browser/elevatedFileService.js';
157
import { IElevatedFileService } from '../../services/files/common/elevatedFileService.js';
158
import { FilesConfigurationService, IFilesConfigurationService } from '../../services/filesConfiguration/common/filesConfigurationService.js';
159
import { IHistoryService } from '../../services/history/common/history.js';
160
import { IHostService } from '../../services/host/browser/host.js';
161
import { LabelService } from '../../services/label/common/labelService.js';
162
import { ILanguageDetectionService } from '../../services/languageDetection/common/languageDetectionWorkerService.js';
163
import { IWorkbenchLayoutService, PanelAlignment, Position as PartPosition, Parts } from '../../services/layout/browser/layoutService.js';
164
import { ILifecycleService, InternalBeforeShutdownEvent, IWillShutdownEventJoiner, ShutdownReason, WillShutdownEvent } from '../../services/lifecycle/common/lifecycle.js';
165
import { IPaneCompositePartService } from '../../services/panecomposite/browser/panecomposite.js';
166
import { IPathService } from '../../services/path/common/pathService.js';
167
import { QuickInputService } from '../../services/quickinput/browser/quickInputService.js';
168
import { IExtensionHostExitInfo, IRemoteAgentConnection, IRemoteAgentService } from '../../services/remote/common/remoteAgentService.js';
169
import { BrowserTextFileService } from '../../services/textfile/browser/browserTextFileService.js';
170
import { EncodingOracle, IEncodingOverride } from '../../services/textfile/browser/textFileService.js';
171
import { UTF16be, UTF16le, UTF8_with_bom } from '../../services/textfile/common/encoding.js';
172
import { ITextEditorService, TextEditorService } from '../../services/textfile/common/textEditorService.js';
173
import { TextFileEditorModel } from '../../services/textfile/common/textFileEditorModel.js';
174
import { IReadTextFileOptions, ITextFileEditorModel, ITextFileEditorModelManager, ITextFileService, ITextFileStreamContent, IWriteTextFileOptions } from '../../services/textfile/common/textfiles.js';
175
import { TextModelResolverService } from '../../services/textmodelResolver/common/textModelResolverService.js';
176
import { UntitledTextEditorInput } from '../../services/untitled/common/untitledTextEditorInput.js';
177
import { IUntitledTextEditorModelManager, IUntitledTextEditorService, UntitledTextEditorService } from '../../services/untitled/common/untitledTextEditorService.js';
178
import { IUserDataProfileService } from '../../services/userDataProfile/common/userDataProfile.js';
179
import { UserDataProfileService } from '../../services/userDataProfile/common/userDataProfileService.js';
180
import { IViewsService } from '../../services/views/common/viewsService.js';
181
import { BrowserWorkingCopyBackupService } from '../../services/workingCopy/browser/workingCopyBackupService.js';
182
import { IWorkingCopy, IWorkingCopyBackupMeta, IWorkingCopyIdentifier } from '../../services/workingCopy/common/workingCopy.js';
183
import { IResolvedWorkingCopyBackup, IWorkingCopyBackupService } from '../../services/workingCopy/common/workingCopyBackup.js';
184
import { InMemoryWorkingCopyBackupService } from '../../services/workingCopy/common/workingCopyBackupService.js';
185
import { IWorkingCopyEditorService, WorkingCopyEditorService } from '../../services/workingCopy/common/workingCopyEditorService.js';
186
import { IWorkingCopyFileService, WorkingCopyFileService } from '../../services/workingCopy/common/workingCopyFileService.js';
187
import { IWorkingCopyService, WorkingCopyService } from '../../services/workingCopy/common/workingCopyService.js';
188
import { TestChatEntitlementService, TestContextService, TestExtensionService, TestFileService, TestHistoryService, TestLifecycleService, TestLoggerService, TestMarkerService, TestProductService, TestStorageService, TestTextResourcePropertiesService, TestWorkspaceTrustManagementService, TestWorkspaceTrustRequestService } from '../common/workbenchTestServices.js';
189
190
// Backcompat export
191
export { TestFileService, TestLifecycleService };
192
193
export function createFileEditorInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
194
return instantiationService.createInstance(FileEditorInput, resource, undefined, undefined, undefined, undefined, undefined, undefined);
195
}
196
197
Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerFileEditorFactory({
198
199
typeId: FILE_EDITOR_INPUT_ID,
200
201
createFileEditor: (resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents, instantiationService): IFileEditorInput => {
202
return instantiationService.createInstance(FileEditorInput, resource, preferredResource, preferredName, preferredDescription, preferredEncoding, preferredLanguageId, preferredContents);
203
},
204
205
isFileEditor: (obj): obj is IFileEditorInput => {
206
return obj instanceof FileEditorInput;
207
}
208
});
209
210
export class TestTextResourceEditor extends TextResourceEditor {
211
212
protected override createEditorControl(parent: HTMLElement, configuration: any): void {
213
this.editorControl = this._register(this.instantiationService.createInstance(TestCodeEditor, parent, configuration, {}));
214
}
215
}
216
217
export class TestTextFileEditor extends TextFileEditor {
218
219
protected override createEditorControl(parent: HTMLElement, configuration: any): void {
220
this.editorControl = this._register(this.instantiationService.createInstance(TestCodeEditor, parent, configuration, { contributions: [] }));
221
}
222
223
setSelection(selection: Selection | undefined, reason: EditorPaneSelectionChangeReason): void {
224
this._options = selection ? upcast<IEditorOptions, ITextEditorOptions>({ selection }) : undefined;
225
226
this._onDidChangeSelection.fire({ reason });
227
}
228
229
override getSelection(): IEditorPaneSelection | undefined {
230
const options = this.options;
231
if (!options) {
232
return undefined;
233
}
234
235
const textSelection = (options as ITextEditorOptions).selection;
236
if (!textSelection) {
237
return undefined;
238
}
239
240
return new TextEditorPaneSelection(new Selection(textSelection.startLineNumber, textSelection.startColumn, textSelection.endLineNumber ?? textSelection.startLineNumber, textSelection.endColumn ?? textSelection.startColumn));
241
}
242
}
243
244
export interface ITestInstantiationService extends IInstantiationService {
245
stub<T>(service: ServiceIdentifier<T>, ctor: any): T;
246
}
247
248
export class TestWorkingCopyService extends WorkingCopyService {
249
testUnregisterWorkingCopy(workingCopy: IWorkingCopy): void {
250
return super.unregisterWorkingCopy(workingCopy);
251
}
252
}
253
254
export function workbenchInstantiationService(
255
overrides?: {
256
environmentService?: (instantiationService: IInstantiationService) => IEnvironmentService;
257
fileService?: (instantiationService: IInstantiationService) => IFileService;
258
workingCopyBackupService?: (instantiationService: IInstantiationService) => IWorkingCopyBackupService;
259
configurationService?: (instantiationService: IInstantiationService) => TestConfigurationService;
260
textFileService?: (instantiationService: IInstantiationService) => ITextFileService;
261
pathService?: (instantiationService: IInstantiationService) => IPathService;
262
editorService?: (instantiationService: IInstantiationService) => IEditorService;
263
contextKeyService?: (instantiationService: IInstantiationService) => IContextKeyService;
264
textEditorService?: (instantiationService: IInstantiationService) => ITextEditorService;
265
},
266
disposables: Pick<DisposableStore, 'add'> = new DisposableStore()
267
): TestInstantiationService {
268
const instantiationService = disposables.add(new TestInstantiationService(new ServiceCollection(
269
[ILifecycleService, disposables.add(new TestLifecycleService())],
270
[IActionViewItemService, new SyncDescriptor(NullActionViewItemService)],
271
)));
272
273
instantiationService.stub(IProductService, TestProductService);
274
instantiationService.stub(IEditorWorkerService, new TestEditorWorkerService());
275
instantiationService.stub(IWorkingCopyService, disposables.add(new TestWorkingCopyService()));
276
const environmentService = overrides?.environmentService ? overrides.environmentService(instantiationService) : TestEnvironmentService;
277
instantiationService.stub(IEnvironmentService, environmentService);
278
instantiationService.stub(IWorkbenchEnvironmentService, environmentService);
279
instantiationService.stub(ILogService, new NullLogService());
280
const contextKeyService = overrides?.contextKeyService ? overrides.contextKeyService(instantiationService) : instantiationService.createInstance(MockContextKeyService);
281
instantiationService.stub(IContextKeyService, contextKeyService);
282
instantiationService.stub(IProgressService, new TestProgressService());
283
const workspaceContextService = new TestContextService(TestWorkspace);
284
instantiationService.stub(IWorkspaceContextService, workspaceContextService);
285
const configService = overrides?.configurationService ? overrides.configurationService(instantiationService) : new TestConfigurationService({
286
files: {
287
participants: {
288
timeout: 60000
289
}
290
}
291
});
292
instantiationService.stub(IConfigurationService, configService);
293
const textResourceConfigurationService = new TestTextResourceConfigurationService(configService);
294
instantiationService.stub(ITextResourceConfigurationService, textResourceConfigurationService);
295
instantiationService.stub(IUntitledTextEditorService, disposables.add(instantiationService.createInstance(UntitledTextEditorService)));
296
instantiationService.stub(IStorageService, disposables.add(new TestStorageService()));
297
instantiationService.stub(IRemoteAgentService, new TestRemoteAgentService());
298
instantiationService.stub(ILanguageDetectionService, new TestLanguageDetectionService());
299
instantiationService.stub(IPathService, overrides?.pathService ? overrides.pathService(instantiationService) : new TestPathService());
300
const layoutService = new TestLayoutService();
301
instantiationService.stub(IWorkbenchLayoutService, layoutService);
302
instantiationService.stub(IDialogService, new TestDialogService());
303
const accessibilityService = new TestAccessibilityService();
304
instantiationService.stub(IAccessibilityService, accessibilityService);
305
// eslint-disable-next-line local/code-no-any-casts
306
instantiationService.stub(IAccessibilitySignalService, {
307
playSignal: async () => { },
308
isSoundEnabled(signal: unknown) { return false; },
309
} as any);
310
instantiationService.stub(IFileDialogService, instantiationService.createInstance(TestFileDialogService));
311
instantiationService.stub(ILanguageService, disposables.add(instantiationService.createInstance(LanguageService)));
312
instantiationService.stub(ILanguageFeaturesService, new LanguageFeaturesService());
313
instantiationService.stub(ILanguageFeatureDebounceService, instantiationService.createInstance(LanguageFeatureDebounceService));
314
instantiationService.stub(IHistoryService, new TestHistoryService());
315
instantiationService.stub(ITextResourcePropertiesService, new TestTextResourcePropertiesService(configService));
316
instantiationService.stub(IUndoRedoService, instantiationService.createInstance(UndoRedoService));
317
const themeService = new TestThemeService();
318
instantiationService.stub(IThemeService, themeService);
319
instantiationService.stub(ILanguageConfigurationService, disposables.add(new TestLanguageConfigurationService()));
320
instantiationService.stub(ITreeSitterLibraryService, new TestTreeSitterLibraryService());
321
instantiationService.stub(IModelService, disposables.add(instantiationService.createInstance(ModelService)));
322
const fileService = overrides?.fileService ? overrides.fileService(instantiationService) : disposables.add(new TestFileService());
323
instantiationService.stub(IFileService, fileService);
324
instantiationService.stub(IUriIdentityService, disposables.add(new UriIdentityService(fileService)));
325
const markerService = new TestMarkerService();
326
instantiationService.stub(IMarkerService, markerService);
327
instantiationService.stub(IFilesConfigurationService, disposables.add(instantiationService.createInstance(TestFilesConfigurationService)));
328
const userDataProfilesService = instantiationService.stub(IUserDataProfilesService, disposables.add(instantiationService.createInstance(UserDataProfilesService)));
329
instantiationService.stub(IUserDataProfileService, disposables.add(new UserDataProfileService(userDataProfilesService.defaultProfile)));
330
instantiationService.stub(IWorkingCopyBackupService, overrides?.workingCopyBackupService ? overrides?.workingCopyBackupService(instantiationService) : disposables.add(new TestWorkingCopyBackupService()));
331
instantiationService.stub(ITelemetryService, NullTelemetryService);
332
instantiationService.stub(INotificationService, new TestNotificationService());
333
instantiationService.stub(IUntitledTextEditorService, disposables.add(instantiationService.createInstance(UntitledTextEditorService)));
334
instantiationService.stub(IMenuService, new TestMenuService());
335
const keybindingService = new MockKeybindingService();
336
instantiationService.stub(IKeybindingService, keybindingService);
337
instantiationService.stub(IDecorationsService, new TestDecorationsService());
338
instantiationService.stub(IExtensionService, new TestExtensionService());
339
instantiationService.stub(IWorkingCopyFileService, disposables.add(instantiationService.createInstance(WorkingCopyFileService)));
340
instantiationService.stub(ITextFileService, overrides?.textFileService ? overrides.textFileService(instantiationService) : disposables.add(<ITextFileService>instantiationService.createInstance(TestTextFileService)));
341
instantiationService.stub(IHostService, <IHostService>instantiationService.createInstance(TestHostService));
342
instantiationService.stub(ITextModelService, <ITextModelService>disposables.add(instantiationService.createInstance(TextModelResolverService)));
343
instantiationService.stub(ILoggerService, disposables.add(new TestLoggerService(TestEnvironmentService.logsHome)));
344
const editorGroupService = new TestEditorGroupsService([new TestEditorGroupView(0)]);
345
instantiationService.stub(IEditorGroupsService, editorGroupService);
346
instantiationService.stub(ILabelService, <ILabelService>disposables.add(instantiationService.createInstance(LabelService)));
347
const editorService = overrides?.editorService ? overrides.editorService(instantiationService) : disposables.add(new TestEditorService(editorGroupService));
348
instantiationService.stub(IEditorService, editorService);
349
instantiationService.stub(IEditorPaneService, new EditorPaneService());
350
instantiationService.stub(IWorkingCopyEditorService, disposables.add(instantiationService.createInstance(WorkingCopyEditorService)));
351
instantiationService.stub(IEditorResolverService, disposables.add(instantiationService.createInstance(EditorResolverService)));
352
const textEditorService = overrides?.textEditorService ? overrides.textEditorService(instantiationService) : disposables.add(instantiationService.createInstance(TextEditorService));
353
instantiationService.stub(ITextEditorService, textEditorService);
354
instantiationService.stub(ICodeEditorService, disposables.add(new CodeEditorService(editorService, themeService, configService)));
355
instantiationService.stub(IPaneCompositePartService, disposables.add(new TestPaneCompositeService()));
356
instantiationService.stub(IListService, new TestListService());
357
instantiationService.stub(IContextViewService, disposables.add(instantiationService.createInstance(ContextViewService)));
358
instantiationService.stub(IContextMenuService, disposables.add(instantiationService.createInstance(ContextMenuService)));
359
instantiationService.stub(IQuickInputService, disposables.add(new QuickInputService(configService, instantiationService, keybindingService, contextKeyService, themeService, layoutService)));
360
instantiationService.stub(IWorkspacesService, new TestWorkspacesService());
361
instantiationService.stub(IWorkspaceTrustManagementService, disposables.add(new TestWorkspaceTrustManagementService()));
362
instantiationService.stub(IWorkspaceTrustRequestService, disposables.add(new TestWorkspaceTrustRequestService(false)));
363
instantiationService.stub(ITerminalInstanceService, new TestTerminalInstanceService());
364
instantiationService.stub(ITerminalEditorService, new TestTerminalEditorService());
365
instantiationService.stub(ITerminalGroupService, new TestTerminalGroupService());
366
instantiationService.stub(ITerminalProfileService, new TestTerminalProfileService());
367
instantiationService.stub(ITerminalProfileResolverService, new TestTerminalProfileResolverService());
368
instantiationService.stub(ITerminalConfigurationService, disposables.add(instantiationService.createInstance(TestTerminalConfigurationService)));
369
instantiationService.stub(ITerminalLogService, disposables.add(instantiationService.createInstance(TerminalLogService)));
370
instantiationService.stub(IEnvironmentVariableService, disposables.add(instantiationService.createInstance(EnvironmentVariableService)));
371
instantiationService.stub(IElevatedFileService, new BrowserElevatedFileService());
372
instantiationService.stub(IRemoteSocketFactoryService, new RemoteSocketFactoryService());
373
instantiationService.stub(ICustomEditorLabelService, disposables.add(new CustomEditorLabelService(configService, workspaceContextService)));
374
instantiationService.stub(IHoverService, NullHoverService);
375
instantiationService.stub(IChatEntitlementService, new TestChatEntitlementService());
376
instantiationService.stub(IMarkdownRendererService, instantiationService.createInstance(MarkdownRendererService));
377
378
return instantiationService;
379
}
380
381
export class TestServiceAccessor {
382
constructor(
383
@ILifecycleService public lifecycleService: TestLifecycleService,
384
@ITextFileService public textFileService: TestTextFileService,
385
@ITextEditorService public textEditorService: ITextEditorService,
386
@IWorkingCopyFileService public workingCopyFileService: IWorkingCopyFileService,
387
@IFilesConfigurationService public filesConfigurationService: TestFilesConfigurationService,
388
@IWorkspaceContextService public contextService: TestContextService,
389
@IModelService public modelService: ModelService,
390
@IFileService public fileService: TestFileService,
391
@IFileDialogService public fileDialogService: TestFileDialogService,
392
@IDialogService public dialogService: TestDialogService,
393
@IWorkingCopyService public workingCopyService: TestWorkingCopyService,
394
@IEditorService public editorService: TestEditorService,
395
@IEditorPaneService public editorPaneService: IEditorPaneService,
396
@IWorkbenchEnvironmentService public environmentService: IWorkbenchEnvironmentService,
397
@IPathService public pathService: IPathService,
398
@IEditorGroupsService public editorGroupService: IEditorGroupsService,
399
@IEditorResolverService public editorResolverService: IEditorResolverService,
400
@ILanguageService public languageService: ILanguageService,
401
@ITextModelService public textModelResolverService: ITextModelService,
402
@IUntitledTextEditorService public untitledTextEditorService: UntitledTextEditorService,
403
@IConfigurationService public testConfigurationService: TestConfigurationService,
404
@IWorkingCopyBackupService public workingCopyBackupService: TestWorkingCopyBackupService,
405
@IHostService public hostService: TestHostService,
406
@IQuickInputService public quickInputService: IQuickInputService,
407
@ILabelService public labelService: ILabelService,
408
@ILogService public logService: ILogService,
409
@IUriIdentityService public uriIdentityService: IUriIdentityService,
410
@IInstantiationService public instantitionService: IInstantiationService,
411
@INotificationService public notificationService: INotificationService,
412
@IWorkingCopyEditorService public workingCopyEditorService: IWorkingCopyEditorService,
413
@IInstantiationService public instantiationService: IInstantiationService,
414
@IElevatedFileService public elevatedFileService: IElevatedFileService,
415
@IWorkspaceTrustRequestService public workspaceTrustRequestService: TestWorkspaceTrustRequestService,
416
@IDecorationsService public decorationsService: IDecorationsService,
417
@IProgressService public progressService: IProgressService,
418
) { }
419
}
420
421
export class TestTextFileService extends BrowserTextFileService {
422
private readStreamError: FileOperationError | undefined = undefined;
423
private writeError: FileOperationError | undefined = undefined;
424
425
constructor(
426
@IFileService fileService: IFileService,
427
@IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorModelManager,
428
@ILifecycleService lifecycleService: ILifecycleService,
429
@IInstantiationService instantiationService: IInstantiationService,
430
@IModelService modelService: IModelService,
431
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
432
@IDialogService dialogService: IDialogService,
433
@IFileDialogService fileDialogService: IFileDialogService,
434
@ITextResourceConfigurationService textResourceConfigurationService: ITextResourceConfigurationService,
435
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService,
436
@ICodeEditorService codeEditorService: ICodeEditorService,
437
@IPathService pathService: IPathService,
438
@IWorkingCopyFileService workingCopyFileService: IWorkingCopyFileService,
439
@IUriIdentityService uriIdentityService: IUriIdentityService,
440
@ILanguageService languageService: ILanguageService,
441
@ILogService logService: ILogService,
442
@IElevatedFileService elevatedFileService: IElevatedFileService,
443
@IDecorationsService decorationsService: IDecorationsService
444
) {
445
super(
446
fileService,
447
untitledTextEditorService,
448
lifecycleService,
449
instantiationService,
450
modelService,
451
environmentService,
452
dialogService,
453
fileDialogService,
454
textResourceConfigurationService,
455
filesConfigurationService,
456
codeEditorService,
457
pathService,
458
workingCopyFileService,
459
uriIdentityService,
460
languageService,
461
elevatedFileService,
462
logService,
463
decorationsService
464
);
465
}
466
467
setReadStreamErrorOnce(error: FileOperationError): void {
468
this.readStreamError = error;
469
}
470
471
override async readStream(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileStreamContent> {
472
if (this.readStreamError) {
473
const error = this.readStreamError;
474
this.readStreamError = undefined;
475
476
throw error;
477
}
478
479
const content = await this.fileService.readFileStream(resource, options);
480
return {
481
resource: content.resource,
482
name: content.name,
483
mtime: content.mtime,
484
ctime: content.ctime,
485
etag: content.etag,
486
encoding: 'utf8',
487
value: await createTextBufferFactoryFromStream(content.value),
488
size: 10,
489
readonly: false,
490
locked: false,
491
executable: false
492
};
493
}
494
495
setWriteErrorOnce(error: FileOperationError): void {
496
this.writeError = error;
497
}
498
499
override async write(resource: URI, value: string | ITextSnapshot, options?: IWriteTextFileOptions): Promise<IFileStatWithMetadata> {
500
if (this.writeError) {
501
const error = this.writeError;
502
this.writeError = undefined;
503
504
throw error;
505
}
506
507
return super.write(resource, value, options);
508
}
509
}
510
511
export class TestBrowserTextFileServiceWithEncodingOverrides extends BrowserTextFileService {
512
513
private _testEncoding: TestEncodingOracle | undefined;
514
override get encoding(): TestEncodingOracle {
515
if (!this._testEncoding) {
516
this._testEncoding = this._register(this.instantiationService.createInstance(TestEncodingOracle));
517
}
518
519
return this._testEncoding;
520
}
521
}
522
523
export class TestEncodingOracle extends EncodingOracle {
524
525
protected override get encodingOverrides(): IEncodingOverride[] {
526
return [
527
{ extension: 'utf16le', encoding: UTF16le },
528
{ extension: 'utf16be', encoding: UTF16be },
529
{ extension: 'utf8bom', encoding: UTF8_with_bom }
530
];
531
}
532
533
protected override set encodingOverrides(overrides: IEncodingOverride[]) { }
534
}
535
536
class TestEnvironmentServiceWithArgs extends BrowserWorkbenchEnvironmentService {
537
args = [];
538
}
539
540
export const TestEnvironmentService = new TestEnvironmentServiceWithArgs('', URI.file('tests').with({ scheme: 'vscode-tests' }), Object.create(null), TestProductService);
541
542
export class TestProgressService implements IProgressService {
543
544
declare readonly _serviceBrand: undefined;
545
546
withProgress(
547
options: IProgressOptions | IProgressDialogOptions | IProgressWindowOptions | IProgressNotificationOptions | IProgressCompositeOptions,
548
task: (progress: IProgress<IProgressStep>) => Promise<any>,
549
onDidCancel?: ((choice?: number | undefined) => void) | undefined
550
): Promise<any> {
551
return task(Progress.None);
552
}
553
}
554
555
export class TestDecorationsService implements IDecorationsService {
556
557
declare readonly _serviceBrand: undefined;
558
559
readonly onDidChangeDecorations: Event<IResourceDecorationChangeEvent> = Event.None;
560
561
registerDecorationsProvider(_provider: IDecorationsProvider): IDisposable { return Disposable.None; }
562
getDecoration(_uri: URI, _includeChildren: boolean, _overwrite?: IDecorationData): IDecoration | undefined { return undefined; }
563
}
564
565
export class TestMenuService implements IMenuService {
566
567
declare readonly _serviceBrand: undefined;
568
569
createMenu(_id: MenuId, _scopedKeybindingService: IContextKeyService): IMenu {
570
return {
571
onDidChange: Event.None,
572
dispose: () => undefined,
573
getActions: () => []
574
};
575
}
576
577
getMenuActions(id: MenuId, contextKeyService: IContextKeyService, options?: IMenuActionOptions): [string, Array<MenuItemAction | SubmenuItemAction>][] {
578
throw new Error('Method not implemented.');
579
}
580
581
getMenuContexts(id: MenuId): ReadonlySet<string> {
582
throw new Error('Method not implemented.');
583
}
584
585
resetHiddenStates(): void {
586
// nothing
587
}
588
}
589
590
export class TestFileDialogService implements IFileDialogService {
591
592
declare readonly _serviceBrand: undefined;
593
594
private confirmResult!: ConfirmResult;
595
596
constructor(
597
@IPathService private readonly pathService: IPathService
598
) { }
599
async defaultFilePath(_schemeFilter?: string): Promise<URI> { return this.pathService.userHome(); }
600
async defaultFolderPath(_schemeFilter?: string): Promise<URI> { return this.pathService.userHome(); }
601
async defaultWorkspacePath(_schemeFilter?: string): Promise<URI> { return this.pathService.userHome(); }
602
async preferredHome(_schemeFilter?: string): Promise<URI> { return this.pathService.userHome(); }
603
pickFileFolderAndOpen(_options: IPickAndOpenOptions): Promise<any> { return Promise.resolve(0); }
604
pickFileAndOpen(_options: IPickAndOpenOptions): Promise<any> { return Promise.resolve(0); }
605
pickFolderAndOpen(_options: IPickAndOpenOptions): Promise<any> { return Promise.resolve(0); }
606
pickWorkspaceAndOpen(_options: IPickAndOpenOptions): Promise<any> { return Promise.resolve(0); }
607
608
private fileToSave!: URI;
609
setPickFileToSave(path: URI): void { this.fileToSave = path; }
610
pickFileToSave(defaultUri: URI, availableFileSystems?: string[]): Promise<URI | undefined> { return Promise.resolve(this.fileToSave); }
611
612
showSaveDialog(_options: ISaveDialogOptions): Promise<URI | undefined> { return Promise.resolve(undefined); }
613
showOpenDialog(_options: IOpenDialogOptions): Promise<URI[] | undefined> { return Promise.resolve(undefined); }
614
615
setConfirmResult(result: ConfirmResult): void { this.confirmResult = result; }
616
showSaveConfirm(fileNamesOrResources: (string | URI)[]): Promise<ConfirmResult> { return Promise.resolve(this.confirmResult); }
617
}
618
619
export class TestLayoutService implements IWorkbenchLayoutService {
620
621
declare readonly _serviceBrand: undefined;
622
623
openedDefaultEditors = false;
624
625
mainContainerDimension: IDimension = { width: 800, height: 600 };
626
activeContainerDimension: IDimension = { width: 800, height: 600 };
627
mainContainerOffset: ILayoutOffsetInfo = { top: 0, quickPickTop: 0 };
628
activeContainerOffset: ILayoutOffsetInfo = { top: 0, quickPickTop: 0 };
629
630
mainContainer: HTMLElement = mainWindow.document.body;
631
containers = [mainWindow.document.body];
632
activeContainer: HTMLElement = mainWindow.document.body;
633
634
readonly onDidChangeZenMode: Event<boolean> = Event.None;
635
readonly onDidChangeMainEditorCenteredLayout: Event<boolean> = Event.None;
636
readonly onDidChangeWindowMaximized: Event<{ windowId: number; maximized: boolean }> = Event.None;
637
readonly onDidChangePanelPosition: Event<string> = Event.None;
638
readonly onDidChangePanelAlignment: Event<PanelAlignment> = Event.None;
639
readonly onDidChangePartVisibility: Event<void> = Event.None;
640
onDidLayoutMainContainer = Event.None;
641
onDidLayoutActiveContainer = Event.None;
642
onDidLayoutContainer = Event.None;
643
onDidChangeNotificationsVisibility = Event.None;
644
onDidAddContainer = Event.None;
645
onDidChangeActiveContainer = Event.None;
646
onDidChangeAuxiliaryBarMaximized = Event.None;
647
648
layout(): void { }
649
isRestored(): boolean { return true; }
650
whenReady: Promise<void> = Promise.resolve(undefined);
651
whenRestored: Promise<void> = Promise.resolve(undefined);
652
hasFocus(_part: Parts): boolean { return false; }
653
focusPart(_part: Parts): void { }
654
hasMainWindowBorder(): boolean { return false; }
655
getMainWindowBorderRadius(): string | undefined { return undefined; }
656
isVisible(_part: Parts): boolean { return true; }
657
getContainer(): HTMLElement { return mainWindow.document.body; }
658
whenContainerStylesLoaded() { return undefined; }
659
isTitleBarHidden(): boolean { return false; }
660
isStatusBarHidden(): boolean { return false; }
661
isActivityBarHidden(): boolean { return false; }
662
setActivityBarHidden(_hidden: boolean): void { }
663
setBannerHidden(_hidden: boolean): void { }
664
isSideBarHidden(): boolean { return false; }
665
async setEditorHidden(_hidden: boolean): Promise<void> { }
666
async setSideBarHidden(_hidden: boolean): Promise<void> { }
667
async setAuxiliaryBarHidden(_hidden: boolean): Promise<void> { }
668
async setPartHidden(_hidden: boolean, part: Parts): Promise<void> { }
669
isPanelHidden(): boolean { return false; }
670
async setPanelHidden(_hidden: boolean): Promise<void> { }
671
toggleMaximizedPanel(): void { }
672
isPanelMaximized(): boolean { return false; }
673
toggleMaximizedAuxiliaryBar(): void { }
674
setAuxiliaryBarMaximized(maximized: boolean): boolean { return false; }
675
isAuxiliaryBarMaximized(): boolean { return false; }
676
getMenubarVisibility(): MenuBarVisibility { throw new Error('not implemented'); }
677
toggleMenuBar(): void { }
678
getSideBarPosition() { return 0; }
679
getPanelPosition() { return 0; }
680
getPanelAlignment(): PanelAlignment { return 'center'; }
681
async setPanelPosition(_position: PartPosition): Promise<void> { }
682
async setPanelAlignment(_alignment: PanelAlignment): Promise<void> { }
683
addClass(_clazz: string): void { }
684
removeClass(_clazz: string): void { }
685
getMaximumEditorDimensions(): IDimension { throw new Error('not implemented'); }
686
toggleZenMode(): void { }
687
isMainEditorLayoutCentered(): boolean { return false; }
688
centerMainEditorLayout(_active: boolean): void { }
689
resizePart(_part: Parts, _sizeChangeWidth: number, _sizeChangeHeight: number): void { }
690
getSize(part: Parts): IViewSize { throw new Error('Method not implemented.'); }
691
setSize(part: Parts, size: IViewSize): void { throw new Error('Method not implemented.'); }
692
registerPart(part: Part): IDisposable { return Disposable.None; }
693
isWindowMaximized(targetWindow: Window) { return false; }
694
updateWindowMaximizedState(targetWindow: Window, maximized: boolean): void { }
695
getVisibleNeighborPart(part: Parts, direction: Direction): Parts | undefined { return undefined; }
696
focus() { }
697
}
698
699
// eslint-disable-next-line local/code-no-any-casts
700
const activeViewlet: PaneComposite = {} as any;
701
702
export class TestPaneCompositeService extends Disposable implements IPaneCompositePartService {
703
declare readonly _serviceBrand: undefined;
704
705
readonly onDidPaneCompositeOpen: Event<{ composite: IPaneComposite; viewContainerLocation: ViewContainerLocation }>;
706
readonly onDidPaneCompositeClose: Event<{ composite: IPaneComposite; viewContainerLocation: ViewContainerLocation }>;
707
708
private parts = new Map<ViewContainerLocation, IPaneCompositePart>();
709
710
constructor() {
711
super();
712
713
this.parts.set(ViewContainerLocation.Panel, new TestPanelPart());
714
this.parts.set(ViewContainerLocation.Sidebar, new TestSideBarPart());
715
716
this.onDidPaneCompositeOpen = Event.any(...([ViewContainerLocation.Panel, ViewContainerLocation.Sidebar].map(loc => Event.map(this.parts.get(loc)!.onDidPaneCompositeOpen, composite => { return { composite, viewContainerLocation: loc }; }))));
717
this.onDidPaneCompositeClose = Event.any(...([ViewContainerLocation.Panel, ViewContainerLocation.Sidebar].map(loc => Event.map(this.parts.get(loc)!.onDidPaneCompositeClose, composite => { return { composite, viewContainerLocation: loc }; }))));
718
}
719
720
openPaneComposite(id: string | undefined, viewContainerLocation: ViewContainerLocation, focus?: boolean): Promise<IPaneComposite | undefined> {
721
return this.getPartByLocation(viewContainerLocation).openPaneComposite(id, focus);
722
}
723
getActivePaneComposite(viewContainerLocation: ViewContainerLocation): IPaneComposite | undefined {
724
return this.getPartByLocation(viewContainerLocation).getActivePaneComposite();
725
}
726
getPaneComposite(id: string, viewContainerLocation: ViewContainerLocation): PaneCompositeDescriptor | undefined {
727
return this.getPartByLocation(viewContainerLocation).getPaneComposite(id);
728
}
729
getPaneComposites(viewContainerLocation: ViewContainerLocation): PaneCompositeDescriptor[] {
730
return this.getPartByLocation(viewContainerLocation).getPaneComposites();
731
}
732
getProgressIndicator(id: string, viewContainerLocation: ViewContainerLocation): IProgressIndicator | undefined {
733
return this.getPartByLocation(viewContainerLocation).getProgressIndicator(id);
734
}
735
hideActivePaneComposite(viewContainerLocation: ViewContainerLocation): void {
736
this.getPartByLocation(viewContainerLocation).hideActivePaneComposite();
737
}
738
getLastActivePaneCompositeId(viewContainerLocation: ViewContainerLocation): string {
739
return this.getPartByLocation(viewContainerLocation).getLastActivePaneCompositeId();
740
}
741
742
getPinnedPaneCompositeIds(viewContainerLocation: ViewContainerLocation): string[] {
743
throw new Error('Method not implemented.');
744
}
745
746
getVisiblePaneCompositeIds(viewContainerLocation: ViewContainerLocation): string[] {
747
throw new Error('Method not implemented.');
748
}
749
750
getPaneCompositeIds(viewContainerLocation: ViewContainerLocation): string[] {
751
throw new Error('Method not implemented.');
752
}
753
754
getPartByLocation(viewContainerLocation: ViewContainerLocation): IPaneCompositePart {
755
return assertReturnsDefined(this.parts.get(viewContainerLocation));
756
}
757
}
758
759
export class TestSideBarPart implements IPaneCompositePart {
760
declare readonly _serviceBrand: undefined;
761
762
onDidViewletRegisterEmitter = new Emitter<PaneCompositeDescriptor>();
763
onDidViewletDeregisterEmitter = new Emitter<PaneCompositeDescriptor>();
764
onDidViewletOpenEmitter = new Emitter<IPaneComposite>();
765
onDidViewletCloseEmitter = new Emitter<IPaneComposite>();
766
767
readonly partId = Parts.SIDEBAR_PART;
768
element: HTMLElement = undefined!;
769
minimumWidth = 0;
770
maximumWidth = 0;
771
minimumHeight = 0;
772
maximumHeight = 0;
773
onDidChange = Event.None;
774
onDidPaneCompositeOpen = this.onDidViewletOpenEmitter.event;
775
onDidPaneCompositeClose = this.onDidViewletCloseEmitter.event;
776
777
openPaneComposite(id: string, focus?: boolean): Promise<IPaneComposite | undefined> { return Promise.resolve(undefined); }
778
getPaneComposites(): PaneCompositeDescriptor[] { return []; }
779
getAllViewlets(): PaneCompositeDescriptor[] { return []; }
780
getActivePaneComposite(): IPaneComposite { return activeViewlet; }
781
getDefaultViewletId(): string { return 'workbench.view.explorer'; }
782
getPaneComposite(id: string): PaneCompositeDescriptor | undefined { return undefined; }
783
getProgressIndicator(id: string) { return undefined; }
784
hideActivePaneComposite(): void { }
785
getLastActivePaneCompositeId(): string { return undefined!; }
786
dispose() { }
787
getPinnedPaneCompositeIds() { return []; }
788
getVisiblePaneCompositeIds() { return []; }
789
getPaneCompositeIds() { return []; }
790
layout(width: number, height: number, top: number, left: number): void { }
791
}
792
793
export class TestPanelPart implements IPaneCompositePart {
794
declare readonly _serviceBrand: undefined;
795
796
element: HTMLElement = undefined!;
797
minimumWidth = 0;
798
maximumWidth = 0;
799
minimumHeight = 0;
800
maximumHeight = 0;
801
onDidChange = Event.None;
802
onDidPaneCompositeOpen = new Emitter<IPaneComposite>().event;
803
onDidPaneCompositeClose = new Emitter<IPaneComposite>().event;
804
readonly partId = Parts.AUXILIARYBAR_PART;
805
806
async openPaneComposite(id?: string, focus?: boolean): Promise<undefined> { return undefined; }
807
getPaneComposite(id: string): any { return activeViewlet; }
808
getPaneComposites() { return []; }
809
getPinnedPaneCompositeIds() { return []; }
810
getVisiblePaneCompositeIds() { return []; }
811
getPaneCompositeIds() { return []; }
812
getActivePaneComposite(): IPaneComposite { return activeViewlet; }
813
setPanelEnablement(id: string, enabled: boolean): void { }
814
dispose() { }
815
getProgressIndicator(id: string) { return null!; }
816
hideActivePaneComposite(): void { }
817
getLastActivePaneCompositeId(): string { return undefined!; }
818
layout(width: number, height: number, top: number, left: number): void { }
819
}
820
821
export class TestViewsService implements IViewsService {
822
declare readonly _serviceBrand: undefined;
823
824
825
onDidChangeViewContainerVisibility = new Emitter<{ id: string; visible: boolean; location: ViewContainerLocation }>().event;
826
isViewContainerVisible(id: string): boolean { return true; }
827
isViewContainerActive(id: string): boolean { return true; }
828
getVisibleViewContainer(): ViewContainer | null { return null; }
829
openViewContainer(id: string, focus?: boolean): Promise<IPaneComposite | null> { return Promise.resolve(null); }
830
closeViewContainer(id: string): void { }
831
832
onDidChangeViewVisibilityEmitter = new Emitter<{ id: string; visible: boolean }>();
833
onDidChangeViewVisibility = this.onDidChangeViewVisibilityEmitter.event;
834
onDidChangeFocusedViewEmitter = new Emitter<void>();
835
onDidChangeFocusedView = this.onDidChangeFocusedViewEmitter.event;
836
isViewVisible(id: string): boolean { return true; }
837
getActiveViewWithId<T extends IView>(id: string): T | null { return null; }
838
getViewWithId<T extends IView>(id: string): T | null { return null; }
839
openView<T extends IView>(id: string, focus?: boolean | undefined): Promise<T | null> { return Promise.resolve(null); }
840
closeView(id: string): void { }
841
getViewProgressIndicator(id: string) { return null!; }
842
getActiveViewPaneContainerWithId(id: string) { return null; }
843
getFocusedViewName(): string { return ''; }
844
getFocusedView(): IViewDescriptor | null { return null; }
845
}
846
847
export class TestEditorGroupsService implements IEditorGroupsService {
848
849
declare readonly _serviceBrand: undefined;
850
851
constructor(public groups: TestEditorGroupView[] = []) { }
852
853
readonly parts: readonly IEditorPart[] = [this];
854
855
windowId = mainWindow.vscodeWindowId;
856
857
readonly onDidCreateAuxiliaryEditorPart: Event<IAuxiliaryEditorPart> = Event.None;
858
readonly onDidChangeActiveGroup: Event<IEditorGroup> = Event.None;
859
readonly onDidActivateGroup: Event<IEditorGroup> = Event.None;
860
readonly onDidAddGroup: Event<IEditorGroup> = Event.None;
861
readonly onDidRemoveGroup: Event<IEditorGroup> = Event.None;
862
readonly onDidMoveGroup: Event<IEditorGroup> = Event.None;
863
readonly onDidChangeGroupIndex: Event<IEditorGroup> = Event.None;
864
readonly onDidChangeGroupLabel: Event<IEditorGroup> = Event.None;
865
readonly onDidChangeGroupLocked: Event<IEditorGroup> = Event.None;
866
readonly onDidChangeGroupMaximized: Event<boolean> = Event.None;
867
readonly onDidLayout: Event<IDimension> = Event.None;
868
onDidChangeEditorPartOptions = Event.None;
869
onDidScroll = Event.None;
870
onWillDispose = Event.None;
871
872
orientation = GroupOrientation.HORIZONTAL;
873
isReady = true;
874
whenReady: Promise<void> = Promise.resolve(undefined);
875
whenRestored: Promise<void> = Promise.resolve(undefined);
876
hasRestorableState = false;
877
878
contentDimension = { width: 800, height: 600 };
879
880
get activeGroup(): IEditorGroup { return this.groups[0]; }
881
get sideGroup(): IEditorGroup { return this.groups[0]; }
882
get count(): number { return this.groups.length; }
883
884
getPart(group: number | IEditorGroup): IEditorPart { return this; }
885
saveWorkingSet(name: string): IEditorWorkingSet { throw new Error('Method not implemented.'); }
886
getWorkingSets(): IEditorWorkingSet[] { throw new Error('Method not implemented.'); }
887
applyWorkingSet(workingSet: IEditorWorkingSet | 'empty', options?: IEditorWorkingSetOptions): Promise<boolean> { throw new Error('Method not implemented.'); }
888
deleteWorkingSet(workingSet: IEditorWorkingSet): Promise<boolean> { throw new Error('Method not implemented.'); }
889
getGroups(_order?: GroupsOrder): readonly IEditorGroup[] { return this.groups; }
890
getGroup(identifier: number): IEditorGroup | undefined { return this.groups.find(group => group.id === identifier); }
891
getLabel(_identifier: number): string { return 'Group 1'; }
892
findGroup(_scope: IFindGroupScope, _source?: number | IEditorGroup, _wrap?: boolean): IEditorGroup { throw new Error('not implemented'); }
893
activateGroup(_group: number | IEditorGroup): IEditorGroup { throw new Error('not implemented'); }
894
restoreGroup(_group: number | IEditorGroup): IEditorGroup { throw new Error('not implemented'); }
895
getSize(_group: number | IEditorGroup): { width: number; height: number } { return { width: 100, height: 100 }; }
896
setSize(_group: number | IEditorGroup, _size: { width: number; height: number }): void { }
897
arrangeGroups(_arrangement: GroupsArrangement): void { }
898
toggleMaximizeGroup(): void { }
899
hasMaximizedGroup(): boolean { throw new Error('not implemented'); }
900
toggleExpandGroup(): void { }
901
applyLayout(_layout: EditorGroupLayout): void { }
902
getLayout(): EditorGroupLayout { throw new Error('not implemented'); }
903
setGroupOrientation(_orientation: GroupOrientation): void { }
904
addGroup(_location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup { throw new Error('not implemented'); }
905
removeGroup(_group: number | IEditorGroup): void { }
906
moveGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup { throw new Error('not implemented'); }
907
mergeGroup(_group: number | IEditorGroup, _target: number | IEditorGroup, _options?: IMergeGroupOptions): boolean { throw new Error('not implemented'); }
908
mergeAllGroups(_group: number | IEditorGroup, _options?: IMergeGroupOptions): boolean { throw new Error('not implemented'); }
909
copyGroup(_group: number | IEditorGroup, _location: number | IEditorGroup, _direction: GroupDirection): IEditorGroup { throw new Error('not implemented'); }
910
centerLayout(active: boolean): void { }
911
isLayoutCentered(): boolean { return false; }
912
createEditorDropTarget(container: HTMLElement, delegate: IEditorDropTargetDelegate): IDisposable { return Disposable.None; }
913
registerContextKeyProvider<T extends ContextKeyValue>(_provider: IEditorGroupContextKeyProvider<T>): IDisposable { throw new Error('not implemented'); }
914
getScopedInstantiationService(part: IEditorPart): IInstantiationService { throw new Error('Method not implemented.'); }
915
916
partOptions!: IEditorPartOptions;
917
enforcePartOptions(options: IEditorPartOptions): IDisposable { return Disposable.None; }
918
919
readonly mainPart = this;
920
registerEditorPart(part: any): IDisposable { return Disposable.None; }
921
createAuxiliaryEditorPart(): Promise<IAuxiliaryEditorPart> { throw new Error('Method not implemented.'); }
922
}
923
924
export class TestEditorGroupView implements IEditorGroupView {
925
926
constructor(public id: number) { }
927
928
windowId = mainWindow.vscodeWindowId;
929
groupsView: IEditorGroupsView = undefined!;
930
activeEditorPane!: IVisibleEditorPane;
931
activeEditor!: EditorInput;
932
selectedEditors: EditorInput[] = [];
933
previewEditor!: EditorInput;
934
count!: number;
935
stickyCount!: number;
936
disposed!: boolean;
937
editors: readonly EditorInput[] = [];
938
label!: string;
939
isLocked!: boolean;
940
ariaLabel!: string;
941
index!: number;
942
whenRestored: Promise<void> = Promise.resolve(undefined);
943
element!: HTMLElement;
944
minimumWidth!: number;
945
maximumWidth!: number;
946
minimumHeight!: number;
947
maximumHeight!: number;
948
949
titleHeight!: IEditorGroupTitleHeight;
950
951
isEmpty = true;
952
953
readonly onWillDispose: Event<void> = Event.None;
954
readonly onDidModelChange: Event<IGroupModelChangeEvent> = Event.None;
955
readonly onWillCloseEditor: Event<IEditorCloseEvent> = Event.None;
956
readonly onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
957
readonly onDidOpenEditorFail: Event<EditorInput> = Event.None;
958
readonly onDidFocus: Event<void> = Event.None;
959
readonly onDidChange: Event<{ width: number; height: number }> = Event.None;
960
readonly onWillMoveEditor: Event<IEditorWillMoveEvent> = Event.None;
961
readonly onWillOpenEditor: Event<IEditorWillOpenEvent> = Event.None;
962
readonly onDidActiveEditorChange: Event<IActiveEditorChangeEvent> = Event.None;
963
964
getEditors(_order?: EditorsOrder): readonly EditorInput[] { return []; }
965
findEditors(_resource: URI): readonly EditorInput[] { return []; }
966
getEditorByIndex(_index: number): EditorInput { throw new Error('not implemented'); }
967
getIndexOfEditor(_editor: EditorInput): number { return -1; }
968
isFirst(editor: EditorInput): boolean { return false; }
969
isLast(editor: EditorInput): boolean { return false; }
970
openEditor(_editor: EditorInput, _options?: IEditorOptions): Promise<IEditorPane> { throw new Error('not implemented'); }
971
openEditors(_editors: EditorInputWithOptions[]): Promise<IEditorPane> { throw new Error('not implemented'); }
972
isPinned(_editor: EditorInput): boolean { return false; }
973
isSticky(_editor: EditorInput): boolean { return false; }
974
isTransient(_editor: EditorInput): boolean { return false; }
975
isActive(_editor: EditorInput | IUntypedEditorInput): boolean { return false; }
976
setSelection(_activeSelectedEditor: EditorInput, _inactiveSelectedEditors: EditorInput[]): Promise<void> { throw new Error('not implemented'); }
977
isSelected(_editor: EditorInput): boolean { return false; }
978
contains(candidate: EditorInput | IUntypedEditorInput): boolean { return false; }
979
moveEditor(_editor: EditorInput, _target: IEditorGroup, _options?: IEditorOptions): boolean { return true; }
980
moveEditors(_editors: EditorInputWithOptions[], _target: IEditorGroup): boolean { return true; }
981
copyEditor(_editor: EditorInput, _target: IEditorGroup, _options?: IEditorOptions): void { }
982
copyEditors(_editors: EditorInputWithOptions[], _target: IEditorGroup): void { }
983
async closeEditor(_editor?: EditorInput, options?: ICloseEditorOptions): Promise<boolean> { return true; }
984
async closeEditors(_editors: EditorInput[] | ICloseEditorsFilter, options?: ICloseEditorOptions): Promise<boolean> { return true; }
985
closeAllEditors(options?: ICloseAllEditorsOptions): any { return true; }
986
async replaceEditors(_editors: IEditorReplacement[]): Promise<void> { }
987
pinEditor(_editor?: EditorInput): void { }
988
stickEditor(editor?: EditorInput | undefined): void { }
989
unstickEditor(editor?: EditorInput | undefined): void { }
990
lock(locked: boolean): void { }
991
focus(): void { }
992
get scopedContextKeyService(): IContextKeyService { throw new Error('not implemented'); }
993
setActive(_isActive: boolean): void { }
994
notifyIndexChanged(_index: number): void { }
995
notifyLabelChanged(_label: string): void { }
996
dispose(): void { }
997
toJSON(): object { return Object.create(null); }
998
layout(_width: number, _height: number): void { }
999
relayout() { }
1000
createEditorActions(_menuDisposable: IDisposable): { actions: IToolbarActions; onDidChange: Event<IMenuChangeEvent> } { throw new Error('not implemented'); }
1001
}
1002
1003
export class TestEditorGroupAccessor implements IEditorGroupsView {
1004
1005
label: string = '';
1006
windowId = mainWindow.vscodeWindowId;
1007
1008
groups: IEditorGroupView[] = [];
1009
activeGroup!: IEditorGroupView;
1010
1011
partOptions: IEditorPartOptions = { ...DEFAULT_EDITOR_PART_OPTIONS };
1012
1013
onDidChangeEditorPartOptions = Event.None;
1014
onDidVisibilityChange = Event.None;
1015
1016
getGroup(identifier: number): IEditorGroupView | undefined { throw new Error('Method not implemented.'); }
1017
getGroups(order: GroupsOrder): IEditorGroupView[] { throw new Error('Method not implemented.'); }
1018
activateGroup(identifier: number | IEditorGroupView): IEditorGroupView { throw new Error('Method not implemented.'); }
1019
restoreGroup(identifier: number | IEditorGroupView): IEditorGroupView { throw new Error('Method not implemented.'); }
1020
addGroup(location: number | IEditorGroupView, direction: GroupDirection): IEditorGroupView { throw new Error('Method not implemented.'); }
1021
mergeGroup(group: number | IEditorGroupView, target: number | IEditorGroupView, options?: IMergeGroupOptions | undefined): boolean { throw new Error('Method not implemented.'); }
1022
moveGroup(group: number | IEditorGroupView, location: number | IEditorGroupView, direction: GroupDirection): IEditorGroupView { throw new Error('Method not implemented.'); }
1023
copyGroup(group: number | IEditorGroupView, location: number | IEditorGroupView, direction: GroupDirection): IEditorGroupView { throw new Error('Method not implemented.'); }
1024
removeGroup(group: number | IEditorGroupView): void { throw new Error('Method not implemented.'); }
1025
arrangeGroups(arrangement: GroupsArrangement, target?: number | IEditorGroupView | undefined): void { throw new Error('Method not implemented.'); }
1026
toggleMaximizeGroup(group: number | IEditorGroupView): void { throw new Error('Method not implemented.'); }
1027
toggleExpandGroup(group: number | IEditorGroupView): void { throw new Error('Method not implemented.'); }
1028
}
1029
1030
export class TestEditorService extends Disposable implements EditorServiceImpl {
1031
1032
declare readonly _serviceBrand: undefined;
1033
1034
readonly onDidActiveEditorChange: Event<void> = Event.None;
1035
readonly onDidVisibleEditorsChange: Event<void> = Event.None;
1036
readonly onDidEditorsChange: Event<IEditorsChangeEvent> = Event.None;
1037
readonly onWillOpenEditor: Event<IEditorWillOpenEvent> = Event.None;
1038
readonly onDidCloseEditor: Event<IEditorCloseEvent> = Event.None;
1039
readonly onDidOpenEditorFail: Event<IEditorIdentifier> = Event.None;
1040
readonly onDidMostRecentlyActiveEditorsChange: Event<void> = Event.None;
1041
1042
private _activeTextEditorControl: ICodeEditor | IDiffEditor | undefined;
1043
public get activeTextEditorControl(): ICodeEditor | IDiffEditor | undefined { return this._activeTextEditorControl; }
1044
public set activeTextEditorControl(value: ICodeEditor | IDiffEditor | undefined) { this._activeTextEditorControl = value; }
1045
1046
activeEditorPane: IVisibleEditorPane | undefined;
1047
activeTextEditorLanguageId: string | undefined;
1048
1049
private _activeEditor: EditorInput | undefined;
1050
public get activeEditor(): EditorInput | undefined { return this._activeEditor; }
1051
public set activeEditor(value: EditorInput | undefined) { this._activeEditor = value; }
1052
1053
editors: readonly EditorInput[] = [];
1054
mostRecentlyActiveEditors: readonly IEditorIdentifier[] = [];
1055
visibleEditorPanes: readonly IVisibleEditorPane[] = [];
1056
visibleTextEditorControls = [];
1057
getVisibleTextEditorControls(order: EditorsOrder): readonly (IEditor | IDiffEditor)[] { return this.visibleTextEditorControls; }
1058
visibleEditors: readonly EditorInput[] = [];
1059
count = this.editors.length;
1060
1061
constructor(private editorGroupService?: IEditorGroupsService) {
1062
super();
1063
}
1064
createScoped(editorGroupsContainer: IEditorGroupsContainer): IEditorService { return this; }
1065
getEditors() { return []; }
1066
// eslint-disable-next-line local/code-no-any-casts
1067
findEditors() { return [] as any; }
1068
openEditor(editor: EditorInput, options?: IEditorOptions, group?: PreferredGroup): Promise<IEditorPane | undefined>;
1069
openEditor(editor: IResourceEditorInput | IUntitledTextResourceEditorInput, group?: PreferredGroup): Promise<IEditorPane | undefined>;
1070
openEditor(editor: IResourceDiffEditorInput, group?: PreferredGroup): Promise<ITextDiffEditorPane | undefined>;
1071
async openEditor(editor: EditorInput | IUntypedEditorInput, optionsOrGroup?: IEditorOptions | PreferredGroup, group?: PreferredGroup): Promise<IEditorPane | undefined> {
1072
// openEditor takes ownership of the input, register it to the TestEditorService
1073
// so it's not marked as leaked during tests.
1074
if ('dispose' in editor) {
1075
this._register(editor);
1076
}
1077
return undefined;
1078
}
1079
async closeEditor(editor: IEditorIdentifier, options?: ICloseEditorOptions): Promise<void> { }
1080
async closeEditors(editors: IEditorIdentifier[], options?: ICloseEditorOptions): Promise<void> { }
1081
doResolveEditorOpenRequest(editor: EditorInput | IUntypedEditorInput): [IEditorGroup, EditorInput, IEditorOptions | undefined] | undefined {
1082
if (!this.editorGroupService) {
1083
return undefined;
1084
}
1085
1086
return [this.editorGroupService.activeGroup, editor as EditorInput, undefined];
1087
}
1088
openEditors(_editors: any, _group?: any): Promise<IEditorPane[]> { throw new Error('not implemented'); }
1089
isOpened(_editor: IResourceEditorInputIdentifier): boolean { return false; }
1090
isVisible(_editor: EditorInput): boolean { return false; }
1091
replaceEditors(_editors: any, _group: any) { return Promise.resolve(undefined); }
1092
save(editors: IEditorIdentifier[], options?: ISaveEditorsOptions): Promise<ISaveEditorsResult> { throw new Error('Method not implemented.'); }
1093
saveAll(options?: ISaveEditorsOptions): Promise<ISaveEditorsResult> { throw new Error('Method not implemented.'); }
1094
revert(editors: IEditorIdentifier[], options?: IRevertOptions): Promise<boolean> { throw new Error('Method not implemented.'); }
1095
revertAll(options?: IRevertAllEditorsOptions): Promise<boolean> { throw new Error('Method not implemented.'); }
1096
}
1097
1098
export class TestWorkingCopyBackupService extends InMemoryWorkingCopyBackupService {
1099
1100
readonly resolved: Set<IWorkingCopyIdentifier> = new Set();
1101
1102
constructor() {
1103
super();
1104
}
1105
1106
parseBackupContent(textBufferFactory: ITextBufferFactory): string {
1107
const textBuffer = textBufferFactory.create(DefaultEndOfLine.LF).textBuffer;
1108
const lineCount = textBuffer.getLineCount();
1109
const range = new Range(1, 1, lineCount, textBuffer.getLineLength(lineCount) + 1);
1110
1111
return textBuffer.getValueInRange(range, EndOfLinePreference.TextDefined);
1112
}
1113
1114
override async resolve<T extends IWorkingCopyBackupMeta>(identifier: IWorkingCopyIdentifier): Promise<IResolvedWorkingCopyBackup<T> | undefined> {
1115
this.resolved.add(identifier);
1116
1117
return super.resolve(identifier);
1118
}
1119
}
1120
1121
export function toUntypedWorkingCopyId(resource: URI): IWorkingCopyIdentifier {
1122
return toTypedWorkingCopyId(resource, '');
1123
}
1124
1125
export function toTypedWorkingCopyId(resource: URI, typeId = 'testBackupTypeId'): IWorkingCopyIdentifier {
1126
return { typeId, resource };
1127
}
1128
1129
export class InMemoryTestWorkingCopyBackupService extends BrowserWorkingCopyBackupService {
1130
1131
private backupResourceJoiners: Function[];
1132
private discardBackupJoiners: Function[];
1133
1134
discardedBackups: IWorkingCopyIdentifier[];
1135
1136
constructor() {
1137
const disposables = new DisposableStore();
1138
const environmentService = TestEnvironmentService;
1139
const logService = new NullLogService();
1140
const fileService = disposables.add(new FileService(logService));
1141
disposables.add(fileService.registerProvider(Schemas.file, disposables.add(new InMemoryFileSystemProvider())));
1142
disposables.add(fileService.registerProvider(Schemas.vscodeUserData, disposables.add(new InMemoryFileSystemProvider())));
1143
1144
super(new TestContextService(TestWorkspace), environmentService, fileService, logService);
1145
1146
this.backupResourceJoiners = [];
1147
this.discardBackupJoiners = [];
1148
this.discardedBackups = [];
1149
1150
this._register(disposables);
1151
}
1152
1153
testGetFileService(): IFileService {
1154
return this.fileService;
1155
}
1156
1157
joinBackupResource(): Promise<void> {
1158
return new Promise(resolve => this.backupResourceJoiners.push(resolve));
1159
}
1160
1161
joinDiscardBackup(): Promise<void> {
1162
return new Promise(resolve => this.discardBackupJoiners.push(resolve));
1163
}
1164
1165
override async backup(identifier: IWorkingCopyIdentifier, content?: VSBufferReadableStream | VSBufferReadable, versionId?: number, meta?: any, token?: CancellationToken): Promise<void> {
1166
await super.backup(identifier, content, versionId, meta, token);
1167
1168
while (this.backupResourceJoiners.length) {
1169
this.backupResourceJoiners.pop()!();
1170
}
1171
}
1172
1173
override async discardBackup(identifier: IWorkingCopyIdentifier): Promise<void> {
1174
await super.discardBackup(identifier);
1175
this.discardedBackups.push(identifier);
1176
1177
while (this.discardBackupJoiners.length) {
1178
this.discardBackupJoiners.pop()!();
1179
}
1180
}
1181
1182
async getBackupContents(identifier: IWorkingCopyIdentifier): Promise<string> {
1183
const backupResource = this.toBackupResource(identifier);
1184
1185
const fileContents = await this.fileService.readFile(backupResource);
1186
1187
return fileContents.value.toString();
1188
}
1189
}
1190
1191
export class TestBeforeShutdownEvent implements InternalBeforeShutdownEvent {
1192
1193
value: boolean | Promise<boolean> | undefined;
1194
finalValue: (() => boolean | Promise<boolean>) | undefined;
1195
reason = ShutdownReason.CLOSE;
1196
1197
veto(value: boolean | Promise<boolean>): void {
1198
this.value = value;
1199
}
1200
1201
finalVeto(vetoFn: () => boolean | Promise<boolean>): void {
1202
this.value = vetoFn();
1203
this.finalValue = vetoFn;
1204
}
1205
}
1206
1207
export class TestWillShutdownEvent implements WillShutdownEvent {
1208
1209
value: Promise<void>[] = [];
1210
joiners = () => [];
1211
reason = ShutdownReason.CLOSE;
1212
token = CancellationToken.None;
1213
1214
join(promise: Promise<void> | (() => Promise<void>), joiner: IWillShutdownEventJoiner): void {
1215
this.value.push(typeof promise === 'function' ? promise() : promise);
1216
}
1217
1218
force() { /* No-Op in tests */ }
1219
}
1220
1221
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {
1222
1223
declare readonly _serviceBrand: undefined;
1224
1225
constructor(private configurationService = new TestConfigurationService()) { }
1226
1227
onDidChangeConfiguration() {
1228
return { dispose() { } };
1229
}
1230
1231
getValue<T>(resource: URI, arg2?: any, arg3?: any): T {
1232
const position: IPosition | null = EditorPosition.isIPosition(arg2) ? arg2 : null;
1233
const section: string | undefined = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);
1234
return this.configurationService.getValue(section, { resource }) as T;
1235
}
1236
1237
inspect<T>(resource: URI | undefined, position: IPosition | null, section: string): IConfigurationValue<Readonly<T>> {
1238
return this.configurationService.inspect<T>(section, { resource });
1239
}
1240
1241
updateValue(resource: URI, key: string, value: any, configurationTarget?: ConfigurationTarget): Promise<void> {
1242
return this.configurationService.updateValue(key, value);
1243
}
1244
}
1245
1246
export class RemoteFileSystemProvider implements IFileSystemProvider {
1247
1248
constructor(private readonly wrappedFsp: IFileSystemProvider, private readonly remoteAuthority: string) {
1249
this.capabilities = this.wrappedFsp.capabilities;
1250
this.onDidChangeCapabilities = this.wrappedFsp.onDidChangeCapabilities;
1251
this.onDidChangeFile = Event.map(this.wrappedFsp.onDidChangeFile, changes => changes.map(c => {
1252
return {
1253
type: c.type,
1254
resource: c.resource.with({ scheme: Schemas.vscodeRemote, authority: this.remoteAuthority }),
1255
};
1256
}));
1257
}
1258
1259
readonly capabilities: FileSystemProviderCapabilities;
1260
readonly onDidChangeCapabilities: Event<void>;
1261
1262
readonly onDidChangeFile: Event<readonly IFileChange[]>;
1263
watch(resource: URI, opts: IWatchOptions): IDisposable { return this.wrappedFsp.watch(this.toFileResource(resource), opts); }
1264
1265
stat(resource: URI): Promise<IStat> { return this.wrappedFsp.stat(this.toFileResource(resource)); }
1266
mkdir(resource: URI): Promise<void> { return this.wrappedFsp.mkdir(this.toFileResource(resource)); }
1267
readdir(resource: URI): Promise<[string, FileType][]> { return this.wrappedFsp.readdir(this.toFileResource(resource)); }
1268
delete(resource: URI, opts: IFileDeleteOptions): Promise<void> { return this.wrappedFsp.delete(this.toFileResource(resource), opts); }
1269
1270
rename(from: URI, to: URI, opts: IFileOverwriteOptions): Promise<void> { return this.wrappedFsp.rename(this.toFileResource(from), this.toFileResource(to), opts); }
1271
copy(from: URI, to: URI, opts: IFileOverwriteOptions): Promise<void> { return this.wrappedFsp.copy!(this.toFileResource(from), this.toFileResource(to), opts); }
1272
1273
readFile(resource: URI): Promise<Uint8Array> { return this.wrappedFsp.readFile!(this.toFileResource(resource)); }
1274
writeFile(resource: URI, content: Uint8Array, opts: IFileWriteOptions): Promise<void> { return this.wrappedFsp.writeFile!(this.toFileResource(resource), content, opts); }
1275
1276
open(resource: URI, opts: IFileOpenOptions): Promise<number> { return this.wrappedFsp.open!(this.toFileResource(resource), opts); }
1277
close(fd: number): Promise<void> { return this.wrappedFsp.close!(fd); }
1278
read(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return this.wrappedFsp.read!(fd, pos, data, offset, length); }
1279
write(fd: number, pos: number, data: Uint8Array, offset: number, length: number): Promise<number> { return this.wrappedFsp.write!(fd, pos, data, offset, length); }
1280
1281
readFileStream(resource: URI, opts: IFileReadStreamOptions, token: CancellationToken): ReadableStreamEvents<Uint8Array> { return this.wrappedFsp.readFileStream!(this.toFileResource(resource), opts, token); }
1282
1283
private toFileResource(resource: URI): URI { return resource.with({ scheme: Schemas.file, authority: '' }); }
1284
}
1285
1286
export class TestInMemoryFileSystemProvider extends InMemoryFileSystemProvider implements IFileSystemProviderWithFileReadStreamCapability {
1287
override get capabilities(): FileSystemProviderCapabilities {
1288
return FileSystemProviderCapabilities.FileReadWrite
1289
| FileSystemProviderCapabilities.PathCaseSensitive
1290
| FileSystemProviderCapabilities.FileReadStream;
1291
}
1292
1293
override readFileStream(resource: URI): ReadableStreamEvents<Uint8Array> {
1294
const BUFFER_SIZE = 64 * 1024;
1295
const stream = newWriteableStream<Uint8Array>(data => VSBuffer.concat(data.map(data => VSBuffer.wrap(data))).buffer);
1296
1297
(async () => {
1298
try {
1299
const data = await this.readFile(resource);
1300
1301
let offset = 0;
1302
while (offset < data.length) {
1303
await timeout(0);
1304
await stream.write(data.subarray(offset, offset + BUFFER_SIZE));
1305
offset += BUFFER_SIZE;
1306
}
1307
1308
await timeout(0);
1309
stream.end();
1310
} catch (error) {
1311
stream.end(error);
1312
}
1313
})();
1314
1315
return stream;
1316
}
1317
}
1318
1319
export const productService: IProductService = { _serviceBrand: undefined, ...product };
1320
1321
export class TestHostService implements IHostService {
1322
1323
declare readonly _serviceBrand: undefined;
1324
1325
private _hasFocus = true;
1326
get hasFocus() { return this._hasFocus; }
1327
async hadLastFocus(): Promise<boolean> { return this._hasFocus; }
1328
1329
private _onDidChangeFocus = new Emitter<boolean>();
1330
readonly onDidChangeFocus = this._onDidChangeFocus.event;
1331
1332
private _onDidChangeWindow = new Emitter<number>();
1333
readonly onDidChangeActiveWindow = this._onDidChangeWindow.event;
1334
1335
readonly onDidChangeFullScreen: Event<{ windowId: number; fullscreen: boolean }> = Event.None;
1336
1337
setFocus(focus: boolean) {
1338
this._hasFocus = focus;
1339
this._onDidChangeFocus.fire(this._hasFocus);
1340
}
1341
1342
async restart(): Promise<void> { }
1343
async reload(): Promise<void> { }
1344
async close(): Promise<void> { }
1345
async withExpectedShutdown<T>(expectedShutdownTask: () => Promise<T>): Promise<T> {
1346
return await expectedShutdownTask();
1347
}
1348
1349
async focus(): Promise<void> { }
1350
async moveTop(): Promise<void> { }
1351
async getCursorScreenPoint(): Promise<undefined> { return undefined; }
1352
1353
async getWindows(options: unknown) { return []; }
1354
1355
async openWindow(arg1?: IOpenEmptyWindowOptions | IWindowOpenable[], arg2?: IOpenWindowOptions): Promise<void> { }
1356
1357
async toggleFullScreen(): Promise<void> { }
1358
1359
async getScreenshot(rect?: IRectangle): Promise<VSBuffer | undefined> { return undefined; }
1360
1361
async getNativeWindowHandle(_windowId: number): Promise<VSBuffer | undefined> { return undefined; }
1362
1363
readonly colorScheme = ColorScheme.DARK;
1364
onDidChangeColorScheme = Event.None;
1365
}
1366
1367
export class TestFilesConfigurationService extends FilesConfigurationService {
1368
1369
testOnFilesConfigurationChange(configuration: any): void {
1370
super.onFilesConfigurationChange(configuration, true);
1371
}
1372
}
1373
1374
export class TestReadonlyTextFileEditorModel extends TextFileEditorModel {
1375
1376
override isReadonly(): boolean {
1377
return true;
1378
}
1379
}
1380
1381
export class TestEditorInput extends EditorInput {
1382
1383
constructor(public resource: URI, private readonly _typeId: string) {
1384
super();
1385
}
1386
1387
override get typeId(): string {
1388
return this._typeId;
1389
}
1390
1391
override get editorId(): string {
1392
return this._typeId;
1393
}
1394
1395
override resolve(): Promise<IDisposable | null> {
1396
return Promise.resolve(null);
1397
}
1398
}
1399
1400
export function registerTestEditor(id: string, inputs: SyncDescriptor<EditorInput>[], serializerInputId?: string): IDisposable {
1401
const disposables = new DisposableStore();
1402
1403
class TestEditor extends EditorPane {
1404
1405
private _scopedContextKeyService: IContextKeyService;
1406
1407
constructor(group: IEditorGroup) {
1408
super(id, group, NullTelemetryService, new TestThemeService(), disposables.add(new TestStorageService()));
1409
this._scopedContextKeyService = new MockContextKeyService();
1410
}
1411
1412
override async setInput(input: EditorInput, options: IEditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void> {
1413
super.setInput(input, options, context, token);
1414
1415
await input.resolve();
1416
}
1417
1418
override getId(): string { return id; }
1419
layout(): void { }
1420
protected createEditor(): void { }
1421
1422
override get scopedContextKeyService() {
1423
return this._scopedContextKeyService;
1424
}
1425
}
1426
1427
disposables.add(Registry.as<IEditorPaneRegistry>(Extensions.EditorPane).registerEditorPane(EditorPaneDescriptor.create(TestEditor, id, 'Test Editor Control'), inputs));
1428
1429
if (serializerInputId) {
1430
1431
interface ISerializedTestInput {
1432
resource: string;
1433
}
1434
1435
class EditorsObserverTestEditorInputSerializer implements IEditorSerializer {
1436
1437
canSerialize(editorInput: EditorInput): boolean {
1438
return true;
1439
}
1440
1441
serialize(editorInput: EditorInput): string {
1442
const testEditorInput = <TestFileEditorInput>editorInput;
1443
const testInput: ISerializedTestInput = {
1444
resource: testEditorInput.resource.toString()
1445
};
1446
1447
return JSON.stringify(testInput);
1448
}
1449
1450
deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): EditorInput {
1451
const testInput: ISerializedTestInput = JSON.parse(serializedEditorInput);
1452
1453
return new TestFileEditorInput(URI.parse(testInput.resource), serializerInputId!);
1454
}
1455
}
1456
1457
disposables.add(Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerEditorSerializer(serializerInputId, EditorsObserverTestEditorInputSerializer));
1458
}
1459
1460
return disposables;
1461
}
1462
1463
export function registerTestFileEditor(): IDisposable {
1464
const disposables = new DisposableStore();
1465
1466
disposables.add(Registry.as<IEditorPaneRegistry>(Extensions.EditorPane).registerEditorPane(
1467
EditorPaneDescriptor.create(
1468
TestTextFileEditor,
1469
TestTextFileEditor.ID,
1470
'Text File Editor'
1471
),
1472
[new SyncDescriptor(FileEditorInput)]
1473
));
1474
1475
return disposables;
1476
}
1477
1478
export function registerTestResourceEditor(): IDisposable {
1479
const disposables = new DisposableStore();
1480
1481
disposables.add(Registry.as<IEditorPaneRegistry>(Extensions.EditorPane).registerEditorPane(
1482
EditorPaneDescriptor.create(
1483
TestTextResourceEditor,
1484
TestTextResourceEditor.ID,
1485
'Text Editor'
1486
),
1487
[
1488
new SyncDescriptor(UntitledTextEditorInput),
1489
new SyncDescriptor(TextResourceEditorInput)
1490
]
1491
));
1492
1493
return disposables;
1494
}
1495
1496
export function registerTestSideBySideEditor(): IDisposable {
1497
const disposables = new DisposableStore();
1498
1499
disposables.add(Registry.as<IEditorPaneRegistry>(Extensions.EditorPane).registerEditorPane(
1500
EditorPaneDescriptor.create(
1501
SideBySideEditor,
1502
SideBySideEditor.ID,
1503
'Text Editor'
1504
),
1505
[
1506
new SyncDescriptor(SideBySideEditorInput)
1507
]
1508
));
1509
1510
return disposables;
1511
}
1512
1513
export class TestFileEditorInput extends EditorInput implements IFileEditorInput {
1514
1515
readonly preferredResource;
1516
1517
gotDisposed = false;
1518
gotSaved = false;
1519
gotSavedAs = false;
1520
gotReverted = false;
1521
dirty = false;
1522
modified: boolean | undefined;
1523
private fails = false;
1524
1525
disableToUntyped = false;
1526
1527
constructor(
1528
public resource: URI,
1529
private _typeId: string
1530
) {
1531
super();
1532
1533
this.preferredResource = this.resource;
1534
}
1535
1536
override get typeId() { return this._typeId; }
1537
override get editorId() { return this._typeId; }
1538
1539
private _capabilities: EditorInputCapabilities = EditorInputCapabilities.None;
1540
override get capabilities(): EditorInputCapabilities { return this._capabilities; }
1541
override set capabilities(capabilities: EditorInputCapabilities) {
1542
if (this._capabilities !== capabilities) {
1543
this._capabilities = capabilities;
1544
this._onDidChangeCapabilities.fire();
1545
}
1546
}
1547
1548
override resolve(): Promise<IDisposable | null> { return !this.fails ? Promise.resolve(null) : Promise.reject(new Error('fails')); }
1549
override matches(other: EditorInput | IResourceEditorInput | ITextResourceEditorInput | IUntitledTextResourceEditorInput): boolean {
1550
if (super.matches(other)) {
1551
return true;
1552
}
1553
if (other instanceof EditorInput) {
1554
return !!(other?.resource && this.resource.toString() === other.resource.toString() && other instanceof TestFileEditorInput && other.typeId === this.typeId);
1555
}
1556
return isEqual(this.resource, other.resource) && (this.editorId === other.options?.override || other.options?.override === undefined);
1557
}
1558
setPreferredResource(resource: URI): void { }
1559
async setEncoding(encoding: string) { }
1560
getEncoding() { return undefined; }
1561
setPreferredName(name: string): void { }
1562
setPreferredDescription(description: string): void { }
1563
setPreferredEncoding(encoding: string) { }
1564
setPreferredContents(contents: string): void { }
1565
setLanguageId(languageId: string, source?: string) { }
1566
setPreferredLanguageId(languageId: string) { }
1567
setForceOpenAsBinary(): void { }
1568
setFailToOpen(): void {
1569
this.fails = true;
1570
}
1571
override async save(groupId: GroupIdentifier, options?: ISaveOptions): Promise<EditorInput | undefined> {
1572
this.gotSaved = true;
1573
this.dirty = false;
1574
return this;
1575
}
1576
override async saveAs(groupId: GroupIdentifier, options?: ISaveOptions): Promise<EditorInput | undefined> {
1577
this.gotSavedAs = true;
1578
return this;
1579
}
1580
override async revert(group: GroupIdentifier, options?: IRevertOptions): Promise<void> {
1581
this.gotReverted = true;
1582
this.gotSaved = false;
1583
this.gotSavedAs = false;
1584
this.dirty = false;
1585
}
1586
override toUntyped(): IUntypedEditorInput | undefined {
1587
if (this.disableToUntyped) {
1588
return undefined;
1589
}
1590
return { resource: this.resource };
1591
}
1592
setModified(): void { this.modified = true; }
1593
override isModified(): boolean {
1594
return this.modified === undefined ? this.dirty : this.modified;
1595
}
1596
setDirty(): void { this.dirty = true; }
1597
override isDirty(): boolean {
1598
return this.dirty;
1599
}
1600
isResolved(): boolean { return false; }
1601
override dispose(): void {
1602
super.dispose();
1603
this.gotDisposed = true;
1604
}
1605
movedEditor: IMoveResult | undefined = undefined;
1606
override async rename(): Promise<IMoveResult | undefined> { return this.movedEditor; }
1607
1608
private moveDisabledReason: string | undefined = undefined;
1609
setMoveDisabled(reason: string): void {
1610
this.moveDisabledReason = reason;
1611
}
1612
1613
override canMove(sourceGroup: GroupIdentifier, targetGroup: GroupIdentifier): string | true {
1614
if (typeof this.moveDisabledReason === 'string') {
1615
return this.moveDisabledReason;
1616
}
1617
return super.canMove(sourceGroup, targetGroup);
1618
}
1619
}
1620
1621
export class TestSingletonFileEditorInput extends TestFileEditorInput {
1622
1623
override get capabilities(): EditorInputCapabilities { return EditorInputCapabilities.Singleton; }
1624
}
1625
1626
export class TestEditorPart extends MainEditorPart implements IEditorGroupsService {
1627
1628
declare readonly _serviceBrand: undefined;
1629
1630
readonly mainPart = this;
1631
readonly parts: readonly IEditorPart[] = [this];
1632
1633
readonly onDidCreateAuxiliaryEditorPart: Event<IAuxiliaryEditorPart> = Event.None;
1634
1635
testSaveState(): void {
1636
return super.saveState();
1637
}
1638
1639
clearState(): void {
1640
const workspaceMemento = this.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE) as Record<string, unknown>;
1641
for (const key of Object.keys(workspaceMemento)) {
1642
delete workspaceMemento[key];
1643
}
1644
1645
const profileMemento = this.getMemento(StorageScope.PROFILE, StorageTarget.MACHINE) as Record<string, unknown>;
1646
for (const key of Object.keys(profileMemento)) {
1647
delete profileMemento[key];
1648
}
1649
}
1650
1651
registerEditorPart(part: IEditorPart): IDisposable {
1652
return Disposable.None;
1653
}
1654
1655
createAuxiliaryEditorPart(): Promise<IAuxiliaryEditorPart> {
1656
throw new Error('Method not implemented.');
1657
}
1658
1659
getScopedInstantiationService(part: IEditorPart): IInstantiationService {
1660
throw new Error('Method not implemented.');
1661
}
1662
1663
getPart(group: number | IEditorGroup): IEditorPart { return this; }
1664
1665
saveWorkingSet(name: string): IEditorWorkingSet { throw new Error('Method not implemented.'); }
1666
getWorkingSets(): IEditorWorkingSet[] { throw new Error('Method not implemented.'); }
1667
applyWorkingSet(workingSet: IEditorWorkingSet | 'empty', options?: IEditorWorkingSetOptions): Promise<boolean> { throw new Error('Method not implemented.'); }
1668
deleteWorkingSet(workingSet: IEditorWorkingSet): Promise<boolean> { throw new Error('Method not implemented.'); }
1669
1670
registerContextKeyProvider<T extends ContextKeyValue>(provider: IEditorGroupContextKeyProvider<T>): IDisposable { throw new Error('Method not implemented.'); }
1671
}
1672
1673
export class TestEditorParts extends EditorParts {
1674
testMainPart!: TestEditorPart;
1675
1676
protected override createMainEditorPart(): MainEditorPart {
1677
this.testMainPart = this.instantiationService.createInstance(TestEditorPart, this);
1678
1679
return this.testMainPart;
1680
}
1681
}
1682
1683
export async function createEditorParts(instantiationService: IInstantiationService, disposables: DisposableStore): Promise<TestEditorParts> {
1684
const parts = instantiationService.createInstance(TestEditorParts);
1685
const part = disposables.add(parts).testMainPart;
1686
part.create(document.createElement('div'));
1687
part.layout(1080, 800, 0, 0);
1688
1689
await parts.whenReady;
1690
1691
return parts;
1692
}
1693
1694
export async function createEditorPart(instantiationService: IInstantiationService, disposables: DisposableStore): Promise<TestEditorPart> {
1695
return (await createEditorParts(instantiationService, disposables)).testMainPart;
1696
}
1697
1698
export class TestListService implements IListService {
1699
declare readonly _serviceBrand: undefined;
1700
1701
lastFocusedList: any | undefined = undefined;
1702
1703
register(): IDisposable {
1704
return Disposable.None;
1705
}
1706
}
1707
1708
export class TestPathService implements IPathService {
1709
1710
declare readonly _serviceBrand: undefined;
1711
1712
constructor(private readonly fallbackUserHome: URI = URI.from({ scheme: Schemas.file, path: '/' }), public defaultUriScheme = Schemas.file) { }
1713
1714
hasValidBasename(resource: URI, basename?: string): Promise<boolean>;
1715
hasValidBasename(resource: URI, os: OperatingSystem, basename?: string): boolean;
1716
hasValidBasename(resource: URI, arg2?: string | OperatingSystem, name?: string): boolean | Promise<boolean> {
1717
if (typeof arg2 === 'string' || typeof arg2 === 'undefined') {
1718
return isValidBasename(arg2 ?? basename(resource));
1719
}
1720
1721
return isValidBasename(name ?? basename(resource));
1722
}
1723
1724
get path() { return Promise.resolve(isWindows ? win32 : posix); }
1725
1726
userHome(options?: { preferLocal: boolean }): Promise<URI>;
1727
userHome(options: { preferLocal: true }): URI;
1728
userHome(options?: { preferLocal: boolean }): Promise<URI> | URI {
1729
return options?.preferLocal ? this.fallbackUserHome : Promise.resolve(this.fallbackUserHome);
1730
}
1731
1732
get resolvedUserHome() { return this.fallbackUserHome; }
1733
1734
async fileURI(path: string): Promise<URI> {
1735
return URI.file(path);
1736
}
1737
}
1738
1739
export interface ITestTextFileEditorModelManager extends ITextFileEditorModelManager, IDisposable {
1740
add(resource: URI, model: TextFileEditorModel): void;
1741
remove(resource: URI): void;
1742
}
1743
1744
interface ITestTextFileEditorModel extends ITextFileEditorModel {
1745
readonly lastResolvedFileStat: IFileStatWithMetadata | undefined;
1746
}
1747
1748
export function getLastResolvedFileStat(model: unknown): IFileStatWithMetadata | undefined {
1749
const candidate = model as ITestTextFileEditorModel | undefined;
1750
1751
return candidate?.lastResolvedFileStat;
1752
}
1753
1754
export class TestWorkspacesService implements IWorkspacesService {
1755
_serviceBrand: undefined;
1756
1757
onDidChangeRecentlyOpened = Event.None;
1758
1759
async createUntitledWorkspace(folders?: IWorkspaceFolderCreationData[], remoteAuthority?: string): Promise<IWorkspaceIdentifier> { throw new Error('Method not implemented.'); }
1760
async deleteUntitledWorkspace(workspace: IWorkspaceIdentifier): Promise<void> { }
1761
async addRecentlyOpened(recents: IRecent[]): Promise<void> { }
1762
async removeRecentlyOpened(workspaces: URI[]): Promise<void> { }
1763
async clearRecentlyOpened(): Promise<void> { }
1764
async getRecentlyOpened(): Promise<IRecentlyOpened> { return { files: [], workspaces: [] }; }
1765
async getDirtyWorkspaces(): Promise<(IFolderBackupInfo | IWorkspaceBackupInfo)[]> { return []; }
1766
async enterWorkspace(path: URI): Promise<IEnterWorkspaceResult | undefined> { throw new Error('Method not implemented.'); }
1767
async getWorkspaceIdentifier(workspacePath: URI): Promise<IWorkspaceIdentifier> { throw new Error('Method not implemented.'); }
1768
}
1769
1770
export class TestTerminalInstanceService implements ITerminalInstanceService {
1771
onDidCreateInstance = Event.None;
1772
onDidRegisterBackend = Event.None;
1773
declare readonly _serviceBrand: undefined;
1774
1775
convertProfileToShellLaunchConfig(shellLaunchConfigOrProfile?: IShellLaunchConfig | ITerminalProfile, cwd?: string | URI): IShellLaunchConfig { throw new Error('Method not implemented.'); }
1776
preparePathForTerminalAsync(path: string, executable: string | undefined, title: string, shellType: TerminalShellType, remoteAuthority: string | undefined): Promise<string> { throw new Error('Method not implemented.'); }
1777
createInstance(options: ICreateTerminalOptions, target: TerminalLocation): ITerminalInstance { throw new Error('Method not implemented.'); }
1778
async getBackend(remoteAuthority?: string): Promise<ITerminalBackend | undefined> { throw new Error('Method not implemented.'); }
1779
didRegisterBackend(backend: ITerminalBackend): void { throw new Error('Method not implemented.'); }
1780
getRegisteredBackends(): IterableIterator<ITerminalBackend> { throw new Error('Method not implemented.'); }
1781
}
1782
1783
export class TestTerminalEditorService implements ITerminalEditorService {
1784
_serviceBrand: undefined;
1785
activeInstance: ITerminalInstance | undefined;
1786
instances: readonly ITerminalInstance[] = [];
1787
onDidDisposeInstance = Event.None;
1788
onDidFocusInstance = Event.None;
1789
onDidChangeInstanceCapability = Event.None;
1790
onDidChangeActiveInstance = Event.None;
1791
onDidChangeInstances = Event.None;
1792
openEditor(instance: ITerminalInstance, editorOptions?: TerminalEditorLocation): Promise<void> { throw new Error('Method not implemented.'); }
1793
detachInstance(instance: ITerminalInstance): void { throw new Error('Method not implemented.'); }
1794
splitInstance(instanceToSplit: ITerminalInstance, shellLaunchConfig?: IShellLaunchConfig): ITerminalInstance { throw new Error('Method not implemented.'); }
1795
revealActiveEditor(preserveFocus?: boolean): Promise<void> { throw new Error('Method not implemented.'); }
1796
resolveResource(instance: ITerminalInstance): URI { throw new Error('Method not implemented.'); }
1797
reviveInput(deserializedInput: IDeserializedTerminalEditorInput): TerminalEditorInput { throw new Error('Method not implemented.'); }
1798
getInputFromResource(resource: URI): TerminalEditorInput { throw new Error('Method not implemented.'); }
1799
setActiveInstance(instance: ITerminalInstance): void { throw new Error('Method not implemented.'); }
1800
focusActiveInstance(): Promise<void> { throw new Error('Method not implemented.'); }
1801
async focusInstance(instance: ITerminalInstance): Promise<void> { throw new Error('Method not implemented.'); }
1802
getInstanceFromResource(resource: URI | undefined): ITerminalInstance | undefined { throw new Error('Method not implemented.'); }
1803
focusFindWidget(): void { throw new Error('Method not implemented.'); }
1804
hideFindWidget(): void { throw new Error('Method not implemented.'); }
1805
findNext(): void { throw new Error('Method not implemented.'); }
1806
findPrevious(): void { throw new Error('Method not implemented.'); }
1807
}
1808
1809
export class TestTerminalGroupService implements ITerminalGroupService {
1810
_serviceBrand: undefined;
1811
activeInstance: ITerminalInstance | undefined;
1812
instances: readonly ITerminalInstance[] = [];
1813
groups: readonly ITerminalGroup[] = [];
1814
activeGroup: ITerminalGroup | undefined;
1815
activeGroupIndex: number = 0;
1816
lastAccessedMenu: 'inline-tab' | 'tab-list' = 'inline-tab';
1817
onDidChangeActiveGroup = Event.None;
1818
onDidDisposeGroup = Event.None;
1819
onDidShow = Event.None;
1820
onDidChangeGroups = Event.None;
1821
onDidChangePanelOrientation = Event.None;
1822
onDidDisposeInstance = Event.None;
1823
onDidFocusInstance = Event.None;
1824
onDidChangeInstanceCapability = Event.None;
1825
onDidChangeActiveInstance = Event.None;
1826
onDidChangeInstances = Event.None;
1827
createGroup(instance?: any): ITerminalGroup { throw new Error('Method not implemented.'); }
1828
getGroupForInstance(instance: ITerminalInstance): ITerminalGroup | undefined { throw new Error('Method not implemented.'); }
1829
moveGroup(source: ITerminalInstance | ITerminalInstance[], target: ITerminalInstance): void { throw new Error('Method not implemented.'); }
1830
moveGroupToEnd(source: ITerminalInstance | ITerminalInstance[]): void { throw new Error('Method not implemented.'); }
1831
moveInstance(source: ITerminalInstance, target: ITerminalInstance, side: 'before' | 'after'): void { throw new Error('Method not implemented.'); }
1832
unsplitInstance(instance: ITerminalInstance): void { throw new Error('Method not implemented.'); }
1833
joinInstances(instances: ITerminalInstance[]): void { throw new Error('Method not implemented.'); }
1834
instanceIsSplit(instance: ITerminalInstance): boolean { throw new Error('Method not implemented.'); }
1835
getGroupLabels(): string[] { throw new Error('Method not implemented.'); }
1836
setActiveGroupByIndex(index: number): void { throw new Error('Method not implemented.'); }
1837
setActiveGroupToNext(): void { throw new Error('Method not implemented.'); }
1838
setActiveGroupToPrevious(): void { throw new Error('Method not implemented.'); }
1839
setActiveInstanceByIndex(terminalIndex: number): void { throw new Error('Method not implemented.'); }
1840
setContainer(container: HTMLElement): void { throw new Error('Method not implemented.'); }
1841
showPanel(focus?: boolean): Promise<void> { throw new Error('Method not implemented.'); }
1842
hidePanel(): void { throw new Error('Method not implemented.'); }
1843
focusTabs(): void { throw new Error('Method not implemented.'); }
1844
focusHover(): void { throw new Error('Method not implemented.'); }
1845
setActiveInstance(instance: ITerminalInstance): void { throw new Error('Method not implemented.'); }
1846
focusActiveInstance(): Promise<void> { throw new Error('Method not implemented.'); }
1847
async focusInstance(instance: ITerminalInstance): Promise<void> { throw new Error('Method not implemented.'); }
1848
getInstanceFromResource(resource: URI | undefined): ITerminalInstance | undefined { throw new Error('Method not implemented.'); }
1849
focusFindWidget(): void { throw new Error('Method not implemented.'); }
1850
hideFindWidget(): void { throw new Error('Method not implemented.'); }
1851
findNext(): void { throw new Error('Method not implemented.'); }
1852
findPrevious(): void { throw new Error('Method not implemented.'); }
1853
updateVisibility(): void { throw new Error('Method not implemented.'); }
1854
}
1855
1856
export class TestTerminalProfileService implements ITerminalProfileService {
1857
_serviceBrand: undefined;
1858
availableProfiles: ITerminalProfile[] = [];
1859
contributedProfiles: IExtensionTerminalProfile[] = [];
1860
profilesReady: Promise<void> = Promise.resolve();
1861
onDidChangeAvailableProfiles = Event.None;
1862
getPlatformKey(): Promise<string> { throw new Error('Method not implemented.'); }
1863
refreshAvailableProfiles(): void { throw new Error('Method not implemented.'); }
1864
getDefaultProfileName(): string | undefined { throw new Error('Method not implemented.'); }
1865
getDefaultProfile(): ITerminalProfile | undefined { throw new Error('Method not implemented.'); }
1866
getContributedDefaultProfile(shellLaunchConfig: IShellLaunchConfig): Promise<IExtensionTerminalProfile | undefined> { throw new Error('Method not implemented.'); }
1867
registerContributedProfile(args: IRegisterContributedProfileArgs): Promise<void> { throw new Error('Method not implemented.'); }
1868
getContributedProfileProvider(extensionIdentifier: string, id: string): ITerminalProfileProvider | undefined { throw new Error('Method not implemented.'); }
1869
registerTerminalProfileProvider(extensionIdentifier: string, id: string, profileProvider: ITerminalProfileProvider): IDisposable { throw new Error('Method not implemented.'); }
1870
}
1871
1872
export class TestTerminalProfileResolverService implements ITerminalProfileResolverService {
1873
_serviceBrand: undefined;
1874
defaultProfileName = '';
1875
resolveIcon(shellLaunchConfig: IShellLaunchConfig): void { }
1876
async resolveShellLaunchConfig(shellLaunchConfig: IShellLaunchConfig, options: IShellLaunchConfigResolveOptions): Promise<void> { }
1877
async getDefaultProfile(options: IShellLaunchConfigResolveOptions): Promise<ITerminalProfile> { return { path: '/default', profileName: 'Default', isDefault: true }; }
1878
async getDefaultShell(options: IShellLaunchConfigResolveOptions): Promise<string> { return '/default'; }
1879
async getDefaultShellArgs(options: IShellLaunchConfigResolveOptions): Promise<string | string[]> { return []; }
1880
getDefaultIcon(): TerminalIcon & ThemeIcon { return Codicon.terminal; }
1881
async getEnvironment(): Promise<IProcessEnvironment> { return env; }
1882
getSafeConfigValue(key: string, os: OperatingSystem): unknown | undefined { return undefined; }
1883
getSafeConfigValueFullKey(key: string): unknown | undefined { return undefined; }
1884
createProfileFromShellAndShellArgs(shell?: unknown, shellArgs?: unknown): Promise<string | ITerminalProfile> { throw new Error('Method not implemented.'); }
1885
}
1886
1887
export class TestTerminalConfigurationService extends TerminalConfigurationService {
1888
get fontMetrics() { return this._fontMetrics; }
1889
// eslint-disable-next-line local/code-no-any-casts
1890
setConfig(config: Partial<ITerminalConfiguration>) { this._config = config as any; }
1891
}
1892
1893
export class TestQuickInputService implements IQuickInputService {
1894
declare readonly _serviceBrand: undefined;
1895
1896
readonly onShow = Event.None;
1897
readonly onHide = Event.None;
1898
1899
readonly currentQuickInput = undefined;
1900
readonly quickAccess = undefined!;
1901
backButton!: IQuickInputButton;
1902
1903
pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: IPickOptions<T> & { canPickMany: true }, token?: CancellationToken): Promise<T[]>;
1904
pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: IPickOptions<T> & { canPickMany: false }, token?: CancellationToken): Promise<T>;
1905
async pick<T extends IQuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: Omit<IPickOptions<T>, 'canPickMany'>, token?: CancellationToken): Promise<T | undefined> {
1906
if (Array.isArray(picks)) {
1907
// eslint-disable-next-line local/code-no-any-casts
1908
return <any>{ label: 'selectedPick', description: 'pick description', value: 'selectedPick' };
1909
} else {
1910
return undefined;
1911
}
1912
}
1913
1914
async input(options?: IInputOptions, token?: CancellationToken): Promise<string> { return options ? 'resolved' + options.prompt : 'resolved'; }
1915
1916
createQuickPick<T extends IQuickPickItem>(): IQuickPick<T, { useSeparators: boolean }> { throw new Error('not implemented.'); }
1917
createInputBox(): IInputBox { throw new Error('not implemented.'); }
1918
createQuickWidget(): IQuickWidget { throw new Error('Method not implemented.'); }
1919
createQuickTree<T extends IQuickTreeItem>(): IQuickTree<T> { throw new Error('not implemented.'); }
1920
focus(): void { throw new Error('not implemented.'); }
1921
toggle(): void { throw new Error('not implemented.'); }
1922
navigate(next: boolean, quickNavigate?: IQuickNavigateConfiguration): void { throw new Error('not implemented.'); }
1923
accept(): Promise<void> { throw new Error('not implemented.'); }
1924
back(): Promise<void> { throw new Error('not implemented.'); }
1925
cancel(): Promise<void> { throw new Error('not implemented.'); }
1926
setAlignment(alignment: 'top' | 'center' | { top: number; left: number }): void { throw new Error('not implemented.'); }
1927
toggleHover(): void { throw new Error('not implemented.'); }
1928
}
1929
1930
class TestLanguageDetectionService implements ILanguageDetectionService {
1931
1932
declare readonly _serviceBrand: undefined;
1933
1934
isEnabledForLanguage(languageId: string): boolean { return false; }
1935
async detectLanguage(resource: URI, supportedLangs?: string[] | undefined): Promise<string | undefined> { return undefined; }
1936
}
1937
1938
export class TestRemoteAgentService implements IRemoteAgentService {
1939
1940
declare readonly _serviceBrand: undefined;
1941
1942
getConnection(): IRemoteAgentConnection | null { return null; }
1943
async getEnvironment(): Promise<IRemoteAgentEnvironment | null> { return null; }
1944
async getRawEnvironment(): Promise<IRemoteAgentEnvironment | null> { return null; }
1945
async getExtensionHostExitInfo(reconnectionToken: string): Promise<IExtensionHostExitInfo | null> { return null; }
1946
async getDiagnosticInfo(options: IDiagnosticInfoOptions): Promise<IDiagnosticInfo | undefined> { return undefined; }
1947
async updateTelemetryLevel(telemetryLevel: TelemetryLevel): Promise<void> { }
1948
async logTelemetry(eventName: string, data?: ITelemetryData): Promise<void> { }
1949
async flushTelemetry(): Promise<void> { }
1950
async getRoundTripTime(): Promise<number | undefined> { return undefined; }
1951
async endConnection(): Promise<void> { }
1952
}
1953
1954
export class TestRemoteExtensionsScannerService implements IRemoteExtensionsScannerService {
1955
declare readonly _serviceBrand: undefined;
1956
async whenExtensionsReady(): Promise<InstallExtensionSummary> { return { failed: [] }; }
1957
scanExtensions(): Promise<IExtensionDescription[]> { throw new Error('Method not implemented.'); }
1958
}
1959
1960
export class TestWorkbenchExtensionEnablementService implements IWorkbenchExtensionEnablementService {
1961
_serviceBrand: undefined;
1962
onEnablementChanged = Event.None;
1963
getEnablementState(extension: IExtension): EnablementState { return EnablementState.EnabledGlobally; }
1964
getEnablementStates(extensions: IExtension[], workspaceTypeOverrides?: { trusted?: boolean | undefined } | undefined): EnablementState[] { return []; }
1965
getDependenciesEnablementStates(extension: IExtension): [IExtension, EnablementState][] { return []; }
1966
canChangeEnablement(extension: IExtension): boolean { return true; }
1967
canChangeWorkspaceEnablement(extension: IExtension): boolean { return true; }
1968
isEnabled(extension: IExtension): boolean { return true; }
1969
isEnabledEnablementState(enablementState: EnablementState): boolean { return true; }
1970
isDisabledGlobally(extension: IExtension): boolean { return false; }
1971
async setEnablement(extensions: IExtension[], state: EnablementState): Promise<boolean[]> { return []; }
1972
async updateExtensionsEnablementsWhenWorkspaceTrustChanges(): Promise<void> { }
1973
}
1974
1975
export class TestWorkbenchExtensionManagementService implements IWorkbenchExtensionManagementService {
1976
_serviceBrand: undefined;
1977
onInstallExtension = Event.None;
1978
onDidInstallExtensions = Event.None;
1979
onUninstallExtension = Event.None;
1980
onDidUninstallExtension = Event.None;
1981
onDidUpdateExtensionMetadata = Event.None;
1982
onProfileAwareInstallExtension = Event.None;
1983
onProfileAwareDidInstallExtensions = Event.None;
1984
onProfileAwareUninstallExtension = Event.None;
1985
onProfileAwareDidUninstallExtension = Event.None;
1986
onDidProfileAwareUninstallExtensions = Event.None;
1987
onProfileAwareDidUpdateExtensionMetadata = Event.None;
1988
onDidChangeProfile = Event.None;
1989
onDidEnableExtensions = Event.None;
1990
preferPreReleases = true;
1991
installVSIX(location: URI, manifest: Readonly<IRelaxedExtensionManifest>, installOptions?: InstallOptions | undefined): Promise<ILocalExtension> {
1992
throw new Error('Method not implemented.');
1993
}
1994
installFromLocation(location: URI): Promise<ILocalExtension> {
1995
throw new Error('Method not implemented.');
1996
}
1997
installGalleryExtensions(extensions: InstallExtensionInfo[]): Promise<InstallExtensionResult[]> {
1998
throw new Error('Method not implemented.');
1999
}
2000
async updateFromGallery(gallery: IGalleryExtension, extension: ILocalExtension, installOptions?: InstallOptions | undefined): Promise<ILocalExtension> { return extension; }
2001
zip(extension: ILocalExtension): Promise<URI> {
2002
throw new Error('Method not implemented.');
2003
}
2004
getManifest(vsix: URI): Promise<Readonly<IRelaxedExtensionManifest>> {
2005
throw new Error('Method not implemented.');
2006
}
2007
install(vsix: URI, options?: InstallOptions | undefined): Promise<ILocalExtension> {
2008
throw new Error('Method not implemented.');
2009
}
2010
isAllowed(): true | IMarkdownString { return true; }
2011
async canInstall(extension: IGalleryExtension): Promise<true> { return true; }
2012
installFromGallery(extension: IGalleryExtension, options?: InstallOptions | undefined): Promise<ILocalExtension> {
2013
throw new Error('Method not implemented.');
2014
}
2015
uninstall(extension: ILocalExtension, options?: UninstallOptions | undefined): Promise<void> {
2016
throw new Error('Method not implemented.');
2017
}
2018
uninstallExtensions(extensions: UninstallExtensionInfo[]): Promise<void> {
2019
throw new Error('Method not implemented.');
2020
}
2021
async getInstalled(type?: ExtensionType | undefined): Promise<ILocalExtension[]> { return []; }
2022
getExtensionsControlManifest(): Promise<IExtensionsControlManifest> {
2023
throw new Error('Method not implemented.');
2024
}
2025
async updateMetadata(local: ILocalExtension, metadata: Partial<Metadata>): Promise<ILocalExtension> { return local; }
2026
registerParticipant(pariticipant: IExtensionManagementParticipant): void { }
2027
async getTargetPlatform(): Promise<TargetPlatform> { return TargetPlatform.UNDEFINED; }
2028
async cleanUp(): Promise<void> { }
2029
download(): Promise<URI> {
2030
throw new Error('Method not implemented.');
2031
}
2032
copyExtensions(): Promise<void> { throw new Error('Not Supported'); }
2033
toggleApplicationScope(): Promise<ILocalExtension> { throw new Error('Not Supported'); }
2034
installExtensionsFromProfile(): Promise<ILocalExtension[]> { throw new Error('Not Supported'); }
2035
whenProfileChanged(from: IUserDataProfile, to: IUserDataProfile): Promise<void> { throw new Error('Not Supported'); }
2036
getInstalledWorkspaceExtensionLocations(): URI[] { throw new Error('Method not implemented.'); }
2037
getInstalledWorkspaceExtensions(): Promise<ILocalExtension[]> { throw new Error('Method not implemented.'); }
2038
installResourceExtension(): Promise<ILocalExtension> { throw new Error('Method not implemented.'); }
2039
getExtensions(): Promise<IResourceExtension[]> { throw new Error('Method not implemented.'); }
2040
resetPinnedStateForAllUserExtensions(pinned: boolean): Promise<void> { throw new Error('Method not implemented.'); }
2041
getInstallableServers(extension: IGalleryExtension): Promise<IExtensionManagementServer[]> { throw new Error('Method not implemented.'); }
2042
isPublisherTrusted(extension: IGalleryExtension): boolean { return false; }
2043
getTrustedPublishers() { return []; }
2044
trustPublishers(): void { }
2045
untrustPublishers(): void { }
2046
async requestPublisherTrust(extensions: InstallExtensionInfo[]): Promise<void> { }
2047
}
2048
2049
2050
2051
export class TestWebExtensionsScannerService implements IWebExtensionsScannerService {
2052
_serviceBrand: undefined;
2053
onDidChangeProfile = Event.None;
2054
async scanSystemExtensions(): Promise<IExtension[]> { return []; }
2055
async scanUserExtensions(): Promise<IScannedExtension[]> { return []; }
2056
async scanExtensionsUnderDevelopment(): Promise<IExtension[]> { return []; }
2057
async copyExtensions(): Promise<void> {
2058
throw new Error('Method not implemented.');
2059
}
2060
scanExistingExtension(extensionLocation: URI, extensionType: ExtensionType): Promise<IScannedExtension | null> {
2061
throw new Error('Method not implemented.');
2062
}
2063
addExtension(location: URI, metadata?: Partial<IGalleryMetadata & { isApplicationScoped: boolean; isMachineScoped: boolean; isBuiltin: boolean; isSystem: boolean; updated: boolean; preRelease: boolean; installedTimestamp: number }> | undefined): Promise<IExtension> {
2064
throw new Error('Method not implemented.');
2065
}
2066
addExtensionFromGallery(galleryExtension: IGalleryExtension, metadata?: Partial<IGalleryMetadata & { isApplicationScoped: boolean; isMachineScoped: boolean; isBuiltin: boolean; isSystem: boolean; updated: boolean; preRelease: boolean; installedTimestamp: number }> | undefined): Promise<IExtension> {
2067
throw new Error('Method not implemented.');
2068
}
2069
removeExtension(): Promise<void> {
2070
throw new Error('Method not implemented.');
2071
}
2072
updateMetadata(extension: IScannedExtension, metaData: Partial<Metadata>, profileLocation: URI): Promise<IScannedExtension> {
2073
throw new Error('Method not implemented.');
2074
}
2075
scanExtensionManifest(extensionLocation: URI): Promise<Readonly<IRelaxedExtensionManifest> | null> {
2076
throw new Error('Method not implemented.');
2077
}
2078
}
2079
2080
export async function workbenchTeardown(instantiationService: IInstantiationService): Promise<void> {
2081
return instantiationService.invokeFunction(async accessor => {
2082
const workingCopyService = accessor.get(IWorkingCopyService);
2083
const editorGroupService = accessor.get(IEditorGroupsService);
2084
2085
for (const workingCopy of workingCopyService.workingCopies) {
2086
await workingCopy.revert();
2087
}
2088
2089
for (const group of editorGroupService.groups) {
2090
await group.closeAllEditors();
2091
}
2092
2093
for (const group of editorGroupService.groups) {
2094
editorGroupService.removeGroup(group);
2095
}
2096
});
2097
}
2098
2099
export class TestContextMenuService implements IContextMenuService {
2100
2101
_serviceBrand: undefined;
2102
2103
readonly onDidShowContextMenu = Event.None;
2104
readonly onDidHideContextMenu = Event.None;
2105
2106
showContextMenu(delegate: IContextMenuDelegate | IContextMenuMenuDelegate): void {
2107
throw new Error('Method not implemented.');
2108
}
2109
}
2110
2111