提交 eab39144 编写于 作者: B Benjamin Pasero

web - more env refactoring and polish

上级 c0ba9bd3
......@@ -15,7 +15,7 @@ import { onUnexpectedError } from 'vs/base/common/errors';
import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform';
import { URI } from 'vs/base/common/uri';
import { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService';
import { WorkbenchEnvironmentService } from 'vs/workbench/services/environment/node/environmentService';
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { stat } from 'vs/base/node/pfs';
......@@ -56,12 +56,12 @@ import { ElectronEnvironmentService, IElectronEnvironmentService } from 'vs/work
class DesktopMain extends Disposable {
private readonly environmentService: WorkbenchEnvironmentService;
private readonly environmentService: NativeWorkbenchEnvironmentService;
constructor(private configuration: IWindowConfiguration) {
super();
this.environmentService = new WorkbenchEnvironmentService(configuration, configuration.execPath, configuration.windowId);
this.environmentService = new NativeWorkbenchEnvironmentService(configuration, configuration.execPath, configuration.windowId);
this.init();
}
......
......@@ -20,7 +20,7 @@ import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { FileService } from 'vs/platform/files/common/fileService';
import { NullLogService } from 'vs/platform/log/common/log';
import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider';
import { WorkbenchEnvironmentService } from 'vs/workbench/services/environment/node/environmentService';
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import { snapshotToString } from 'vs/workbench/services/textfile/common/textfiles';
import { IFileService } from 'vs/platform/files/common/files';
......@@ -46,7 +46,7 @@ const fooBackupPath = path.join(workspaceBackupPath, 'file', hashPath(fooFile));
const barBackupPath = path.join(workspaceBackupPath, 'file', hashPath(barFile));
const untitledBackupPath = path.join(workspaceBackupPath, 'untitled', hashPath(untitledFile));
class TestBackupEnvironmentService extends WorkbenchEnvironmentService {
class TestBackupEnvironmentService extends NativeWorkbenchEnvironmentService {
constructor(backupPath: string) {
super({ ...parseArgs(process.argv, OPTIONS), ...{ backupPath, 'user-data-dir': userdataDir } } as IWindowConfiguration, process.execPath, 0);
......
......@@ -39,11 +39,11 @@ import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemPro
import { IFileService } from 'vs/platform/files/common/files';
import { ConfigurationCache } from 'vs/workbench/services/configuration/node/configurationCache';
import { KeybindingsEditingService, IKeybindingEditingService } from 'vs/workbench/services/keybinding/common/keybindingEditing';
import { WorkbenchEnvironmentService } from 'vs/workbench/services/environment/node/environmentService';
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider';
class TestEnvironmentService extends WorkbenchEnvironmentService {
class TestEnvironmentService extends NativeWorkbenchEnvironmentService {
constructor(private _appSettingsHome: URI) {
super(parseArgs(process.argv, OPTIONS) as IWindowConfiguration, process.execPath, 0);
......
......@@ -45,10 +45,10 @@ import { IConfigurationCache } from 'vs/workbench/services/configuration/common/
import { SignService } from 'vs/platform/sign/browser/signService';
import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider';
import { IKeybindingEditingService, KeybindingsEditingService } from 'vs/workbench/services/keybinding/common/keybindingEditing';
import { WorkbenchEnvironmentService } from 'vs/workbench/services/environment/node/environmentService';
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
class TestEnvironmentService extends WorkbenchEnvironmentService {
class TestEnvironmentService extends NativeWorkbenchEnvironmentService {
constructor(private _appSettingsHome: URI) {
super(parseArgs(process.argv, OPTIONS) as IWindowConfiguration, process.execPath, 0);
......
......@@ -19,7 +19,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import * as Types from 'vs/base/common/types';
import { EditorType } from 'vs/editor/common/editorCommon';
import { Selection } from 'vs/editor/common/core/selection';
import { WorkbenchEnvironmentService } from 'vs/workbench/services/environment/node/environmentService';
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
......@@ -642,7 +642,7 @@ class MockInputsConfigurationService extends TestConfigurationService {
}
}
class MockWorkbenchEnvironmentService extends WorkbenchEnvironmentService {
class MockWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService {
constructor(env: platform.IProcessEnvironment) {
super({ userEnv: env } as IWindowConfiguration, process.execPath, 0);
......
......@@ -14,28 +14,24 @@ import { join } from 'vs/base/common/path';
import { IDebugParams } from 'vs/platform/environment/common/environment';
import product from 'vs/platform/product/common/product';
export class WorkbenchEnvironmentService extends EnvironmentService implements IWorkbenchEnvironmentService {
export class NativeWorkbenchEnvironmentService extends EnvironmentService implements IWorkbenchEnvironmentService {
_serviceBrand: undefined;
@memoize
get webviewExternalEndpoint(): string {
const baseEndpoint = 'https://{{uuid}}.vscode-webview-test.com/{{commit}}';
return baseEndpoint.replace('{{commit}}', product.commit || 'c58aaab8a1cc22a7139b761166a0d4f37d41e998');
}
readonly webviewResourceRoot = 'vscode-resource://{{resource}}';
readonly webviewCspSource = 'vscode-resource:';
constructor(
readonly configuration: IWindowConfiguration,
execPath: string,
private readonly windowId: number
) {
super(configuration, execPath);
@memoize
get webviewResourceRoot(): string { return 'vscode-resource://{{resource}}'; }
this.configuration.backupWorkspaceResource = this.configuration.backupPath ? toBackupWorkspaceResource(this.configuration.backupPath, this) : undefined;
}
@memoize
get webviewCspSource(): string { return 'vscode-resource:'; }
@memoize
get skipReleaseNotes(): boolean { return !!this.args['skip-release-notes']; }
@memoize
......@@ -44,8 +40,19 @@ export class WorkbenchEnvironmentService extends EnvironmentService implements I
@memoize
get logFile(): URI { return URI.file(join(this.logsPath, `renderer${this.windowId}.log`)); }
@memoize
get logExtensionHostCommunication(): boolean { return !!this.args.logExtensionHostCommunication; }
@memoize
get debugSearch(): IDebugParams { return parseSearchPort(this.args, this.isBuilt); }
constructor(
readonly configuration: IWindowConfiguration,
execPath: string,
private readonly windowId: number
) {
super(configuration, execPath);
this.configuration.backupWorkspaceResource = this.configuration.backupPath ? toBackupWorkspaceResource(this.configuration.backupPath, this) : undefined;
}
}
......@@ -46,11 +46,11 @@ import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemPro
import { URI } from 'vs/base/common/uri';
import { FileUserDataProvider } from 'vs/workbench/services/userData/common/fileUserDataProvider';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import { WorkbenchEnvironmentService } from 'vs/workbench/services/environment/node/environmentService';
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
class TestEnvironmentService extends WorkbenchEnvironmentService {
class TestEnvironmentService extends NativeWorkbenchEnvironmentService {
constructor(private _appSettingsHome: URI) {
super(parseArgs(process.argv, OPTIONS) as IWindowConfiguration, process.execPath, 0);
......
......@@ -23,6 +23,15 @@ import { BrowserWorkbenchEnvironmentService } from 'vs/workbench/services/enviro
import { Emitter, Event } from 'vs/base/common/event';
import { timeout } from 'vs/base/common/async';
class TestBrowserWorkbenchEnvironmentService extends BrowserWorkbenchEnvironmentService {
testUserRoamingDataHome!: URI;
get userRoamingDataHome(): URI {
return this.testUserRoamingDataHome;
}
}
suite('FileUserDataProvider', () => {
let testObject: IFileService;
......@@ -47,8 +56,8 @@ suite('FileUserDataProvider', () => {
userDataResource = URI.file(userDataPath).with({ scheme: Schemas.userData });
await Promise.all([pfs.mkdirp(userDataPath), pfs.mkdirp(backupsPath)]);
const environmentService = new BrowserWorkbenchEnvironmentService({ remoteAuthority: 'remote', workspaceId: 'workspaceId', logsPath: URI.file('logFile') });
environmentService.userRoamingDataHome = userDataResource;
const environmentService = new TestBrowserWorkbenchEnvironmentService({ remoteAuthority: 'remote', workspaceId: 'workspaceId', logsPath: URI.file('logFile') });
environmentService.testUserRoamingDataHome = userDataResource;
const userDataFileSystemProvider = new FileUserDataProvider(URI.file(userDataPath), URI.file(backupsPath), diskFileSystemProvider, environmentService);
disposables.add(userDataFileSystemProvider);
......@@ -321,8 +330,8 @@ suite('FileUserDataProvider - Watching', () => {
localUserDataResource = URI.file(userDataPath);
userDataResource = localUserDataResource.with({ scheme: Schemas.userData });
const environmentService = new BrowserWorkbenchEnvironmentService({ remoteAuthority: 'remote', workspaceId: 'workspaceId', logsPath: URI.file('logFile') });
environmentService.userRoamingDataHome = userDataResource;
const environmentService = new TestBrowserWorkbenchEnvironmentService({ remoteAuthority: 'remote', workspaceId: 'workspaceId', logsPath: URI.file('logFile') });
environmentService.testUserRoamingDataHome = userDataResource;
const userDataFileSystemProvider = new FileUserDataProvider(localUserDataResource, localBackupsResource, new TestFileSystemProvider(fileEventEmitter.event), environmentService);
disposables.add(userDataFileSystemProvider);
......
......@@ -79,7 +79,7 @@ import { IPanel } from 'vs/workbench/common/panel';
import { IBadge } from 'vs/workbench/services/activity/common/activity';
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { WorkbenchEnvironmentService } from 'vs/workbench/services/environment/node/environmentService';
import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { VSBuffer, VSBufferReadable } from 'vs/base/common/buffer';
import { NativeTextFileService } from 'vs/workbench/services/textfile/electron-browser/nativeTextFileService';
import { Schemas } from 'vs/base/common/network';
......@@ -97,7 +97,7 @@ export function createFileInput(instantiationService: IInstantiationService, res
return instantiationService.createInstance(FileEditorInput, resource, undefined, undefined);
}
export const TestEnvironmentService = new WorkbenchEnvironmentService(parseArgs(process.argv, OPTIONS) as IWindowConfiguration, process.execPath, 0);
export const TestEnvironmentService = new NativeWorkbenchEnvironmentService(parseArgs(process.argv, OPTIONS) as IWindowConfiguration, process.execPath, 0);
export class TestContextService implements IWorkspaceContextService {
public _serviceBrand: undefined;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册