import * as vscode from 'vscode' ; export abstract class Reconfigurable < T > implements vscode . Disposable { protected disposables : vscode . Disposable [ ] = [ ] ; protected onDidConfigurationChange : vscode . EventEmitter < T > = new vscode . EventEmitter ( ) ; constructor ( section ) { const reconfigure = async ( section ) => { try { const cfg = await this . configure ( vscode . workspace . getConfiguration ( section ) ) ; this . onDidConfigurationChange . fire ( cfg ) ; } catch ( e ) { vscode . window . showWarningMessage ( `could not reconfigure "${ section }": ${ e . message }` ) ; } } ; this . add ( vscode . workspace . onDidChangeConfiguration ( async ( e ) => { if ( e . affectsConfiguration ( section ) ) { reconfigure ( section ) ; } } ) ) ; reconfigure ( section ) ; } param config protected abstract configure ( config ) ; param disposable returns protected add < D extends vscode . Disposable > ( disposable ) { this . disposables . push ( disposable ) ; return disposable ; } @override
      public dispose ( ) { for ( const disposable of this . disposables ) { disposable . dispose ( ) ; } this . disposables . length = 0 ; } }