import * as vscode from 'vscode' ; export type ConfigCache < T > = { [ key ] : T ; } ; export abstract class ConfigReader extends vscode . Disposable { private _section : string ; private _disposables : vscode . Disposable [ ] = [ ] ; constructor ( section ) { super ( ( ) => this . dispose ( ) ) ; this . _section = section ; this . _disposables . push ( vscode . workspace . onDidChangeConfiguration ( e => this . onChange ( e ) ) , vscode . workspace . onDidGrantWorkspaceTrust ( e => this . onChange ( e ) ) ) ; } dispose ( ) { this . _disposables . length && this . _disposables . forEach ( d => d . dispose ( ) ) ; } param key read < T > ( key ) ; param key param resource read < T > ( key , resource ) ; param key param resource param func read < T > ( key , resource , func ) ; read < T > ( key , ... para ) { let resource = para . shift ( ) as vscode . Uri ; let folder = resource ? vscode . workspace . getWorkspaceFolder ( resource ) : undefined ; let conf = vscode . workspace . getConfiguration ( this . _section , resource ) ; let value = conf . get < T > ( key ) ; let func = undefined ; if ( para . length ) func = para . shift ( ) ; if ( func && folder && folder . uri ) { value = func ( folder . uri , value ) ; } return value ; } abstract onChange ( ... args ) ; }