@@ -39,15 +39,13 @@ import { fs } from '../../shared/fs/fs'
39
39
import { getLogger } from '../../shared/logger/logger'
40
40
import globals from '../../shared/extensionGlobals'
41
41
import { ResourcePaths } from '../../shared/lsp/types'
42
- import { createServerOptions } from '../../shared/lsp/utils/platform'
42
+ import { createServerOptions , validateNodeExe } from '../../shared/lsp/utils/platform'
43
43
import { waitUntil } from '../../shared/utilities/timeoutUtils'
44
- import { ToolkitError } from '../../shared/errors'
45
- import { ChildProcess } from '../../shared/utilities/processUtils'
46
44
47
45
const localize = nls . loadMessageBundle ( )
48
46
49
47
const key = crypto . randomBytes ( 32 )
50
- const logger = getLogger ( 'amazonqLsp.lspClient ' )
48
+ const logger = getLogger ( 'amazonqWorkspaceLsp ' )
51
49
52
50
/**
53
51
* LspClient manages the API call between VS Code extension and LSP server
@@ -226,53 +224,6 @@ export class LspClient {
226
224
}
227
225
}
228
226
229
- /**
230
- * Checks that we can actually run the `node` executable and execute code with it.
231
- */
232
- async function validateNodeExe ( nodePath : string , lsp : string , args : string [ ] ) {
233
- // Check that we can start `node` by itself.
234
- const proc = new ChildProcess ( nodePath , [ '-e' , 'console.log("ok " + process.version)' ] , { logging : 'no' } )
235
- const r = await proc . run ( )
236
- const ok = r . exitCode === 0 && r . stdout . includes ( 'ok' )
237
- if ( ! ok ) {
238
- const msg = `failed to run basic "node -e" test (exitcode=${ r . exitCode } ): ${ proc . toString ( false , true ) } `
239
- logger . error ( msg )
240
- throw new ToolkitError ( `amazonqLsp: ${ msg } ` )
241
- }
242
-
243
- // Check that we can start `node …/lsp.js --stdio …`.
244
- const lspProc = new ChildProcess ( nodePath , [ lsp , ...args ] , { logging : 'no' } )
245
- try {
246
- // Start asynchronously (it never stops; we need to stop it below).
247
- lspProc . run ( ) . catch ( ( e ) => logger . error ( 'failed to run: %s' , lspProc . toString ( false , true ) ) )
248
-
249
- const ok2 =
250
- ! lspProc . stopped &&
251
- ( await waitUntil (
252
- async ( ) => {
253
- return lspProc . pid ( ) !== undefined
254
- } ,
255
- {
256
- timeout : 5000 ,
257
- interval : 100 ,
258
- truthy : true ,
259
- }
260
- ) )
261
- const selfExit = await waitUntil ( async ( ) => lspProc . stopped , {
262
- timeout : 500 ,
263
- interval : 100 ,
264
- truthy : true ,
265
- } )
266
- if ( ! ok2 || selfExit ) {
267
- throw new ToolkitError (
268
- `amazonqLsp: failed to run (exitcode=${ lspProc . exitCode ( ) } ): ${ lspProc . toString ( false , true ) } `
269
- )
270
- }
271
- } finally {
272
- lspProc . stop ( true )
273
- }
274
- }
275
-
276
227
/**
277
228
* Activates the language server (assumes the LSP server has already been downloaded):
278
229
* 1. start LSP server running over IPC protocol.
@@ -312,7 +263,7 @@ export async function activate(extensionContext: ExtensionContext, resourcePaths
312
263
313
264
const documentSelector = [ { scheme : 'file' , language : '*' } ]
314
265
315
- await validateNodeExe ( resourcePaths . node , resourcePaths . lsp , debugOptions . execArgv )
266
+ await validateNodeExe ( resourcePaths . node , resourcePaths . lsp , debugOptions . execArgv , logger )
316
267
317
268
// Options to control the language client
318
269
const clientOptions : LanguageClientOptions = {
0 commit comments