Skip to content

Commit 01b5fe0

Browse files
author
Benjamin Pasero
committed
debt - remove windowId from window service
1 parent 4285509 commit 01b5fe0

21 files changed

Lines changed: 105 additions & 116 deletions

File tree

src/vs/platform/instantiation/common/instantiationService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export class InstantiationService implements IInstantiationService {
206206
} else if (this._parent) {
207207
return this._parent._createServiceInstanceWithOwner(id, ctor, args, supportsDelayedInstantiation, _trace);
208208
} else {
209-
throw new Error('illegalState - creating UNKNOWN service instance');
209+
throw new Error(`illegalState - creating UNKNOWN service instance ${ctor.name}`);
210210
}
211211
}
212212

src/vs/platform/ipc/electron-browser/sharedProcessService.ts

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
7-
import { Client } from 'vs/base/parts/ipc/common/ipc.net';
8-
import { connect } from 'vs/base/parts/ipc/node/ipc.net';
9-
import { IWindowService } from 'vs/platform/windows/common/windows';
10-
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
11-
import { IChannel, IServerChannel, getDelayedChannel } from 'vs/base/parts/ipc/common/ipc';
12-
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
7+
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
138

149
export const ISharedProcessService = createDecorator<ISharedProcessService>('sharedProcessService');
1510

@@ -23,38 +18,3 @@ export interface ISharedProcessService {
2318
whenSharedProcessReady(): Promise<void>;
2419
toggleSharedProcessWindow(): Promise<void>;
2520
}
26-
27-
export class SharedProcessService implements ISharedProcessService {
28-
29-
_serviceBrand: undefined;
30-
31-
private withSharedProcessConnection: Promise<Client<string>>;
32-
private sharedProcessMainChannel: IChannel;
33-
34-
constructor(
35-
@IMainProcessService mainProcessService: IMainProcessService,
36-
@IWindowService windowService: IWindowService,
37-
@IEnvironmentService environmentService: IEnvironmentService
38-
) {
39-
this.sharedProcessMainChannel = mainProcessService.getChannel('sharedProcess');
40-
41-
this.withSharedProcessConnection = this.whenSharedProcessReady()
42-
.then(() => connect(environmentService.sharedIPCHandle, `window:${windowService.windowId}`));
43-
}
44-
45-
whenSharedProcessReady(): Promise<void> {
46-
return this.sharedProcessMainChannel.call('whenSharedProcessReady');
47-
}
48-
49-
getChannel(channelName: string): IChannel {
50-
return getDelayedChannel(this.withSharedProcessConnection.then(connection => connection.getChannel(channelName)));
51-
}
52-
53-
registerChannel(channelName: string, channel: IServerChannel<string>): void {
54-
this.withSharedProcessConnection.then(connection => connection.registerChannel(channelName, channel));
55-
}
56-
57-
toggleSharedProcessWindow(): Promise<void> {
58-
return this.sharedProcessMainChannel.call('toggleSharedProcessWindow');
59-
}
60-
}

