Merge from vscode 718331d6f3ebd1b571530ab499edb266ddd493d5

This commit is contained in:
ADS Merger
2020-02-08 04:50:58 +00:00
parent 8c61538a27
commit 2af13c18d2
752 changed files with 16458 additions and 10063 deletions

View File

@@ -0,0 +1,189 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { workbenchInstantiationService as browserWorkbenchInstantiationService, ITestInstantiationService } from 'vs/workbench/test/browser/workbenchTestServices';
import { Event } from 'vs/base/common/event';
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { NativeTextFileService } from 'vs/workbench/services/textfile/electron-browser/nativeTextFileService';
import { IElectronService } from 'vs/platform/electron/node/electron';
import { INativeOpenDialogOptions } from 'vs/platform/dialogs/node/dialogs';
import { FileOperationError, IFileService } from 'vs/platform/files/common/files';
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IDialogService, IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfigurationService';
import { IProductService } from 'vs/platform/product/common/productService';
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { URI } from 'vs/base/common/uri';
import { IReadTextFileOptions, ITextFileStreamContent, ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { createTextBufferFactoryFromStream } from 'vs/editor/common/model/textModel';
import { IOpenedWindow, IOpenEmptyWindowOptions, IWindowOpenable, IOpenWindowOptions, IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import { LogLevel } from 'vs/platform/log/common/log';
import { IRemotePathService } from 'vs/workbench/services/path/common/remotePathService';
export const TestWindowConfiguration: IWindowConfiguration = {
windowId: 0,
sessionId: 'testSessionId',
logLevel: LogLevel.Error,
mainPid: 0,
appRoot: '',
userEnv: {},
execPath: process.execPath,
perfEntries: [],
...parseArgs(process.argv, OPTIONS)
};
export const TestEnvironmentService = new NativeWorkbenchEnvironmentService(TestWindowConfiguration, process.execPath, 0);
export class TestTextFileService extends NativeTextFileService {
private resolveTextContentError!: FileOperationError | null;
constructor(
@IFileService protected fileService: IFileService,
@IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorService,
@ILifecycleService lifecycleService: ILifecycleService,
@IInstantiationService instantiationService: IInstantiationService,
@IModelService modelService: IModelService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IDialogService dialogService: IDialogService,
@IFileDialogService fileDialogService: IFileDialogService,
@ITextResourceConfigurationService textResourceConfigurationService: ITextResourceConfigurationService,
@IProductService productService: IProductService,
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService,
@ITextModelService textModelService: ITextModelService,
@ICodeEditorService codeEditorService: ICodeEditorService,
@INotificationService notificationService: INotificationService,
@IRemotePathService remotePathService: IRemotePathService
) {
super(
fileService,
untitledTextEditorService,
lifecycleService,
instantiationService,
modelService,
environmentService,
dialogService,
fileDialogService,
textResourceConfigurationService,
productService,
filesConfigurationService,
textModelService,
codeEditorService,
notificationService,
remotePathService
);
}
setResolveTextContentErrorOnce(error: FileOperationError): void {
this.resolveTextContentError = error;
}
async readStream(resource: URI, options?: IReadTextFileOptions): Promise<ITextFileStreamContent> {
if (this.resolveTextContentError) {
const error = this.resolveTextContentError;
this.resolveTextContentError = null;
throw error;
}
const content = await this.fileService.readFileStream(resource, options);
return {
resource: content.resource,
name: content.name,
mtime: content.mtime,
ctime: content.ctime,
etag: content.etag,
encoding: 'utf8',
value: await createTextBufferFactoryFromStream(content.value),
size: 10
};
}
}
export class TestSharedProcessService implements ISharedProcessService {
_serviceBrand: undefined;
getChannel(channelName: string): any { return undefined; }
registerChannel(channelName: string, channel: any): void { }
async toggleSharedProcessWindow(): Promise<void> { }
async whenSharedProcessReady(): Promise<void> { }
}
export class TestElectronService implements IElectronService {
_serviceBrand: undefined;
onWindowOpen: Event<number> = Event.None;
onWindowMaximize: Event<number> = Event.None;
onWindowUnmaximize: Event<number> = Event.None;
onWindowFocus: Event<number> = Event.None;
onWindowBlur: Event<number> = Event.None;
windowCount = Promise.resolve(1);
getWindowCount(): Promise<number> { return this.windowCount; }
async getWindows(): Promise<IOpenedWindow[]> { return []; }
async getActiveWindowId(): Promise<number | undefined> { return undefined; }
openWindow(options?: IOpenEmptyWindowOptions): Promise<void>;
openWindow(toOpen: IWindowOpenable[], options?: IOpenWindowOptions): Promise<void>;
openWindow(arg1?: IOpenEmptyWindowOptions | IWindowOpenable[], arg2?: IOpenWindowOptions): Promise<void> {
throw new Error('Method not implemented.');
}
async toggleFullScreen(): Promise<void> { }
async handleTitleDoubleClick(): Promise<void> { }
async isMaximized(): Promise<boolean> { return true; }
async maximizeWindow(): Promise<void> { }
async unmaximizeWindow(): Promise<void> { }
async minimizeWindow(): Promise<void> { }
async focusWindow(options?: { windowId?: number | undefined; } | undefined): Promise<void> { }
async showMessageBox(options: Electron.MessageBoxOptions): Promise<Electron.MessageBoxReturnValue> { throw new Error('Method not implemented.'); }
async showSaveDialog(options: Electron.SaveDialogOptions): Promise<Electron.SaveDialogReturnValue> { throw new Error('Method not implemented.'); }
async showOpenDialog(options: Electron.OpenDialogOptions): Promise<Electron.OpenDialogReturnValue> { throw new Error('Method not implemented.'); }
async pickFileFolderAndOpen(options: INativeOpenDialogOptions): Promise<void> { }
async pickFileAndOpen(options: INativeOpenDialogOptions): Promise<void> { }
async pickFolderAndOpen(options: INativeOpenDialogOptions): Promise<void> { }
async pickWorkspaceAndOpen(options: INativeOpenDialogOptions): Promise<void> { }
async showItemInFolder(path: string): Promise<void> { }
async setRepresentedFilename(path: string): Promise<void> { }
async setDocumentEdited(edited: boolean): Promise<void> { }
async openExternal(url: string): Promise<boolean> { return false; }
async updateTouchBar(): Promise<void> { }
async newWindowTab(): Promise<void> { }
async showPreviousWindowTab(): Promise<void> { }
async showNextWindowTab(): Promise<void> { }
async moveWindowTabToNewWindow(): Promise<void> { }
async mergeAllWindowTabs(): Promise<void> { }
async toggleWindowTabsBar(): Promise<void> { }
async relaunch(options?: { addArgs?: string[] | undefined; removeArgs?: string[] | undefined; } | undefined): Promise<void> { }
async reload(): Promise<void> { }
async closeWindow(): Promise<void> { }
async quit(): Promise<void> { }
async openDevTools(options?: Electron.OpenDevToolsOptions | undefined): Promise<void> { }
async toggleDevTools(): Promise<void> { }
async startCrashReporter(options: Electron.CrashReporterStartOptions): Promise<void> { }
async resolveProxy(url: string): Promise<string | undefined> { return undefined; }
}
export function workbenchInstantiationService(): ITestInstantiationService {
const instantiationService = browserWorkbenchInstantiationService({
textFileService: insta => <ITextFileService>insta.createInstance(TestTextFileService)
});
instantiationService.stub(IElectronService, new TestElectronService());
return instantiationService;
}