'use strict' ; import { createConnection , Connection , ProposedFeatures } from 'vscode-languageserver/node' ; import * as nls from 'vscode-nls' ; import { schemaRequestHandler , workspaceContext } from './languageservice/services/schemaRequestHandler' ; import { YAMLServerInit } from './yamlServerInit' ; import { SettingsState } from './yamlSettings' ; import { promises as fs } from 'fs' ; import { convertErrorToTelemetryMsg } from './languageservice/utils/objects' ; nls . config ( process . env [ 'VSCODE_NLS_CONFIG' ] as any ) ; let connection = null ; if ( process . argv . indexOf ( '--stdio' ) === - 1 ) { connection = createConnection ( ProposedFeatures . all ) ; } else { connection = createConnection ( ) ; } process . on ( 'uncaughtException' , ( err ) => { connection . console . error ( convertErrorToTelemetryMsg ( err ) ) ; } ) ; console . log = connection . console . log . bind ( connection . console ) ; console . error = connection . console . error . bind ( connection . console ) ; console . error = ( arg ) => { if ( arg === null ) { connection . console . info ( arg ) ; } else { connection . console . error ( arg ) ; } } ; const yamlSettings = new SettingsState ( ) ; const fileSystem = { readFile : ( fsPath , encoding ? ) => { return fs . readFile ( fsPath , encoding ) . then ( ( b ) => b . toString ( ) ) ; } , } ; param uri const schemaRequestHandlerWrapper = ( connection , uri ) : Promise < string > => { return schemaRequestHandler ( connection , uri , yamlSettings . workspaceFolders , yamlSettings . workspaceRoot , yamlSettings . useVSCodeContentRequest , fileSystem ) ; } ; const schemaRequestService = schemaRequestHandlerWrapper . bind ( this , connection ) ; new YAMLServerInit ( connection , yamlSettings , workspaceContext , schemaRequestService ) . start ( ) ;