-
Notifications
You must be signed in to change notification settings - Fork 30.7k
/
Copy pathworkbench.ts
1494 lines (1216 loc) · 59.2 KB
/
workbench.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import 'vs/css!./media/workbench';
import { localize } from 'vs/nls';
import { TPromise } from 'vs/base/common/winjs.base';
import { IDisposable, dispose, toDisposable, Disposable } from 'vs/base/common/lifecycle';
import { Event, Emitter } from 'vs/base/common/event';
import * as DOM from 'vs/base/browser/dom';
import { Builder, $ } from 'vs/base/browser/builder';
import { RunOnceScheduler } from 'vs/base/common/async';
import * as browser from 'vs/base/browser/browser';
import * as perf from 'vs/base/common/performance';
import * as errors from 'vs/base/common/errors';
import { BackupFileService, InMemoryBackupFileService } from 'vs/workbench/services/backup/node/backupFileService';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { Registry } from 'vs/platform/registry/common/platform';
import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform';
import { IResourceInput } from 'vs/platform/editor/common/editor';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { IEditorInputFactoryRegistry, Extensions as EditorExtensions, TextCompareEditorVisibleContext, TEXT_DIFF_EDITOR_ID, EditorsVisibleContext, InEditorZenModeContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, IUntitledResourceInput, IResourceDiffInput, SplitEditorsVertically } from 'vs/workbench/common/editor';
import { HistoryService } from 'vs/workbench/services/history/electron-browser/history';
import { ActivitybarPart } from 'vs/workbench/browser/parts/activitybar/activitybarPart';
import { SidebarPart } from 'vs/workbench/browser/parts/sidebar/sidebarPart';
import { PanelPart } from 'vs/workbench/browser/parts/panel/panelPart';
import { StatusbarPart } from 'vs/workbench/browser/parts/statusbar/statusbarPart';
import { TitlebarPart } from 'vs/workbench/browser/parts/titlebar/titlebarPart';
import { MenubarPart } from 'vs/workbench/browser/parts/menubar/menubarPart';
import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart';
import { WorkbenchLayout } from 'vs/workbench/browser/layout';
import { IActionBarRegistry, Extensions as ActionBarExtensions } from 'vs/workbench/browser/actions';
import { PanelRegistry, Extensions as PanelExtensions } from 'vs/workbench/browser/panel';
import { QuickOpenController } from 'vs/workbench/browser/parts/quickopen/quickOpenController';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { QuickInputService } from 'vs/workbench/browser/parts/quickinput/quickInput';
import { getServices } from 'vs/platform/instantiation/common/extensions';
import { Position, Parts, IPartService, ILayoutOptions, IDimension } from 'vs/workbench/services/part/common/partService';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { ContextMenuService as NativeContextMenuService } from 'vs/workbench/services/contextview/electron-browser/contextmenuService';
import { ContextMenuService as HTMLContextMenuService } from 'vs/platform/contextview/browser/contextMenuService';
import { WorkbenchKeybindingService } from 'vs/workbench/services/keybinding/electron-browser/keybindingService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { WorkspaceService, DefaultConfigurationExportHelper } from 'vs/workbench/services/configuration/node/configurationService';
import { IJSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditing';
import { JSONEditingService } from 'vs/workbench/services/configuration/node/jsonEditingService';
import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyService';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IKeybindingEditingService, KeybindingsEditingService } from 'vs/workbench/services/keybinding/common/keybindingEditing';
import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IActivityService } from 'vs/workbench/services/activity/common/activity';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { ViewletService } from 'vs/workbench/services/viewlet/browser/viewletService';
import { RemoteFileService } from 'vs/workbench/services/files/electron-browser/remoteFileService';
import { IFileService } from 'vs/platform/files/common/files';
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import { ConfigurationResolverService } from 'vs/workbench/services/configurationResolver/electron-browser/configurationResolverService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { ITitleService } from 'vs/workbench/services/title/common/titleService';
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { ClipboardService } from 'vs/platform/clipboard/electron-browser/clipboardService';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { TextFileService } from 'vs/workbench/services/textfile/electron-browser/textFileService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { ISCMService } from 'vs/workbench/services/scm/common/scm';
import { SCMService } from 'vs/workbench/services/scm/common/scmService';
import { IProgressService2 } from 'vs/workbench/services/progress/common/progress';
import { ProgressService2 } from 'vs/workbench/services/progress/browser/progressService2';
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { ShutdownReason } from 'vs/platform/lifecycle/common/lifecycle';
import { LifecycleService } from 'vs/platform/lifecycle/electron-browser/lifecycleService';
import { IWindowService, IWindowConfiguration as IWindowSettings, IWindowConfiguration, IPath, MenuBarVisibility } from 'vs/platform/windows/common/windows';
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
import { IMenuService, SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { MenuService } from 'vs/workbench/services/actions/common/menuService';
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
import { OpenRecentAction, ToggleDevToolsAction, ReloadWindowAction, ShowPreviousWindowTab, MoveWindowTabToNewWindow, MergeAllWindowTabs, ShowNextWindowTab, ToggleWindowTabsBar, ReloadWindowWithExtensionsDisabledAction } from 'vs/workbench/electron-browser/actions';
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
import { WorkspaceEditingService } from 'vs/workbench/services/workspace/node/workspaceEditingService';
import { FileDecorationsService } from 'vs/workbench/services/decorations/browser/decorationsService';
import { IDecorationsService } from 'vs/workbench/services/decorations/browser/decorations';
import { ActivityService } from 'vs/workbench/services/activity/browser/activityService';
import URI from 'vs/base/common/uri';
import { IListService, ListService } from 'vs/platform/list/browser/listService';
import { InputFocusedContext } from 'vs/platform/workbench/common/contextkeys';
import { IViewsService } from 'vs/workbench/common/views';
import { ViewsService } from 'vs/workbench/browser/parts/views/views';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { NotificationService } from 'vs/workbench/services/notification/common/notificationService';
import { NotificationsCenter } from 'vs/workbench/browser/parts/notifications/notificationsCenter';
import { NotificationsAlerts } from 'vs/workbench/browser/parts/notifications/notificationsAlerts';
import { NotificationsStatus } from 'vs/workbench/browser/parts/notifications/notificationsStatus';
import { registerNotificationCommands } from 'vs/workbench/browser/parts/notifications/notificationsCommands';
import { NotificationsToasts } from 'vs/workbench/browser/parts/notifications/notificationsToasts';
import { IPCClient } from 'vs/base/parts/ipc/common/ipc';
import { registerWindowDriver } from 'vs/platform/driver/electron-browser/driver';
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { PreferencesService } from 'vs/workbench/services/preferences/browser/preferencesService';
import { IEditorService, IResourceEditor } from 'vs/workbench/services/editor/common/editorService';
import { IEditorGroupsService, GroupDirection, preferredSideBySideGroupDirection } from 'vs/workbench/services/group/common/editorGroupsService';
import { EditorService } from 'vs/workbench/services/editor/browser/editorService';
import { IExtensionUrlHandler, ExtensionUrlHandler } from 'vs/platform/url/electron-browser/inactiveExtensionUrlHandler';
import { ContextViewService } from 'vs/platform/contextview/browser/contextViewService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { TelemetryService } from 'vs/platform/telemetry/common/telemetryService';
import { WorkbenchThemeService } from 'vs/workbench/services/themes/electron-browser/workbenchThemeService';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
interface WorkbenchParams {
configuration: IWindowConfiguration;
serviceCollection: ServiceCollection;
}
interface IZenModeSettings {
fullScreen: boolean;
centerLayout: boolean;
hideTabs: boolean;
hideActivityBar: boolean;
hideStatusBar: boolean;
restore: boolean;
}
export interface IWorkbenchStartedInfo {
customKeybindingsCount: number;
pinnedViewlets: string[];
restoredViewlet: string;
restoredEditorsCount: number;
}
type FontAliasingOption = 'default' | 'antialiased' | 'none' | 'auto';
const fontAliasingValues: FontAliasingOption[] = ['antialiased', 'none', 'auto'];
const Identifiers = {
WORKBENCH_CONTAINER: 'workbench.main.container',
TITLEBAR_PART: 'workbench.parts.titlebar',
ACTIVITYBAR_PART: 'workbench.parts.activitybar',
SIDEBAR_PART: 'workbench.parts.sidebar',
PANEL_PART: 'workbench.parts.panel',
EDITOR_PART: 'workbench.parts.editor',
STATUSBAR_PART: 'workbench.parts.statusbar',
MENUBAR_PART: 'workbench.parts.menubar'
};
function getWorkbenchStateString(state: WorkbenchState): string {
switch (state) {
case WorkbenchState.EMPTY: return 'empty';
case WorkbenchState.FOLDER: return 'folder';
case WorkbenchState.WORKSPACE: return 'workspace';
}
}
interface IZenMode {
active: boolean;
transitionedToFullScreen: boolean;
transitionedToCenteredEditorLayout: boolean;
transitionDisposeables: IDisposable[];
wasSideBarVisible: boolean;
wasPanelVisible: boolean;
}
export class Workbench extends Disposable implements IPartService {
private static readonly sidebarHiddenStorageKey = 'workbench.sidebar.hidden';
private static readonly menubarVisibilityConfigurationKey = 'window.menuBarVisibility';
private static readonly sidebarRestoreStorageKey = 'workbench.sidebar.restore';
private static readonly panelHiddenStorageKey = 'workbench.panel.hidden';
private static readonly zenModeActiveStorageKey = 'workbench.zenmode.active';
private static readonly centeredEditorLayoutActiveStorageKey = 'workbench.centerededitorlayout.active';
private static readonly panelPositionStorageKey = 'workbench.panel.location';
private static readonly defaultPanelPositionStorageKey = 'workbench.panel.defaultLocation';
private static readonly sidebarPositionConfigurationKey = 'workbench.sideBar.location';
private static readonly statusbarVisibleConfigurationKey = 'workbench.statusBar.visible';
private static readonly activityBarVisibleConfigurationKey = 'workbench.activityBar.visible';
private static readonly closeWhenEmptyConfigurationKey = 'window.closeWhenEmpty';
private static readonly fontAliasingConfigurationKey = 'workbench.fontAliasing';
_serviceBrand: any;
private workbenchParams: WorkbenchParams;
private workbench: Builder;
private workbenchStarted: boolean;
private workbenchCreated: boolean;
private workbenchShutdown: boolean;
private editorService: EditorService;
private editorGroupService: IEditorGroupsService;
private viewletService: IViewletService;
private contextViewService: ContextViewService;
private contextKeyService: IContextKeyService;
private keybindingService: IKeybindingService;
private backupFileService: IBackupFileService;
private fileService: IFileService;
private quickInput: QuickInputService;
private workbenchLayout: WorkbenchLayout;
private titlebarPart: TitlebarPart;
private menubarPart: MenubarPart;
private activitybarPart: ActivitybarPart;
private sidebarPart: SidebarPart;
private panelPart: PanelPart;
private editorPart: EditorPart;
private statusbarPart: StatusbarPart;
private quickOpen: QuickOpenController;
private notificationsCenter: NotificationsCenter;
private notificationsToasts: NotificationsToasts;
private sideBarHidden: boolean;
private statusBarHidden: boolean;
private activityBarHidden: boolean;
private sideBarPosition: Position;
private panelPosition: Position;
private panelHidden: boolean;
private menubarVisibility: MenuBarVisibility;
private zenMode: IZenMode;
private fontAliasing: FontAliasingOption;
private hasInitialFilesToOpen: boolean;
private inZenMode: IContextKey<boolean>;
private sideBarVisibleContext: IContextKey<boolean>;
private closeEmptyWindowScheduler: RunOnceScheduler = this._register(new RunOnceScheduler(() => this.onAllEditorsClosed(), 50));
constructor(
private container: HTMLElement,
private configuration: IWindowConfiguration,
serviceCollection: ServiceCollection,
private lifecycleService: LifecycleService,
private mainProcessClient: IPCClient,
@IInstantiationService private instantiationService: IInstantiationService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IStorageService private storageService: IStorageService,
@IConfigurationService private configurationService: WorkspaceService,
@IWorkbenchThemeService private themeService: WorkbenchThemeService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IWindowService private windowService: IWindowService,
@INotificationService private notificationService: NotificationService,
@ITelemetryService private telemetryService: TelemetryService
) {
super();
this.workbenchParams = { configuration, serviceCollection };
this.hasInitialFilesToOpen =
(configuration.filesToCreate && configuration.filesToCreate.length > 0) ||
(configuration.filesToOpen && configuration.filesToOpen.length > 0) ||
(configuration.filesToDiff && configuration.filesToDiff.length > 0);
}
startup(): TPromise<IWorkbenchStartedInfo> {
this.workbenchStarted = true;
// Create Workbench Container
this.createWorkbench();
// Install some global actions
this.createGlobalActions();
// Services
this.initServices();
// Context Keys
this.handleContextKeys();
// Register Listeners
this.registerListeners();
// Settings
this.initSettings();
// Create Workbench and Parts
this.renderWorkbench();
// Workbench Layout
this.createWorkbenchLayout();
// Driver
if (this.environmentService.driverHandle) {
registerWindowDriver(this.mainProcessClient, this.configuration.windowId, this.instantiationService).then(disposable => this._register(disposable));
}
// Restore Parts
return this.restoreParts();
}
private createWorkbench(): void {
this.workbench = $().div({
'class': `monaco-workbench ${isWindows ? 'windows' : isLinux ? 'linux' : 'mac'}`,
id: Identifiers.WORKBENCH_CONTAINER
});
}
private createGlobalActions(): void {
const isDeveloping = !this.environmentService.isBuilt || this.environmentService.isExtensionDevelopment;
// Actions registered here to adjust for developing vs built workbench
const registry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
registry.registerWorkbenchAction(new SyncActionDescriptor(ReloadWindowAction, ReloadWindowAction.ID, ReloadWindowAction.LABEL, isDeveloping ? { primary: KeyMod.CtrlCmd | KeyCode.KEY_R } : void 0), 'Reload Window');
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleDevToolsAction, ToggleDevToolsAction.ID, ToggleDevToolsAction.LABEL, isDeveloping ? { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_I, mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.KEY_I } } : void 0), 'Developer: Toggle Developer Tools', localize('developer', "Developer"));
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenRecentAction, OpenRecentAction.ID, OpenRecentAction.LABEL, { primary: isDeveloping ? null : KeyMod.CtrlCmd | KeyCode.KEY_R, mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_R } }), 'File: Open Recent...', localize('file', "File"));
registry.registerWorkbenchAction(new SyncActionDescriptor(ReloadWindowWithExtensionsDisabledAction, ReloadWindowWithExtensionsDisabledAction.ID, ReloadWindowWithExtensionsDisabledAction.LABEL), 'Reload Window Without Extensions');
// Actions for macOS native tabs management (only when enabled)
const windowConfig = this.configurationService.getValue<IWindowConfiguration>();
if (windowConfig && windowConfig.window && windowConfig.window.nativeTabs) {
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowPreviousWindowTab, ShowPreviousWindowTab.ID, ShowPreviousWindowTab.LABEL), 'Show Previous Window Tab');
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowNextWindowTab, ShowNextWindowTab.ID, ShowNextWindowTab.LABEL), 'Show Next Window Tab');
registry.registerWorkbenchAction(new SyncActionDescriptor(MoveWindowTabToNewWindow, MoveWindowTabToNewWindow.ID, MoveWindowTabToNewWindow.LABEL), 'Move Window Tab to New Window');
registry.registerWorkbenchAction(new SyncActionDescriptor(MergeAllWindowTabs, MergeAllWindowTabs.ID, MergeAllWindowTabs.LABEL), 'Merge All Windows');
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleWindowTabsBar, ToggleWindowTabsBar.ID, ToggleWindowTabsBar.LABEL), 'Toggle Window Tabs Bar');
}
}
private initServices(): void {
const { serviceCollection } = this.workbenchParams;
// Services we contribute
serviceCollection.set(IPartService, this);
// Clipboard
serviceCollection.set(IClipboardService, new ClipboardService());
// Status bar
this.statusbarPart = this.instantiationService.createInstance(StatusbarPart, Identifiers.STATUSBAR_PART);
this._register(toDisposable(() => this.statusbarPart.shutdown()));
serviceCollection.set(IStatusbarService, this.statusbarPart);
// Progress 2
serviceCollection.set(IProgressService2, new SyncDescriptor(ProgressService2));
// Keybindings
this.contextKeyService = this.instantiationService.createInstance(ContextKeyService);
serviceCollection.set(IContextKeyService, this.contextKeyService);
this.keybindingService = this.instantiationService.createInstance(WorkbenchKeybindingService, window);
serviceCollection.set(IKeybindingService, this.keybindingService);
// List
serviceCollection.set(IListService, this.instantiationService.createInstance(ListService));
// Context view service
this.contextViewService = this.instantiationService.createInstance(ContextViewService, this.workbench.getHTMLElement());
serviceCollection.set(IContextViewService, this.contextViewService);
// Use themable context menus when custom titlebar is enabled to match custom menubar
if (!isMacintosh && this.getCustomTitleBarStyle() === 'custom') {
serviceCollection.set(IContextMenuService, new SyncDescriptor(HTMLContextMenuService, null, this.telemetryService, this.notificationService, this.contextViewService));
} else {
serviceCollection.set(IContextMenuService, new SyncDescriptor(NativeContextMenuService));
}
// Menus/Actions
serviceCollection.set(IMenuService, new SyncDescriptor(MenuService));
// Sidebar part
this.sidebarPart = this.instantiationService.createInstance(SidebarPart, Identifiers.SIDEBAR_PART);
this._register(toDisposable(() => this.sidebarPart.shutdown()));
// Viewlet service
this.viewletService = this.instantiationService.createInstance(ViewletService, this.sidebarPart);
serviceCollection.set(IViewletService, this.viewletService);
// Panel service (panel part)
this.panelPart = this.instantiationService.createInstance(PanelPart, Identifiers.PANEL_PART);
this._register(toDisposable(() => this.panelPart.shutdown()));
serviceCollection.set(IPanelService, this.panelPart);
// views service
const viewsService = this.instantiationService.createInstance(ViewsService);
serviceCollection.set(IViewsService, viewsService);
// Activity service (activitybar part)
this.activitybarPart = this.instantiationService.createInstance(ActivitybarPart, Identifiers.ACTIVITYBAR_PART);
this._register(toDisposable(() => this.activitybarPart.shutdown()));
const activityService = this.instantiationService.createInstance(ActivityService, this.activitybarPart, this.panelPart);
serviceCollection.set(IActivityService, activityService);
// File Service
this.fileService = this.instantiationService.createInstance(RemoteFileService);
serviceCollection.set(IFileService, this.fileService);
this.configurationService.acquireFileService(this.fileService);
this.themeService.acquireFileService(this.fileService);
// Editor and Group services
const restorePreviousEditorState = !this.hasInitialFilesToOpen;
this.editorPart = this.instantiationService.createInstance(EditorPart, Identifiers.EDITOR_PART, restorePreviousEditorState);
this._register(toDisposable(() => this.editorPart.shutdown()));
this.editorGroupService = this.editorPart;
serviceCollection.set(IEditorGroupsService, this.editorPart);
this.editorService = this.instantiationService.createInstance(EditorService);
serviceCollection.set(IEditorService, this.editorService);
// Title bar
this.titlebarPart = this.instantiationService.createInstance(TitlebarPart, Identifiers.TITLEBAR_PART);
this._register(toDisposable(() => this.titlebarPart.shutdown()));
serviceCollection.set(ITitleService, this.titlebarPart);
// History
serviceCollection.set(IHistoryService, new SyncDescriptor(HistoryService));
// Menubar
this.menubarPart = this.instantiationService.createInstance(MenubarPart, Identifiers.MENUBAR_PART);
// Backup File Service
if (this.workbenchParams.configuration.backupPath) {
this.backupFileService = this.instantiationService.createInstance(BackupFileService, this.workbenchParams.configuration.backupPath);
} else {
this.backupFileService = new InMemoryBackupFileService();
}
serviceCollection.set(IBackupFileService, this.backupFileService);
// Text File Service
serviceCollection.set(ITextFileService, new SyncDescriptor(TextFileService));
// File Decorations
serviceCollection.set(IDecorationsService, new SyncDescriptor(FileDecorationsService));
// SCM Service
serviceCollection.set(ISCMService, new SyncDescriptor(SCMService));
// Inactive extension URL handler
serviceCollection.set(IExtensionUrlHandler, new SyncDescriptor(ExtensionUrlHandler));
// Text Model Resolver Service
serviceCollection.set(ITextModelService, new SyncDescriptor(TextModelResolverService));
// JSON Editing
const jsonEditingService = this.instantiationService.createInstance(JSONEditingService);
serviceCollection.set(IJSONEditingService, jsonEditingService);
// Workspace Editing
serviceCollection.set(IWorkspaceEditingService, new SyncDescriptor(WorkspaceEditingService));
// Keybinding Editing
serviceCollection.set(IKeybindingEditingService, this.instantiationService.createInstance(KeybindingsEditingService));
// Configuration Resolver
serviceCollection.set(IConfigurationResolverService, new SyncDescriptor(ConfigurationResolverService, process.env));
// Quick open service (quick open controller)
this.quickOpen = this.instantiationService.createInstance(QuickOpenController);
this._register(toDisposable(() => this.quickOpen.shutdown()));
serviceCollection.set(IQuickOpenService, this.quickOpen);
// Quick input service
this.quickInput = this.instantiationService.createInstance(QuickInputService);
this._register(toDisposable(() => this.quickInput.shutdown()));
serviceCollection.set(IQuickInputService, this.quickInput);
// PreferencesService
serviceCollection.set(IPreferencesService, this.instantiationService.createInstance(PreferencesService));
// Contributed services
const contributedServices = getServices();
for (let contributedService of contributedServices) {
serviceCollection.set(contributedService.id, contributedService.descriptor);
}
// Set the some services to registries that have been created eagerly
Registry.as<IActionBarRegistry>(ActionBarExtensions.Actionbar).setInstantiationService(this.instantiationService);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).start(this.instantiationService, this.lifecycleService);
Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).setInstantiationService(this.instantiationService);
this.instantiationService.createInstance(DefaultConfigurationExportHelper);
this.configurationService.acquireInstantiationService(this.getInstantiationService());
}
//#region event handling
private registerListeners(): void {
// Listen to visible editor changes
this._register(this.editorService.onDidVisibleEditorsChange(() => this.onDidVisibleEditorsChange()));
// Listen to editor closing (if we run with --wait)
const filesToWait = this.workbenchParams.configuration.filesToWait;
if (filesToWait) {
const resourcesToWaitFor = filesToWait.paths.map(p => URI.file(p.filePath));
const waitMarkerFile = URI.file(filesToWait.waitMarkerFilePath);
const listenerDispose = this.editorService.onDidCloseEditor(() => this.onEditorClosed(listenerDispose, resourcesToWaitFor, waitMarkerFile));
this._register(listenerDispose);
}
// Configuration changes
this._register(this.configurationService.onDidChangeConfiguration(() => this.onDidUpdateConfiguration()));
// Fullscreen changes
this._register(browser.onDidChangeFullscreen(() => this.onFullscreenChanged()));
}
private onFullscreenChanged(): void {
if (!this.isCreated) {
return; // we need to be ready
}
// Apply as CSS class
const isFullscreen = browser.isFullscreen();
if (isFullscreen) {
this.workbench.addClass('fullscreen');
} else {
this.workbench.removeClass('fullscreen');
if (this.zenMode.transitionedToFullScreen && this.zenMode.active) {
this.toggleZenMode();
}
}
// Changing fullscreen state of the window has an impact on custom title bar visibility, so we need to update
const hasCustomTitle = this.getCustomTitleBarStyle() === 'custom';
if (hasCustomTitle) {
this._onTitleBarVisibilityChange.fire();
this.layout(); // handle title bar when fullscreen changes
}
}
private onEditorClosed(listenerDispose: IDisposable, resourcesToWaitFor: URI[], waitMarkerFile: URI): void {
// In wait mode, listen to changes to the editors and wait until the files
// are closed that the user wants to wait for. When this happens we delete
// the wait marker file to signal to the outside that editing is done.
if (resourcesToWaitFor.every(resource => !this.editorService.isOpen({ resource }))) {
listenerDispose.dispose();
this.fileService.del(waitMarkerFile).done(null, errors.onUnexpectedError);
}
}
private onDidVisibleEditorsChange(): void {
const visibleEditors = this.editorService.visibleControls;
// Close when empty: check if we should close the window based on the setting
// Overruled by: window has a workspace opened or this window is for extension development
// or setting is disabled. Also enabled when running with --wait from the command line.
if (visibleEditors.length === 0 && this.contextService.getWorkbenchState() === WorkbenchState.EMPTY && !this.environmentService.isExtensionDevelopment) {
const closeWhenEmpty = this.configurationService.getValue<boolean>(Workbench.closeWhenEmptyConfigurationKey);
if (closeWhenEmpty || this.environmentService.args.wait) {
this.closeEmptyWindowScheduler.schedule();
}
}
}
private onAllEditorsClosed(): void {
const visibleEditors = this.editorService.visibleControls.length;
if (visibleEditors === 0) {
this.windowService.closeWindow();
}
}
private onDidUpdateConfiguration(skipLayout?: boolean): void {
const newSidebarPositionValue = this.configurationService.getValue<string>(Workbench.sidebarPositionConfigurationKey);
const newSidebarPosition = (newSidebarPositionValue === 'right') ? Position.RIGHT : Position.LEFT;
if (newSidebarPosition !== this.getSideBarPosition()) {
this.setSideBarPosition(newSidebarPosition);
}
this.setPanelPositionFromStorageOrConfig();
const fontAliasing = this.configurationService.getValue<FontAliasingOption>(Workbench.fontAliasingConfigurationKey);
if (fontAliasing !== this.fontAliasing) {
this.setFontAliasing(fontAliasing);
}
if (!this.zenMode.active) {
const newStatusbarHiddenValue = !this.configurationService.getValue<boolean>(Workbench.statusbarVisibleConfigurationKey);
if (newStatusbarHiddenValue !== this.statusBarHidden) {
this.setStatusBarHidden(newStatusbarHiddenValue, skipLayout);
}
const newActivityBarHiddenValue = !this.configurationService.getValue<boolean>(Workbench.activityBarVisibleConfigurationKey);
if (newActivityBarHiddenValue !== this.activityBarHidden) {
this.setActivityBarHidden(newActivityBarHiddenValue, skipLayout);
}
}
const newMenubarVisibility = this.configurationService.getValue<MenuBarVisibility>(Workbench.menubarVisibilityConfigurationKey);
this.setMenubarVisibility(newMenubarVisibility, skipLayout);
}
//#endregion
private handleContextKeys(): void {
this.inZenMode = InEditorZenModeContext.bindTo(this.contextKeyService);
const sidebarVisibleContextRaw = new RawContextKey<boolean>('sidebarVisible', false);
this.sideBarVisibleContext = sidebarVisibleContextRaw.bindTo(this.contextKeyService);
const editorsVisibleContext = EditorsVisibleContext.bindTo(this.contextKeyService);
const textCompareEditorVisible = TextCompareEditorVisibleContext.bindTo(this.contextKeyService);
const activeEditorGroupEmpty = ActiveEditorGroupEmptyContext.bindTo(this.contextKeyService);
const multipleEditorGroups = MultipleEditorGroupsContext.bindTo(this.contextKeyService);
const updateEditorContextKeys = () => {
const visibleEditors = this.editorService.visibleControls;
textCompareEditorVisible.set(visibleEditors.some(control => control.getId() === TEXT_DIFF_EDITOR_ID));
if (visibleEditors.length > 0) {
editorsVisibleContext.set(true);
} else {
editorsVisibleContext.reset();
}
if (!this.editorService.activeEditor) {
activeEditorGroupEmpty.set(true);
} else {
activeEditorGroupEmpty.reset();
}
if (this.editorGroupService.count > 1) {
multipleEditorGroups.set(true);
} else {
multipleEditorGroups.reset();
}
};
this.editorPart.whenRestored.then(() => updateEditorContextKeys());
this._register(this.editorService.onDidActiveEditorChange(() => updateEditorContextKeys()));
this._register(this.editorService.onDidVisibleEditorsChange(() => updateEditorContextKeys()));
this._register(this.editorGroupService.onDidAddGroup(() => updateEditorContextKeys()));
this._register(this.editorGroupService.onDidRemoveGroup(() => updateEditorContextKeys()));
const inputFocused = InputFocusedContext.bindTo(this.contextKeyService);
this._register(DOM.addDisposableListener(window, 'focusin', () => {
inputFocused.set(document.activeElement && (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA'));
}, true));
const workbenchStateRawContext = new RawContextKey<string>('workbenchState', getWorkbenchStateString(this.configurationService.getWorkbenchState()));
const workbenchStateContext = workbenchStateRawContext.bindTo(this.contextKeyService);
this._register(this.configurationService.onDidChangeWorkbenchState(() => {
workbenchStateContext.set(getWorkbenchStateString(this.configurationService.getWorkbenchState()));
}));
const workspaceFolderCountRawContext = new RawContextKey<number>('workspaceFolderCount', this.configurationService.getWorkspace().folders.length);
const workspaceFolderCountContext = workspaceFolderCountRawContext.bindTo(this.contextKeyService);
this._register(this.configurationService.onDidChangeWorkspaceFolders(() => {
workspaceFolderCountContext.set(this.configurationService.getWorkspace().folders.length);
}));
const splitEditorsVerticallyContext = SplitEditorsVertically.bindTo(this.contextKeyService);
const updateSplitEditorsVerticallyContext = () => {
const direction = preferredSideBySideGroupDirection(this.configurationService);
splitEditorsVerticallyContext.set(direction === GroupDirection.DOWN);
};
this._register(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('workbench.editor.openSideBySideDirection')) {
updateSplitEditorsVerticallyContext();
}
}));
updateSplitEditorsVerticallyContext();
}
private restoreParts(): TPromise<IWorkbenchStartedInfo> {
const restorePromises: Thenable<any>[] = [];
// Restore Editorpart
perf.mark('willRestoreEditors');
restorePromises.push(this.editorPart.whenRestored.then(() => {
return this.resolveEditorsToOpen().then(inputs => {
if (inputs.length) {
return this.editorService.openEditors(inputs);
}
return TPromise.as(void 0);
});
}).then(() => {
perf.mark('didRestoreEditors');
}));
// Restore Sidebar
let viewletIdToRestore: string;
if (!this.sideBarHidden) {
this.sideBarVisibleContext.set(true);
if (this.shouldRestoreLastOpenedViewlet()) {
viewletIdToRestore = this.storageService.get(SidebarPart.activeViewletSettingsKey, StorageScope.WORKSPACE);
}
if (!viewletIdToRestore) {
viewletIdToRestore = this.viewletService.getDefaultViewletId();
}
perf.mark('willRestoreViewlet');
restorePromises.push(this.viewletService.openViewlet(viewletIdToRestore)
.then(viewlet => viewlet || this.viewletService.openViewlet(this.viewletService.getDefaultViewletId()))
.then(() => {
perf.mark('didRestoreViewlet');
}));
}
// Restore Panel
const panelRegistry = Registry.as<PanelRegistry>(PanelExtensions.Panels);
const panelId = this.storageService.get(PanelPart.activePanelSettingsKey, StorageScope.WORKSPACE, panelRegistry.getDefaultPanelId());
if (!this.panelHidden && !!panelId) {
const isPanelToRestoreEnabled = !!this.panelPart.getPanels().filter(p => p.id === panelId).length;
if (isPanelToRestoreEnabled) {
restorePromises.push(this.panelPart.openPanel(panelId, false));
} else {
restorePromises.push(this.panelPart.openPanel(panelRegistry.getDefaultPanelId(), false));
}
}
// Restore Zen Mode if active
if (this.storageService.getBoolean(Workbench.zenModeActiveStorageKey, StorageScope.WORKSPACE, false)) {
this.toggleZenMode(true, true);
}
// Restore Forced Editor Center Mode
if (this.storageService.getBoolean(Workbench.centeredEditorLayoutActiveStorageKey, StorageScope.WORKSPACE, false)) {
this.centerEditorLayout(true);
}
const onRestored = (error?: Error): IWorkbenchStartedInfo => {
this.workbenchCreated = true;
if (error) {
errors.onUnexpectedError(error);
}
return {
customKeybindingsCount: this.keybindingService.customKeybindingsCount(),
pinnedViewlets: this.activitybarPart.getPinned(),
restoredViewlet: viewletIdToRestore,
restoredEditorsCount: this.editorService.visibleEditors.length
};
};
return TPromise.join(restorePromises).then(() => onRestored(), error => onRestored(error));
}
private shouldRestoreLastOpenedViewlet(): boolean {
if (!this.environmentService.isBuilt) {
return true; // always restore sidebar when we are in development mode
}
const restore = this.storageService.getBoolean(Workbench.sidebarRestoreStorageKey, StorageScope.WORKSPACE);
if (restore) {
this.storageService.remove(Workbench.sidebarRestoreStorageKey, StorageScope.WORKSPACE); // only support once
}
return restore;
}
private resolveEditorsToOpen(): TPromise<IResourceEditor[]> {
const config = this.workbenchParams.configuration;
// Files to open, diff or create
if (this.hasInitialFilesToOpen) {
// Files to diff is exclusive
const filesToDiff = this.toInputs(config.filesToDiff, false);
if (filesToDiff && filesToDiff.length === 2) {
return TPromise.as([<IResourceDiffInput>{
leftResource: filesToDiff[0].resource,
rightResource: filesToDiff[1].resource,
options: { pinned: true }
}]);
}
const filesToCreate = this.toInputs(config.filesToCreate, true);
const filesToOpen = this.toInputs(config.filesToOpen, false);
// Otherwise: Open/Create files
return TPromise.as([...filesToOpen, ...filesToCreate]);
}
// Empty workbench
else if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY && this.openUntitledFile()) {
const isEmpty = this.editorGroupService.count === 1 && this.editorGroupService.activeGroup.count === 0;
if (!isEmpty) {
return TPromise.as([]); // do not open any empty untitled file if we restored editors from previous session
}
return this.backupFileService.hasBackups().then(hasBackups => {
if (hasBackups) {
return TPromise.as([]); // do not open any empty untitled file if we have backups to restore
}
return TPromise.as([<IUntitledResourceInput>{}]);
});
}
return TPromise.as([]);
}
private toInputs(paths: IPath[], isNew: boolean): (IResourceInput | IUntitledResourceInput)[] {
if (!paths || !paths.length) {
return [];
}
return paths.map(p => {
const resource = URI.file(p.filePath);
let input: IResourceInput | IUntitledResourceInput;
if (isNew) {
input = { filePath: resource.fsPath, options: { pinned: true } } as IUntitledResourceInput;
} else {
input = { resource, options: { pinned: true } } as IResourceInput;
}
if (!isNew && p.lineNumber) {
input.options.selection = {
startLineNumber: p.lineNumber,
startColumn: p.columnNumber
};
}
return input;
});
}
private openUntitledFile() {
const startupEditor = this.configurationService.inspect('workbench.startupEditor');
// Fallback to previous workbench.welcome.enabled setting in case startupEditor is not defined
if (!startupEditor.user && !startupEditor.workspace) {
const welcomeEnabledValue = this.configurationService.getValue('workbench.welcome.enabled');
if (typeof welcomeEnabledValue === 'boolean') {
return !welcomeEnabledValue;
}
}
return startupEditor.value === 'newUntitledFile';
}
private initSettings(): void {
// Sidebar visibility
this.sideBarHidden = this.storageService.getBoolean(Workbench.sidebarHiddenStorageKey, StorageScope.WORKSPACE, this.contextService.getWorkbenchState() === WorkbenchState.EMPTY);
// Panel part visibility
const panelRegistry = Registry.as<PanelRegistry>(PanelExtensions.Panels);
this.panelHidden = this.storageService.getBoolean(Workbench.panelHiddenStorageKey, StorageScope.WORKSPACE, true);
if (!panelRegistry.getDefaultPanelId()) {
this.panelHidden = true; // we hide panel part if there is no default panel
}
// Sidebar position
const sideBarPosition = this.configurationService.getValue<string>(Workbench.sidebarPositionConfigurationKey);
this.sideBarPosition = (sideBarPosition === 'right') ? Position.RIGHT : Position.LEFT;
// Panel position
this.setPanelPositionFromStorageOrConfig();
// Menubar visibility
const menuBarVisibility = this.configurationService.getValue<MenuBarVisibility>(Workbench.menubarVisibilityConfigurationKey);
this.setMenubarVisibility(menuBarVisibility, true);
// Statusbar visibility
const statusBarVisible = this.configurationService.getValue<string>(Workbench.statusbarVisibleConfigurationKey);
this.statusBarHidden = !statusBarVisible;
// Activity bar visibility
const activityBarVisible = this.configurationService.getValue<string>(Workbench.activityBarVisibleConfigurationKey);
this.activityBarHidden = !activityBarVisible;
// Font aliasing
this.fontAliasing = this.configurationService.getValue<FontAliasingOption>(Workbench.fontAliasingConfigurationKey);
// Zen mode
this.zenMode = {
active: false,
transitionedToFullScreen: false,
transitionedToCenteredEditorLayout: false,
wasSideBarVisible: false,
wasPanelVisible: false,
transitionDisposeables: []
};
}
private setPanelPositionFromStorageOrConfig() {
const defaultPanelPosition = this.configurationService.getValue<string>(Workbench.defaultPanelPositionStorageKey);
const panelPosition = this.storageService.get(Workbench.panelPositionStorageKey, StorageScope.WORKSPACE, defaultPanelPosition);
this.panelPosition = (panelPosition === 'right') ? Position.RIGHT : Position.BOTTOM;
}
private getCustomTitleBarStyle(): 'custom' {
const isDev = !this.environmentService.isBuilt || this.environmentService.isExtensionDevelopment;
if (isMacintosh && isDev) {
return null; // not enabled when developing due to https://github.com/electron/electron/issues/3647
}
const windowConfig = this.configurationService.getValue<IWindowSettings>();
if (windowConfig && windowConfig.window) {
const useNativeTabs = windowConfig.window.nativeTabs;
if (useNativeTabs) {
return null; // native tabs on sierra do not work with custom title style
}
const style = windowConfig.window.titleBarStyle;
if (style === 'custom') {
return style;
}
}
return null;
}
private setStatusBarHidden(hidden: boolean, skipLayout?: boolean): void {
this.statusBarHidden = hidden;
// Adjust CSS
if (hidden) {
this.workbench.addClass('nostatusbar');
} else {
this.workbench.removeClass('nostatusbar');
}
// Layout
if (!skipLayout) {
this.workbenchLayout.layout();
}
}
private setFontAliasing(aliasing: FontAliasingOption) {
this.fontAliasing = aliasing;
// Remove all
document.body.classList.remove(...fontAliasingValues.map(value => `monaco-font-aliasing-${value}`));
// Add specific
if (fontAliasingValues.some(option => option === aliasing)) {
document.body.classList.add(`monaco-font-aliasing-${aliasing}`);
}
}
private createWorkbenchLayout(): void {
this.workbenchLayout = this.instantiationService.createInstance(
WorkbenchLayout,
this.container,
this.workbench.getHTMLElement(),
{
titlebar: this.titlebarPart,
menubar: this.menubarPart,
activitybar: this.activitybarPart,
editor: this.editorPart,
sidebar: this.sidebarPart,
panel: this.panelPart,
statusbar: this.statusbarPart,
},
this.quickOpen,
this.quickInput,
this.notificationsCenter,
this.notificationsToasts
);
}
private renderWorkbench(): void {
// Apply sidebar state as CSS class
if (this.sideBarHidden) {
this.workbench.addClass('nosidebar');
}
if (this.panelHidden) {
this.workbench.addClass('nopanel');
}
if (this.statusBarHidden) {
this.workbench.addClass('nostatusbar');
}
// Apply font aliasing
this.setFontAliasing(this.fontAliasing);
// Apply fullscreen state
if (browser.isFullscreen()) {
this.workbench.addClass('fullscreen');
}
// Create Parts
this.createTitlebarPart();
this.createMenubarPart();
this.createActivityBarPart();
this.createSidebarPart();
this.createEditorPart();
this.createPanelPart();
this.createStatusbarPart();
// Notification Handlers
this.createNotificationsHandlers();
// Add Workbench to DOM
this.workbench.appendTo(this.container);
}
private createTitlebarPart(): void {