Skip to content

Commit ff66f65

Browse files
author
Benjamin Pasero
committed
debt - do not duplicate product and environment
1 parent b25446b commit ff66f65

13 files changed

Lines changed: 38 additions & 39 deletions

File tree

src/vs/platform/environment/common/environment.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ export interface IEnvironmentService {
112112
userHome: string;
113113
userDataPath: string;
114114

115-
appNameLong: string;
116-
appQuality?: string;
117115
appSettingsHome: URI;
118116

119117
// user roaming data

src/vs/platform/environment/node/environmentService.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@ export class EnvironmentService implements IEnvironmentService {
102102
return parseUserDataDir(this._args, process);
103103
}
104104

105-
get appNameLong(): string { return product.nameLong; }
106-
107-
get appQuality(): string | undefined { return product.quality; }
108-
109105
@memoize
110106
get appSettingsHome(): URI { return URI.file(path.join(this.userDataPath, 'User')); }
111107

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { createAndFillInContextMenuActions } from 'vs/platform/actions/browser/m
3939
import { IMenuService, IMenu, MenuId } from 'vs/platform/actions/common/actions';
4040
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
4141
import { IHostService } from 'vs/workbench/services/host/browser/host';
42+
import { IProductService } from 'vs/platform/product/common/productService';
4243

4344
// TODO@sbatten https://github.com/microsoft/vscode/issues/81360
4445
// tslint:disable-next-line: import-patterns layering
@@ -104,6 +105,7 @@ export class TitlebarPart extends Part implements ITitleService {
104105
@IMenuService menuService: IMenuService,
105106
@IContextKeyService contextKeyService: IContextKeyService,
106107
@IHostService private readonly hostService: IHostService,
108+
@IProductService private readonly productService: IProductService,
107109
@optional(IElectronService) private electronService: IElectronService,
108110
@optional(IElectronEnvironmentService) private readonly electronEnvironmentService: IElectronEnvironmentService
109111
) {
@@ -207,7 +209,7 @@ export class TitlebarPart extends Part implements ITitleService {
207209
// Always set the native window title to identify us properly to the OS
208210
let nativeTitle = title;
209211
if (!trim(nativeTitle)) {
210-
nativeTitle = this.environmentService.appNameLong;
212+
nativeTitle = this.productService.nameLong;
211213
}
212214
window.document.title = nativeTitle;
213215

@@ -229,15 +231,15 @@ export class TitlebarPart extends Part implements ITitleService {
229231
let title = this.doGetWindowTitle();
230232

231233
if (this.properties.isAdmin) {
232-
title = `${title || this.environmentService.appNameLong} ${TitlebarPart.NLS_USER_IS_ADMIN}`;
234+
title = `${title || this.productService.nameLong} ${TitlebarPart.NLS_USER_IS_ADMIN}`;
233235
}
234236

235237
if (!this.properties.isPure) {
236-
title = `${title || this.environmentService.appNameLong} ${TitlebarPart.NLS_UNSUPPORTED}`;
238+
title = `${title || this.productService.nameLong} ${TitlebarPart.NLS_UNSUPPORTED}`;
237239
}
238240

239241
if (this.environmentService.isExtensionDevelopment) {
240-
title = `${TitlebarPart.NLS_EXTENSION_HOST} - ${title || this.environmentService.appNameLong}`;
242+
title = `${TitlebarPart.NLS_EXTENSION_HOST} - ${title || this.productService.nameLong}`;
241243
}
242244

243245
return title;
@@ -317,7 +319,7 @@ export class TitlebarPart extends Part implements ITitleService {
317319
const folderName = folder ? folder.name : '';
318320
const folderPath = folder ? this.labelService.getUriLabel(folder.uri) : '';
319321
const dirty = editor?.isDirty() ? TitlebarPart.TITLE_DIRTY : '';
320-
const appName = this.environmentService.appNameLong;
322+
const appName = this.productService.nameLong;
321323
const remoteName = this.environmentService.configuration.remoteAuthority;
322324
const separator = TitlebarPart.TITLE_SEPARATOR;
323325
const titleTemplate = this.configurationService.getValue<string>('window.title');

src/vs/workbench/contrib/experiments/common/experimentService.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
77
import { Emitter, Event } from 'vs/base/common/event';
88
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
9-
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
109
import { ITelemetryService, lastSessionDateStorageKey } from 'vs/platform/telemetry/common/telemetry';
1110
import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
1211
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -120,7 +119,6 @@ export class ExperimentService extends Disposable implements IExperimentService
120119
@IStorageService private readonly storageService: IStorageService,
121120
@IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService,
122121
@ITextFileService private readonly textFileService: ITextFileService,
123-
@IEnvironmentService private readonly environmentService: IEnvironmentService,
124122
@ITelemetryService private readonly telemetryService: ITelemetryService,
125123
@ILifecycleService private readonly lifecycleService: ILifecycleService,
126124
@IRequestService private readonly requestService: IRequestService,
@@ -333,7 +331,7 @@ export class ExperimentService extends Disposable implements IExperimentService
333331
return Promise.resolve(ExperimentState.NoRun);
334332
}
335333

336-
if (this.environmentService.appQuality === 'stable' && condition.insidersOnly === true) {
334+
if (this.productService.quality === 'stable' && condition.insidersOnly === true) {
337335
return Promise.resolve(ExperimentState.NoRun);
338336
}
339337

src/vs/workbench/contrib/experiments/test/electron-browser/experimentService.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import * as assert from 'assert';
77
import { ExperimentActionType, ExperimentState, IExperiment, ExperimentService } from 'vs/workbench/contrib/experiments/common/experimentService';
88
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
9-
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
109
import { TestLifecycleService } from 'vs/workbench/test/workbenchTestServices';
1110
import {
1211
IExtensionManagementService, DidInstallExtensionEvent, DidUninstallExtensionEvent, InstallExtensionEvent, IExtensionIdentifier, ILocalExtension
@@ -27,6 +26,7 @@ import { URI } from 'vs/base/common/uri';
2726
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
2827
import { getGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
2928
import { ExtensionType } from 'vs/platform/extensions/common/extensions';
29+
import { IProductService } from 'vs/platform/product/common/productService';
3030

3131
interface ExperimentSettings {
3232
enabled?: boolean;
@@ -88,7 +88,7 @@ suite('Experiment Service', () => {
8888
instantiationService.stub(IStorageService, <Partial<IStorageService>>{ get: (a: string, b: StorageScope, c?: string) => c, getBoolean: (a: string, b: StorageScope, c?: boolean) => c, store: () => { }, remove: () => { } });
8989

9090
setup(() => {
91-
instantiationService.stub(IEnvironmentService, {});
91+
instantiationService.stub(IProductService, {});
9292
instantiationService.stub(IStorageService, <Partial<IStorageService>>{ get: (a: string, b: StorageScope, c?: string) => c, getBoolean: (a: string, b: StorageScope, c?: boolean) => c, store: () => { }, remove: () => { } });
9393
});
9494

@@ -174,7 +174,7 @@ suite('Experiment Service', () => {
174174
]
175175
};
176176

177-
instantiationService.stub(IEnvironmentService, { appQuality: 'stable' });
177+
instantiationService.stub(IProductService, { quality: 'stable' });
178178
testObject = instantiationService.createInstance(TestExperimentService);
179179
return testObject.getExperimentById('experiment1').then(result => {
180180
assert.equal(result.enabled, true);

src/vs/workbench/contrib/files/browser/saveErrorHandler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { INotificationService, INotificationHandle, INotificationActions, Severi
2828
import { IOpenerService } from 'vs/platform/opener/common/opener';
2929
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
3030
import { ExecuteCommandAction } from 'vs/platform/actions/common/actions';
31-
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
31+
import { IProductService } from 'vs/platform/product/common/productService';
3232
import { Event } from 'vs/base/common/event';
3333
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
3434
import { isWindows } from 'vs/base/common/platform';
@@ -236,7 +236,7 @@ class ResolveSaveConflictAction extends Action {
236236
@IEditorService private readonly editorService: IEditorService,
237237
@INotificationService private readonly notificationService: INotificationService,
238238
@IInstantiationService private readonly instantiationService: IInstantiationService,
239-
@IEnvironmentService private readonly environmentService: IEnvironmentService
239+
@IProductService private readonly productService: IProductService
240240
) {
241241
super('workbench.files.action.resolveConflict', nls.localize('compareChanges', "Compare"));
242242
}
@@ -245,7 +245,7 @@ class ResolveSaveConflictAction extends Action {
245245
if (!this.model.isDisposed()) {
246246
const resource = this.model.getResource();
247247
const name = basename(resource);
248-
const editorLabel = nls.localize('saveConflictDiffLabel', "{0} (in file) ↔ {1} (in {2}) - Resolve save conflict", name, name, this.environmentService.appNameLong);
248+
const editorLabel = nls.localize('saveConflictDiffLabel', "{0} (in file) ↔ {1} (in {2}) - Resolve save conflict", name, name, this.productService.nameLong);
249249

250250
await TextFileContentProvider.open(resource, CONFLICT_RESOLUTION_SCHEME, editorLabel, this.editorService, { pinned: true });
251251

src/vs/workbench/contrib/localizations/browser/localizationsActions.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { firstIndex } from 'vs/base/common/arrays';
1616
import { IExtensionsViewlet, VIEWLET_ID as EXTENSIONS_VIEWLET_ID } from 'vs/workbench/contrib/extensions/common/extensions';
1717
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
1818
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
19+
import { IProductService } from 'vs/platform/product/common/productService';
1920

2021
export class ConfigureLocaleAction extends Action {
2122
public static readonly ID = 'workbench.action.configureLocale';
@@ -29,7 +30,8 @@ export class ConfigureLocaleAction extends Action {
2930
@IHostService private readonly hostService: IHostService,
3031
@INotificationService private readonly notificationService: INotificationService,
3132
@IViewletService private readonly viewletService: IViewletService,
32-
@IDialogService private readonly dialogService: IDialogService
33+
@IDialogService private readonly dialogService: IDialogService,
34+
@IProductService private readonly productService: IProductService
3335
) {
3436
super(id, label);
3537
}
@@ -69,7 +71,7 @@ export class ConfigureLocaleAction extends Action {
6971
const restart = await this.dialogService.confirm({
7072
type: 'info',
7173
message: localize('relaunchDisplayLanguageMessage', "A restart is required for the change in display language to take effect."),
72-
detail: localize('relaunchDisplayLanguageDetail', "Press the restart button to restart {0} and change the display language.", this.environmentService.appNameLong),
74+
detail: localize('relaunchDisplayLanguageDetail', "Press the restart button to restart {0} and change the display language.", this.productService.nameLong),
7375
primaryButton: localize('restart', "&&Restart")
7476
});
7577

src/vs/workbench/contrib/performance/electron-browser/startupProfiler.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
1818
import { URI } from 'vs/base/common/uri';
1919
import { IOpenerService } from 'vs/platform/opener/common/opener';
2020
import { IElectronService } from 'vs/platform/electron/node/electron';
21+
import { IProductService } from 'vs/platform/product/common/productService';
2122

2223
export class StartupProfiler implements IWorkbenchContribution {
2324

@@ -29,7 +30,8 @@ export class StartupProfiler implements IWorkbenchContribution {
2930
@ILifecycleService lifecycleService: ILifecycleService,
3031
@IExtensionService extensionService: IExtensionService,
3132
@IOpenerService private readonly _openerService: IOpenerService,
32-
@IElectronService private readonly _electronService: IElectronService
33+
@IElectronService private readonly _electronService: IElectronService,
34+
@IProductService private readonly _productService: IProductService
3335
) {
3436
// wait for everything to be ready
3537
Promise.all([
@@ -88,7 +90,7 @@ export class StartupProfiler implements IWorkbenchContribution {
8890
return this._dialogService.confirm({
8991
type: 'info',
9092
message: localize('prof.thanks', "Thanks for helping us."),
91-
detail: localize('prof.detail.restart', "A final restart is required to continue to use '{0}'. Again, thank you for your contribution.", this._environmentService.appNameLong),
93+
detail: localize('prof.detail.restart', "A final restart is required to continue to use '{0}'. Again, thank you for your contribution.", this._productService.nameLong),
9294
primaryButton: localize('prof.restart', "Restart"),
9395
secondaryButton: undefined
9496
}).then(() => {

src/vs/workbench/contrib/relauncher/browser/relauncher.contribution.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { IWindowsConfiguration } from 'vs/platform/windows/common/windows';
1010
import { IHostService } from 'vs/workbench/services/host/browser/host';
1111
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1212
import { localize } from 'vs/nls';
13-
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
1413
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
1514
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
1615
import { RunOnceScheduler } from 'vs/base/common/async';
@@ -20,6 +19,7 @@ import { isMacintosh, isNative } from 'vs/base/common/platform';
2019
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
2120
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
2221
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
22+
import { IProductService } from 'vs/platform/product/common/productService';
2323

2424
interface IConfiguration extends IWindowsConfiguration {
2525
update: { mode: string; };
@@ -44,7 +44,7 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
4444
constructor(
4545
@IHostService private readonly hostService: IHostService,
4646
@IConfigurationService private readonly configurationService: IConfigurationService,
47-
@IEnvironmentService private readonly envService: IEnvironmentService,
47+
@IProductService private readonly productService: IProductService,
4848
@IDialogService private readonly dialogService: IDialogService
4949
) {
5050
super();
@@ -120,8 +120,8 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
120120
localize('relaunchSettingMessage', "A setting has changed that requires a restart to take effect.") :
121121
localize('relaunchSettingMessageWeb', "A setting has changed that requires a reload to take effect."),
122122
isNative ?
123-
localize('relaunchSettingDetail', "Press the restart button to restart {0} and enable the setting.", this.envService.appNameLong) :
124-
localize('relaunchSettingDetailWeb', "Press the reload button to reload {0} and enable the setting.", this.envService.appNameLong),
123+
localize('relaunchSettingDetail', "Press the restart button to restart {0} and enable the setting.", this.productService.nameLong) :
124+
localize('relaunchSettingDetailWeb', "Press the reload button to reload {0} and enable the setting.", this.productService.nameLong),
125125
isNative ?
126126
localize('restart', "&&Restart") :
127127
localize('restartWeb', "&&Reload"),

src/vs/workbench/contrib/stats/electron-browser/workspaceStatsService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { joinPath } from 'vs/base/common/resources';
2121
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
2222
import { IWorkspaceStatsService, Tags } from 'vs/workbench/contrib/stats/common/workspaceStats';
2323
import { getHashedRemotesFromConfig } from 'vs/workbench/contrib/stats/electron-browser/workspaceStats';
24+
import { IProductService } from 'vs/platform/product/common/productService';
2425

2526
const ModulesToLookFor = [
2627
// Packages that suggest a node server
@@ -98,6 +99,7 @@ export class WorkspaceStatsService implements IWorkspaceStatsService {
9899
@IFileService private readonly fileService: IFileService,
99100
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
100101
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
102+
@IProductService private readonly productService: IProductService,
101103
@IHostService private readonly hostService: IHostService,
102104
@INotificationService private readonly notificationService: INotificationService,
103105
@IQuickInputService private readonly quickInputService: IQuickInputService,
@@ -260,7 +262,7 @@ export class WorkspaceStatsService implements IWorkspaceStatsService {
260262
tags['workspace.roots'] = isEmpty ? 0 : workspace.folders.length;
261263
tags['workspace.empty'] = isEmpty;
262264

263-
const folders = !isEmpty ? workspace.folders.map(folder => folder.uri) : this.environmentService.appQuality !== 'stable' && this.findFolders(configuration);
265+
const folders = !isEmpty ? workspace.folders.map(folder => folder.uri) : this.productService.quality !== 'stable' && this.findFolders(configuration);
264266
if (!folders || !folders.length || !this.fileService) {
265267
return Promise.resolve(tags);
266268
}

0 commit comments

Comments
 (0)