mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
Switches all samples to use eslint 9 with flat configs. I've tried to migrate existing settings as much as possible. However our eslint configs were also inconsistent so I've tried to align these too
37 lines
740 B
TypeScript
37 lines
740 B
TypeScript
import * as vscode from 'vscode';
|
|
|
|
export function disposeAll(disposables: vscode.Disposable[]): void {
|
|
while (disposables.length) {
|
|
const item = disposables.pop();
|
|
if (item) {
|
|
item.dispose();
|
|
}
|
|
}
|
|
}
|
|
|
|
export abstract class Disposable {
|
|
private _isDisposed = false;
|
|
|
|
protected _disposables: vscode.Disposable[] = [];
|
|
|
|
public dispose() {
|
|
if (this._isDisposed) {
|
|
return;
|
|
}
|
|
this._isDisposed = true;
|
|
disposeAll(this._disposables);
|
|
}
|
|
|
|
protected _register<T extends vscode.Disposable>(value: T): T {
|
|
if (this._isDisposed) {
|
|
value.dispose();
|
|
} else {
|
|
this._disposables.push(value);
|
|
}
|
|
return value;
|
|
}
|
|
|
|
protected get isDisposed(): boolean {
|
|
return this._isDisposed;
|
|
}
|
|
} |