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

sqlite - first cut next storage adoption

上级 03222d20
......@@ -13,7 +13,7 @@ import { FontInfo, BareFontInfo } from 'vs/editor/common/config/fontInfo';
import { ElementSizeObserver } from 'vs/editor/browser/config/elementSizeObserver';
import { FastDomNode } from 'vs/base/browser/fastDomNode';
import { CharWidthRequest, CharWidthRequestType, readCharWidths } from 'vs/editor/browser/config/charWidthReader';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
class CSSBasedConfigurationCache {
......@@ -57,8 +57,8 @@ export function readFontInfo(bareFontInfo: BareFontInfo): FontInfo {
return CSSBasedConfiguration.INSTANCE.readConfiguration(bareFontInfo);
}
export function restoreFontInfo(storageService: IStorageService): void {
let strStoredFontInfo = storageService.get('editorFontInfo', StorageScope.GLOBAL);
export function restoreFontInfo(nextStorage2Service: INextStorage2Service): void {
let strStoredFontInfo = nextStorage2Service.get('editorFontInfo', StorageScope.GLOBAL);
if (typeof strStoredFontInfo !== 'string') {
return;
}
......@@ -74,9 +74,9 @@ export function restoreFontInfo(storageService: IStorageService): void {
CSSBasedConfiguration.INSTANCE.restoreFontInfo(storedFontInfo);
}
export function saveFontInfo(storageService: IStorageService): void {
export function saveFontInfo(nextStorage2Service: INextStorage2Service): void {
let knownFontInfo = CSSBasedConfiguration.INSTANCE.saveFontInfo();
storageService.store('editorFontInfo', JSON.stringify(knownFontInfo), StorageScope.GLOBAL);
nextStorage2Service.set('editorFontInfo', JSON.stringify(knownFontInfo), StorageScope.GLOBAL);
}
export interface ISerializedFontInfo {
......
......@@ -14,7 +14,7 @@ import { FIND_IDS, FindModelBoundToEditorModel, ToggleCaseSensitiveKeybinding, T
import { FindReplaceState, FindReplaceStateChangedEvent, INewFindReplaceState } from 'vs/editor/contrib/find/findState';
import { Delayer } from 'vs/base/common/async';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
......@@ -72,7 +72,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
protected _state: FindReplaceState;
protected _updateHistoryDelayer: Delayer<void>;
private _model: FindModelBoundToEditorModel;
protected _storageService: IStorageService;
private _nextStorage2Service: INextStorage2Service;
private _clipboardService: IClipboardService;
protected readonly _contextKeyService: IContextKeyService;
......@@ -83,14 +83,14 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
constructor(
editor: ICodeEditor,
@IContextKeyService contextKeyService: IContextKeyService,
@IStorageService storageService: IStorageService,
@INextStorage2Service nextStorage2Service: INextStorage2Service,
@IClipboardService clipboardService: IClipboardService
) {
super();
this._editor = editor;
this._findWidgetVisible = CONTEXT_FIND_WIDGET_VISIBLE.bindTo(contextKeyService);
this._contextKeyService = contextKeyService;
this._storageService = storageService;
this._nextStorage2Service = nextStorage2Service;
this._clipboardService = clipboardService;
this._updateHistoryDelayer = new Delayer<void>(500);
......@@ -107,9 +107,9 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
this._state.change({
searchScope: null,
matchCase: this._storageService.getBoolean('editor.matchCase', StorageScope.WORKSPACE, false),
wholeWord: this._storageService.getBoolean('editor.wholeWord', StorageScope.WORKSPACE, false),
isRegex: this._storageService.getBoolean('editor.isRegex', StorageScope.WORKSPACE, false)
matchCase: this._nextStorage2Service.getBoolean('editor.matchCase', StorageScope.WORKSPACE, false),
wholeWord: this._nextStorage2Service.getBoolean('editor.wholeWord', StorageScope.WORKSPACE, false),
isRegex: this._nextStorage2Service.getBoolean('editor.isRegex', StorageScope.WORKSPACE, false)
}, false);
if (shouldRestartFind) {
......@@ -159,21 +159,21 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
private saveQueryState(e: FindReplaceStateChangedEvent) {
if (e.isRegex) {
this._storageService.store('editor.isRegex', this._state.actualIsRegex, StorageScope.WORKSPACE);
this._nextStorage2Service.set('editor.isRegex', this._state.actualIsRegex, StorageScope.WORKSPACE);
}
if (e.wholeWord) {
this._storageService.store('editor.wholeWord', this._state.actualWholeWord, StorageScope.WORKSPACE);
this._nextStorage2Service.set('editor.wholeWord', this._state.actualWholeWord, StorageScope.WORKSPACE);
}
if (e.matchCase) {
this._storageService.store('editor.matchCase', this._state.actualMatchCase, StorageScope.WORKSPACE);
this._nextStorage2Service.set('editor.matchCase', this._state.actualMatchCase, StorageScope.WORKSPACE);
}
}
private loadQueryState() {
this._state.change({
matchCase: this._storageService.getBoolean('editor.matchCase', StorageScope.WORKSPACE, this._state.matchCase),
wholeWord: this._storageService.getBoolean('editor.wholeWord', StorageScope.WORKSPACE, this._state.wholeWord),
isRegex: this._storageService.getBoolean('editor.isRegex', StorageScope.WORKSPACE, this._state.isRegex)
matchCase: this._nextStorage2Service.getBoolean('editor.matchCase', StorageScope.WORKSPACE, this._state.matchCase),
wholeWord: this._nextStorage2Service.getBoolean('editor.wholeWord', StorageScope.WORKSPACE, this._state.wholeWord),
isRegex: this._nextStorage2Service.getBoolean('editor.isRegex', StorageScope.WORKSPACE, this._state.isRegex)
}, false);
}
......@@ -366,10 +366,10 @@ export class FindController extends CommonFindController implements IFindControl
@IContextKeyService _contextKeyService: IContextKeyService,
@IKeybindingService private readonly _keybindingService: IKeybindingService,
@IThemeService private readonly _themeService: IThemeService,
@IStorageService storageService: IStorageService,
@INextStorage2Service nextStorage2Service: INextStorage2Service,
@optional(IClipboardService) clipboardService: IClipboardService
) {
super(editor, _contextKeyService, storageService, clipboardService);
super(editor, _contextKeyService, nextStorage2Service, clipboardService);
}
protected _start(opts: IFindStartOptions): void {
......
......@@ -14,7 +14,8 @@ import { CONTEXT_FIND_INPUT_FOCUSED } from 'vs/editor/contrib/find/findModel';
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { INextStorage2Service } from 'vs/platform/storage2/common/storage2';
import { Event } from 'vs/base/common/event';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { Delayer } from 'vs/base/common/async';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
......@@ -30,10 +31,10 @@ export class TestFindController extends CommonFindController {
constructor(
editor: ICodeEditor,
@IContextKeyService contextKeyService: IContextKeyService,
@IStorageService storageService: IStorageService,
@INextStorage2Service nextStorage2Service: INextStorage2Service,
@IClipboardService clipboardService: IClipboardService
) {
super(editor, contextKeyService, storageService, clipboardService);
super(editor, contextKeyService, nextStorage2Service, clipboardService);
this._findInputFocused = CONTEXT_FIND_INPUT_FOCUSED.bindTo(contextKeyService);
this._updateHistoryDelayer = new Delayer<void>(50);
}
......@@ -58,11 +59,16 @@ suite('FindController', () => {
let queryState: { [key: string]: any; } = {};
let clipboardState = '';
let serviceCollection = new ServiceCollection();
serviceCollection.set(IStorageService, {
serviceCollection.set(INextStorage2Service, {
_serviceBrand: undefined,
onDidChangeStorage: Event.None,
onWillClose: Event.None,
get: (key: string) => queryState[key],
getBoolean: (key: string) => !!queryState[key],
store: (key: string, value: any) => { queryState[key] = value; }
} as IStorageService);
getInteger: (key: string) => undefined,
set: (key: string, value: any) => { queryState[key] = value; return Promise.resolve(); },
delete: (key) => void 0
} as INextStorage2Service);
if (platform.isMacintosh) {
serviceCollection.set(IClipboardService, <any>{
......@@ -428,11 +434,16 @@ suite('FindController query options persistence', () => {
queryState['editor.matchCase'] = false;
queryState['editor.wholeWord'] = false;
let serviceCollection = new ServiceCollection();
serviceCollection.set(IStorageService, {
serviceCollection.set(INextStorage2Service, {
_serviceBrand: undefined,
onDidChangeStorage: Event.None,
onWillClose: Event.None,
get: (key: string) => queryState[key],
getBoolean: (key: string) => !!queryState[key],
store: (key: string, value: any) => { queryState[key] = value; }
} as IStorageService);
getInteger: (key: string) => undefined,
set: (key: string, value: any) => { queryState[key] = value; return Promise.resolve(); },
delete: (key) => void 0
} as INextStorage2Service);
test('matchCase', () => {
withTestCodeEditor([
......
......@@ -9,7 +9,8 @@ import { Range } from 'vs/editor/common/core/range';
import { InsertCursorAbove, InsertCursorBelow, MultiCursorSelectionController, SelectHighlightsAction, AddSelectionToNextFindMatchAction } from 'vs/editor/contrib/multicursor/multicursor';
import { Handler } from 'vs/editor/common/editorCommon';
import { EndOfLineSequence } from 'vs/editor/common/model';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { INextStorage2Service } from 'vs/platform/storage2/common/storage2';
import { Event } from 'vs/base/common/event';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { CommonFindController } from 'vs/editor/contrib/find/findController';
......@@ -58,11 +59,16 @@ function fromRange(rng: Range): number[] {
suite('Multicursor selection', () => {
let queryState: { [key: string]: any; } = {};
let serviceCollection = new ServiceCollection();
serviceCollection.set(IStorageService, {
serviceCollection.set(INextStorage2Service, {
_serviceBrand: undefined,
onDidChangeStorage: Event.None,
onWillClose: Event.None,
get: (key: string) => queryState[key],
getBoolean: (key: string) => !!queryState[key],
store: (key: string, value: any) => { queryState[key] = value; }
} as IStorageService);
getInteger: (key: string) => undefined,
set: (key: string, value: any) => { queryState[key] = value; return Promise.resolve(); },
delete: (key) => void 0
} as INextStorage2Service);
test('issue #8817: Cursor position changes when you cancel multicursor', () => {
withTestCodeEditor([
......
......@@ -14,7 +14,7 @@ import { TextModel } from 'vs/editor/common/model/textModel';
import * as modes from 'vs/editor/common/modes';
import { createTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { IStorageService, NullStorageService } from 'vs/platform/storage/common/storage';
import { INextStorage2Service, NullNextStorage2Service } from 'vs/platform/storage2/common/storage2';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { ParameterHintsModel } from '../parameterHintsWidget';
......@@ -44,7 +44,7 @@ suite('ParameterHintsModel', () => {
model: textModel,
serviceCollection: new ServiceCollection(
[ITelemetryService, NullTelemetryService],
[IStorageService, NullStorageService]
[INextStorage2Service, NullNextStorage2Service]
)
});
disposables.push(textModel);
......
......@@ -10,7 +10,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { ReferencesModel } from './referencesModel';
......@@ -52,7 +52,7 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
@ICodeEditorService private readonly _editorService: ICodeEditorService,
@INotificationService private readonly _notificationService: INotificationService,
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@IStorageService private readonly _storageService: IStorageService,
@INextStorage2Service private readonly _nextStorage2Service: INextStorage2Service,
@IConfigurationService private readonly _configurationService: IConfigurationService,
) {
this._editor = editor;
......@@ -95,14 +95,14 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
}
}));
const storageKey = 'peekViewLayout';
const data = <LayoutData>JSON.parse(this._storageService.get(storageKey, undefined, '{}'));
const data = <LayoutData>JSON.parse(this._nextStorage2Service.get(storageKey, StorageScope.GLOBAL, '{}'));
this._widget = this._instantiationService.createInstance(ReferenceWidget, this._editor, this._defaultTreeKeyboardSupport, data);
this._widget.setTitle(nls.localize('labelLoading', "Loading..."));
this._widget.show(range);
this._disposables.push(this._widget.onDidClose(() => {
modelPromise.cancel();
this._storageService.store(storageKey, JSON.stringify(this._widget.layoutData));
this._nextStorage2Service.set(storageKey, JSON.stringify(this._widget.layoutData), StorageScope.GLOBAL);
this._widget = null;
this.closeWidget();
}));
......
......@@ -5,7 +5,7 @@
import { ICompletionItem } from 'vs/editor/contrib/suggest/completionModel';
import { LRUCache, TernarySearchTree } from 'vs/base/common/map';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2';
import { ITextModel } from 'vs/editor/common/model';
import { IPosition } from 'vs/editor/common/core/position';
import { RunOnceScheduler } from 'vs/base/common/async';
......@@ -205,7 +205,7 @@ export class SuggestMemories {
constructor(
editor: ICodeEditor,
@IStorageService private readonly _storageService: IStorageService,
@INextStorage2Service private readonly _nextStorage2Service: INextStorage2Service,
) {
this._persistSoon = new RunOnceScheduler(() => this._flush(), 3000);
this._setMode(editor.getConfiguration().contribInfo.suggestSelection);
......@@ -224,7 +224,7 @@ export class SuggestMemories {
this._strategy = mode === 'recentlyUsedByPrefix' ? new PrefixMemory() : mode === 'recentlyUsed' ? new LRUMemory() : new NoMemory();
try {
const raw = this._storageService.get(`${this._storagePrefix}/${this._mode}`, StorageScope.WORKSPACE);
const raw = this._nextStorage2Service.get(`${this._storagePrefix}/${this._mode}`, StorageScope.WORKSPACE);
if (raw) {
this._strategy.fromJSON(JSON.parse(raw));
}
......@@ -244,6 +244,6 @@ export class SuggestMemories {
private _flush() {
const raw = JSON.stringify(this._strategy);
this._storageService.store(`${this._storagePrefix}/${this._mode}`, raw, StorageScope.WORKSPACE);
this._nextStorage2Service.set(`${this._storagePrefix}/${this._mode}`, raw, StorageScope.WORKSPACE);
}
}
......@@ -26,7 +26,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { attachListStyler } from 'vs/platform/theme/common/styler';
import { IThemeService, ITheme, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { registerColor, editorWidgetBackground, listFocusBackground, activeContrastBorder, listHighlightForeground, editorForeground, editorWidgetBorder, focusBorder, textLinkForeground, textCodeBlockBackground } from 'vs/platform/theme/common/colorRegistry';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2';
import { MarkdownRenderer } from 'vs/editor/contrib/markdown/markdownRenderer';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IOpenerService } from 'vs/platform/opener/common/opener';
......@@ -397,13 +397,10 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
private readonly maxWidgetWidth = 660;
private readonly listWidth = 330;
private storageService: IStorageService;
private nextStorage2Service: INextStorage2Service;
private detailsFocusBorderColor: string;
private detailsBorderColor: string;
private storageServiceAvailable: boolean = true;
private expandSuggestionDocs: boolean = false;
private firstFocusInCurrentList: boolean = false;
constructor(
......@@ -411,7 +408,7 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
@ITelemetryService private telemetryService: ITelemetryService,
@IContextKeyService contextKeyService: IContextKeyService,
@IThemeService themeService: IThemeService,
@IStorageService storageService: IStorageService,
@INextStorage2Service nextStorage2Service: INextStorage2Service,
@IKeybindingService keybindingService: IKeybindingService,
@IModeService modeService: IModeService,
@IOpenerService openerService: IOpenerService
......@@ -422,14 +419,7 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
this.isAuto = false;
this.focusedItem = null;
this.storageService = storageService;
if (this.expandDocsSettingFromStorage() === undefined) {
this.storageService.store('expandSuggestionDocs', expandSuggestionDocsByDefault, StorageScope.GLOBAL);
if (this.expandDocsSettingFromStorage() === undefined) {
this.storageServiceAvailable = false;
}
}
this.nextStorage2Service = nextStorage2Service;
this.element = $('.editor-widget.suggest-widget');
if (!this.editor.getConfiguration().contribInfo.iconsInSuggestions) {
......@@ -1053,22 +1043,12 @@ export class SuggestWidget implements IContentWidget, IVirtualDelegate<ICompleti
return 'suggestion';
}
// Monaco Editor does not have a storage service
private expandDocsSettingFromStorage(): boolean {
if (this.storageServiceAvailable) {
return this.storageService.getBoolean('expandSuggestionDocs', StorageScope.GLOBAL);
} else {
return this.expandSuggestionDocs;
}
return this.nextStorage2Service.getBoolean('expandSuggestionDocs', StorageScope.GLOBAL, expandSuggestionDocsByDefault);
}
// Monaco Editor does not have a storage service
private updateExpandDocsSetting(value: boolean) {
if (this.storageServiceAvailable) {
this.storageService.store('expandSuggestionDocs', value, StorageScope.GLOBAL);
} else {
this.expandSuggestionDocs = value;
}
this.nextStorage2Service.set('expandSuggestionDocs', value, StorageScope.GLOBAL);
}
dispose(): void {
......
......@@ -23,7 +23,7 @@ import { ISelectedSuggestion } from 'vs/editor/contrib/suggest/suggestWidget';
import { TestCodeEditor, createTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
import { MockMode } from 'vs/editor/test/common/mocks/mockMode';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { IStorageService, NullStorageService } from 'vs/platform/storage/common/storage';
import { INextStorage2Service, NullNextStorage2Service } from 'vs/platform/storage2/common/storage2';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
......@@ -42,7 +42,7 @@ function createMockEditor(model: TextModel): TestCodeEditor {
model: model,
serviceCollection: new ServiceCollection(
[ITelemetryService, NullTelemetryService],
[IStorageService, NullStorageService]
[INextStorage2Service, NullNextStorage2Service]
),
});
editor.registerAndInstantiateContribution(SnippetController2);
......
......@@ -7,7 +7,7 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { INextStorage2Service } from 'vs/platform/storage2/common/storage2';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { INotificationService } from 'vs/platform/notification/common/notification';
......@@ -21,7 +21,7 @@ export class StandaloneReferencesController extends ReferencesController {
@ICodeEditorService editorService: ICodeEditorService,
@INotificationService notificationService: INotificationService,
@IInstantiationService instantiationService: IInstantiationService,
@IStorageService storageService: IStorageService,
@INextStorage2Service nextStorage2Service: INextStorage2Service,
@IConfigurationService configurationService: IConfigurationService,
) {
super(
......@@ -31,8 +31,8 @@ export class StandaloneReferencesController extends ReferencesController {
editorService,
notificationService,
instantiationService,
storageService,
configurationService,
nextStorage2Service,
configurationService
);
}
}
......
......@@ -17,6 +17,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { MarkerService } from 'vs/platform/markers/common/markerService';
import { IMarkerService } from 'vs/platform/markers/common/markers';
import { IProgressService } from 'vs/platform/progress/common/progress';
import { INextStorage2Service, NullNextStorage2Service } from 'vs/platform/storage2/common/storage2';
import { IStorageService, NullStorageService } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
......@@ -144,6 +145,8 @@ export module StaticServices {
export const progressService = define(IProgressService, () => new SimpleProgressService());
export const nextStorage2Service = define(INextStorage2Service, () => NullNextStorage2Service);
export const storageService = define(IStorageService, () => NullStorageService);
export const logService = define(ILogService, () => new NullLogService());
......
......@@ -94,7 +94,7 @@ export class NextStorage2Service extends Disposable implements INextStorage2Serv
}
}
export class NextDelegatingStorageService extends Disposable implements INextStorage2Service {
export class NextDelegatingStorage2Service extends Disposable implements INextStorage2Service {
_serviceBrand: any;
private _onDidChangeStorage: Emitter<IWorkspaceStorageChangeEvent> = this._register(new Emitter<IWorkspaceStorageChangeEvent>());
......
......@@ -5,37 +5,42 @@
import { TPromise } from 'vs/base/common/winjs.base';
import * as uuid from 'vs/base/common/uuid';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { resolveCommonProperties } from '../node/commonProperties';
import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2';
import { resolveCommonProperties } from 'vs/platform/telemetry/node/commonProperties';
export function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string, version: string, machineId: string, installSourcePath: string): TPromise<{ [name: string]: string }> {
export function resolveWorkbenchCommonProperties(nextStorage2Service: INextStorage2Service, commit: string, version: string, machineId: string, installSourcePath: string): TPromise<{ [name: string]: string }> {
return resolveCommonProperties(commit, version, machineId, installSourcePath).then(result => {
// __GDPR__COMMON__ "common.version.shell" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
result['common.version.shell'] = process.versions && (<any>process).versions['electron'];
// __GDPR__COMMON__ "common.version.renderer" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
result['common.version.renderer'] = process.versions && (<any>process).versions['chrome'];
const lastSessionDate = storageService.get('telemetry.lastSessionDate');
const firstSessionDate = storageService.get('telemetry.firstSessionDate') || new Date().toUTCString();
storageService.store('telemetry.firstSessionDate', firstSessionDate);
storageService.store('telemetry.lastSessionDate', new Date().toUTCString());
const lastSessionDate = nextStorage2Service.get('telemetry.lastSessionDate', StorageScope.GLOBAL);
nextStorage2Service.set('telemetry.lastSessionDate', new Date().toUTCString(), StorageScope.GLOBAL);
// __GDPR__COMMON__ "common.firstSessionDate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.firstSessionDate'] = firstSessionDate;
result['common.firstSessionDate'] = getOrCreateFirstSessionDate(nextStorage2Service);
// __GDPR__COMMON__ "common.lastSessionDate" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.lastSessionDate'] = lastSessionDate;
// __GDPR__COMMON__ "common.isNewSession" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.isNewSession'] = !lastSessionDate ? '1' : '0';
// __GDPR__COMMON__ "common.instanceId" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.instanceId'] = getOrCreateInstanceId(storageService);
result['common.instanceId'] = getOrCreateInstanceId(nextStorage2Service);
return result;
});
}
function getOrCreateInstanceId(storageService: IStorageService): string {
const result = storageService.get('telemetry.instanceId') || uuid.generateUuid();
storageService.store('telemetry.instanceId', result);
function getOrCreateInstanceId(nextStorage2Service: INextStorage2Service): string {
const result = nextStorage2Service.get('telemetry.instanceId', StorageScope.GLOBAL, uuid.generateUuid());
nextStorage2Service.set('telemetry.instanceId', result, StorageScope.GLOBAL);
return result;
}
function getOrCreateFirstSessionDate(nextStorage2Service: INextStorage2Service): string {
const firstSessionDate = nextStorage2Service.get('telemetry.firstSessionDate', StorageScope.GLOBAL, new Date().toUTCString());
nextStorage2Service.set('telemetry.firstSessionDate', firstSessionDate, StorageScope.GLOBAL);
return firstSessionDate;
}
\ No newline at end of file
......@@ -7,9 +7,10 @@ import * as path from 'path';
import * as os from 'os';
import * as fs from 'fs';
import { resolveWorkbenchCommonProperties } from 'vs/platform/telemetry/node/workbenchCommonProperties';
import { StorageService, InMemoryLocalStorage } from 'vs/platform/storage/common/storageService';
import { TestWorkspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { getRandomTestPath } from 'vs/workbench/test/workbenchTestServices';
import { getRandomTestPath, TestEnvironmentService } from 'vs/workbench/test/workbenchTestServices';
import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2';
import { NextStorage2Service } from 'vs/platform/storage2/electron-browser/nextStorage2Service';
import { NullLogService } from 'vs/platform/log/common/log';
import { del } from 'vs/base/node/extfs';
import { mkdirp } from 'vs/base/node/pfs';
import { timeout } from 'vs/base/common/async';
......@@ -20,10 +21,10 @@ suite('Telemetry - common properties', function () {
const commit: string = void 0;
const version: string = void 0;
let storageService: StorageService;
let nestStorage2Service: INextStorage2Service;
setup(() => {
storageService = new StorageService(new InMemoryLocalStorage(), null, TestWorkspace.id);
nestStorage2Service = new NextStorage2Service(':memory:', new NullLogService(), TestEnvironmentService);
});
teardown(done => {
......@@ -33,7 +34,7 @@ suite('Telemetry - common properties', function () {
test('default', async function () {
await mkdirp(parentDir);
fs.writeFileSync(installSource, 'my.install.source');
const props = await resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource);
const props = await resolveWorkbenchCommonProperties(nestStorage2Service, commit, version, 'someMachineId', installSource);
assert.ok('commitHash' in props);
assert.ok('sessionID' in props);
assert.ok('timestamp' in props);
......@@ -54,22 +55,22 @@ suite('Telemetry - common properties', function () {
assert.ok('common.instanceId' in props, 'instanceId');
assert.ok('common.machineId' in props, 'machineId');
fs.unlinkSync(installSource);
const props_1 = await resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource);
const props_1 = await resolveWorkbenchCommonProperties(nestStorage2Service, commit, version, 'someMachineId', installSource);
assert.ok(!('common.source' in props_1));
});
test('lastSessionDate when aviablale', async function () {
storageService.store('telemetry.lastSessionDate', new Date().toUTCString());
nestStorage2Service.set('telemetry.lastSessionDate', new Date().toUTCString(), StorageScope.GLOBAL);
const props = await resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource);
const props = await resolveWorkbenchCommonProperties(nestStorage2Service, commit, version, 'someMachineId', installSource);
assert.ok('common.lastSessionDate' in props); // conditional, see below
assert.ok('common.isNewSession' in props);
assert.equal(props['common.isNewSession'], 0);
});
test('values chance on ask', async function () {
const props = await resolveWorkbenchCommonProperties(storageService, commit, version, 'someMachineId', installSource);
const props = await resolveWorkbenchCommonProperties(nestStorage2Service, commit, version, 'someMachineId', installSource);
let value1 = props['common.sequence'];
let value2 = props['common.sequence'];
assert.ok(value1 !== value2, 'seq');
......
......@@ -36,7 +36,7 @@ import { IWorkspacesService, ISingleFolderWorkspaceIdentifier } from 'vs/platfor
import { createSpdLogService } from 'vs/platform/log/node/spdlogService';
import * as fs from 'fs';
import { ConsoleLogService, MultiplexLogService, ILogService } from 'vs/platform/log/common/log';
import { NextStorage2Service, NextDelegatingStorageService } from 'vs/platform/storage2/electron-browser/nextStorage2Service';
import { NextStorage2Service, NextDelegatingStorage2Service } from 'vs/platform/storage2/electron-browser/nextStorage2Service';
import { IssueChannelClient } from 'vs/platform/issue/node/issueIpc';
import { IIssueService } from 'vs/platform/issue/common/issue';
import { LogLevelSetterChannelClient, FollowerLogService } from 'vs/platform/log/node/logIpc';
......@@ -104,7 +104,7 @@ function openWorkbench(configuration: IWindowConfiguration): Promise<void> {
]).then(services => {
const workspaceService = services[0];
const storageService = createStorageService(workspaceService, environmentService);
const nextStorage2Service = new NextDelegatingStorageService(services[1], storageService, logService, environmentService);
const nextStorage2Service = new NextDelegatingStorage2Service(services[1], storageService, logService, environmentService);
return domContentLoaded().then(() => {
perf.mark('willStartWorkbench');
......
......@@ -75,7 +75,7 @@ import { IBroadcastService, BroadcastService } from 'vs/platform/broadcast/elect
import { HashService } from 'vs/workbench/services/hash/node/hashService';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
import { ILogService } from 'vs/platform/log/common/log';
import { INextStorage2Service } from 'vs/platform/storage2/common/storage2';
import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2';
import { Event, Emitter } from 'vs/base/common/event';
import { WORKBENCH_BACKGROUND } from 'vs/workbench/common/theme';
import { stat } from 'fs';
......@@ -170,8 +170,11 @@ export class WorkbenchShell extends Disposable {
const [instantiationService, serviceCollection] = this.initServiceCollection(this.container);
// Warm up font cache information before building up too many dom elements
restoreFontInfo(this.storageService);
restoreFontInfo(this.nextStorage2Service);
readFontInfo(BareFontInfo.createFromRawSettings(this.configurationService.getValue('editor'), browser.getZoomLevel()));
this._register(this.nextStorage2Service.onWillClose(() => {
saveFontInfo(this.nextStorage2Service); // Keep font info for next startup around
}));
// Workbench
this.workbench = this.createWorkbench(instantiationService, serviceCollection, this.container);
......@@ -286,17 +289,17 @@ export class WorkbenchShell extends Disposable {
}
perf.mark('willReadLocalStorage');
const readyToSend = this.storageService.getBoolean('localStorageMetricsReadyToSend2');
const readyToSend = this.nextStorage2Service.getBoolean('localStorageMetricsReadyToSend2', StorageScope.GLOBAL);
perf.mark('didReadLocalStorage');
if (!readyToSend) {
this.storageService.store('localStorageMetricsReadyToSend2', true);
this.nextStorage2Service.set('localStorageMetricsReadyToSend2', true, StorageScope.GLOBAL);
return; // avoid logging localStorage metrics directly after the update, we prefer cold startup numbers
}
if (!this.storageService.getBoolean('localStorageMetricsSent2')) {
if (!this.nextStorage2Service.getBoolean('localStorageMetricsSent2', StorageScope.GLOBAL)) {
perf.mark('willWriteLocalStorage');
this.storageService.store('localStorageMetricsSent2', true);
this.nextStorage2Service.set('localStorageMetricsSent2', true, StorageScope.GLOBAL);
perf.mark('didWriteLocalStorage');
perf.mark('willStatLocalStorage');
......@@ -366,7 +369,7 @@ export class WorkbenchShell extends Disposable {
const channel = getDelayedChannel<ITelemetryAppenderChannel>(sharedProcess.then(c => c.getChannel('telemetryAppender')));
const config: ITelemetryServiceConfig = {
appender: combinedAppender(new TelemetryAppenderClient(channel), new LogAppender(this.logService)),
commonProperties: resolveWorkbenchCommonProperties(this.storageService, product.commit, pkg.version, this.configuration.machineId, this.environmentService.installSourcePath),
commonProperties: resolveWorkbenchCommonProperties(this.nextStorage2Service, product.commit, pkg.version, this.configuration.machineId, this.environmentService.installSourcePath),
piiPaths: [this.environmentService.appRoot, this.environmentService.extensionsPath]
};
......@@ -517,9 +520,6 @@ export class WorkbenchShell extends Disposable {
dispose(reason = ShutdownReason.QUIT): void {
super.dispose();
// Keep font info for next startup around
saveFontInfo(this.storageService);
// Dispose Workbench
if (this.workbench) {
this.workbench.dispose(reason);
......@@ -529,7 +529,6 @@ export class WorkbenchShell extends Disposable {
}
}
registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
// Foreground
......
......@@ -6,7 +6,7 @@
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { INextStorage2Service } from 'vs/platform/storage2/common/storage2';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { INotificationService } from 'vs/platform/notification/common/notification';
......@@ -21,7 +21,7 @@ export class WorkbenchReferencesController extends ReferencesController {
@ICodeEditorService editorService: ICodeEditorService,
@INotificationService notificationService: INotificationService,
@IInstantiationService instantiationService: IInstantiationService,
@IStorageService storageService: IStorageService,
@INextStorage2Service nextStorage2Service: INextStorage2Service,
@IConfigurationService configurationService: IConfigurationService,
) {
super(
......@@ -31,8 +31,8 @@ export class WorkbenchReferencesController extends ReferencesController {
editorService,
notificationService,
instantiationService,
storageService,
configurationService,
nextStorage2Service,
configurationService
);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册