提交 c5601021 编写于 作者: B Benjamin Pasero

debt - reduce usage of environmentService.configuration

Inline machineId and sessionId
上级 3b993525
......@@ -449,7 +449,7 @@ export class CustomMenubarControl extends MenubarControl {
case StateType.Idle:
return new Action('update.check', nls.localize({ key: 'checkForUpdates', comment: ['&& denotes a mnemonic'] }, "Check for &&Updates..."), undefined, true, () =>
this.updateService.checkForUpdates(this.environmentService.configuration.sessionId));
this.updateService.checkForUpdates(this.environmentService.sessionId));
case StateType.CheckingForUpdates:
return new Action('update.checking', nls.localize('checkingForUpdates', "Checking for Updates..."), undefined, false);
......
......@@ -17,7 +17,7 @@ export class ExtensionPoints implements IWorkbenchContribution {
@INativeWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService
) {
// Config Exporter
if (environmentService.configuration['export-default-configuration']) {
if (environmentService.args['export-default-configuration']) {
instantiationService.createInstance(DefaultConfigurationExportHelper);
}
}
......
......@@ -224,7 +224,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
case StateType.Idle:
if (state.error) {
this.onError(state.error);
} else if (this.state.type === StateType.CheckingForUpdates && this.state.context === this.environmentService.configuration.sessionId) {
} else if (this.state.type === StateType.CheckingForUpdates && this.state.context === this.environmentService.sessionId) {
this.onUpdateNotAvailable();
}
break;
......@@ -409,7 +409,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
}
private registerGlobalActivityActions(): void {
CommandsRegistry.registerCommand('update.check', () => this.updateService.checkForUpdates(this.environmentService.configuration.sessionId));
CommandsRegistry.registerCommand('update.check', () => this.updateService.checkForUpdates(this.environmentService.sessionId));
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
group: '6_update',
command: {
......@@ -543,7 +543,7 @@ export class CheckForVSCodeUpdateAction extends Action {
}
run(): Promise<void> {
return this.updateService.checkForUpdates(this.environmentService.configuration.sessionId);
return this.updateService.checkForUpdates(this.environmentService.sessionId);
}
}
......@@ -71,27 +71,27 @@ class DesktopMain extends Disposable {
this.reviveUris();
// Setup perf
importEntries(this.environmentService.configuration.perfEntries);
importEntries(this.configuration.perfEntries);
// Browser config
const zoomLevel = this.configuration.zoomLevel || 0;
setZoomFactor(zoomLevelToZoomFactor(zoomLevel));
setZoomLevel(zoomLevel, true /* isTrusted */);
setFullscreen(!!this.environmentService.configuration.fullscreen);
setFullscreen(!!this.configuration.fullscreen);
}
private reviveUris() {
if (this.environmentService.configuration.folderUri) {
this.environmentService.configuration.folderUri = URI.revive(this.environmentService.configuration.folderUri);
if (this.configuration.folderUri) {
this.configuration.folderUri = URI.revive(this.configuration.folderUri);
}
if (this.environmentService.configuration.workspace) {
this.environmentService.configuration.workspace = reviveWorkspaceIdentifier(this.environmentService.configuration.workspace);
if (this.configuration.workspace) {
this.configuration.workspace = reviveWorkspaceIdentifier(this.configuration.workspace);
}
const filesToWait = this.environmentService.configuration.filesToWait;
const filesToWait = this.configuration.filesToWait;
const filesToWaitPaths = filesToWait?.paths;
[filesToWaitPaths, this.environmentService.configuration.filesToOpenOrCreate, this.environmentService.configuration.filesToDiff].forEach(paths => {
[filesToWaitPaths, this.configuration.filesToOpenOrCreate, this.configuration.filesToDiff].forEach(paths => {
if (Array.isArray(paths)) {
paths.forEach(path => {
if (path.fileUri) {
......@@ -125,12 +125,12 @@ class DesktopMain extends Disposable {
this._register(instantiationService.createInstance(NativeWindow));
// Driver
if (this.environmentService.configuration.driver) {
if (this.configuration.driver) {
instantiationService.invokeFunction(async accessor => this._register(await registerWindowDriver(accessor, this.configuration.windowId)));
}
// Logging
services.logService.trace('workbench configuration', JSON.stringify(this.environmentService.configuration));
services.logService.trace('workbench configuration', JSON.stringify(this.configuration));
}
private registerListeners(workbench: Workbench, storageService: NativeStorageService): void {
......@@ -231,7 +231,7 @@ class DesktopMain extends Disposable {
fileService.registerProvider(Schemas.file, diskFileSystemProvider);
// User Data Provider
fileService.registerProvider(Schemas.userData, new FileUserDataProvider(this.environmentService.appSettingsHome, this.environmentService.configuration.backupPath ? URI.file(this.environmentService.configuration.backupPath) : undefined, diskFileSystemProvider, this.environmentService, logService));
fileService.registerProvider(Schemas.userData, new FileUserDataProvider(this.environmentService.appSettingsHome, this.configuration.backupPath ? URI.file(this.configuration.backupPath) : undefined, diskFileSystemProvider, this.environmentService, logService));
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
......@@ -299,14 +299,14 @@ class DesktopMain extends Disposable {
private async resolveWorkspaceInitializationPayload(resourceIdentityService: IResourceIdentityService): Promise<IWorkspaceInitializationPayload> {
// Multi-root workspace
if (this.environmentService.configuration.workspace) {
return this.environmentService.configuration.workspace;
if (this.configuration.workspace) {
return this.configuration.workspace;
}
// Single-folder workspace
let workspaceInitializationPayload: IWorkspaceInitializationPayload | undefined;
if (this.environmentService.configuration.folderUri) {
workspaceInitializationPayload = await this.resolveSingleFolderWorkspaceInitializationPayload(this.environmentService.configuration.folderUri, resourceIdentityService);
if (this.configuration.folderUri) {
workspaceInitializationPayload = await this.resolveSingleFolderWorkspaceInitializationPayload(this.configuration.folderUri, resourceIdentityService);
}
// Fallback to empty workspace if we have no payload yet.
......
......@@ -52,27 +52,27 @@ class DesktopMain extends Disposable {
this.reviveUris();
// Setup perf
importEntries(this.environmentService.configuration.perfEntries);
importEntries(this.configuration.perfEntries);
// Browser config
const zoomLevel = this.configuration.zoomLevel || 0;
setZoomFactor(zoomLevelToZoomFactor(zoomLevel));
setZoomLevel(zoomLevel, true /* isTrusted */);
setFullscreen(!!this.environmentService.configuration.fullscreen);
setFullscreen(!!this.configuration.fullscreen);
}
private reviveUris() {
if (this.environmentService.configuration.folderUri) {
this.environmentService.configuration.folderUri = URI.revive(this.environmentService.configuration.folderUri);
if (this.configuration.folderUri) {
this.configuration.folderUri = URI.revive(this.configuration.folderUri);
}
if (this.environmentService.configuration.workspace) {
this.environmentService.configuration.workspace = reviveWorkspaceIdentifier(this.environmentService.configuration.workspace);
if (this.configuration.workspace) {
this.configuration.workspace = reviveWorkspaceIdentifier(this.configuration.workspace);
}
const filesToWait = this.environmentService.configuration.filesToWait;
const filesToWait = this.configuration.filesToWait;
const filesToWaitPaths = filesToWait?.paths;
[filesToWaitPaths, this.environmentService.configuration.filesToOpenOrCreate, this.environmentService.configuration.filesToDiff].forEach(paths => {
[filesToWaitPaths, this.configuration.filesToOpenOrCreate, this.configuration.filesToDiff].forEach(paths => {
if (Array.isArray(paths)) {
paths.forEach(path => {
if (path.fileUri) {
......@@ -106,7 +106,7 @@ class DesktopMain extends Disposable {
this._register(instantiationService.createInstance(NativeWindow));
// Logging
services.logService.trace('workbench configuration', JSON.stringify(this.environmentService.configuration));
services.logService.trace('workbench configuration', JSON.stringify(this.configuration));
}
private registerListeners(workbench: Workbench, storageService: SimpleStorageService): void {
......
......@@ -89,6 +89,9 @@ export class SimpleNativeWorkbenchEnvironmentService implements INativeWorkbench
get backupWorkspaceHome(): URI { return joinPath(this.userRoamingDataHome, 'Backups', 'workspace'); }
get logsPath(): string { return joinPath(this.userRoamingDataHome, 'logs').path; }
sessionId = this.configuration.sessionId;
machineId = this.configuration.machineId;
options?: IWorkbenchConstructionOptions | undefined;
logExtensionHostCommunication?: boolean | undefined;
extensionEnabledProposedApi?: string[] | undefined;
......
......@@ -104,6 +104,9 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
@memoize
get remoteAuthority(): string | undefined { return this.options.remoteAuthority; }
@memoize
get sessionId(): string { return this.configuration.sessionId; }
@memoize
get isBuilt(): boolean { return !!this.productService.commit; }
......@@ -231,6 +234,8 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
get verbose(): boolean { return this.payload?.get('verbose') === 'true'; }
get logExtensionHostCommunication(): boolean { return this.payload?.get('logExtensionHostCommunication') === 'true'; }
get skipReleaseNotes(): boolean { return false; }
private payload: Map<string, string> | undefined;
constructor(
......@@ -286,6 +291,4 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
return extensionHostDebugEnvironment;
}
get skipReleaseNotes(): boolean { return false; }
}
......@@ -32,6 +32,8 @@ export interface IWorkbenchEnvironmentService extends IEnvironmentService {
readonly remoteAuthority?: string;
readonly sessionId: string;
readonly logFile: URI;
readonly backupWorkspaceHome?: URI;
......
......@@ -16,23 +16,28 @@ export class NativeWorkbenchEnvironmentService extends NativeEnvironmentService
declare readonly _serviceBrand: undefined;
@memoize
get webviewExternalEndpoint(): string {
const baseEndpoint = 'https://{{uuid}}.vscode-webview-test.com/{{commit}}';
get machineId() { return this.configuration.machineId; }
return baseEndpoint.replace('{{commit}}', this.productService.commit || '0d728c31ebdf03869d2687d9be0b017667c9ff37');
}
@memoize
get sessionId() { return this.configuration.sessionId; }
@memoize
get webviewResourceRoot(): string { return `${Schemas.vscodeWebviewResource}://{{uuid}}/{{resource}}`; }
get remoteAuthority() { return this.configuration.remoteAuthority; }
@memoize
get webviewCspSource(): string { return `${Schemas.vscodeWebviewResource}:`; }
get execPath() { return this.configuration.execPath; }
@memoize
get userRoamingDataHome(): URI { return this.appSettingsHome.with({ scheme: Schemas.userData }); }
// Do not memoize as `backupPath` can change in configuration
get backupWorkspaceHome(): URI | undefined { return this.configuration.backupPath ? URI.file(this.configuration.backupPath).with({ scheme: this.userRoamingDataHome.scheme }) : undefined; }
// Do NOT! memoize as `backupPath` can change in configuration
get backupWorkspaceHome(): URI | undefined {
if (this.configuration.backupPath) {
return URI.file(this.configuration.backupPath).with({ scheme: this.userRoamingDataHome.scheme });
}
return undefined;
}
@memoize
get logFile(): URI { return URI.file(join(this.logsPath, `renderer${this.configuration.windowId}.log`)); }
......@@ -40,6 +45,19 @@ export class NativeWorkbenchEnvironmentService extends NativeEnvironmentService
@memoize
get extHostLogsPath(): URI { return URI.file(join(this.logsPath, `exthost${this.configuration.windowId}`)); }
@memoize
get webviewExternalEndpoint(): string {
const baseEndpoint = 'https://{{uuid}}.vscode-webview-test.com/{{commit}}';
return baseEndpoint.replace('{{commit}}', this.productService.commit || '0d728c31ebdf03869d2687d9be0b017667c9ff37');
}
@memoize
get webviewResourceRoot(): string { return `${Schemas.vscodeWebviewResource}://{{uuid}}/{{resource}}`; }
@memoize
get webviewCspSource(): string { return `${Schemas.vscodeWebviewResource}:`; }
@memoize
get skipReleaseNotes(): boolean { return !!this.args['skip-release-notes']; }
......@@ -59,10 +77,6 @@ export class NativeWorkbenchEnvironmentService extends NativeEnvironmentService
return undefined;
}
readonly execPath = this.configuration.execPath;
readonly remoteAuthority = this.configuration.remoteAuthority;
constructor(
readonly configuration: INativeWorkbenchConfiguration,
private readonly productService: IProductService
......
......@@ -21,6 +21,8 @@ export interface INativeWorkbenchEnvironmentService extends IWorkbenchEnvironmen
readonly configuration: INativeWorkbenchConfiguration;
readonly machineId: string;
readonly crashReporterDirectory?: string;
readonly crashReporterId?: string;
......
......@@ -39,7 +39,7 @@ export class TelemetryService extends Disposable implements ITelemetryService {
const channel = sharedProcessService.getChannel('telemetryAppender');
const config: ITelemetryServiceConfig = {
appender: combinedAppender(new TelemetryAppenderClient(channel), new LogAppender(logService)),
commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, environmentService.configuration.machineId, productService.msftInternalDomains, environmentService.installSourcePath, environmentService.remoteAuthority),
commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, environmentService.machineId, productService.msftInternalDomains, environmentService.installSourcePath, environmentService.remoteAuthority),
piiPaths: environmentService.extensionsPath ? [environmentService.appRoot, environmentService.extensionsPath] : [environmentService.appRoot],
sendErrorTelemetry: true
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册