Skip to content

Commit 7e9546a

Browse files
author
Benjamin Pasero
committed
sqlite - memento conversion
1 parent d206715 commit 7e9546a

70 files changed

Lines changed: 428 additions & 536 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/vs/editor/standalone/browser/standaloneServices.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { MarkerService } from 'vs/platform/markers/common/markerService';
1818
import { IMarkerService } from 'vs/platform/markers/common/markers';
1919
import { IProgressService } from 'vs/platform/progress/common/progress';
2020
import { INextStorage2Service, NullNextStorage2Service } from 'vs/platform/storage2/common/storage2';
21-
import { IStorageService, NullStorageService } from 'vs/platform/storage/common/storage';
2221
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
2322
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
2423
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
@@ -147,10 +146,7 @@ export module StaticServices {
147146

148147
export const nextStorage2Service = define(INextStorage2Service, () => NullNextStorage2Service);
149148

150-
export const storageService = define(IStorageService, () => NullStorageService);
151-
152149
export const logService = define(ILogService, () => new NullLogService());
153-
154150
}
155151

156152
export class DynamicStandaloneServices extends Disposable {

src/vs/workbench/api/browser/viewsContainersExtensionPoint.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
1515
import { IPartService } from 'vs/workbench/services/part/common/partService';
1616
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1717
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
18-
import { IStorageService } from 'vs/platform/storage/common/storage';
18+
import { INextStorage2Service } from 'vs/platform/storage2/common/storage2';
1919
import { IThemeService } from 'vs/platform/theme/common/themeService';
2020
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
2121
import { IExtensionService, IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
@@ -165,14 +165,14 @@ class ViewsContainersExtensionHandler implements IWorkbenchContribution {
165165
@IPartService partService: IPartService,
166166
@ITelemetryService telemetryService: ITelemetryService,
167167
@IWorkspaceContextService contextService: IWorkspaceContextService,
168-
@IStorageService storageService: IStorageService,
168+
@INextStorage2Service nextStorage2Service: INextStorage2Service,
169169
@IEditorService editorService: IEditorService,
170170
@IInstantiationService instantiationService: IInstantiationService,
171171
@IThemeService themeService: IThemeService,
172172
@IContextMenuService contextMenuService: IContextMenuService,
173173
@IExtensionService extensionService: IExtensionService
174174
) {
175-
super(id, `${id}.state`, true, configurationService, partService, telemetryService, storageService, instantiationService, themeService, contextMenuService, extensionService, contextService);
175+
super(id, `${id}.state`, true, configurationService, partService, telemetryService, nextStorage2Service, instantiationService, themeService, contextMenuService, extensionService, contextService);
176176
}
177177
}
178178
const viewletDescriptor = new ViewletDescriptor(

src/vs/workbench/browser/composite.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ import { Event, Emitter } from 'vs/base/common/event';
1212
import { IThemeService } from 'vs/platform/theme/common/themeService';
1313
import { IConstructorSignature0, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1414
import { trackFocus, Dimension } from 'vs/base/browser/dom';
15+
import { INextStorage2Service } from 'vs/platform/storage2/common/storage2';
16+
import { Disposable } from 'vs/base/common/lifecycle';
1517

1618
/**
1719
* Composites are layed out in the sidebar and panel part of the workbench. At a time only one composite
1820
* can be open in the sidebar, and only one composite can be open in the panel.
21+
*
1922
* Each composite has a minimized representation that is good enough to provide some
2023
* information about the state of the composite data.
24+
*
2125
* The workbench will keep a composite alive after it has been created and show/hide it based on
2226
* user interaction. The lifecycle of a composite goes in the order create(), setVisible(true|false),
2327
* layout(), focus(), dispose(). During use of the workbench, a composite will often receive a setVisible,
@@ -33,6 +37,7 @@ export abstract class Composite extends Component implements IComposite {
3337
if (!this._onDidFocus) {
3438
this._registerFocusTrackEvents();
3539
}
40+
3641
return this._onDidFocus.event;
3742
}
3843

@@ -41,6 +46,7 @@ export abstract class Composite extends Component implements IComposite {
4146
if (!this._onDidBlur) {
4247
this._registerFocusTrackEvents();
4348
}
49+
4450
return this._onDidBlur.event;
4551
}
4652

@@ -64,9 +70,10 @@ export abstract class Composite extends Component implements IComposite {
6470
constructor(
6571
id: string,
6672
private _telemetryService: ITelemetryService,
67-
themeService: IThemeService
73+
themeService: IThemeService,
74+
nextStorage2Service: INextStorage2Service
6875
) {
69-
super(id, themeService);
76+
super(id, themeService, nextStorage2Service);
7077

7178
this.visible = false;
7279
}
@@ -232,9 +239,9 @@ export abstract class CompositeDescriptor<T extends Composite> {
232239
}
233240
}
234241

235-
export abstract class CompositeRegistry<T extends Composite> {
242+
export abstract class CompositeRegistry<T extends Composite> extends Disposable {
236243

237-
private readonly _onDidRegister: Emitter<CompositeDescriptor<T>> = new Emitter<CompositeDescriptor<T>>();
244+
private readonly _onDidRegister: Emitter<CompositeDescriptor<T>> = this._register(new Emitter<CompositeDescriptor<T>>());
238245
get onDidRegister(): Event<CompositeDescriptor<T>> { return this._onDidRegister.event; }
239246

240247
private composites: CompositeDescriptor<T>[] = [];

src/vs/workbench/browser/part.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ import 'vs/css!./media/part';
77
import { Component } from 'vs/workbench/common/component';
88
import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService';
99
import { Dimension, size } from 'vs/base/browser/dom';
10+
import { INextStorage2Service } from 'vs/platform/storage2/common/storage2';
1011

1112
export interface IPartOptions {
1213
hasTitle?: boolean;
1314
borderWidth?: () => number;
1415
}
1516

1617
/**
17-
* Parts are layed out in the workbench and have their own layout that arranges an optional title
18-
* and mandatory content area to show content.
18+
* Parts are layed out in the workbench and have their own layout that
19+
* arranges an optional title and mandatory content area to show content.
1920
*/
2021
export abstract class Part extends Component {
2122
private parent: HTMLElement;
@@ -26,9 +27,10 @@ export abstract class Part extends Component {
2627
constructor(
2728
id: string,
2829
private options: IPartOptions,
29-
themeService: IThemeService
30+
themeService: IThemeService,
31+
nextStorage2Service: INextStorage2Service
3032
) {
31-
super(id, themeService);
33+
super(id, themeService, nextStorage2Service);
3234
}
3335

3436
protected onThemeChange(theme: ITheme): void {
@@ -98,10 +100,10 @@ export abstract class Part extends Component {
98100
}
99101
}
100102

101-
const TITLE_HEIGHT = 35;
102-
103103
export class PartLayout {
104104

105+
private static readonly TITLE_HEIGHT = 35;
106+
105107
constructor(container: HTMLElement, private options: IPartOptions, titleArea: HTMLElement, private contentArea: HTMLElement) { }
106108

107109
layout(dimension: Dimension): Dimension[] {
@@ -113,7 +115,7 @@ export class PartLayout {
113115
// Title Size: Width (Fill), Height (Variable)
114116
let titleSize: Dimension;
115117
if (this.options && this.options.hasTitle) {
116-
titleSize = new Dimension(width, Math.min(height, TITLE_HEIGHT));
118+
titleSize = new Dimension(width, Math.min(height, PartLayout.TITLE_HEIGHT));
117119
} else {
118120
titleSize = new Dimension(0, 0);
119121
}

src/vs/workbench/browser/parts/activitybar/activitybarPart.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class ActivitybarPart extends Part {
6161
@INextStorage2Service private nextStorage2Service: INextStorage2Service,
6262
@IExtensionService private extensionService: IExtensionService
6363
) {
64-
super(id, { hasTitle: false }, themeService);
64+
super(id, { hasTitle: false }, themeService, nextStorage2Service);
6565

6666
this.compositeBar = this._register(this.instantiationService.createInstance(CompositeBar, {
6767
icon: true,
@@ -110,11 +110,6 @@ export class ActivitybarPart extends Part {
110110
}));
111111

112112
this._register(this.extensionService.onDidRegisterExtensions(() => this.onDidRegisterExtensions()));
113-
114-
this._register(this.nextStorage2Service.onWillClose(() => {
115-
const state = this.viewletService.getAllViewlets().map(({ id, iconUrl }) => ({ id, iconUrl }));
116-
this.nextStorage2Service.set(ActivitybarPart.PLACEHOLDER_VIEWLETS, JSON.stringify(state), StorageScope.GLOBAL);
117-
}));
118113
}
119114

120115
private onDidRegisterExtensions(): void {
@@ -336,4 +331,11 @@ export class ActivitybarPart extends Part {
336331

337332
return sizes;
338333
}
334+
335+
protected saveState(): void {
336+
const state = this.viewletService.getAllViewlets().map(({ id, iconUrl }) => ({ id, iconUrl }));
337+
this.nextStorage2Service.set(ActivitybarPart.PLACEHOLDER_VIEWLETS, JSON.stringify(state), StorageScope.GLOBAL);
338+
339+
super.saveState();
340+
}
339341
}

src/vs/workbench/browser/parts/compositePart.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
8585
id: string,
8686
options: IPartOptions
8787
) {
88-
super(id, options, themeService);
88+
super(id, options, themeService, nextStorage2Service);
8989

9090
this.instantiatedCompositeListeners = [];
9191
this.mapCompositeToCompositeContainer = {};
@@ -495,12 +495,6 @@ export abstract class CompositePart<T extends Composite> extends Part {
495495
return sizes;
496496
}
497497

498-
shutdown(): void {
499-
this.instantiatedComposites.forEach(i => i.shutdown());
500-
501-
super.shutdown();
502-
}
503-
504498
dispose(): void {
505499
this.mapCompositeToCompositeContainer = null;
506500
this.mapProgressServiceToComposite = null;

src/vs/workbench/browser/parts/editor/baseEditor.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1010
import { IThemeService } from 'vs/platform/theme/common/themeService';
1111
import { CancellationToken } from 'vs/base/common/cancellation';
1212
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
13-
import { IStorageService } from 'vs/platform/storage/common/storage';
13+
import { INextStorage2Service, StorageScope } from 'vs/platform/storage2/common/storage2';
1414
import { LRUCache } from 'vs/base/common/map';
1515
import { URI } from 'vs/base/common/uri';
1616
import { once, Event } from 'vs/base/common/event';
1717
import { isEmptyObject } from 'vs/base/common/types';
1818
import { DEFAULT_EDITOR_MIN_DIMENSIONS, DEFAULT_EDITOR_MAX_DIMENSIONS } from 'vs/workbench/browser/parts/editor/editor';
19-
import { Scope } from 'vs/workbench/common/memento';
2019

2120
/**
2221
* The base class of editors in the workbench. Editors register themselves for specific editor inputs.
@@ -50,9 +49,10 @@ export abstract class BaseEditor extends Panel implements IEditor {
5049
constructor(
5150
id: string,
5251
telemetryService: ITelemetryService,
53-
themeService: IThemeService
52+
themeService: IThemeService,
53+
nextStorage2Service: INextStorage2Service
5454
) {
55-
super(id, telemetryService, themeService);
55+
super(id, telemetryService, themeService, nextStorage2Service);
5656
}
5757

5858
get input(): EditorInput {
@@ -143,28 +143,26 @@ export abstract class BaseEditor extends Panel implements IEditor {
143143
this._group = group;
144144
}
145145

146-
protected getEditorMemento<T>(storageService: IStorageService, editorGroupService: IEditorGroupsService, key: string, limit: number = 10): IEditorMemento<T> {
146+
protected getEditorMemento<T>(editorGroupService: IEditorGroupsService, key: string, limit: number = 10): IEditorMemento<T> {
147147
const mementoKey = `${this.getId()}${key}`;
148148

149149
let editorMemento = BaseEditor.EDITOR_MEMENTOS.get(mementoKey);
150150
if (!editorMemento) {
151-
editorMemento = new EditorMemento(this.getId(), key, this.getMemento(storageService, Scope.WORKSPACE), limit, editorGroupService);
151+
editorMemento = new EditorMemento(this.getId(), key, this.getMemento(StorageScope.WORKSPACE), limit, editorGroupService);
152152
BaseEditor.EDITOR_MEMENTOS.set(mementoKey, editorMemento);
153153
}
154154

155155
return editorMemento;
156156
}
157157

158-
shutdown(): void {
158+
protected saveState(): void {
159159

160-
// Shutdown all editor memento for this editor type
160+
// Save all editor memento for this editor type
161161
BaseEditor.EDITOR_MEMENTOS.forEach(editorMemento => {
162162
if (editorMemento.id === this.getId()) {
163-
editorMemento.shutdown();
163+
editorMemento.save();
164164
}
165165
});
166-
167-
super.shutdown();
168166
}
169167

170168
dispose(): void {
@@ -279,7 +277,7 @@ export class EditorMemento<T> implements IEditorMemento<T> {
279277
return this.cache;
280278
}
281279

282-
shutdown(): void {
280+
save(): void {
283281
const cache = this.doLoad();
284282

285283
// Cleanup once during shutdown

src/vs/workbench/browser/parts/editor/binaryDiffEditor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
1010
import { SideBySideEditor } from 'vs/workbench/browser/parts/editor/sideBySideEditor';
1111
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1212
import { BaseBinaryResourceEditor } from 'vs/workbench/browser/parts/editor/binaryEditor';
13+
import { INextStorage2Service } from 'vs/platform/storage2/common/storage2';
1314

1415
/**
1516
* An implementation of editor for diffing binary files like images or videos.
@@ -21,9 +22,10 @@ export class BinaryResourceDiffEditor extends SideBySideEditor {
2122
constructor(
2223
@ITelemetryService telemetryService: ITelemetryService,
2324
@IInstantiationService instantiationService: IInstantiationService,
24-
@IThemeService themeService: IThemeService
25+
@IThemeService themeService: IThemeService,
26+
@INextStorage2Service nextStorage2Service: INextStorage2Service
2527
) {
26-
super(telemetryService, instantiationService, themeService);
28+
super(telemetryService, instantiationService, themeService, nextStorage2Service);
2729
}
2830

2931
getMetadata(): string {

src/vs/workbench/browser/parts/editor/binaryEditor.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { Dimension, size, clearNode } from 'vs/base/browser/dom';
1919
import { IFileService } from 'vs/platform/files/common/files';
2020
import { CancellationToken } from 'vs/base/common/cancellation';
2121
import { dispose } from 'vs/base/common/lifecycle';
22+
import { INextStorage2Service } from 'vs/platform/storage2/common/storage2';
2223

2324
export interface IOpenCallbacks {
2425
openInternal: (input: EditorInput, options: EditorOptions) => Thenable<void>;
@@ -48,8 +49,9 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
4849
telemetryService: ITelemetryService,
4950
themeService: IThemeService,
5051
@IFileService private readonly _fileService: IFileService,
52+
@INextStorage2Service nextStorage2Service: INextStorage2Service
5153
) {
52-
super(id, telemetryService, themeService);
54+
super(id, telemetryService, themeService, nextStorage2Service);
5355

5456
this.callbacks = callbacks;
5557
}

src/vs/workbench/browser/parts/editor/editor.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ export interface IEditorGroupView extends IDisposable, ISerializableView, IEdito
117117
setActive(isActive: boolean): void;
118118
setLabel(label: string): void;
119119
relayout(): void;
120-
121-
shutdown(): void;
122120
}
123121

124122
export function getActiveTextEditorOptions(group: IEditorGroup, expectedActiveEditor?: IEditorInput, presetOptions?: EditorOptions): EditorOptions {

0 commit comments

Comments
 (0)