提交 9ce4ebbf 编写于 作者: B Benjamin Pasero

debt - fold electron environment and native environment into one

上级 44c76bd3
......@@ -16,7 +16,7 @@ export interface INativeWindowConfiguration extends IWindowConfiguration {
mainPid: number;
windowId: number;
machineId: string; // NOTE: This is undefined in the web, the telemetry service directly resolves this.
machineId: string;
appRoot: string;
execPath: string;
......
......@@ -9,8 +9,9 @@ import { URI } from 'vs/base/common/uri';
import * as nls from 'vs/nls';
import { IElectronService } from 'vs/platform/electron/node/electron';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IFileService } from 'vs/platform/files/common/files';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
export class OpenLogsFolderAction extends Action {
......@@ -35,7 +36,7 @@ export class OpenExtensionLogsFolderAction extends Action {
static readonly LABEL = nls.localize('openExtensionLogsFolder', "Open Extension Logs Folder");
constructor(id: string, label: string,
@IElectronEnvironmentService private readonly electronEnvironmentSerice: IElectronEnvironmentService,
@IWorkbenchEnvironmentService private readonly environmentSerice: INativeWorkbenchEnvironmentService,
@IFileService private readonly fileService: IFileService,
@IElectronService private readonly electronService: IElectronService
) {
......@@ -43,7 +44,7 @@ export class OpenExtensionLogsFolderAction extends Action {
}
async run(): Promise<void> {
const folderStat = await this.fileService.resolve(this.electronEnvironmentSerice.extHostLogsPath);
const folderStat = await this.fileService.resolve(this.environmentSerice.extHostLogsPath);
if (folderStat.children && folderStat.children[0]) {
return this.electronService.showItemInFolder(folderStat.children[0].resource.fsPath);
}
......
......@@ -24,7 +24,7 @@ import { URI } from 'vs/base/common/uri';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import * as perf from 'vs/base/common/performance';
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { assertIsDefined } from 'vs/base/common/types';
class PartsSplash {
......@@ -41,8 +41,7 @@ class PartsSplash {
@IThemeService private readonly _themeService: IThemeService,
@IWorkbenchLayoutService private readonly _layoutService: IWorkbenchLayoutService,
@ITextFileService private readonly _textFileService: ITextFileService,
@IWorkbenchEnvironmentService private readonly _envService: IWorkbenchEnvironmentService,
@IElectronEnvironmentService private readonly _electronEnvService: IElectronEnvironmentService,
@IWorkbenchEnvironmentService private readonly _envService: INativeWorkbenchEnvironmentService,
@ILifecycleService lifecycleService: ILifecycleService,
@IEditorGroupsService editorGroupsService: IEditorGroupsService,
@IConfigurationService configService: IConfigurationService,
......@@ -113,7 +112,7 @@ class PartsSplash {
// the color needs to be in hex
const backgroundColor = this._themeService.getColorTheme().getColor(editorBackground) || themes.WORKBENCH_BACKGROUND(this._themeService.getColorTheme());
const payload = JSON.stringify({ baseTheme, background: Color.Format.CSS.formatHex(backgroundColor) });
ipc.send('vscode:changeColorTheme', this._electronEnvService.windowId, payload);
ipc.send('vscode:changeColorTheme', this._envService.configuration.windowId, payload);
}
}
......
......@@ -18,7 +18,8 @@ import { ICommandHandler } from 'vs/platform/commands/common/commands';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IElectronService } from 'vs/platform/electron/node/electron';
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
export class CloseCurrentWindowAction extends Action {
......@@ -167,7 +168,7 @@ export abstract class BaseSwitchWindow extends Action {
constructor(
id: string,
label: string,
private electronEnvironmentService: IElectronEnvironmentService,
private environmentService: INativeWorkbenchEnvironmentService,
private quickInputService: IQuickInputService,
private keybindingService: IKeybindingService,
private modelService: IModelService,
......@@ -180,7 +181,7 @@ export abstract class BaseSwitchWindow extends Action {
protected abstract isQuickNavigate(): boolean;
async run(): Promise<void> {
const currentWindowId = this.electronEnvironmentService.windowId;
const currentWindowId = this.environmentService.configuration.windowId;
const windows = await this.electronService.getWindows();
const placeHolder = nls.localize('switchWindowPlaceHolder', "Select a window to switch to");
......@@ -222,14 +223,14 @@ export class SwitchWindow extends BaseSwitchWindow {
constructor(
id: string,
label: string,
@IElectronEnvironmentService electronEnvironmentService: IElectronEnvironmentService,
@IWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService,
@IQuickInputService quickInputService: IQuickInputService,
@IKeybindingService keybindingService: IKeybindingService,
@IModelService modelService: IModelService,
@IModeService modeService: IModeService,
@IElectronService electronService: IElectronService
) {
super(id, label, electronEnvironmentService, quickInputService, keybindingService, modelService, modeService, electronService);
super(id, label, environmentService, quickInputService, keybindingService, modelService, modeService, electronService);
}
protected isQuickNavigate(): boolean {
......@@ -245,14 +246,14 @@ export class QuickSwitchWindow extends BaseSwitchWindow {
constructor(
id: string,
label: string,
@IElectronEnvironmentService electronEnvironmentService: IElectronEnvironmentService,
@IWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService,
@IQuickInputService quickInputService: IQuickInputService,
@IKeybindingService keybindingService: IKeybindingService,
@IModelService modelService: IModelService,
@IModeService modeService: IModeService,
@IElectronService electronService: IElectronService
) {
super(id, label, electronEnvironmentService, quickInputService, keybindingService, modelService, modeService, electronService);
super(id, label, environmentService, quickInputService, keybindingService, modelService, modeService, electronService);
}
protected isQuickNavigate(): boolean {
......
......@@ -51,7 +51,6 @@ import { FileUserDataProvider } from 'vs/workbench/services/userData/common/file
import { basename } from 'vs/base/common/resources';
import { IProductService } from 'vs/platform/product/common/productService';
import product from 'vs/platform/product/common/product';
import { ElectronEnvironmentService, IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
class DesktopMain extends Disposable {
......@@ -60,7 +59,7 @@ class DesktopMain extends Disposable {
constructor(private configuration: INativeWindowConfiguration) {
super();
this.environmentService = new NativeWorkbenchEnvironmentService(configuration, configuration.execPath, configuration.windowId);
this.environmentService = new NativeWorkbenchEnvironmentService(configuration, configuration.execPath);
this.init();
}
......@@ -180,11 +179,6 @@ class DesktopMain extends Disposable {
// Environment
serviceCollection.set(IWorkbenchEnvironmentService, this.environmentService);
serviceCollection.set(IElectronEnvironmentService, new ElectronEnvironmentService(
this.configuration.windowId,
this.environmentService.sharedIPCHandle,
this.environmentService
));
// Product
serviceCollection.set(IProductService, { _serviceBrand: undefined, ...product });
......
......@@ -58,7 +58,6 @@ import { getBaseLabel } from 'vs/base/common/labels';
import { ITunnelService, extractLocalHostUriMetaDataForPortMapping } from 'vs/platform/remote/common/tunnel';
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
import { IHostService } from 'vs/workbench/services/host/browser/host';
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
import { IWorkingCopyService, WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopyService';
import { AutoSaveMode, IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
import { Event } from 'vs/base/common/event';
......@@ -69,7 +68,6 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IProductService } from 'vs/platform/product/common/productService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
export class ElectronWindow extends Disposable {
private touchBarMenu: IMenu | undefined;
......@@ -109,7 +107,6 @@ export class ElectronWindow extends Disposable {
@IElectronService private readonly electronService: IElectronService,
@ITunnelService private readonly tunnelService: ITunnelService,
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
@IElectronEnvironmentService private readonly electronEnvironmentService: IElectronEnvironmentService,
@IWorkingCopyService private readonly workingCopyService: IWorkingCopyService,
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService
) {
......@@ -287,8 +284,8 @@ export class ElectronWindow extends Disposable {
// Detect minimize / maximize
this._register(Event.any(
Event.map(Event.filter(this.electronService.onWindowMaximize, id => id === this.electronEnvironmentService.windowId), () => true),
Event.map(Event.filter(this.electronService.onWindowUnmaximize, id => id === this.electronEnvironmentService.windowId), () => false)
Event.map(Event.filter(this.electronService.onWindowMaximize, id => id === this.environmentService.configuration.windowId), () => true),
Event.map(Event.filter(this.electronService.onWindowUnmaximize, id => id === this.environmentService.configuration.windowId), () => false)
)(e => this.onDidChangeMaximized(e)));
this.onDidChangeMaximized(this.environmentService.configuration.maximized ?? false);
......@@ -402,7 +399,7 @@ export class ElectronWindow extends Disposable {
this.setupOpenHandlers();
// Emit event when vscode is ready
this.lifecycleService.when(LifecyclePhase.Ready).then(() => ipc.send('vscode:workbenchReady', this.electronEnvironmentService.windowId));
this.lifecycleService.when(LifecyclePhase.Ready).then(() => ipc.send('vscode:workbenchReady', this.environmentService.configuration.windowId));
// Integrity warning
this.integrityService.isPure().then(res => this.titleService.updateProperties({ isPure: res.isPure }));
......@@ -704,11 +701,10 @@ class NativeMenubarControl extends MenubarControl {
@IStorageService storageService: IStorageService,
@INotificationService notificationService: INotificationService,
@IPreferencesService preferencesService: IPreferencesService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IWorkbenchEnvironmentService protected readonly environmentService: INativeWorkbenchEnvironmentService,
@IAccessibilityService accessibilityService: IAccessibilityService,
@IMenubarService private readonly menubarService: IMenubarService,
@IHostService hostService: IHostService,
@IElectronEnvironmentService private readonly electronEnvironmentService: IElectronEnvironmentService
) {
super(
menuService,
......@@ -757,7 +753,7 @@ class NativeMenubarControl extends MenubarControl {
// Send menus to main process to be rendered by Electron
const menubarData = { menus: {}, keybindings: {} };
if (this.getMenubarMenus(menubarData)) {
this.menubarService.updateMenubar(this.electronEnvironmentService.windowId, menubarData);
this.menubarService.updateMenubar(this.environmentService.configuration.windowId, menubarData);
}
}
......
......@@ -48,7 +48,7 @@ const untitledBackupPath = path.join(workspaceBackupPath, 'untitled', hashPath(u
class TestBackupEnvironmentService extends NativeWorkbenchEnvironmentService {
constructor(backupPath: string) {
super({ ...TestWindowConfiguration, backupPath, 'user-data-dir': userdataDir }, TestWindowConfiguration.execPath, TestWindowConfiguration.windowId);
super({ ...TestWindowConfiguration, backupPath, 'user-data-dir': userdataDir }, TestWindowConfiguration.execPath);
}
}
......
......@@ -45,7 +45,7 @@ import { FileUserDataProvider } from 'vs/workbench/services/userData/common/file
class TestEnvironmentService extends NativeWorkbenchEnvironmentService {
constructor(private _appSettingsHome: URI) {
super(TestWindowConfiguration, TestWindowConfiguration.execPath, TestWindowConfiguration.windowId);
super(TestWindowConfiguration, TestWindowConfiguration.execPath);
}
get appSettingsHome() { return this._appSettingsHome; }
......
......@@ -51,7 +51,7 @@ import { timeout } from 'vs/base/common/async';
class TestEnvironmentService extends NativeWorkbenchEnvironmentService {
constructor(private _appSettingsHome: URI) {
super(TestWindowConfiguration, TestWindowConfiguration.execPath, TestWindowConfiguration.windowId);
super(TestWindowConfiguration, TestWindowConfiguration.execPath);
}
get appSettingsHome() { return this._appSettingsHome; }
......
......@@ -623,6 +623,6 @@ class MockInputsConfigurationService extends TestConfigurationService {
class MockWorkbenchEnvironmentService extends NativeWorkbenchEnvironmentService {
constructor(public userEnv: platform.IProcessEnvironment) {
super({ ...TestWindowConfiguration, userEnv }, TestWindowConfiguration.execPath, TestWindowConfiguration.windowId);
super({ ...TestWindowConfiguration, userEnv }, TestWindowConfiguration.execPath);
}
}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { URI } from 'vs/base/common/uri';
import { memoize } from 'vs/base/common/decorators';
import { join } from 'vs/base/common/path';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
export const IElectronEnvironmentService = createDecorator<IElectronEnvironmentService>('electronEnvironmentService');
export interface IElectronEnvironmentService {
_serviceBrand: undefined;
readonly windowId: number;
readonly sharedIPCHandle: string;
readonly extHostLogsPath: URI;
}
export class ElectronEnvironmentService implements IElectronEnvironmentService {
_serviceBrand: undefined;
constructor(
public readonly windowId: number,
public readonly sharedIPCHandle: string,
private readonly environmentService: IEnvironmentService
) { }
@memoize
get extHostLogsPath(): URI { return URI.file(join(this.environmentService.logsPath, `exthost${this.windowId}`)); }
}
......@@ -6,8 +6,9 @@
import { IElectronService } from 'vs/platform/electron/node/electron';
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { createChannelSender } from 'vs/base/parts/ipc/node/ipc';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
export class ElectronService {
......@@ -15,9 +16,9 @@ export class ElectronService {
constructor(
@IMainProcessService mainProcessService: IMainProcessService,
@IElectronEnvironmentService electronEnvironmentService: IElectronEnvironmentService
@IWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService
) {
return createChannelSender<IElectronService>(mainProcessService.getChannel('electron'), { context: electronEnvironmentService.windowId });
return createChannelSender<IElectronService>(mainProcessService.getChannel('electron'), { context: environmentService.configuration.windowId });
}
}
......
......@@ -17,9 +17,12 @@ export interface INativeWorkbenchEnvironmentService extends IWorkbenchEnvironmen
readonly configuration: INativeWindowConfiguration;
log?: string;
cliPath: string;
disableCrashReporter: boolean;
readonly disableCrashReporter: boolean;
readonly cliPath: string;
readonly log?: string;
readonly extHostLogsPath: URI;
}
export class NativeWorkbenchEnvironmentService extends EnvironmentService implements INativeWorkbenchEnvironmentService {
......@@ -43,12 +46,14 @@ export class NativeWorkbenchEnvironmentService extends EnvironmentService implem
get userRoamingDataHome(): URI { return this.appSettingsHome.with({ scheme: Schemas.userData }); }
@memoize
get logFile(): URI { return URI.file(join(this.logsPath, `renderer${this.windowId}.log`)); }
get logFile(): URI { return URI.file(join(this.logsPath, `renderer${this.configuration.windowId}.log`)); }
@memoize
get extHostLogsPath(): URI { return URI.file(join(this.logsPath, `exthost${this.configuration.windowId}`)); }
constructor(
readonly configuration: INativeWindowConfiguration,
execPath: string,
private readonly windowId: number
execPath: string
) {
super(configuration, execPath);
......
......@@ -35,7 +35,7 @@ import { Logger } from 'vs/workbench/services/extensions/common/extensionPoints'
import { flatten } from 'vs/base/common/arrays';
import { IStaticExtensionsService } from 'vs/workbench/services/extensions/common/staticExtensions';
import { IElectronService } from 'vs/platform/electron/node/electron';
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
import { IRemoteExplorerService } from 'vs/workbench/services/remote/common/remoteExplorerService';
import { Action } from 'vs/base/common/actions';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
......@@ -60,7 +60,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
constructor(
@IInstantiationService instantiationService: IInstantiationService,
@INotificationService notificationService: INotificationService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IWorkbenchEnvironmentService protected readonly _environmentService: INativeWorkbenchEnvironmentService,
@ITelemetryService telemetryService: ITelemetryService,
@IWorkbenchExtensionEnablementService extensionEnablementService: IWorkbenchExtensionEnablementService,
@IFileService fileService: IFileService,
......@@ -73,14 +73,13 @@ export class ExtensionService extends AbstractExtensionService implements IExten
@IStaticExtensionsService private readonly _staticExtensions: IStaticExtensionsService,
@IElectronService private readonly _electronService: IElectronService,
@IHostService private readonly _hostService: IHostService,
@IElectronEnvironmentService private readonly _electronEnvironmentService: IElectronEnvironmentService,
@IRemoteExplorerService private readonly _remoteExplorerService: IRemoteExplorerService,
@IExtensionGalleryService private readonly _extensionGalleryService: IExtensionGalleryService,
) {
super(
instantiationService,
notificationService,
environmentService,
_environmentService,
telemetryService,
extensionEnablementService,
fileService,
......@@ -361,7 +360,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
const result: ExtensionHostProcessManager[] = [];
const extHostProcessWorker = this._instantiationService.createInstance(ExtensionHostProcessWorker, autoStart, extensions, this._electronEnvironmentService.extHostLogsPath);
const extHostProcessWorker = this._instantiationService.createInstance(ExtensionHostProcessWorker, autoStart, extensions, this._environmentService.extHostLogsPath);
const extHostProcessManager = this._instantiationService.createInstance(ExtensionHostProcessManager, true, extHostProcessWorker, null, initialActivationEvents);
result.push(extHostProcessManager);
......
......@@ -11,7 +11,7 @@ import { ILabelService } from 'vs/platform/label/common/label';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IWindowOpenable, IOpenWindowOptions, isFolderToOpen, isWorkspaceToOpen, IOpenEmptyWindowOptions } from 'vs/platform/windows/common/windows';
import { Disposable } from 'vs/base/common/lifecycle';
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
export class DesktopHostService extends Disposable implements IHostService {
......@@ -20,16 +20,15 @@ export class DesktopHostService extends Disposable implements IHostService {
constructor(
@IElectronService private readonly electronService: IElectronService,
@ILabelService private readonly labelService: ILabelService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IElectronEnvironmentService private readonly electronEnvironmentService: IElectronEnvironmentService
@IWorkbenchEnvironmentService private readonly environmentService: INativeWorkbenchEnvironmentService
) {
super();
}
get onDidChangeFocus(): Event<boolean> { return this._onDidChangeFocus; }
private _onDidChangeFocus: Event<boolean> = Event.any(
Event.map(Event.filter(this.electronService.onWindowFocus, id => id === this.electronEnvironmentService.windowId), () => this.hasFocus),
Event.map(Event.filter(this.electronService.onWindowBlur, id => id === this.electronEnvironmentService.windowId), () => this.hasFocus)
Event.map(Event.filter(this.electronService.onWindowFocus, id => id === this.environmentService.configuration.windowId), () => this.hasFocus),
Event.map(Event.filter(this.electronService.onWindowBlur, id => id === this.environmentService.configuration.windowId), () => this.hasFocus)
);
get hasFocus(): boolean {
......@@ -43,7 +42,7 @@ export class DesktopHostService extends Disposable implements IHostService {
return false;
}
return activeWindowId === this.electronEnvironmentService.windowId;
return activeWindowId === this.environmentService.configuration.windowId;
}
openWindow(options?: IOpenEmptyWindowOptions): Promise<void>;
......
......@@ -58,7 +58,7 @@ import { UndoRedoService } from 'vs/platform/undoRedo/common/undoRedoService';
class TestEnvironmentService extends NativeWorkbenchEnvironmentService {
constructor(private _appSettingsHome: URI) {
super(TestWindowConfiguration, TestWindowConfiguration.execPath, TestWindowConfiguration.windowId);
super(TestWindowConfiguration, TestWindowConfiguration.execPath);
}
get appSettingsHome() { return this._appSettingsHome; }
......
......@@ -7,7 +7,6 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
import { ShutdownReason, StartupKind, handleVetos, ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IStorageService, StorageScope, WillSaveStateReason } from 'vs/platform/storage/common/storage';
import { ipcRenderer as ipc } from 'electron';
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
import { ILogService } from 'vs/platform/log/common/log';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { onUnexpectedError } from 'vs/base/common/errors';
......@@ -15,6 +14,8 @@ import { AbstractLifecycleService } from 'vs/platform/lifecycle/common/lifecycle
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import Severity from 'vs/base/common/severity';
import { localize } from 'vs/nls';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
export class NativeLifecycleService extends AbstractLifecycleService {
......@@ -26,7 +27,7 @@ export class NativeLifecycleService extends AbstractLifecycleService {
constructor(
@INotificationService private readonly notificationService: INotificationService,
@IElectronEnvironmentService private readonly electronEnvironmentService: IElectronEnvironmentService,
@IWorkbenchEnvironmentService private readonly environmentService: INativeWorkbenchEnvironmentService,
@IStorageService readonly storageService: IStorageService,
@ILogService readonly logService: ILogService
) {
......@@ -56,7 +57,7 @@ export class NativeLifecycleService extends AbstractLifecycleService {
}
private registerListeners(): void {
const windowId = this.electronEnvironmentService.windowId;
const windowId = this.environmentService.configuration.windowId;
// Main side indicates that window is about to unload, check for vetos
ipc.on('vscode:onBeforeUnload', (_event: unknown, reply: { okChannel: string, cancelChannel: string, reason: ShutdownReason }) => {
......
......@@ -21,7 +21,7 @@ import { toLocalISOString } from 'vs/base/common/date';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { Emitter, Event } from 'vs/base/common/event';
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
class OutputChannelBackedByFile extends AbstractFileOutputChannelModel implements IOutputChannelModel {
......@@ -203,8 +203,7 @@ export class OutputChannelModelService extends AsbtractOutputChannelModelService
constructor(
@IInstantiationService instantiationService: IInstantiationService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IElectronEnvironmentService private readonly electronEnvironmentService: IElectronEnvironmentService,
@IWorkbenchEnvironmentService private readonly environmentService: INativeWorkbenchEnvironmentService,
@IFileService private readonly fileService: IFileService
) {
super(instantiationService);
......@@ -218,7 +217,7 @@ export class OutputChannelModelService extends AsbtractOutputChannelModelService
private _outputDir: Promise<URI> | null = null;
private get outputDir(): Promise<URI> {
if (!this._outputDir) {
const outputDir = URI.file(join(this.environmentService.logsPath, `output_${this.electronEnvironmentService.windowId}_${toLocalISOString(new Date()).replace(/-|:|\.\d+Z$/g, '')}`));
const outputDir = URI.file(join(this.environmentService.logsPath, `output_${this.environmentService.configuration.windowId}_${toLocalISOString(new Date()).replace(/-|:|\.\d+Z$/g, '')}`));
this._outputDir = this.fileService.createFolder(outputDir).then(() => outputDir);
}
return this._outputDir;
......
......@@ -5,11 +5,12 @@
import { Client } from 'vs/base/parts/ipc/common/ipc.net';
import { connect } from 'vs/base/parts/ipc/node/ipc.net';
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
import { IChannel, IServerChannel, getDelayedChannel } from 'vs/base/parts/ipc/common/ipc';
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
export class SharedProcessService implements ISharedProcessService {
......@@ -20,12 +21,12 @@ export class SharedProcessService implements ISharedProcessService {
constructor(
@IMainProcessService mainProcessService: IMainProcessService,
@IElectronEnvironmentService environmentService: IElectronEnvironmentService
@IWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService
) {
this.sharedProcessMainChannel = mainProcessService.getChannel('sharedProcess');
this.withSharedProcessConnection = this.whenSharedProcessReady()
.then(() => connect(environmentService.sharedIPCHandle, `window:${environmentService.windowId}`));
.then(() => connect(environmentService.sharedIPCHandle, `window:${environmentService.configuration.windowId}`));
}
whenSharedProcessReady(): Promise<void> {
......
......@@ -11,9 +11,10 @@ import { URLService } from 'vs/platform/url/node/urlService';
import { IOpenerService, IOpener, matchesScheme } from 'vs/platform/opener/common/opener';
import product from 'vs/platform/product/common/product';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
import { createChannelSender } from 'vs/base/parts/ipc/node/ipc';
import { IElectronService } from 'vs/platform/electron/node/electron';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
export interface IRelayOpenURLOptions extends IOpenURLOptions {
openToSide?: boolean;
......@@ -27,7 +28,7 @@ export class RelayURLService extends URLService implements IURLHandler, IOpener
constructor(
@IMainProcessService mainProcessService: IMainProcessService,
@IOpenerService openerService: IOpenerService,
@IElectronEnvironmentService private electronEnvironmentService: IElectronEnvironmentService,
@IWorkbenchEnvironmentService private readonly environmentService: INativeWorkbenchEnvironmentService,
@IElectronService private electronService: IElectronService
) {
super();
......@@ -43,9 +44,9 @@ export class RelayURLService extends URLService implements IURLHandler, IOpener
let query = uri.query;
if (!query) {
query = `windowId=${encodeURIComponent(this.electronEnvironmentService.windowId)}`;
query = `windowId=${encodeURIComponent(this.environmentService.configuration.windowId)}`;
} else {
query += `&windowId=${encodeURIComponent(this.electronEnvironmentService.windowId)}`;
query += `&windowId=${encodeURIComponent(this.environmentService.configuration.windowId)}`;
}
return uri.with({ query });
......
......@@ -6,8 +6,9 @@
import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
import { createChannelSender } from 'vs/base/parts/ipc/node/ipc';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
export class NativeWorkspacesService {
......@@ -15,9 +16,9 @@ export class NativeWorkspacesService {
constructor(
@IMainProcessService mainProcessService: IMainProcessService,
@IElectronEnvironmentService electronEnvironmentService: IElectronEnvironmentService
@IWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService
) {
return createChannelSender<IWorkspacesService>(mainProcessService.getChannel('workspaces'), { context: electronEnvironmentService.windowId });
return createChannelSender<IWorkspacesService>(mainProcessService.getChannel('workspaces'), { context: environmentService.configuration.windowId });
}
}
......
......@@ -53,7 +53,7 @@ export const TestWindowConfiguration: INativeWindowConfiguration = {
...parseArgs(process.argv, OPTIONS)
};
export const TestEnvironmentService = new NativeWorkbenchEnvironmentService(TestWindowConfiguration, process.execPath, 0);
export const TestEnvironmentService = new NativeWorkbenchEnvironmentService(TestWindowConfiguration, process.execPath);
export class TestTextFileService extends NativeTextFileService {
private resolveTextContentError!: FileOperationError | null;
......
......@@ -24,12 +24,14 @@ import 'vs/workbench/browser/web.main';
//#endregion
////#region --- workbench parts
//#region --- workbench parts
import 'vs/workbench/browser/parts/titlebar/titlebarPart';
//#endregion
//#region --- workbench services
import 'vs/workbench/services/integrity/browser/integrityService';
import 'vs/workbench/services/textMate/browser/textMateService';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册