Initial VS Code 1.19 source merge (#571)

* Initial 1.19 xcopy

* Fix yarn build

* Fix numerous build breaks

* Next batch of build break fixes

* More build break fixes

* Runtime breaks

* Additional post merge fixes

* Fix windows setup file

* Fix test failures.

* Update license header blocks to refer to source eula
This commit is contained in:
Karl Burtram
2018-01-28 23:37:17 -08:00
committed by GitHub
parent 9a1ac20710
commit 251ae01c3e
8009 changed files with 93378 additions and 35634 deletions

View File

@@ -13,7 +13,6 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
export interface IStorage {
length: number;
key(index: number): string;
clear(): void;
setItem(key: string, value: any): void;
getItem(key: string): string;
removeItem(key: string): void;
@@ -23,11 +22,11 @@ export class StorageService implements IStorageService {
public _serviceBrand: any;
public static COMMON_PREFIX = 'storage://';
public static GLOBAL_PREFIX = `${StorageService.COMMON_PREFIX}global/`;
public static WORKSPACE_PREFIX = `${StorageService.COMMON_PREFIX}workspace/`;
public static WORKSPACE_IDENTIFIER = 'workspaceidentifier';
public static NO_WORKSPACE_IDENTIFIER = '__$noWorkspace__';
public static readonly COMMON_PREFIX = 'storage://';
public static readonly GLOBAL_PREFIX = `${StorageService.COMMON_PREFIX}global/`;
public static readonly WORKSPACE_PREFIX = `${StorageService.COMMON_PREFIX}workspace/`;
public static readonly WORKSPACE_IDENTIFIER = 'workspaceidentifier';
public static readonly NO_WORKSPACE_IDENTIFIER = '__$noWorkspace__';
private _workspaceStorage: IStorage;
private _globalStorage: IStorage;
@@ -122,11 +121,6 @@ export class StorageService implements IStorageService {
}
}
public clear(): void {
this._globalStorage.clear();
this._workspaceStorage.clear();
}
public store(key: string, value: any, scope = StorageScope.GLOBAL): void {
const storage = (scope === StorageScope.GLOBAL) ? this._globalStorage : this._workspaceStorage;
@@ -217,10 +211,6 @@ export class InMemoryLocalStorage implements IStorage {
return null;
}
public clear(): void {
this.store = {};
}
public setItem(key: string, value: any): void {
this.store[key] = value.toString();
}

View File

@@ -1,94 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
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';
export const IStorageService = createDecorator<IStorageService>('storageService');
export interface IStorageService {
_serviceBrand: any;
getItem<T>(key: string, defaultValue?: T): T;
setItem(key: string, data: any): void;
removeItem(key: string): void;
}
export class StorageService implements IStorageService {
_serviceBrand: any;
private dbPath: string;
private database: any = null;
constructor( @IEnvironmentService private environmentService: IEnvironmentService) {
this.dbPath = path.join(environmentService.userDataPath, 'storage.json');
}
public getItem<T>(key: string, defaultValue?: T): T {
if (!this.database) {
this.database = this.load();
}
const res = this.database[key];
if (typeof res === 'undefined') {
return defaultValue;
}
return this.database[key];
}
public setItem(key: string, data: any): void {
if (!this.database) {
this.database = this.load();
}
// Shortcut for primitives that did not change
if (typeof data === 'string' || typeof data === 'number' || typeof data === 'boolean') {
if (this.database[key] === data) {
return;
}
}
this.database[key] = data;
this.save();
}
public removeItem(key: string): void {
if (!this.database) {
this.database = this.load();
}
if (this.database[key]) {
delete this.database[key];
this.save();
}
}
private load(): any {
try {
return JSON.parse(fs.readFileSync(this.dbPath).toString()); // invalid JSON or permission issue can happen here
} catch (error) {
if (this.environmentService.verbose) {
console.error(error);
}
return {};
}
}
private save(): void {
try {
fs.writeFileSync(this.dbPath, JSON.stringify(this.database, null, 4)); // permission issue can happen here
} catch (error) {
if (this.environmentService.verbose) {
console.error(error);
}
}
}
}

View File

@@ -13,25 +13,7 @@ import { StorageScope } from 'vs/platform/storage/common/storage';
import { startsWith } from 'vs/base/common/strings';
suite('Storage Migration', () => {
//slet storage = window.localStorage;
setup(() => {
//storage.clear();
});
teardown(() => {
//storage.clear();
});
test('Parse Storage (Global)', () => {
// const service = createService();
// const parsed = parseStorage(storage);
// assert.equal(parsed.global.size, 4);
// assert.equal(parsed.global.get('key1'), service.get('key1'));
// assert.equal(parsed.global.get('key2.something'), service.get('key2.something'));
// assert.equal(parsed.global.get('key3/special'), service.get('key3/special'));
// assert.equal(parsed.global.get('key4 space'), service.get('key4 space'));
});
});