import { debug , Disposable , languages , TextDocumentChangeEvent , TextEditor , window , workspace , WorkspaceConfiguration , } from "vscode" ; import { Parser } from "./parser" ; export class Listener { constructor ( private parser ) { this . config = parser . config ; } public listen ( ) { this . dispose ( ) ; const fileSwitch = window . onDidChangeActiveTextEditor , fileEdit = workspace . onDidChangeTextDocument , debugStart = debug . onDidStartDebugSession , debugEnd = debug . onDidTerminateDebugSession , diagnostictsChange = languages . onDidChangeDiagnostics ; if ( this . config . get ( "showFile" ) ) this . disposables . push ( fileSwitch ( ( e ) => this . parser . fileSwitch ( e ) ) , fileEdit ( ( e ) => this . parser . fileEdit ( e ) ) ) ; if ( this . config . get ( "showDebugging" ) ) this . disposables . push ( debugStart ( ( ) => this . parser . toggleDebug ( ) ) , debugEnd ( ( ) => this . parser . toggleDebug ( ) ) ) ; if ( this . config . get ( "showProblems" ) ) this . disposables . push ( diagnostictsChange ( ( ) => this . parser . diagnosticsChange ( ) ) ) ; } private disposables : Disposable [ ] = [ ] ; private config : WorkspaceConfiguration ; public dispose ( ) { this . disposables . forEach ( ( disposable ) => disposable . dispose ( ) ) ; } }