import { _Connection , TextDocumentIdentifier , Diagnostic } from 'vscode-languageserver' ; import { DocumentManager , Document } from './documents' ; export type SendDiagnostics = _Connection [ 'sendDiagnostics' ] ; export type GetDiagnostics = ( doc : TextDocumentIdentifier ) => Thenable < Diagnostic [ ] > ; export class DiagnosticsManager { constructor ( private sendDiagnostics , private docManager , private getDiagnostics ) { } updateAll ( ) { this . docManager . getAllOpenedByClient ( ) . forEach ( ( doc ) => { this . update ( doc [ 1 ] ) ; } ) ; } async update ( document ) { const diagnostics = await this . getDiagnostics ( { uri : document . getURL ( ) } ) ; this . sendDiagnostics ( { uri : document . getURL ( ) , diagnostics } ) ; } removeDiagnostics ( document ) { this . sendDiagnostics ( { uri : document . getURL ( ) , diagnostics : [ ] } ) ; } }