Skip to content

Commit 79f3ea1

Browse files
author
Benjamin Pasero
committed
startup - convert more to workbench contributions
1 parent ecb2beb commit 79f3ea1

6 files changed

Lines changed: 34 additions & 34 deletions

File tree

src/vs/workbench/electron-browser/shell.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ import { WorkbenchModeServiceImpl } from 'vs/workbench/services/mode/common/work
6767
import { IModeService } from 'vs/editor/common/services/modeService';
6868
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
6969
import { ICrashReporterService, NullCrashReporterService, CrashReporterService } from 'vs/workbench/services/crashReporter/electron-browser/crashReporterService';
70-
import { NodeCachedDataManager } from 'vs/workbench/electron-browser/nodeCachedDataManager';
7170
import { getDelayedChannel } from 'vs/base/parts/ipc/common/ipc';
7271
import { connect as connectNet } from 'vs/base/parts/ipc/node/ipc.net';
7372
import { IExtensionManagementChannel, ExtensionManagementChannelClient } from 'vs/platform/extensionManagement/common/extensionManagementIpc';
@@ -253,11 +252,7 @@ export class WorkbenchShell {
253252
this.messageService.show(Severity.Warning, nls.localize('runningAsRoot', "It is recommended not to run Code as 'root'."));
254253
}
255254

256-
// Start cached data manager
257-
instantiationService.createInstance(NodeCachedDataManager);
258-
259-
// Set lifecycle phase to `Runnning` so that other contributions
260-
// can now do something
255+
// Set lifecycle phase to `Runnning` so that other contributions can now do something
261256
this.lifecycleService.phase = LifecyclePhase.Running;
262257
}
263258

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
'use strict';
7+
8+
import { Registry } from 'vs/platform/registry/common/platform';
9+
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
10+
import { NodeCachedDataManager } from 'vs/workbench/parts/cache/node/nodeCachedDataManager';
11+
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
12+
13+
// Register NodeCachedDataManager Contribution
14+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(NodeCachedDataManager, LifecyclePhase.Running);

src/vs/workbench/electron-browser/nodeCachedDataManager.ts renamed to src/vs/workbench/parts/cache/node/nodeCachedDataManager.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,26 @@
66

77
import { basename } from 'path';
88
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
9+
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
910

1011
declare type OnNodeCachedDataArgs = [{ errorCode: string, path: string, detail?: string }, { path: string, length: number }];
1112
declare const MonacoEnvironment: { onNodeCachedData: OnNodeCachedDataArgs[] };
1213

13-
export class NodeCachedDataManager {
14+
export class NodeCachedDataManager implements IWorkbenchContribution {
1415

1516
private readonly _telemetryService: ITelemetryService;
1617

1718
constructor(
18-
@ITelemetryService telemetryService: ITelemetryService,
19+
@ITelemetryService telemetryService: ITelemetryService
1920
) {
2021
this._telemetryService = telemetryService;
2122
this._handleCachedDataInfo();
2223
}
2324

25+
public getId(): string {
26+
return 'vs.cache.nodeCachedDataManager';
27+
}
28+
2429
private _handleCachedDataInfo(): void {
2530

2631
let didRejectCachedData = false;

src/vs/workbench/parts/stats/node/stats.contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
import { Registry } from 'vs/platform/registry/common/platform';
99
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
10-
import { WorkspaceStatsReporter } from 'vs/workbench/parts/stats/node/workspaceStats';
10+
import { WorkspaceStats } from 'vs/workbench/parts/stats/node/workspaceStats';
1111
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
1212

1313
// Register Workspace Stats Contribution
14-
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkspaceStatsReporter, LifecyclePhase.Running);
14+
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(WorkspaceStats, LifecyclePhase.Running);

src/vs/workbench/parts/stats/node/workspaceStats.ts

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/
1515
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
1616
import { IWindowConfiguration, IWindowService } from 'vs/platform/windows/common/windows';
1717
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
18-
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1918

2019
const SshProtocolMatcher = /^([^@:]+@)?([^:]+):/;
2120
const SshUrlMatcher = /^([^@:]+@)?([^:]+):(.+)$/;
@@ -133,13 +132,20 @@ export function getHashedRemotes(text: string): string[] {
133132
});
134133
}
135134

136-
class WorkspaceStats {
135+
export class WorkspaceStats implements IWorkbenchContribution {
137136
constructor(
138137
@IFileService private fileService: IFileService,
139138
@IWorkspaceContextService private contextService: IWorkspaceContextService,
140139
@ITelemetryService private telemetryService: ITelemetryService,
141-
@IEnvironmentService private environmentService: IEnvironmentService
140+
@IEnvironmentService private environmentService: IEnvironmentService,
141+
@IWindowService windowService: IWindowService
142142
) {
143+
this.reportWorkspaceTags(windowService.getConfiguration());
144+
this.reportCloudStats();
145+
}
146+
147+
public getId(): string {
148+
return 'vs.stats.workspaceStatsReporter';
143149
}
144150

145151
private searchArray(arr: string[], regEx: RegExp): boolean {
@@ -415,25 +421,4 @@ class WorkspaceStats {
415421
this.reportAzure(uris);
416422
}
417423
}
418-
}
419-
420-
// Telemetry: workspace tags
421-
export class WorkspaceStatsReporter implements IWorkbenchContribution {
422-
423-
constructor(
424-
@IInstantiationService private instantiationService: IInstantiationService,
425-
@IWindowService private windowService: IWindowService
426-
) {
427-
this.reportWorkspaceStats();
428-
}
429-
430-
public getId(): string {
431-
return 'vs.backup.backupModelTracker';
432-
}
433-
434-
private reportWorkspaceStats(): void {
435-
const workspaceStats: WorkspaceStats = this.instantiationService.createInstance(WorkspaceStats);
436-
workspaceStats.reportWorkspaceTags(this.windowService.getConfiguration());
437-
workspaceStats.reportCloudStats();
438-
}
439424
}

src/vs/workbench/workbench.main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import 'vs/workbench/parts/files/browser/files.contribution';
4343
import 'vs/workbench/parts/backup/common/backup.contribution';
4444

4545
import 'vs/workbench/parts/stats/node/stats.contribution';
46+
import 'vs/workbench/parts/cache/node/cache.contribution';
4647

4748
import 'vs/workbench/parts/search/browser/search.contribution';
4849
import 'vs/workbench/parts/search/browser/searchViewlet'; // can be packaged separately

0 commit comments

Comments
 (0)