@@ -585,7 +585,7 @@ namespace ts.server {
585585 undefined ;
586586 }
587587
588- const invalidSyntaxOnlyCommands : readonly CommandNames [ ] = [
588+ const invalidApproximateSemanticOnlyCommands : readonly CommandNames [ ] = [
589589 CommandNames . OpenExternalProject ,
590590 CommandNames . OpenExternalProjects ,
591591 CommandNames . CloseExternalProject ,
@@ -621,6 +621,36 @@ namespace ts.server {
621621 CommandNames . ProvideCallHierarchyOutgoingCalls ,
622622 ] ;
623623
624+ const invalidSyntaxOnlyCommands : readonly CommandNames [ ] = [
625+ ...invalidApproximateSemanticOnlyCommands ,
626+ CommandNames . Definition ,
627+ CommandNames . DefinitionFull ,
628+ CommandNames . DefinitionAndBoundSpan ,
629+ CommandNames . DefinitionAndBoundSpanFull ,
630+ CommandNames . TypeDefinition ,
631+ CommandNames . Implementation ,
632+ CommandNames . ImplementationFull ,
633+ CommandNames . References ,
634+ CommandNames . ReferencesFull ,
635+ CommandNames . Rename ,
636+ CommandNames . RenameLocationsFull ,
637+ CommandNames . RenameInfoFull ,
638+ CommandNames . Quickinfo ,
639+ CommandNames . QuickinfoFull ,
640+ CommandNames . CompletionInfo ,
641+ CommandNames . Completions ,
642+ CommandNames . CompletionsFull ,
643+ CommandNames . CompletionDetails ,
644+ CommandNames . CompletionDetailsFull ,
645+ CommandNames . SignatureHelp ,
646+ CommandNames . SignatureHelpFull ,
647+ CommandNames . Navto ,
648+ CommandNames . NavtoFull ,
649+ CommandNames . Occurrences ,
650+ CommandNames . DocumentHighlights ,
651+ CommandNames . DocumentHighlightsFull ,
652+ ] ;
653+
624654 export interface SessionOptions {
625655 host : ServerHost ;
626656 cancellationToken : ServerCancellationToken ;
@@ -637,7 +667,9 @@ namespace ts.server {
637667 eventHandler ?: ProjectServiceEventHandler ;
638668 /** Has no effect if eventHandler is also specified. */
639669 suppressDiagnosticEvents ?: boolean ;
670+ /** @deprecated use serverMode instead */
640671 syntaxOnly ?: boolean ;
672+ serverMode ?: LanguageServiceMode ;
641673 throttleWaitMilliseconds ?: number ;
642674 noGetErrOnBackgroundUpdate ?: boolean ;
643675
@@ -709,18 +741,32 @@ namespace ts.server {
709741 allowLocalPluginLoads : opts . allowLocalPluginLoads ,
710742 typesMapLocation : opts . typesMapLocation ,
711743 syntaxOnly : opts . syntaxOnly ,
744+ serverMode : opts . serverMode ,
712745 } ;
713746 this . projectService = new ProjectService ( settings ) ;
714747 this . projectService . setPerformanceEventHandler ( this . performanceEventHandler . bind ( this ) ) ;
715748 this . gcTimer = new GcTimer ( this . host , /*delay*/ 7000 , this . logger ) ;
716749
717- // Make sure to setup handlers to throw error for not allowed commands on syntax server;
718- if ( this . projectService . syntaxOnly ) {
719- invalidSyntaxOnlyCommands . forEach ( commandName =>
720- this . handlers . set ( commandName , request => {
721- throw new Error ( `Request: ${ request . command } not allowed on syntaxServer` ) ;
722- } )
723- ) ;
750+ // Make sure to setup handlers to throw error for not allowed commands on syntax server
751+ switch ( this . projectService . serverMode ) {
752+ case LanguageServiceMode . Semantic :
753+ break ;
754+ case LanguageServiceMode . ApproximateSemanticOnly :
755+ invalidApproximateSemanticOnlyCommands . forEach ( commandName =>
756+ this . handlers . set ( commandName , request => {
757+ throw new Error ( `Request: ${ request . command } not allowed on approximate semantic only server` ) ;
758+ } )
759+ ) ;
760+ break ;
761+ case LanguageServiceMode . SyntaxOnly :
762+ invalidSyntaxOnlyCommands . forEach ( commandName =>
763+ this . handlers . set ( commandName , request => {
764+ throw new Error ( `Request: ${ request . command } not allowed on syntax only server` ) ;
765+ } )
766+ ) ;
767+ break ;
768+ default :
769+ Debug . assertNever ( this . projectService . serverMode ) ;
724770 }
725771 }
726772
0 commit comments