@@ -379,75 +379,6 @@ class RequestRouter {
379379 }
380380}
381381
382-
383- const syntaxAlwaysCommands : ReadonlySet < keyof TypeScriptRequests > = new Set < keyof TypeScriptRequests > ( [
384- 'navtree' ,
385- 'getOutliningSpans' ,
386- 'jsxClosingTag' ,
387- 'selectionRange' ,
388- 'format' ,
389- 'formatonkey' ,
390- 'docCommentTemplate' ,
391- ] ) ;
392-
393- export class SyntaxRoutingTsServer extends Disposable implements ITypeScriptServer {
394-
395- private readonly syntaxServer : ITypeScriptServer ;
396- private readonly semanticServer : ITypeScriptServer ;
397- private readonly router : RequestRouter ;
398-
399- public constructor (
400- servers : { syntax : ITypeScriptServer , semantic : ITypeScriptServer } ,
401- delegate : TsServerDelegate ,
402- ) {
403- super ( ) ;
404-
405- this . syntaxServer = servers . syntax ;
406- this . semanticServer = servers . semantic ;
407-
408- this . router = new RequestRouter (
409- [
410- { server : this . syntaxServer , canRun : ( command ) => syntaxAlwaysCommands . has ( command ) } ,
411- { server : this . semanticServer , canRun : undefined /* gets all other commands */ }
412- ] ,
413- delegate ) ;
414-
415- this . _register ( this . syntaxServer . onEvent ( e => this . _onEvent . fire ( e ) ) ) ;
416- this . _register ( this . semanticServer . onEvent ( e => this . _onEvent . fire ( e ) ) ) ;
417-
418- this . _register ( this . semanticServer . onExit ( e => {
419- this . _onExit . fire ( e ) ;
420- this . syntaxServer . kill ( ) ;
421- } ) ) ;
422- this . _register ( this . semanticServer . onError ( e => this . _onError . fire ( e ) ) ) ;
423- }
424-
425- private readonly _onEvent = this . _register ( new vscode . EventEmitter < Proto . Event > ( ) ) ;
426- public readonly onEvent = this . _onEvent . event ;
427-
428- private readonly _onExit = this . _register ( new vscode . EventEmitter < any > ( ) ) ;
429- public readonly onExit = this . _onExit . event ;
430-
431- private readonly _onError = this . _register ( new vscode . EventEmitter < any > ( ) ) ;
432- public readonly onError = this . _onError . event ;
433-
434- public get onReaderError ( ) { return this . semanticServer . onReaderError ; }
435-
436- public get tsServerLogFile ( ) { return this . semanticServer . tsServerLogFile ; }
437-
438- public kill ( ) : void {
439- this . syntaxServer . kill ( ) ;
440- this . semanticServer . kill ( ) ;
441- }
442-
443- public executeImpl ( command : keyof TypeScriptRequests , args : any , executeInfo : { isAsync : boolean , token ?: vscode . CancellationToken , expectsResult : false , lowPriority ?: boolean } ) : undefined ;
444- public executeImpl ( command : keyof TypeScriptRequests , args : any , executeInfo : { isAsync : boolean , token ?: vscode . CancellationToken , expectsResult : boolean , lowPriority ?: boolean } ) : Promise < ServerResponse . Response < Proto . Response > > ;
445- public executeImpl ( command : keyof TypeScriptRequests , args : any , executeInfo : { isAsync : boolean , token ?: vscode . CancellationToken , expectsResult : boolean , lowPriority ?: boolean } ) : Promise < ServerResponse . Response < Proto . Response > > | undefined {
446- return this . router . execute ( command , args , executeInfo ) ;
447- }
448- }
449-
450-
451382export class GetErrRoutingTsServer extends Disposable implements ITypeScriptServer {
452383
453384 private static readonly diagnosticEvents = new Set < string > ( [
@@ -525,7 +456,20 @@ export class GetErrRoutingTsServer extends Disposable implements ITypeScriptServ
525456}
526457
527458
528- export class ProjectLoadingRoutingSyntaxTsServer extends Disposable implements ITypeScriptServer {
459+ export class SyntaxRoutingTsServer extends Disposable implements ITypeScriptServer {
460+
461+ /**
462+ * Commands that should always be run on the syntax server.
463+ */
464+ private static readonly syntaxAlwaysCommands = new Set < keyof TypeScriptRequests > ( [
465+ 'navtree' ,
466+ 'getOutliningSpans' ,
467+ 'jsxClosingTag' ,
468+ 'selectionRange' ,
469+ 'format' ,
470+ 'formatonkey' ,
471+ 'docCommentTemplate' ,
472+ ] ) ;
529473
530474 /**
531475 * Commands that should always be run on the semantic server.
@@ -539,7 +483,7 @@ export class ProjectLoadingRoutingSyntaxTsServer extends Disposable implements I
539483 /**
540484 * Commands that can be run on the syntax server but would benefit from being upgraded to the semantic server.
541485 */
542- private syntaxAllowedCommands = new Set < keyof TypeScriptRequests > ( [
486+ private static readonly syntaxAllowedCommands = new Set < keyof TypeScriptRequests > ( [
543487 'completions' ,
544488 'completionEntryDetails' ,
545489 'completionInfo' ,
@@ -563,6 +507,7 @@ export class ProjectLoadingRoutingSyntaxTsServer extends Disposable implements I
563507 public constructor (
564508 servers : { syntax : ITypeScriptServer , semantic : ITypeScriptServer } ,
565509 delegate : TsServerDelegate ,
510+ enableDynamicRouting : boolean ,
566511 ) {
567512 super ( ) ;
568513
@@ -574,13 +519,13 @@ export class ProjectLoadingRoutingSyntaxTsServer extends Disposable implements I
574519 {
575520 server : this . syntaxServer ,
576521 canRun : ( command ) => {
577- if ( syntaxAlwaysCommands . has ( command ) ) {
522+ if ( SyntaxRoutingTsServer . syntaxAlwaysCommands . has ( command ) ) {
578523 return true ;
579524 }
580- if ( ProjectLoadingRoutingSyntaxTsServer . semanticCommands . has ( command ) ) {
525+ if ( SyntaxRoutingTsServer . semanticCommands . has ( command ) ) {
581526 return false ;
582527 }
583- if ( this . projectLoading && this . syntaxAllowedCommands . has ( command ) ) {
528+ if ( enableDynamicRouting && this . projectLoading && SyntaxRoutingTsServer . syntaxAllowedCommands . has ( command ) ) {
584529 return true ;
585530 }
586531 return false ;
0 commit comments