From 7e473e3ee7e92859f5474df0c8fb46c6468695bc Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Fri, 22 Feb 2019 18:51:18 +0100 Subject: [PATCH] debt - register hash service as singleton --- src/vs/workbench/electron-browser/workbench.ts | 4 +--- src/vs/workbench/services/hash/node/hashService.ts | 7 +++++-- src/vs/workbench/workbench.main.ts | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 7ddf68cfaae..ba4eded2f3d 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -99,7 +99,6 @@ import { ILogService } from 'vs/platform/log/common/log'; import { toErrorMessage } from 'vs/base/common/errorMessage'; import { ILabelService } from 'vs/platform/label/common/label'; import { LabelService } from 'vs/workbench/services/label/common/labelService'; -import { IHashService } from 'vs/workbench/services/hash/common/hashService'; import { ITelemetryServiceConfig, TelemetryService } from 'vs/platform/telemetry/common/telemetryService'; import { combinedAppender, LogAppender, NullTelemetryService, configurationTelemetry } from 'vs/platform/telemetry/common/telemetryUtils'; import ErrorTelemetry from 'vs/platform/telemetry/browser/errorTelemetry'; @@ -143,7 +142,6 @@ import { WorkspaceService } from 'vs/workbench/services/configuration/node/confi import { JSONEditingService } from 'vs/workbench/services/configuration/node/jsonEditingService'; import { WorkspaceEditingService } from 'vs/workbench/services/workspace/node/workspaceEditingService'; import { getDelayedChannel } from 'vs/base/parts/ipc/node/ipc'; -import { HashService } from 'vs/workbench/services/hash/node/hashService'; import { connect as connectNet } from 'vs/base/parts/ipc/node/ipc.net'; import { DialogChannel } from 'vs/platform/dialogs/node/dialogIpc'; import { TelemetryAppenderClient } from 'vs/platform/telemetry/node/telemetryIpc'; @@ -612,7 +610,7 @@ export class Workbench extends Disposable implements IPartService { serviceCollection.set(ILocalizationsService, new SyncDescriptor(LocalizationsChannelClient, [localizationsChannel])); // Hash - serviceCollection.set(IHashService, new SyncDescriptor(HashService, undefined, true)); + // serviceCollection.set(IHashService, new SyncDescriptor(HashService, undefined, true)); // Status bar this.statusbarPart = this.instantiationService.createInstance(StatusbarPart, Identifiers.STATUSBAR_PART); diff --git a/src/vs/workbench/services/hash/node/hashService.ts b/src/vs/workbench/services/hash/node/hashService.ts index 20ff60090a4..7d48db14487 100644 --- a/src/vs/workbench/services/hash/node/hashService.ts +++ b/src/vs/workbench/services/hash/node/hashService.ts @@ -5,12 +5,15 @@ import { createHash } from 'crypto'; import { IHashService } from 'vs/workbench/services/hash/common/hashService'; +import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; export class HashService implements IHashService { _serviceBrand: any; - public createSHA1(content: string): string { + createSHA1(content: string): string { return createHash('sha1').update(content).digest('hex'); } -} \ No newline at end of file +} + +registerSingleton(IHashService, HashService, true); \ No newline at end of file diff --git a/src/vs/workbench/workbench.main.ts b/src/vs/workbench/workbench.main.ts index 75ee523212b..550e2d7f813 100644 --- a/src/vs/workbench/workbench.main.ts +++ b/src/vs/workbench/workbench.main.ts @@ -42,6 +42,7 @@ import 'vs/workbench/api/browser/viewsExtensionPoint'; import 'vs/workbench/services/bulkEdit/browser/bulkEditService'; import 'vs/workbench/services/integrity/node/integrityService'; import 'vs/workbench/services/keybinding/common/keybindingEditing'; +import 'vs/workbench/services/hash/node/hashService'; //#endregion -- GitLab