From e3085ebf2660519ef3718eeeaf7a0c5efbb7cfad Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 23 Nov 2017 15:03:14 +0100 Subject: [PATCH] storage => main storage (storage2) --- src/vs/code/electron-main/app.ts | 4 ++-- src/vs/code/electron-main/keyboard.ts | 4 ++-- src/vs/code/electron-main/main.ts | 5 +++-- src/vs/code/electron-main/window.ts | 4 ++-- src/vs/code/electron-main/windows.ts | 6 +++--- .../electron-main/historyMainService.ts | 4 ++-- .../lifecycle/electron-main/lifecycleMain.ts | 4 ++-- src/vs/platform/storage2/common/storage.ts | 18 ++++++++++++++++++ .../node/storageMainService.ts} | 14 ++------------ .../test/node/storage.test.ts | 4 ++-- 10 files changed, 38 insertions(+), 29 deletions(-) create mode 100644 src/vs/platform/storage2/common/storage.ts rename src/vs/platform/{storage/node/storage.ts => storage2/node/storageMainService.ts} (87%) rename src/vs/platform/{storage => storage2}/test/node/storage.test.ts (94%) diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index 71b1557292d..02606df0e1d 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -26,7 +26,7 @@ import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiati import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { ILogService } from 'vs/platform/log/common/log'; -import { IStorageService } from 'vs/platform/storage/node/storage'; +import { IStorageMainService } from 'vs/platform/storage2/common/storage'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IURLService } from 'vs/platform/url/common/url'; @@ -74,7 +74,7 @@ export class CodeApplication { @IEnvironmentService private environmentService: IEnvironmentService, @ILifecycleService private lifecycleService: ILifecycleService, @IConfigurationService configurationService: ConfigurationService, - @IStorageService private storageService: IStorageService, + @IStorageMainService private storageService: IStorageMainService, @IHistoryMainService private historyService: IHistoryMainService ) { this.toDispose = [mainIpcServer, configurationService]; diff --git a/src/vs/code/electron-main/keyboard.ts b/src/vs/code/electron-main/keyboard.ts index fbec79fd50f..f3d443c2d12 100644 --- a/src/vs/code/electron-main/keyboard.ts +++ b/src/vs/code/electron-main/keyboard.ts @@ -7,7 +7,7 @@ import * as nativeKeymap from 'native-keymap'; import { IDisposable } from 'vs/base/common/lifecycle'; -import { IStorageService } from 'vs/platform/storage/node/storage'; +import { IStorageMainService } from 'vs/platform/storage2/common/storage'; import Event, { Emitter, once } from 'vs/base/common/event'; import { ConfigWatcher } from 'vs/base/node/config'; import { IUserFriendlyKeybinding } from 'vs/platform/keybinding/common/keybinding'; @@ -58,7 +58,7 @@ export class KeybindingsResolver { onKeybindingsChanged: Event = this._onKeybindingsChanged.event; constructor( - @IStorageService private storageService: IStorageService, + @IStorageMainService private storageService: IStorageMainService, @IEnvironmentService environmentService: IEnvironmentService, @IWindowsMainService private windowsService: IWindowsMainService, @ILogService private logService: ILogService diff --git a/src/vs/code/electron-main/main.ts b/src/vs/code/electron-main/main.ts index 550ab41f174..fb8ddc3e74c 100644 --- a/src/vs/code/electron-main/main.ts +++ b/src/vs/code/electron-main/main.ts @@ -21,7 +21,8 @@ import { InstantiationService } from 'vs/platform/instantiation/common/instantia import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { ILogService, LogMainService } from 'vs/platform/log/common/log'; -import { IStorageService, StorageService } from 'vs/platform/storage/node/storage'; +import { StorageMainService } from 'vs/platform/storage2/node/storageMainService'; +import { IStorageMainService } from 'vs/platform/storage2/common/storage'; import { IBackupMainService } from 'vs/platform/backup/common/backup'; import { BackupMainService } from 'vs/platform/backup/electron-main/backupMainService'; import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment'; @@ -49,7 +50,7 @@ function createServices(args: ParsedArgs): IInstantiationService { services.set(IWorkspacesMainService, new SyncDescriptor(WorkspacesMainService)); services.set(IHistoryMainService, new SyncDescriptor(HistoryMainService)); services.set(ILifecycleService, new SyncDescriptor(LifecycleService)); - services.set(IStorageService, new SyncDescriptor(StorageService)); + services.set(IStorageMainService, new SyncDescriptor(StorageMainService)); services.set(IConfigurationService, new SyncDescriptor(ConfigurationService)); services.set(IRequestService, new SyncDescriptor(RequestService)); services.set(IURLService, new SyncDescriptor(URLService, args['open-url'])); diff --git a/src/vs/code/electron-main/window.ts b/src/vs/code/electron-main/window.ts index 5374b058e05..1dc414c1b9d 100644 --- a/src/vs/code/electron-main/window.ts +++ b/src/vs/code/electron-main/window.ts @@ -9,7 +9,7 @@ import * as path from 'path'; import * as objects from 'vs/base/common/objects'; import nls = require('vs/nls'); import URI from 'vs/base/common/uri'; -import { IStorageService } from 'vs/platform/storage/node/storage'; +import { IStorageMainService } from 'vs/platform/storage2/common/storage'; import { shell, screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage } from 'electron'; import { TPromise, TValueCallback } from 'vs/base/common/winjs.base'; import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment'; @@ -104,7 +104,7 @@ export class CodeWindow implements ICodeWindow { @ILogService private logService: ILogService, @IEnvironmentService private environmentService: IEnvironmentService, @IConfigurationService private configurationService: IConfigurationService, - @IStorageService private storageService: IStorageService, + @IStorageMainService private storageService: IStorageMainService, @IWorkspacesMainService private workspaceService: IWorkspacesMainService, @IBackupMainService private backupService: IBackupMainService ) { diff --git a/src/vs/code/electron-main/windows.ts b/src/vs/code/electron-main/windows.ts index 14825f0daf4..1a32137e0ae 100644 --- a/src/vs/code/electron-main/windows.ts +++ b/src/vs/code/electron-main/windows.ts @@ -12,7 +12,7 @@ import * as arrays from 'vs/base/common/arrays'; import { assign, mixin, equals } from 'vs/base/common/objects'; import { IBackupMainService } from 'vs/platform/backup/common/backup'; import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment'; -import { IStorageService } from 'vs/platform/storage/node/storage'; +import { IStorageMainService } from 'vs/platform/storage2/common/storage'; import { CodeWindow, IWindowState as ISingleWindowState, defaultWindowState, WindowMode } from 'vs/code/electron-main/window'; import { ipcMain as ipc, screen, BrowserWindow, dialog, systemPreferences, app } from 'electron'; import { IPathWithLineAndColumn, parseLineAndColumnAware } from 'vs/code/node/paths'; @@ -139,7 +139,7 @@ export class WindowsManager implements IWindowsMainService { constructor( @ILogService private logService: ILogService, - @IStorageService private storageService: IStorageService, + @IStorageMainService private storageService: IStorageMainService, @IEnvironmentService private environmentService: IEnvironmentService, @ILifecycleService private lifecycleService: ILifecycleService, @IBackupMainService private backupService: IBackupMainService, @@ -1587,7 +1587,7 @@ class FileDialog { constructor( private environmentService: IEnvironmentService, private telemetryService: ITelemetryService, - private storageService: IStorageService, + private storageService: IStorageMainService, private windowsMainService: IWindowsMainService ) { } diff --git a/src/vs/platform/history/electron-main/historyMainService.ts b/src/vs/platform/history/electron-main/historyMainService.ts index 069fa2c4733..c991973d883 100644 --- a/src/vs/platform/history/electron-main/historyMainService.ts +++ b/src/vs/platform/history/electron-main/historyMainService.ts @@ -9,7 +9,7 @@ import * as path from 'path'; import * as nls from 'vs/nls'; import * as arrays from 'vs/base/common/arrays'; import { trim } from 'vs/base/common/strings'; -import { IStorageService } from 'vs/platform/storage/node/storage'; +import { IStorageMainService } from 'vs/platform/storage2/common/storage'; import { app } from 'electron'; import { ILogService } from 'vs/platform/log/common/log'; import { getPathLabel, getBaseLabel } from 'vs/base/common/labels'; @@ -41,7 +41,7 @@ export class HistoryMainService implements IHistoryMainService { private macOSRecentDocumentsUpdater: RunOnceScheduler; constructor( - @IStorageService private storageService: IStorageService, + @IStorageMainService private storageService: IStorageMainService, @ILogService private logService: ILogService, @IWorkspacesMainService private workspacesService: IWorkspacesMainService, @IEnvironmentService private environmentService: IEnvironmentService, diff --git a/src/vs/platform/lifecycle/electron-main/lifecycleMain.ts b/src/vs/platform/lifecycle/electron-main/lifecycleMain.ts index d9b3be30cfd..0239c0d8447 100644 --- a/src/vs/platform/lifecycle/electron-main/lifecycleMain.ts +++ b/src/vs/platform/lifecycle/electron-main/lifecycleMain.ts @@ -8,7 +8,7 @@ import { ipcMain as ipc, app } from 'electron'; import { TPromise, TValueCallback } from 'vs/base/common/winjs.base'; import { ILogService } from 'vs/platform/log/common/log'; -import { IStorageService } from 'vs/platform/storage/node/storage'; +import { IStorageMainService } from 'vs/platform/storage2/common/storage'; import Event, { Emitter } from 'vs/base/common/event'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { ICodeWindow } from 'vs/platform/windows/electron-main/windows'; @@ -94,7 +94,7 @@ export class LifecycleService implements ILifecycleService { constructor( @ILogService private logService: ILogService, - @IStorageService private storageService: IStorageService + @IStorageMainService private storageService: IStorageMainService ) { this.windowToCloseRequest = Object.create(null); this.quitRequested = false; diff --git a/src/vs/platform/storage2/common/storage.ts b/src/vs/platform/storage2/common/storage.ts new file mode 100644 index 00000000000..73e8214ef84 --- /dev/null +++ b/src/vs/platform/storage2/common/storage.ts @@ -0,0 +1,18 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +'use strict'; + +import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; + +export const IStorageMainService = createDecorator('storageMainService'); + +export interface IStorageMainService { + _serviceBrand: any; + + getItem(key: string, defaultValue?: T): T; + setItem(key: string, data: any): void; + removeItem(key: string): void; +} \ No newline at end of file diff --git a/src/vs/platform/storage/node/storage.ts b/src/vs/platform/storage2/node/storageMainService.ts similarity index 87% rename from src/vs/platform/storage/node/storage.ts rename to src/vs/platform/storage2/node/storageMainService.ts index e8e8346c970..36aadecad41 100644 --- a/src/vs/platform/storage/node/storage.ts +++ b/src/vs/platform/storage2/node/storageMainService.ts @@ -8,19 +8,9 @@ import * as path from 'path'; import * as fs from 'original-fs'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { writeFileAndFlushSync } from 'vs/base/node/extfs'; import { isUndefined, isUndefinedOrNull } from 'vs/base/common/types'; - -export const IStorageService = createDecorator('storageService'); - -export interface IStorageService { - _serviceBrand: any; - - getItem(key: string, defaultValue?: T): T; - setItem(key: string, data: any): void; - removeItem(key: string): void; -} +import { IStorageMainService } from 'vs/platform/storage2/common/storage'; export class FileStorage { @@ -97,7 +87,7 @@ export class FileStorage { } } -export class StorageService implements IStorageService { +export class StorageMainService implements IStorageMainService { _serviceBrand: any; diff --git a/src/vs/platform/storage/test/node/storage.test.ts b/src/vs/platform/storage2/test/node/storage.test.ts similarity index 94% rename from src/vs/platform/storage/test/node/storage.test.ts rename to src/vs/platform/storage2/test/node/storage.test.ts index 99f23712f66..3ec0dba4d22 100644 --- a/src/vs/platform/storage/test/node/storage.test.ts +++ b/src/vs/platform/storage2/test/node/storage.test.ts @@ -11,9 +11,9 @@ import path = require('path'); import extfs = require('vs/base/node/extfs'); import { getRandomTestPath } from 'vs/workbench/test/workbenchTestServices'; import { writeFileAndFlushSync, mkdirp } from 'vs/base/node/extfs'; -import { FileStorage } from 'vs/platform/storage/node/storage'; +import { FileStorage } from 'vs/platform/storage2/node/storageMainService'; -suite('StorageService', () => { +suite('StorageMainService', () => { const parentDir = getRandomTestPath(os.tmpdir(), 'vsctests', 'storageservice'); const storageFile = path.join(parentDir, 'storage.json');