Skip to content

Commit fa63c87

Browse files
committed
convert indentation to spaces
1 parent 33acc5b commit fa63c87

6 files changed

+214
-214
lines changed

1. Fundamentals/2023-06-15-Resource Management - Dispose Pattern.md

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -230,40 +230,40 @@ resource.dispose(); // Don't forget to dispose of it when done
230230
In addition, VSCode also provide a simple but powerful base class named `Disposable`. Here is the code:
231231
```ts
232232
export interface IDisposable {
233-
dispose(): void;
233+
dispose(): void;
234234
}
235235

236236
export abstract class Disposable implements IDisposable {
237237

238-
/**
239-
* A disposable that does nothing when it is disposed of.
240-
*
241-
* TODO: This should not be a static property.
242-
*/
243-
static readonly None = Object.freeze<IDisposable>({ dispose() { } });
244-
245-
protected readonly _store = new DisposableStore();
246-
247-
constructor() {
248-
trackDisposable(this);
249-
setParentOfDisposable(this._store, this);
250-
}
251-
252-
public dispose(): void {
253-
markAsDisposed(this);
254-
255-
this._store.dispose();
256-
}
257-
258-
/**
259-
* Adds `o` to the collection of disposables managed by this object.
260-
*/
261-
protected _register<T extends IDisposable>(o: T): T {
262-
if ((o as unknown as Disposable) === this) {
263-
throw new Error('Cannot register a disposable on itself!');
264-
}
265-
return this._store.add(o);
266-
}
238+
/**
239+
* A disposable that does nothing when it is disposed of.
240+
*
241+
* TODO: This should not be a static property.
242+
*/
243+
static readonly None = Object.freeze<IDisposable>({ dispose() { } });
244+
245+
protected readonly _store = new DisposableStore();
246+
247+
constructor() {
248+
trackDisposable(this);
249+
setParentOfDisposable(this._store, this);
250+
}
251+
252+
public dispose(): void {
253+
markAsDisposed(this);
254+
255+
this._store.dispose();
256+
}
257+
258+
/**
259+
* Adds `o` to the collection of disposables managed by this object.
260+
*/
261+
protected _register<T extends IDisposable>(o: T): T {
262+
if ((o as unknown as Disposable) === this) {
263+
throw new Error('Cannot register a disposable on itself!');
264+
}
265+
return this._store.add(o);
266+
}
267267
}
268268
```
269269

