提交 25a0274d 编写于 作者: R Ramya Achutha Rao

Reverting hashservice

上级 dc44eab7
......@@ -39,6 +39,33 @@ export function combinedAppender(...appenders: ITelemetryAppender[]): ITelemetry
export const NullAppender: ITelemetryAppender = { log: () => null };
// --- util
export function anonymize(input: string): string {
if (!input) {
return input;
}
let r = '';
for (let i = 0; i < input.length; i++) {
let ch = input[i];
if (ch >= '0' && ch <= '9') {
r += '0';
continue;
}
if (ch >= 'a' && ch <= 'z') {
r += 'a';
continue;
}
if (ch >= 'A' && ch <= 'Z') {
r += 'A';
continue;
}
r += ch;
}
return r;
}
/* __GDPR__FRAGMENT__
"URIDescriptor" : {
"mimeType" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
......@@ -52,9 +79,9 @@ export interface URIDescriptor {
path?: string;
}
export function telemetryURIDescriptor(uri: URI, hashPath: (path: string) => string): URIDescriptor {
export function telemetryURIDescriptor(uri: URI): URIDescriptor {
const fsPath = uri && uri.fsPath;
return fsPath ? { mimeType: guessMimeTypes(fsPath).join(', '), ext: paths.extname(fsPath), path: hashPath(fsPath) } : {};
return fsPath ? { mimeType: guessMimeTypes(fsPath).join(', '), ext: paths.extname(fsPath), path: anonymize(fsPath) } : {};
}
/**
......
......@@ -11,7 +11,6 @@ import { IReference } from 'vs/base/common/lifecycle';
import { telemetryURIDescriptor } from 'vs/platform/telemetry/common/telemetryUtils';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { ResourceEditorModel } from 'vs/workbench/common/editor/resourceEditorModel';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
/**
* A read-only text editor input whos contents are made of the provided resource that points to an existing
......@@ -30,8 +29,7 @@ export class ResourceEditorInput extends EditorInput {
name: string,
description: string,
resource: URI,
@ITextModelService private textModelResolverService: ITextModelService,
@IHashService private hashService: IHashService
@ITextModelService private textModelResolverService: ITextModelService
) {
super();
......@@ -72,7 +70,7 @@ export class ResourceEditorInput extends EditorInput {
public getTelemetryDescriptor(): object {
const descriptor = super.getTelemetryDescriptor();
descriptor['resource'] = telemetryURIDescriptor(this.resource, path => this.hashService.createSHA1(path));
descriptor['resource'] = telemetryURIDescriptor(this.resource);
/* __GDPR__FRAGMENT__
"EditorTelemetryDescriptor" : {
......
......@@ -22,7 +22,6 @@ import { ITextFileService } from 'vs/workbench/services/textfile/common/textfile
import { telemetryURIDescriptor } from 'vs/platform/telemetry/common/telemetryUtils';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { Verbosity } from 'vs/platform/editor/common/editor';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
/**
* An editor input to be used for untitled text buffers.
......@@ -49,8 +48,7 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
@IInstantiationService private instantiationService: IInstantiationService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@ITextFileService private textFileService: ITextFileService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IHashService private hashService: IHashService
@IEnvironmentService private environmentService: IEnvironmentService
) {
super();
......@@ -254,7 +252,7 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
public getTelemetryDescriptor(): object {
const descriptor = super.getTelemetryDescriptor();
descriptor['resource'] = telemetryURIDescriptor(this.getResource(), path => this.hashService.createSHA1(path));
descriptor['resource'] = telemetryURIDescriptor(this.getResource());
/* __GDPR__FRAGMENT__
"EditorTelemetryDescriptor" : {
......
......@@ -91,8 +91,6 @@ import { foreground, selectionBackground, focusBorder, scrollbarShadow, scrollba
import { TextMateService } from 'vs/workbench/services/textMate/electron-browser/TMSyntax';
import { ITextMateService } from 'vs/workbench/services/textMate/electron-browser/textMateService';
import { IBroadcastService, BroadcastService } from 'vs/platform/broadcast/electron-browser/broadcastService';
import { HashService } from 'vs/workbench/services/hash/node/hashService';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
/**
* Services that we require for the Shell
......@@ -295,9 +293,6 @@ export class WorkbenchShell {
restoreFontInfo(this.storageService);
readFontInfo(BareFontInfo.createFromRawSettings(this.configurationService.getConfiguration('editor'), browser.getZoomLevel()));
// Hash
serviceCollection.set(IHashService, new SyncDescriptor(HashService));
// Experiments
this.experimentService = instantiationService.createInstance(ExperimentService);
serviceCollection.set(IExperimentService, this.experimentService);
......
......@@ -24,7 +24,6 @@ import { telemetryURIDescriptor } from 'vs/platform/telemetry/common/telemetryUt
import { Verbosity } from 'vs/platform/editor/common/editor';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
/**
* A file editor input is the input type for the file editor of file system resources.
......@@ -48,8 +47,7 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@ITextFileService private textFileService: ITextFileService,
@IEnvironmentService private environmentService: IEnvironmentService,
@ITextModelService private textModelResolverService: ITextModelService,
@IHashService private hashService: IHashService
@ITextModelService private textModelResolverService: ITextModelService
) {
super();
......@@ -276,7 +274,7 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
public getTelemetryDescriptor(): object {
const descriptor = super.getTelemetryDescriptor();
descriptor['resource'] = telemetryURIDescriptor(this.getResource(), path => this.hashService.createSHA1(path));
descriptor['resource'] = telemetryURIDescriptor(this.getResource());
/* __GDPR__FRAGMENT__
"EditorTelemetryDescriptor" : {
......
......@@ -7,7 +7,6 @@
import URI from 'vs/base/common/uri';
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
export interface HtmlInputOptions {
......@@ -26,9 +25,8 @@ export class HtmlInput extends ResourceEditorInput {
description: string,
resource: URI,
public readonly options: HtmlInputOptions,
@ITextModelService textModelResolverService: ITextModelService,
@IHashService hashService: IHashService
@ITextModelService textModelResolverService: ITextModelService
) {
super(name, description, resource, textModelResolverService, hashService);
super(name, description, resource, textModelResolverService);
}
}
......@@ -59,7 +59,6 @@ import Event, { Emitter } from 'vs/base/common/event';
import { Registry } from 'vs/platform/registry/common/platform';
import { MessageController } from 'vs/editor/contrib/message/messageController';
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
export class PreferencesEditorInput extends SideBySideEditorInput {
public static ID: string = 'workbench.editorinputs.preferencesEditorInput';
......@@ -76,10 +75,9 @@ export class PreferencesEditorInput extends SideBySideEditorInput {
export class DefaultPreferencesEditorInput extends ResourceEditorInput {
public static ID = 'workbench.editorinputs.defaultpreferences';
constructor(defaultSettingsResource: URI,
@ITextModelService textModelResolverService: ITextModelService,
@IHashService hashService: IHashService
@ITextModelService textModelResolverService: ITextModelService
) {
super(nls.localize('settingsEditorName', "Default Settings"), '', defaultSettingsResource, textModelResolverService, hashService);
super(nls.localize('settingsEditorName', "Default Settings"), '', defaultSettingsResource, textModelResolverService);
}
getTypeId(): string {
......
......@@ -15,7 +15,6 @@ import { marked } from 'vs/base/common/marked/marked';
import { Schemas } from 'vs/base/common/network';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ILifecycleService, ShutdownReason } from 'vs/platform/lifecycle/common/lifecycle';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
export class WalkThroughModel extends EditorModel {
......@@ -64,8 +63,7 @@ export class WalkThroughInput extends EditorInput {
private options: WalkThroughInputOptions,
@ITelemetryService private telemetryService: ITelemetryService,
@ILifecycleService lifecycleService: ILifecycleService,
@ITextModelService private textModelResolverService: ITextModelService,
@IHashService private hashService: IHashService
@ITextModelService private textModelResolverService: ITextModelService
) {
super();
this.disposables.push(lifecycleService.onShutdown(e => this.disposeTelemetry(e)));
......@@ -94,7 +92,7 @@ export class WalkThroughInput extends EditorInput {
getTelemetryDescriptor(): object {
const descriptor = super.getTelemetryDescriptor();
descriptor['target'] = this.getTelemetryFrom();
descriptor['resource'] = telemetryURIDescriptor(this.options.resource, path => this.hashService.createSHA1(path));
descriptor['resource'] = telemetryURIDescriptor(this.options.resource);
/* __GDPR__FRAGMENT__
"EditorTelemetryDescriptor" : {
"target" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
......
......@@ -16,7 +16,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { KeyCode, SimpleKeybinding, ChordKeybinding } from 'vs/base/common/keyCodes';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import extfs = require('vs/base/node/extfs');
import { TestTextFileService, TestEditorGroupService, TestLifecycleService, TestBackupFileService, TestContextService, TestTextResourceConfigurationService, TestHashService } from 'vs/workbench/test/workbenchTestServices';
import { TestTextFileService, TestEditorGroupService, TestLifecycleService, TestBackupFileService, TestContextService, TestTextResourceConfigurationService } from 'vs/workbench/test/workbenchTestServices';
import { IWorkspaceContextService, Workspace, toWorkspaceFolders } from 'vs/platform/workspace/common/workspace';
import uuid = require('vs/base/common/uuid');
import { ConfigurationService } from 'vs/platform/configuration/node/configurationService';
......@@ -42,7 +42,6 @@ import { KeybindingsEditingService } from 'vs/workbench/services/keybinding/comm
import { IUserFriendlyKeybinding } from 'vs/platform/keybinding/common/keybinding';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
interface Modifiers {
metaKey?: boolean;
......@@ -71,7 +70,6 @@ suite('Keybindings Editing', () => {
instantiationService.stub(IConfigurationService, 'onDidChangeConfiguration', () => { });
instantiationService.stub(IWorkspaceContextService, new TestContextService());
instantiationService.stub(ILifecycleService, new TestLifecycleService());
instantiationService.stub(IHashService, new TestHashService());
instantiationService.stub(IEditorGroupService, new TestEditorGroupService());
instantiationService.stub(ITelemetryService, NullTelemetryService);
instantiationService.stub(IModeService, ModeServiceImpl);
......
......@@ -31,9 +31,9 @@ import { IMessageService, Severity } from 'vs/platform/message/common/message';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IModelService } from 'vs/editor/common/services/modelService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { anonymize } from 'vs/platform/telemetry/common/telemetryUtils';
import { RunOnceScheduler } from 'vs/base/common/async';
import { IRawTextSource } from 'vs/editor/common/model/textSource';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
/**
* The text file editor model listens to changes to its underlying code editor model and saves these changes through the file service back to the disk.
......@@ -87,7 +87,6 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
@IBackupFileService private backupFileService: IBackupFileService,
@IEnvironmentService private environmentService: IEnvironmentService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IHashService private hashService: IHashService
) {
super(modelService, modeService);
......@@ -381,7 +380,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
"path": { "classification": "CustomerContent", "purpose": "FeatureInsight" }
}
*/
this.telemetryService.publicLog('fileGet', { mimeType: guessMimeTypes(this.resource.fsPath).join(', '), ext: paths.extname(this.resource.fsPath), path: this.hashService.createSHA1(this.resource.fsPath) });
this.telemetryService.publicLog('fileGet', { mimeType: guessMimeTypes(this.resource.fsPath).join(', '), ext: paths.extname(this.resource.fsPath), path: anonymize(this.resource.fsPath) });
}
return model;
......
......@@ -59,7 +59,6 @@ import { IRecentlyOpened } from 'vs/platform/history/common/history';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
import { IPosition } from 'vs/editor/common/core/position';
import { ICommandAction } from 'vs/platform/actions/common/actions';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
export function createFileInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
return instantiationService.createInstance(FileEditorInput, resource, void 0);
......@@ -268,7 +267,6 @@ export function workbenchInstantiationService(): IInstantiationService {
instantiationService.stub(ITextModelService, <ITextModelService>instantiationService.createInstance(TextModelResolverService));
instantiationService.stub(IEnvironmentService, TestEnvironmentService);
instantiationService.stub(IThemeService, new TestThemeService());
instantiationService.stub(IHashService, new TestHashService());
instantiationService.stub(IChoiceService, {
choose: (severity, message, options, cancelId): TPromise<number> => {
return TPromise.as(cancelId);
......@@ -1240,14 +1238,6 @@ export class TestTextResourceConfigurationService implements ITextResourceConfig
}
}
export class TestHashService implements IHashService {
_serviceBrand: any;
createSHA1(content: string): string {
return content;
}
}
export function getRandomTestPath(tmpdir: string, ...segments: string[]): string {
return paths.join(tmpdir, ...segments, generateUuid());
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册