src/vs/platform/windows/common/windows.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ export interface IWindowService {
9797

9898
_serviceBrand: undefined;
9999

100-
readonly windowId: number;
101-
102100
getRecentlyOpened(): Promise<IRecentlyOpened>;
103101
addRecentlyOpened(recents: IRecent[]): Promise<void>;
104102
removeFromRecentlyOpened(paths: URI[]): Promise<void>;

src/vs/workbench/browser/parts/titlebar/menubarControl.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { IUpdateService, StateType } from 'vs/platform/update/common/update';
2525
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
2626
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
2727
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
28-
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
28+
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
2929
import { MenuBar } from 'vs/base/browser/ui/menu/menubar';
3030
import { SubmenuAction, Direction } from 'vs/base/browser/ui/menu/menu';
3131
import { attachMenuStyler } from 'vs/platform/theme/common/styler';
@@ -93,7 +93,7 @@ export abstract class MenubarControl extends Disposable {
9393
protected readonly storageService: IStorageService,
9494
protected readonly notificationService: INotificationService,
9595
protected readonly preferencesService: IPreferencesService,
96-
protected readonly environmentService: IEnvironmentService,
96+
protected readonly environmentService: IWorkbenchEnvironmentService,
9797
protected readonly accessibilityService: IAccessibilityService,
9898
protected readonly hostService: IHostService
9999
) {
@@ -278,7 +278,7 @@ export class CustomMenubarControl extends MenubarControl {
278278
@IStorageService storageService: IStorageService,
279279
@INotificationService notificationService: INotificationService,
280280
@IPreferencesService preferencesService: IPreferencesService,
281-
@IEnvironmentService environmentService: IEnvironmentService,
281+
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
282282
@IAccessibilityService accessibilityService: IAccessibilityService,
283283
@IThemeService private readonly themeService: IThemeService,
284284
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
@@ -434,7 +434,7 @@ export class CustomMenubarControl extends MenubarControl {
434434
return null;
435435

436436
case StateType.Idle:
437-
const windowId = this.windowService.windowId;
437+
const windowId = this.environmentService.configuration.windowId;
438438
return new Action('update.check', nls.localize({ key: 'checkForUpdates', comment: ['&& denotes a mnemonic'] }, "Check for &&Updates..."), undefined, true, () =>
439439
this.updateService.checkForUpdates({ windowId }));
440440

@@ -643,8 +643,8 @@ export class CustomMenubarControl extends MenubarControl {
643643
// Listen for maximize/unmaximize
644644
if (!isWeb) {
645645
this._register(Event.any(
646-
Event.map(Event.filter(this.electronService.onWindowMaximize, id => id === this.windowService.windowId), _ => true),
647-
Event.map(Event.filter(this.electronService.onWindowUnmaximize, id => id === this.windowService.windowId), _ => false)
646+
Event.map(Event.filter(this.electronService.onWindowMaximize, id => id === this.environmentService.configuration.windowId), _ => true),
647+
Event.map(Event.filter(this.electronService.onWindowUnmaximize, id => id === this.environmentService.configuration.windowId), _ => false)
648648
)(e => this.updateMenubar()));
649649
}
650650

src/vs/workbench/browser/parts/titlebar/titlebarPart.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as resources from 'vs/base/common/resources';
88
import { Part } from 'vs/workbench/browser/part';
99
import { ITitleService, ITitleProperties } from 'vs/workbench/services/title/common/titleService';
1010
import { getZoomFactor } from 'vs/base/browser/browser';
11-
import { IWindowService, MenuBarVisibility, getTitleBarStyle } from 'vs/platform/windows/common/windows';
11+
import { MenuBarVisibility, getTitleBarStyle, IWindowService } from 'vs/platform/windows/common/windows';
1212
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
1313
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
1414
import { IAction } from 'vs/base/common/actions';
@@ -89,7 +89,6 @@ export class TitlebarPart extends Part implements ITitleService {
8989

9090
constructor(
9191
@IContextMenuService private readonly contextMenuService: IContextMenuService,
92-
@IWindowService private readonly windowService: IWindowService,
9392
@IConfigurationService private readonly configurationService: IConfigurationService,
9493
@IEditorService private readonly editorService: IEditorService,
9594
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@@ -102,6 +101,7 @@ export class TitlebarPart extends Part implements ITitleService {
102101
@IMenuService menuService: IMenuService,
103102
@IContextKeyService contextKeyService: IContextKeyService,
104103
@IHostService private readonly hostService: IHostService,
104+
@IWindowService windowService: IWindowService,
105105
@optional(IElectronService) private electronService: IElectronService
106106
) {
107107
super(Parts.TITLEBAR_PART, { hasTitle: false }, themeService, storageService, layoutService);
@@ -434,8 +434,8 @@ export class TitlebarPart extends Part implements ITitleService {
434434
this.onDidChangeMaximized(isMaximized);
435435

436436
this._register(Event.any(
437-
Event.map(Event.filter(this.electronService.onWindowMaximize, id => id === this.windowService.windowId), _ => true),
438-
Event.map(Event.filter(this.electronService.onWindowUnmaximize, id => id === this.windowService.windowId), _ => false)
437+
Event.map(Event.filter(this.electronService.onWindowMaximize, id => id === this.environmentService.configuration.windowId), _ => true),
438+
Event.map(Event.filter(this.electronService.onWindowUnmaximize, id => id === this.environmentService.configuration.windowId), _ => false)
439439
)(e => this.onDidChangeMaximized(e)));
440440
}
441441

src/vs/workbench/browser/web.simpleservices.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ export class SimpleWindowService extends Disposable implements IWindowService {
2020

2121
_serviceBrand: undefined;
2222

23-
readonly windowId = 0;
24-
2523
static readonly RECENTLY_OPENED_KEY = 'recently.opened';
2624

2725
constructor(

src/vs/workbench/contrib/splash/electron-browser/partsSplash.contribution.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ import { DEFAULT_EDITOR_MIN_DIMENSIONS } from 'vs/workbench/browser/parts/editor
1818
import { Extensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
1919
import * as themes from 'vs/workbench/common/theme';
2020
import { IWorkbenchLayoutService, Parts, Position } from 'vs/workbench/services/layout/browser/layoutService';
21-
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
21+
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
2222
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
2323
import { URI } from 'vs/base/common/uri';
2424
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
2525
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
26-
import { IWindowService } from 'vs/platform/windows/common/windows';
2726
import * as perf from 'vs/base/common/performance';
2827

2928
class PartsSplash {
@@ -40,8 +39,7 @@ class PartsSplash {
4039
@IThemeService private readonly _themeService: IThemeService,
4140
@IWorkbenchLayoutService private readonly _layoutService: IWorkbenchLayoutService,
4241
@ITextFileService private readonly _textFileService: ITextFileService,
43-
@IEnvironmentService private readonly _envService: IEnvironmentService,
44-
@IWindowService private readonly windowService: IWindowService,
42+
@IWorkbenchEnvironmentService private readonly _envService: IWorkbenchEnvironmentService,
4543
@ILifecycleService lifecycleService: ILifecycleService,
4644
@IEditorGroupsService editorGroupsService: IEditorGroupsService,
4745
@IConfigurationService configService: IConfigurationService,
@@ -105,7 +103,7 @@ class PartsSplash {
105103
// the color needs to be in hex
106104
const backgroundColor = this._themeService.getTheme().getColor(editorBackground) || themes.WORKBENCH_BACKGROUND(this._themeService.getTheme());
107105
const payload = JSON.stringify({ baseTheme, background: Color.Format.CSS.formatHex(backgroundColor) });
108-
ipc.send('vscode:changeColorTheme', this.windowService.windowId, payload);
106+
ipc.send('vscode:changeColorTheme', this._envService.configuration.windowId, payload);
109107
}
110108
}
111109

src/vs/workbench/electron-browser/actions/windowActions.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { URI } from 'vs/base/common/uri';
77
import { Action } from 'vs/base/common/actions';
8-
import { IWindowService } from 'vs/platform/windows/common/windows';
8+
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
99
import * as nls from 'vs/nls';
1010
import * as browser from 'vs/base/browser/browser';
1111
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
@@ -167,7 +167,7 @@ export abstract class BaseSwitchWindow extends Action {
167167
constructor(
168168
id: string,
169169
label: string,
170-
private windowService: IWindowService,
170+
private environmentService: IWorkbenchEnvironmentService,
171171
private quickInputService: IQuickInputService,
172172
private keybindingService: IKeybindingService,
173173
private modelService: IModelService,
@@ -180,7 +180,7 @@ export abstract class BaseSwitchWindow extends Action {
180180
protected abstract isQuickNavigate(): boolean;
181181

182182
async run(): Promise<void> {
183-
const currentWindowId = this.windowService.windowId;
183+
const currentWindowId = this.environmentService.configuration.windowId;
184184

185185
const windows = await this.electronService.getWindows();
186186
const placeHolder = nls.localize('switchWindowPlaceHolder', "Select a window to switch to");
@@ -222,14 +222,14 @@ export class SwitchWindow extends BaseSwitchWindow {
222222
constructor(
223223
id: string,
224224
label: string,
225-
@IWindowService windowService: IWindowService,
225+
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
226226
@IQuickInputService quickInputService: IQuickInputService,
227227
@IKeybindingService keybindingService: IKeybindingService,
228228
@IModelService modelService: IModelService,
229229
@IModeService modeService: IModeService,
230230
@IElectronService electronService: IElectronService
231231
) {
232-
super(id, label, windowService, quickInputService, keybindingService, modelService, modeService, electronService);
232+
super(id, label, environmentService, quickInputService, keybindingService, modelService, modeService, electronService);
233233
}
234234

235235
protected isQuickNavigate(): boolean {
@@ -245,14 +245,14 @@ export class QuickSwitchWindow extends BaseSwitchWindow {
245245
constructor(
246246
id: string,
247247
label: string,
248-
@IWindowService windowService: IWindowService,
248+
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
249249
@IQuickInputService quickInputService: IQuickInputService,
250250
@IKeybindingService keybindingService: IKeybindingService,
251251
@IModelService modelService: IModelService,
252252
@IModeService modeService: IModeService,
253253
@IElectronService electronService: IElectronService
254254
) {
255-
super(id, label, windowService, quickInputService, keybindingService, modelService, modeService, electronService);
255+
super(id, label, environmentService, quickInputService, keybindingService, modelService, modeService, electronService);
256256
}
257257

258258
protected isQuickNavigate(): boolean {

src/vs/workbench/electron-browser/desktop.main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
3333
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
3434
import { IStorageService } from 'vs/platform/storage/common/storage';
3535
import { Disposable } from 'vs/base/common/lifecycle';
36-
import { registerWindowDriver } from 'vs/platform/driver/electron-browser/driver';
36+
import { registerWindowDriver } from 'vs/workbench/electron-browser/driver';
3737
import { IMainProcessService, MainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
3838
import { RemoteAuthorityResolverService } from 'vs/platform/remote/electron-browser/remoteAuthorityResolverService';
3939
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';

src/vs/platform/driver/electron-browser/driver.ts renamed to src/vs/workbench/electron-browser/driver.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import { WindowDriverChannel, WindowDriverRegistryChannelClient } from 'vs/platf
88
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
99
import { IMainProcessService } from 'vs/platform/ipc/electron-browser/mainProcessService';
1010
import * as electron from 'electron';
11-
import { IWindowService } from 'vs/platform/windows/common/windows';
1211
import { timeout } from 'vs/base/common/async';
1312
import { BaseWindowDriver } from 'vs/platform/driver/browser/baseDriver';
1413
import { IElectronService } from 'vs/platform/electron/node/electron';
14+
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
1515

1616
class WindowDriver extends BaseWindowDriver {
1717

@@ -49,7 +49,7 @@ class WindowDriver extends BaseWindowDriver {
4949
export async function registerWindowDriver(accessor: ServicesAccessor): Promise<IDisposable> {
5050
const instantiationService = accessor.get(IInstantiationService);
5151
const mainProcessService = accessor.get(IMainProcessService);
52-
const windowService = accessor.get(IWindowService);
52+
const environmentService = accessor.get(IWorkbenchEnvironmentService);
5353

5454
const windowDriver = instantiationService.createInstance(WindowDriver);
5555
const windowDriverChannel = new WindowDriverChannel(windowDriver);
@@ -58,12 +58,12 @@ export async function registerWindowDriver(accessor: ServicesAccessor): Promise<
5858
const windowDriverRegistryChannel = mainProcessService.getChannel('windowDriverRegistry');
5959
const windowDriverRegistry = new WindowDriverRegistryChannelClient(windowDriverRegistryChannel);
6060

61-
await windowDriverRegistry.registerWindowDriver(windowService.windowId);
61+
await windowDriverRegistry.registerWindowDriver(environmentService.configuration.windowId);
6262
// const options = await windowDriverRegistry.registerWindowDriver(windowId);
6363

6464
// if (options.verbose) {
6565
// windowDriver.openDevTools();
6666
// }
6767

68-
return toDisposable(() => windowDriverRegistry.reloadWindowDriver(windowService.windowId));
68+
return toDisposable(() => windowDriverRegistry.reloadWindowDriver(environmentService.configuration.windowId));
6969
}

0 commit comments

Comments
 (0)