@@ -272,23 +272,23 @@ export abstract class Disposable implements IDisposable {
272272
Here is one of the unit test:
273273
```ts
274274
test('dispose recursively', () => {
275-
const mainDisposable = new DisposableManager();
276-
277-
const disposable2 = new Disposable();
278-
const disposable3 = new DisposableManager();
275+
const mainDisposable = new DisposableManager();
276+
277+
const disposable2 = new Disposable();
278+
const disposable3 = new DisposableManager();
279279

280-
mainDisposable.register(disposable2);
281-
mainDisposable.register(disposable3);
280+
mainDisposable.register(disposable2);
281+
mainDisposable.register(disposable3);
282282

283-
const disposable4 = new Disposable();
284-
disposable3.register(disposable4);
283+
const disposable4 = new Disposable();
284+
disposable3.register(disposable4);
285285

286-
mainDisposable.dispose();
286+
mainDisposable.dispose();
287287

288-
assert.ok(mainDisposable.disposed);
289-
assert.ok(disposable2.isDisposed());
290-
assert.ok(disposable3.disposed);
291-
assert.ok(disposable4.isDisposed());
288+
assert.ok(mainDisposable.disposed);
289+
assert.ok(disposable2.isDisposed());
290+
assert.ok(disposable3.disposed);
291+
assert.ok(disposable4.isDisposed());
292292
});
293293
```
294294

1. Fundamentals/2023-06-16-Introduction to Event.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,20 @@ We can assembly the `Emitters` inside our classes to simplify the registering pr
145145
export class Sash extends Disposable implements ISash {
146146

147147
/** An event which fires whenever the user starts dragging the sash. */
148-
private readonly _onDidStart = this.__register(new Emitter<ISashEvent>());
148+
private readonly _onDidStart = this.__register(new Emitter<ISashEvent>());
149149
public readonly onDidStart: Event<ISashEvent> = this._onDidStart.event;
150150

151-
/** An event which fires whenever the user moves the mouse while dragging the sash. */
151+
/** An event which fires whenever the user moves the mouse while dragging the sash. */
152152
private readonly _onDidMove = this.__register(new Emitter<ISashEvent>());
153-
public readonly onDidMove: Event<ISashEvent> = this._onDidMove.event;
153+
public readonly onDidMove: Event<ISashEvent> = this._onDidMove.event;
154154

155-
/** An event which fires whenever the user stops dragging the sash. */
156-
private readonly _onDidEnd = this.__register(new Emitter<void>());
157-
public readonly onDidEnd: Event<void> = this._onDidEnd.event;
155+
/** An event which fires whenever the user stops dragging the sash. */
156+
private readonly _onDidEnd = this.__register(new Emitter<void>());
157+
public readonly onDidEnd: Event<void> = this._onDidEnd.event;
158158

159159
/** An event which fires whenever the user double clicks the sash. */
160160
private readonly _onDidReset = this.__register(new Emitter<void>());
161-
public readonly onDidReset: Event<void> = this._onDidReset.event;
161+
public readonly onDidReset: Event<void> = this._onDidReset.event;
162162
}
163163
```
164164
* `_onDidStart` (note it is a private field) is the actual `Emitter` that when a event is detected (e.g. A click action is captured).

1. Fundamentals/2023-06-16-Microservice-Driven Architecture.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,15 @@ One might wonder how a microservice can be registered into the DI system without
328328
```ts
329329
export class SyncDescriptor<T> {
330330

331-
readonly ctor: any;
332-
readonly staticArguments: any[];
333-
readonly supportsDelayedInstantiation: boolean;
334-
335-
constructor(ctor: new (...args: any[]) => T, staticArguments: any[] = [], supportsDelayedInstantiation: boolean = false) {
336-
this.ctor = ctor;
337-
this.staticArguments = staticArguments;
338-
this.supportsDelayedInstantiation = supportsDelayedInstantiation;
339-
}
331+
readonly ctor: any;
332+
readonly staticArguments: any[];
333+
readonly supportsDelayedInstantiation: boolean;
334+
335+
constructor(ctor: new (...args: any[]) => T, staticArguments: any[] = [], supportsDelayedInstantiation: boolean = false) {
336+
this.ctor = ctor;
337+
this.staticArguments = staticArguments;
338+
this.supportsDelayedInstantiation = supportsDelayedInstantiation;
339+
}
340340
}
341341
```
342342
With the help of `SyncDescriptor`, we can achieve lazy loading when registering a microservice:

3. Systems/2023-08-19-VSCode配置系统 1:Configuration Service.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -108,26 +108,26 @@ categories: [VSCode, Crucial Systems]
108108
readonly onDidChangeConfiguration: Event<IConfigurationChangeEvent> = this._onDidChangeConfiguration.event;
109109

110110
constructor(
111-
private readonly settingsResource: URI,
112-
fileService: IFileService,
113-
policyService: IPolicyService,
114-
logService: ILogService,
111+
private readonly settingsResource: URI,
112+
fileService: IFileService,
113+
policyService: IPolicyService,
114+
logService: ILogService,
115115
) {
116-
super();
117-
this.defaultConfiguration = this._register(new DefaultConfiguration());
118-
this.policyConfiguration = policyService instanceof NullPolicyService ? new NullPolicyConfiguration() : this._register(new PolicyConfiguration(this.defaultConfiguration, policyService, logService));
119-
this.userConfiguration = this._register(new UserSettings(this.settingsResource, undefined, extUriBiasedIgnorePathCase, fileService));
120-
this.configuration = new Configuration(this.defaultConfiguration.configurationModel, this.policyConfiguration.configurationModel, new ConfigurationModel(), new ConfigurationModel());
116+
super();
117+
this.defaultConfiguration = this._register(new DefaultConfiguration());
118+
this.policyConfiguration = policyService instanceof NullPolicyService ? new NullPolicyConfiguration() : this._register(new PolicyConfiguration(this.defaultConfiguration, policyService, logService));
119+
this.userConfiguration = this._register(new UserSettings(this.settingsResource, undefined, extUriBiasedIgnorePathCase, fileService));
120+
this.configuration = new Configuration(this.defaultConfiguration.configurationModel, this.policyConfiguration.configurationModel, new ConfigurationModel(), new ConfigurationModel());
121121

122-
this.reloadConfigurationScheduler = this._register(new RunOnceScheduler(() => this.reloadConfiguration(), 50));
123-
this._register(this.defaultConfiguration.onDidChangeConfiguration(({ defaults, properties }) => this.onDidDefaultConfigurationChange(defaults, properties)));
124-
this._register(this.policyConfiguration.onDidChangeConfiguration(model => this.onDidPolicyConfigurationChange(model)));
125-
this._register(this.userConfiguration.onDidChange(() => this.reloadConfigurationScheduler.schedule()));
122+
this.reloadConfigurationScheduler = this._register(new RunOnceScheduler(() => this.reloadConfiguration(), 50));
123+
this._register(this.defaultConfiguration.onDidChangeConfiguration(({ defaults, properties }) => this.onDidDefaultConfigurationChange(defaults, properties)));
124+
this._register(this.policyConfiguration.onDidChangeConfiguration(model => this.onDidPolicyConfigurationChange(model)));
125+
this._register(this.userConfiguration.onDidChange(() => this.reloadConfigurationScheduler.schedule()));
126126
}
127127

128128
async initialize(): Promise<void> {
129-
const [defaultModel, policyModel, userModel] = await Promise.all([this.defaultConfiguration.initialize(), this.policyConfiguration.initialize(), this.userConfiguration.loadConfiguration()]);
130-
this.configuration = new Configuration(defaultModel, policyModel, new ConfigurationModel(), userModel);
129+
const [defaultModel, policyModel, userModel] = await Promise.all([this.defaultConfiguration.initialize(), this.policyConfiguration.initialize(), this.userConfiguration.loadConfiguration()]);
130+
this.configuration = new Configuration(defaultModel, policyModel, new ConfigurationModel(), userModel);
131131
}
132132

133133
// ...
@@ -185,21 +185,21 @@ categories: [VSCode, Crucial Systems]
185185
```ts
186186
export class Configuration {
187187

188-
private _workspaceConsolidatedConfiguration: ConfigurationModel | null = null;
189-
private _foldersConsolidatedConfigurations = new ResourceMap<ConfigurationModel>();
190-
191-
constructor(
192-
private _defaultConfiguration: ConfigurationModel,
193-
private _policyConfiguration: ConfigurationModel,
194-
private _applicationConfiguration: ConfigurationModel,
195-
private _localUserConfiguration: ConfigurationModel,
196-
private _remoteUserConfiguration: ConfigurationModel = new ConfigurationModel(),
197-
private _workspaceConfiguration: ConfigurationModel = new ConfigurationModel(),
198-
private _folderConfigurations: ResourceMap<ConfigurationModel> = new ResourceMap<ConfigurationModel>(),
199-
private _memoryConfiguration: ConfigurationModel = new ConfigurationModel(),
200-
private _memoryConfigurationByResource: ResourceMap<ConfigurationModel> = new ResourceMap<ConfigurationModel>()
201-
) {
202-
}
188+
private _workspaceConsolidatedConfiguration: ConfigurationModel | null = null;
189+
private _foldersConsolidatedConfigurations = new ResourceMap<ConfigurationModel>();
190+
191+
constructor(
192+
private _defaultConfiguration: ConfigurationModel,
193+
private _policyConfiguration: ConfigurationModel,
194+
private _applicationConfiguration: ConfigurationModel,
195+
private _localUserConfiguration: ConfigurationModel,
196+
private _remoteUserConfiguration: ConfigurationModel = new ConfigurationModel(),
197+
private _workspaceConfiguration: ConfigurationModel = new ConfigurationModel(),
198+
private _folderConfigurations: ResourceMap<ConfigurationModel> = new ResourceMap<ConfigurationModel>(),
199+
private _memoryConfiguration: ConfigurationModel = new ConfigurationModel(),
200+
private _memoryConfigurationByResource: ResourceMap<ConfigurationModel> = new ResourceMap<ConfigurationModel>()
201+
) {
202+
}
203203
// ...
204204
```
205205
@@ -223,10 +223,10 @@ export class Configuration {
223223
export type ConfigurationKey = { type: 'defaults' | 'user' | 'workspaces' | 'folder'; key: string; };
224224

225225
export interface IConfigurationCache {
226-
needsCaching(resource: URI): boolean;
227-
read(key: ConfigurationKey): Promise<string>;
228-
write(key: ConfigurationKey, content: string): Promise<void>;
229-
remove(key: ConfigurationKey): Promise<void>;
226+
needsCaching(resource: URI): boolean;
227+
read(key: ConfigurationKey): Promise<string>;
228+
write(key: ConfigurationKey, content: string): Promise<void>;
229+
remove(key: ConfigurationKey): Promise<void>;
230230
}
231231
```
232232

3. Systems/2024-11-07-VSCode配置系统 2:JSON Schema.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -49,39 +49,39 @@ let userData = {
4949

5050
```typescript
5151
export interface IJSONSchema {
52-
id?: string;
53-
$id?: string;
54-
$schema?: string;
55-
type?: JSONSchemaType | JSONSchemaType[];
56-
title?: string;
57-
default?: any;
58-
definitions?: IJSONSchemaMap;
59-
description?: string;
60-
properties?: IJSONSchemaMap;
61-
patternProperties?: IJSONSchemaMap;
62-
additionalProperties?: boolean | IJSONSchema;
63-
minProperties?: number;
64-
maxProperties?: number;
65-
dependencies?: IJSONSchemaMap | { [prop: string]: string[]; };
66-
items?: IJSONSchema | IJSONSchema[];
67-
minItems?: number;
68-
maxItems?: number;
69-
uniqueItems?: boolean;
70-
additionalItems?: boolean | IJSONSchema;
71-
pattern?: string;
72-
minLength?: number;
73-
maxLength?: number;
74-
minimum?: number;
75-
maximum?: number;
76-
exclusiveMinimum?: boolean | number;
77-
exclusiveMaximum?: boolean | number;
78-
multipleOf?: number;
79-
required?: string[];
80-
$ref?: string;
81-
anyOf?: IJSONSchema[];
82-
allOf?: IJSONSchema[];
83-
oneOf?: IJSONSchema[];
84-
not?: IJSONSchema;
52+
id?: string;
53+
$id?: string;
54+
$schema?: string;
55+
type?: JSONSchemaType | JSONSchemaType[];
56+
title?: string;
57+
default?: any;
58+
definitions?: IJSONSchemaMap;
59+
description?: string;
60+
properties?: IJSONSchemaMap;
61+
patternProperties?: IJSONSchemaMap;
62+
additionalProperties?: boolean | IJSONSchema;
63+
minProperties?: number;
64+
maxProperties?: number;
65+
dependencies?: IJSONSchemaMap | { [prop: string]: string[]; };
66+
items?: IJSONSchema | IJSONSchema[];
67+
minItems?: number;
68+
maxItems?: number;
69+
uniqueItems?: boolean;
70+
additionalItems?: boolean | IJSONSchema;
71+
pattern?: string;
72+
minLength?: number;
73+
maxLength?: number;
74+
minimum?: number;
75+
maximum?: number;
76+
exclusiveMinimum?: boolean | number;
77+
exclusiveMaximum?: boolean | number;
78+
multipleOf?: number;
79+
required?: string[];
80+
$ref?: string;
81+
anyOf?: IJSONSchema[];
82+
allOf?: IJSONSchema[];
83+
oneOf?: IJSONSchema[];
84+
not?: IJSONSchema;
8585
}
8686
```
8787

0 commit comments

Comments
 (0)