import { TextDocument } from 'vscode-languageserver-textdocument' ; import { Connection , createConnection , DidChangeTextDocumentParams , NotificationHandler , ProposedFeatures , TextDocuments , } from 'vscode-languageserver/node' ; import { AnsibleLanguageService } from './ansibleLanguageService' ; const connection = createConnection ( ProposedFeatures . all ) ; const docChangeHandlers = [ ] ; connection . onDidChangeTextDocument ( ( params ) => { for ( const handler of docChangeHandlers ) { handler ( params ) ; } } ) ; const connectionProxy = new Proxy ( connection , { get : ( target , p , receiver ) => { if ( p === 'onDidChangeTextDocument' ) { return ( handler ) => { docChangeHandlers . push ( handler ) ; } ; } else { return Reflect . get ( target , p , receiver ) ; } } , } ) ; const documents = new TextDocuments ( TextDocument ) ; const context = new AnsibleLanguageService ( connectionProxy , documents ) ; context . initialize ( ) ; documents . listen ( connectionProxy ) ; connection . listen ( ) ;