import * as path from 'path' ; import { DiagnosticCollection , ExtensionContext , workspace } from 'vscode' ; import * as queryValidation from './queryValidation' ; import * as codeCompletion from './codeCompletion' ; import { LanguageClient , LanguageClientOptions , ServerOptions , TransportKind } from 'vscode-languageclient' ; let client ; export function clearDiagnostics ( ) { client ?. diagnostics ?. clear ( ) ; } export async function startLanguageClient ( extensionContext ) { const serverModule = extensionContext . asAbsolutePath ( path . join ( 'node_modules' , '@salesforce' , 'soql-language-server' , 'lib' , 'server.js' ) ) ; const debugOptions = { execArgv : [ '--nolazy' , '--inspect=6009' ] } ; const serverOptions = { run : { module : serverModule , transport : TransportKind . ipc } , debug : { module : serverModule , transport : TransportKind . ipc , options : debugOptions } } ; const clientOptions = { documentSelector : [ { language : 'soql' } ] , synchronize : { configurationSection : 'soql' , fileEvents : workspace . createFileSystemWatcher ( '**/*.soql' ) } , middleware : codeCompletion . middleware } ; client = new LanguageClient ( 'soql-language-server' , 'SOQL Language Server' , serverOptions , clientOptions ) ; client = queryValidation . init ( client ) ; client . start ( ) ; await client . onReady ( ) ; client = queryValidation . afterStart ( client ) ; } export function stopLanguageClient ( ) { if ( ! client ) { return undefined ; } return client . stop ( ) ; }