@@ -405,12 +405,8 @@ function registerProgressHandlers(client: lsp.LanguageClient) {
405
405
* @param configName
406
406
* @param bundled
407
407
*/
408
- function getProbeLocations ( configValue : string | null , bundled : string ) : string [ ] {
408
+ function getProbeLocations ( bundled : string ) : string [ ] {
409
409
const locations = [ ] ;
410
- // Always use config value if it's specified
411
- if ( configValue ) {
412
- locations . push ( configValue ) ;
413
- }
414
410
// Prioritize the bundled version
415
411
locations . push ( bundled ) ;
416
412
// Look in workspaces currently open
@@ -425,7 +421,7 @@ function getProbeLocations(configValue: string|null, bundled: string): string[]
425
421
* Construct the arguments that's used to spawn the server process.
426
422
* @param ctx vscode extension context
427
423
*/
428
- function constructArgs ( ctx : vscode . ExtensionContext ) : string [ ] {
424
+ function constructArgs ( ctx : vscode . ExtensionContext , viewEngine : boolean ) : string [ ] {
429
425
const config = vscode . workspace . getConfiguration ( ) ;
430
426
const args : string [ ] = [ '--logToConsole' ] ;
431
427
@@ -437,15 +433,15 @@ function constructArgs(ctx: vscode.ExtensionContext): string[] {
437
433
args . push ( '--logVerbosity' , ngLog ) ;
438
434
}
439
435
440
- const ngProbeLocations = getProbeLocations ( null , ctx . extensionPath ) ;
441
- args . push ( '--ngProbeLocations' , ngProbeLocations . join ( ',' ) ) ;
442
-
443
- // Because the configuration is typed as "boolean" in package.json, vscode
444
- // will return false even when the value is not set. If value is false, then
445
- // we need to check if all projects support Ivy language service.
446
- const viewEngine : boolean = config . get ( 'angular.view-engine' ) || ! allProjectsSupportIvy ( ) ;
436
+ const ngProbeLocations = getProbeLocations ( ctx . extensionPath ) ;
447
437
if ( viewEngine ) {
448
438
args . push ( '--viewEngine' ) ;
439
+ args . push ( '--ngProbeLocations' , [
440
+ path . join ( ctx . extensionPath , 'v12_language_service' ) ,
441
+ ...ngProbeLocations ,
442
+ ] . join ( ',' ) ) ;
443
+ } else {
444
+ args . push ( '--ngProbeLocations' , ngProbeLocations . join ( ',' ) ) ;
449
445
}
450
446
451
447
const includeAutomaticOptionalChainCompletions =
@@ -461,7 +457,7 @@ function constructArgs(ctx: vscode.ExtensionContext): string[] {
461
457
}
462
458
463
459
const tsdk : string | null = config . get ( 'typescript.tsdk' , null ) ;
464
- const tsProbeLocations = getProbeLocations ( tsdk , ctx . extensionPath ) ;
460
+ const tsProbeLocations = [ tsdk , ... getProbeLocations ( ctx . extensionPath ) ] ;
465
461
args . push ( '--tsProbeLocations' , tsProbeLocations . join ( ',' ) ) ;
466
462
467
463
return args ;
@@ -475,9 +471,22 @@ function getServerOptions(ctx: vscode.ExtensionContext, debug: boolean): lsp.Nod
475
471
NG_DEBUG : true ,
476
472
} ;
477
473
474
+ // Because the configuration is typed as "boolean" in package.json, vscode
475
+ // will return false even when the value is not set. If value is false, then
476
+ // we need to check if all projects support Ivy language service.
477
+ const config = vscode . workspace . getConfiguration ( ) ;
478
+ const viewEngine : boolean = config . get ( 'angular.view-engine' ) || ! allProjectsSupportIvy ( ) ;
479
+
478
480
// Node module for the language server
481
+ const args = constructArgs ( ctx , viewEngine ) ;
479
482
const prodBundle = ctx . asAbsolutePath ( 'server' ) ;
480
483
const devBundle = ctx . asAbsolutePath ( path . join ( 'dist' , 'server' , 'server.js' ) ) ;
484
+ // VS Code Insider launches extensions in debug mode by default but users
485
+ // install prod bundle so we have to check whether dev bundle exists.
486
+ const latestServerModule = debug && fs . existsSync ( devBundle ) ? devBundle : prodBundle ;
487
+ const v12ServerModule = ctx . asAbsolutePath (
488
+ path . join ( 'v12_language_service' , 'node_modules' , '@angular' , 'language-server' ) ) ;
489
+ const module = viewEngine ? v12ServerModule : latestServerModule ;
481
490
482
491
// Argv options for Node.js
483
492
const prodExecArgv : string [ ] = [ ] ;
@@ -489,11 +498,9 @@ function getServerOptions(ctx: vscode.ExtensionContext, debug: boolean): lsp.Nod
489
498
] ;
490
499
491
500
return {
492
- // VS Code Insider launches extensions in debug mode by default but users
493
- // install prod bundle so we have to check whether dev bundle exists.
494
- module : debug && fs . existsSync ( devBundle ) ? devBundle : prodBundle ,
501
+ module,
495
502
transport : lsp . TransportKind . ipc ,
496
- args : constructArgs ( ctx ) ,
503
+ args,
497
504
options : {
498
505
env : debug ? devEnv : prodEnv ,
499
506
execArgv : debug ? devExecArgv : prodExecArgv ,
@@ -514,4 +521,4 @@ function allProjectsSupportIvy() {
514
521
}
515
522
}
516
523
return true ;
517
- }
524
+ }
0 commit comments