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