mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 04:23:32 +01:00
* Use MD LS for resolving all document links This switches the markdown extension to use the markdown language service when resolving the link. This lets us delete a lot of code that was duplicated between the extension and the LS * Pick up new ls version
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import * as vscode from 'vscode';
|
|
|
|
export function disposeAll(disposables: Iterable<vscode.Disposable>) {
|
|
const errors: any[] = [];
|
|
|
|
for (const disposable of disposables) {
|
|
try {
|
|
disposable.dispose();
|
|
} catch (e) {
|
|
errors.push(e);
|
|
}
|
|
}
|
|
|
|
if (errors.length === 1) {
|
|
throw errors[0];
|
|
} else if (errors.length > 1) {
|
|
throw new AggregateError(errors, 'Encountered errors while disposing of store');
|
|
}
|
|
}
|
|
|
|
export interface IDisposable {
|
|
dispose(): void;
|
|
}
|
|
|
|
export abstract class Disposable {
|
|
private _isDisposed = false;
|
|
|
|
protected _disposables: vscode.Disposable[] = [];
|
|
|
|
public dispose(): any {
|
|
if (this._isDisposed) {
|
|
return;
|
|
}
|
|
this._isDisposed = true;
|
|
disposeAll(this._disposables);
|
|
}
|
|
|
|
protected _register<T extends IDisposable>(value: T): T {
|
|
if (this._isDisposed) {
|
|
value.dispose();
|
|
} else {
|
|
this._disposables.push(value);
|
|
}
|
|
return value;
|
|
}
|
|
|
|
protected get isDisposed() {
|
|
return this._isDisposed;
|
|
}
|
|
}
|