Skip to content

Commit a97e98b

Browse files
committed
💄
1 parent f6f37aa commit a97e98b

9 files changed

Lines changed: 64 additions & 49 deletions

File tree

‎src/vs/base/node/storage.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class SQLiteStorageLogger {
213213
private logError: boolean;
214214

215215
constructor(private options?: ISQLiteStorageLoggingOptions) {
216-
this.logInfo = this.verbose && !!options.infoLogger;
216+
this.logInfo = this.verbose && options && !!options.infoLogger;
217217
this.logError = options && !!options.errorLogger;
218218
}
219219

‎src/vs/platform/lifecycle/common/lifecycle.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const ILifecycleService = createDecorator<ILifecycleService>('lifecycleSe
1616
* resolves to a boolean. Returning a promise is useful in cases of long running operations
1717
* on shutdown.
1818
*
19-
* Note: It is absolutely important to avoid long running promises on this call. Please try hard
19+
* Note: It is absolutely important to avoid long running promises if possible. Please try hard
2020
* to return a boolean directly. Returning a promise has quite an impact on the shutdown sequence!
2121
*/
2222
export interface WillShutdownEvent {
@@ -38,7 +38,7 @@ export interface WillShutdownEvent {
3838
* by providing a promise from the join method. Returning a promise is useful in cases of long
3939
* running operations on shutdown.
4040
*
41-
* Note: It is absolutely important to avoid long running promises on this call. Please try hard
41+
* Note: It is absolutely important to avoid long running promises if possible. Please try hard
4242
* to return a boolean directly. Returning a promise has quite an impact on the shutdown sequence!
4343
*/
4444
export interface ShutdownEvent {
@@ -141,11 +141,11 @@ export interface ILifecycleService {
141141

142142
export const NullLifecycleService: ILifecycleService = {
143143
_serviceBrand: null,
144+
onWillShutdown: Event.None,
145+
onShutdown: Event.None,
144146
phase: LifecyclePhase.Running,
145-
when() { return Promise.resolve(); },
146147
startupKind: StartupKind.NewWindow,
147-
onWillShutdown: Event.None,
148-
onShutdown: Event.None
148+
when() { return Promise.resolve(); }
149149
};
150150

151151
// Shared veto handling across main and renderer

‎src/vs/platform/lifecycle/electron-browser/lifecycleService.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class LifecycleService extends Disposable implements ILifecycleService {
3535
private _phase: LifecyclePhase = LifecyclePhase.Starting;
3636
get phase(): LifecyclePhase { return this._phase; }
3737

38-
private _phaseWhen = new Map<LifecyclePhase, Barrier>();
38+
private phaseWhen = new Map<LifecyclePhase, Barrier>();
3939

4040
constructor(
4141
@INotificationService private notificationService: INotificationService,
@@ -150,9 +150,9 @@ export class LifecycleService extends Disposable implements ILifecycleService {
150150
this._phase = value;
151151
mark(`LifecyclePhase/${LifecyclePhaseToString(value)}`);
152152

153-
if (this._phaseWhen.has(this._phase)) {
154-
this._phaseWhen.get(this._phase).open();
155-
this._phaseWhen.delete(this._phase);
153+
if (this.phaseWhen.has(this._phase)) {
154+
this.phaseWhen.get(this._phase).open();
155+
this.phaseWhen.delete(this._phase);
156156
}
157157
}
158158

@@ -161,10 +161,10 @@ export class LifecycleService extends Disposable implements ILifecycleService {
161161
return Promise.resolve();
162162
}
163163

164-
let barrier = this._phaseWhen.get(phase);
164+
let barrier = this.phaseWhen.get(phase);
165165
if (!barrier) {
166166
barrier = new Barrier();
167-
this._phaseWhen.set(phase, barrier);
167+
this.phaseWhen.set(phase, barrier);
168168
}
169169

170170
return barrier.wait();

‎src/vs/platform/lifecycle/electron-main/lifecycleMain.ts‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,28 @@ export interface ILifecycleService {
6969
*/
7070
onBeforeWindowUnload: Event<IWindowUnloadEvent>;
7171

72-
ready(): void;
73-
registerWindow(window: ICodeWindow): void;
74-
72+
/**
73+
* Close a window for the provided reason. Shutdown handlers are triggered.
74+
*/
7575
unload(window: ICodeWindow, reason: UnloadReason): TPromise<boolean /* veto */>;
7676

77+
/**
78+
* Restart the application with optional arguments (CLI). Shutdown handlers are triggered.
79+
*/
7780
relaunch(options?: { addArgs?: string[], removeArgs?: string[] }): void;
7881

82+
/**
83+
* Shutdown the application normally. Shutdown handlers are triggered.
84+
*/
7985
quit(fromUpdate?: boolean): TPromise<boolean /* veto */>;
8086

87+
/**
88+
* Forcefully shutdown the application. No shutdown handlers are triggered.
89+
*/
8190
kill(code?: number): void;
91+
92+
ready(): void;
93+
registerWindow(window: ICodeWindow): void;
8294
}
8395

8496
export class LifecycleService extends Disposable implements ILifecycleService {

‎src/vs/platform/storage2/common/storage2.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,47 +62,47 @@ export interface INextWorkspaceStorageService {
6262
* Retrieve an element stored with the given key from storage. Use
6363
* the provided defaultValue if the element is null or undefined.
6464
*
65-
* The optional scope argument allows to define the scope of the storage
65+
* The scope argument allows to define the scope of the storage
6666
* operation to either the current workspace only or all workspaces.
6767
*/
68-
get(key: string, scope?: StorageScope, fallbackValue?: string): string;
68+
get(key: string, scope: StorageScope, fallbackValue?: string): string;
6969

7070
/**
7171
* Retrieve an element stored with the given key from storage. Use
7272
* the provided defaultValue if the element is null or undefined. The element
7373
* will be converted to a boolean.
7474
*
75-
* The optional scope argument allows to define the scope of the storage
75+
* The scope argument allows to define the scope of the storage
7676
* operation to either the current workspace only or all workspaces.
7777
*/
78-
getBoolean(key: string, scope?: StorageScope, fallbackValue?: boolean): boolean;
78+
getBoolean(key: string, scope: StorageScope, fallbackValue?: boolean): boolean;
7979

8080
/**
8181
* Retrieve an element stored with the given key from storage. Use
8282
* the provided defaultValue if the element is null or undefined. The element
8383
* will be converted to a number using parseInt with a base of 10.
8484
*
85-
* The optional scope argument allows to define the scope of the storage
85+
* The scope argument allows to define the scope of the storage
8686
* operation to either the current workspace only or all workspaces.
8787
*/
88-
getInteger(key: string, scope?: StorageScope, fallbackValue?: number): number;
88+
getInteger(key: string, scope: StorageScope, fallbackValue?: number): number;
8989

9090
/**
9191
* Store a string value under the given key to storage. The value will
9292
* be converted to a string.
9393
*
94-
* The optional scope argument allows to define the scope of the storage
94+
* The scope argument allows to define the scope of the storage
9595
* operation to either the current workspace only or all workspaces.
9696
*/
97-
set(key: string, value: any, scope?: StorageScope): Promise<void>;
97+
set(key: string, value: any, scope: StorageScope): Promise<void>;
9898

9999
/**
100100
* Delete an element stored under the provided key from storage.
101101
*
102-
* The optional scope argument allows to define the scope of the storage
102+
* The scope argument allows to define the scope of the storage
103103
* operation to either the current workspace only or all workspaces.
104104
*/
105-
delete(key: string, scope?: StorageScope): Promise<void>;
105+
delete(key: string, scope: StorageScope): Promise<void>;
106106
}
107107

108108
export const enum StorageScope {

src/vs/platform/storage2/node/nextStorageServiceImpl.ts renamed to src/vs/platform/storage2/node/nextStorageService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ enum StorageState {
1818
Closed
1919
}
2020

21-
export class NextStorageServiceImpl extends Disposable implements INextStorageService {
21+
export class NextStorageService extends Disposable implements INextStorageService {
2222
_serviceBrand: any;
2323

2424
private static readonly FLUSH_DELAY = 10;
@@ -52,7 +52,7 @@ export class NextStorageServiceImpl extends Disposable implements INextStorageSe
5252
}
5353
});
5454

55-
this.pendingScheduler = new RunOnceScheduler(() => this.flushPending(), NextStorageServiceImpl.FLUSH_DELAY);
55+
this.pendingScheduler = new RunOnceScheduler(() => this.flushPending(), NextStorageService.FLUSH_DELAY);
5656
}
5757

5858
init(): Promise<void> {

src/vs/platform/storage2/node/nextWorkspaceStorageServiceImpl.ts renamed to src/vs/platform/storage2/node/nextWorkspaceStorageService.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import { Event, Emitter } from 'vs/base/common/event';
88
import { ILogService } from 'vs/platform/log/common/log';
99
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
1010
import { INextStorageService, IWorkspaceStorageChangeEvent, INextWorkspaceStorageService, StorageScope } from 'vs/platform/storage2/common/storage2';
11-
import { NextStorageServiceImpl } from 'vs/platform/storage2/node/nextStorageServiceImpl';
11+
import { NextStorageService } from 'vs/platform/storage2/node/nextStorageService';
1212

13-
export class NextWorkspaceStorageServiceImpl extends Disposable implements INextWorkspaceStorageService {
13+
export class NextWorkspaceStorageService extends Disposable implements INextWorkspaceStorageService {
1414
_serviceBrand: any;
1515

1616
private _onDidChangeStorage: Emitter<IWorkspaceStorageChangeEvent> = this._register(new Emitter<IWorkspaceStorageChangeEvent>());
1717
get onDidChangeStorage(): Event<IWorkspaceStorageChangeEvent> { return this._onDidChangeStorage.event; }
1818

19-
private globalStorage: NextStorageServiceImpl;
20-
private workspaceStorage: NextStorageServiceImpl;
19+
private globalStorage: NextStorageService;
20+
private workspaceStorage: NextStorageService;
2121

2222
constructor(
2323
workspaceDBPath: string,
@@ -26,8 +26,8 @@ export class NextWorkspaceStorageServiceImpl extends Disposable implements INext
2626
) {
2727
super();
2828

29-
this.globalStorage = new NextStorageServiceImpl(':memory:', logService, environmentService); // TODO proxy from main side!
30-
this.workspaceStorage = new NextStorageServiceImpl(workspaceDBPath, logService, environmentService);
29+
this.globalStorage = new NextStorageService(':memory:', logService, environmentService);
30+
this.workspaceStorage = new NextStorageService(workspaceDBPath, logService, environmentService);
3131

3232
this.registerListeners();
3333
}
@@ -45,28 +45,31 @@ export class NextWorkspaceStorageServiceImpl extends Disposable implements INext
4545
return Promise.all([this.globalStorage.init(), this.workspaceStorage.init()]).then(() => void 0);
4646
}
4747

48-
get(key: string, scope: StorageScope = StorageScope.GLOBAL, fallbackValue?: any): string {
48+
get(key: string, scope: StorageScope, fallbackValue?: any): string {
4949
return this.getStorage(scope).get(key, fallbackValue);
5050
}
5151

52-
getBoolean(key: string, scope: StorageScope = StorageScope.GLOBAL, fallbackValue?: boolean): boolean {
52+
getBoolean(key: string, scope: StorageScope, fallbackValue?: boolean): boolean {
5353
return this.getStorage(scope).getBoolean(key, fallbackValue);
5454
}
5555

56-
getInteger(key: string, scope: StorageScope = StorageScope.GLOBAL, fallbackValue?: number): number {
56+
getInteger(key: string, scope: StorageScope, fallbackValue?: number): number {
5757
return this.getStorage(scope).getInteger(key, fallbackValue);
5858
}
5959

60-
set(key: string, value: any, scope: StorageScope = StorageScope.GLOBAL): Promise<void> {
60+
set(key: string, value: any, scope: StorageScope): Promise<void> {
6161
return this.getStorage(scope).set(key, value);
6262
}
6363

64-
delete(key: string, scope: StorageScope = StorageScope.GLOBAL): Promise<void> {
64+
delete(key: string, scope: StorageScope): Promise<void> {
6565
return this.getStorage(scope).delete(key);
6666
}
6767

6868
close(): Promise<void> {
69-
return this.workspaceStorage.close();
69+
return Promise.all([
70+
this.globalStorage.close(),
71+
this.workspaceStorage.close()
72+
]).then(() => void 0);
7073
}
7174

7275
private getStorage(scope: StorageScope): INextStorageService {

‎src/vs/platform/storage2/test/node/nextStorageService.test.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { NullLogService } from 'vs/platform/log/common/log';
77
import { TestEnvironmentService } from 'vs/workbench/test/workbenchTestServices';
8-
import { NextStorageServiceImpl } from 'vs/platform/storage2/node/nextStorageServiceImpl';
8+
import { NextStorageService } from 'vs/platform/storage2/node/nextStorageService';
99
import { generateUuid } from 'vs/base/common/uuid';
1010
import { join } from 'path';
1111
import { tmpdir } from 'os';
@@ -33,7 +33,7 @@ suite('Workbench NextStorageService', () => {
3333
const storageDir = uniqueStorageDir();
3434
await mkdirp(storageDir);
3535

36-
const storageService = new NextStorageServiceImpl(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
36+
const storageService = new NextStorageService(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
3737

3838
await storageService.init();
3939

@@ -90,7 +90,7 @@ suite('Workbench NextStorageService', () => {
9090
const storageDir = uniqueStorageDir();
9191
await mkdirp(storageDir);
9292

93-
let storageService = new NextStorageServiceImpl(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
93+
let storageService = new NextStorageService(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
9494
await storageService.init();
9595

9696
const set1Promise = storageService.set('foo', 'bar');
@@ -106,15 +106,15 @@ suite('Workbench NextStorageService', () => {
106106

107107
equal(setPromiseResolved, true);
108108

109-
storageService = new NextStorageServiceImpl(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
109+
storageService = new NextStorageService(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
110110
await storageService.init();
111111

112112
equal(storageService.get('foo'), 'bar');
113113
equal(storageService.get('bar'), 'foo');
114114

115115
await storageService.close();
116116

117-
storageService = new NextStorageServiceImpl(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
117+
storageService = new NextStorageService(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
118118
await storageService.init();
119119

120120
const delete1Promise = storageService.delete('foo');
@@ -130,7 +130,7 @@ suite('Workbench NextStorageService', () => {
130130

131131
equal(deletePromiseResolved, true);
132132

133-
storageService = new NextStorageServiceImpl(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
133+
storageService = new NextStorageService(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
134134
await storageService.init();
135135

136136
ok(!storageService.get('foo'));
@@ -144,7 +144,7 @@ suite('Workbench NextStorageService', () => {
144144
const storageDir = uniqueStorageDir();
145145
await mkdirp(storageDir);
146146

147-
let storageService = new NextStorageServiceImpl(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
147+
let storageService = new NextStorageService(join(storageDir, 'storage.db'), new NullLogService(), TestEnvironmentService);
148148
await storageService.init();
149149

150150
const set1Promise = storageService.set('foo', 'bar1');

‎src/vs/workbench/electron-browser/main.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { IWorkspacesService, ISingleFolderWorkspaceIdentifier } from 'vs/platfor
3636
import { createSpdLogService } from 'vs/platform/log/node/spdlogService';
3737
import * as fs from 'fs';
3838
import { ConsoleLogService, MultiplexLogService, ILogService } from 'vs/platform/log/common/log';
39-
import { NextWorkspaceStorageServiceImpl } from 'vs/platform/storage2/node/nextWorkspaceStorageServiceImpl';
39+
import { NextWorkspaceStorageService } from 'vs/platform/storage2/node/nextWorkspaceStorageService';
4040
import { IssueChannelClient } from 'vs/platform/issue/node/issueIpc';
4141
import { IIssueService } from 'vs/platform/issue/common/issue';
4242
import { LogLevelSetterChannelClient, FollowerLogService } from 'vs/platform/log/node/logIpc';
@@ -166,8 +166,8 @@ function validateFolderUri(folderUri: ISingleFolderWorkspaceIdentifier, verbose:
166166
});
167167
}
168168

169-
function createNextWorkspaceStorageService(environmentService: IEnvironmentService, logService: ILogService): Promise<NextWorkspaceStorageServiceImpl> {
170-
const nextStorageService = new NextWorkspaceStorageServiceImpl(':memory:', logService, environmentService);
169+
function createNextWorkspaceStorageService(environmentService: IEnvironmentService, logService: ILogService): Promise<NextWorkspaceStorageService> {
170+
const nextStorageService = new NextWorkspaceStorageService(':memory:', logService, environmentService);
171171

172172
return nextStorageService.init().then(() => nextStorageService);
173173
}

0 commit comments

Comments
 (0)