@@ -10,6 +10,7 @@ import {
1010} from "../helpers/solutionBuilder" ;
1111import {
1212 baselineTsserverLogs ,
13+ closeFilesForSession ,
1314 createHostWithSolutionBuild ,
1415 openFilesForSession ,
1516 protocolFileLocationFromSubstring ,
@@ -121,12 +122,16 @@ describe("unittests:: tsserver:: with project references and tsbuild", () => {
121122
122123 it ( "does not error on container only project" , ( ) => {
123124 const { files, session, containerConfig } = setup ( ) ;
124- const service = session . getProjectService ( ) ;
125- service . openExternalProjects ( [ {
126- projectFileName : "/user/username/projects/container/container" ,
127- rootFiles : files . map ( f => ( { fileName : f . path } ) ) ,
128- options : { } ,
129- } ] ) ;
125+ session . executeCommandSeq < ts . server . protocol . OpenExternalProjectsRequest > ( {
126+ command : ts . server . protocol . CommandTypes . OpenExternalProjects ,
127+ arguments : {
128+ projects : [ {
129+ projectFileName : "/user/username/projects/container/container" ,
130+ rootFiles : files . map ( f => ( { fileName : f . path } ) ) ,
131+ options : { } ,
132+ } ] ,
133+ } ,
134+ } ) ;
130135 files . forEach ( f => {
131136 const args : ts . server . protocol . FileRequestArgs = {
132137 file : f . path ,
@@ -141,7 +146,7 @@ describe("unittests:: tsserver:: with project references and tsbuild", () => {
141146 arguments : args ,
142147 } ) ;
143148 } ) ;
144- const containerProject = service . configuredProjects . get ( containerConfig . path ) ! ;
149+ const containerProject = session . getProjectService ( ) . configuredProjects . get ( containerConfig . path ) ! ;
145150 session . executeCommandSeq < ts . server . protocol . CompilerOptionsDiagnosticsRequest > ( {
146151 command : ts . server . protocol . CommandTypes . CompilerOptionsDiagnosticsFull ,
147152 arguments : { projectFileName : containerProject . projectName } ,
@@ -168,7 +173,6 @@ describe("unittests:: tsserver:: with project references and tsbuild", () => {
168173 } ;
169174 const { session, containerCompositeExecIndex } = setup ( tempFile ) ;
170175 openFilesForSession ( [ containerCompositeExecIndex ] , session ) ;
171- const service = session . getProjectService ( ) ;
172176
173177 // Open temp file and verify all projects alive
174178 openFilesForSession ( [ tempFile ] , session ) ;
@@ -184,12 +188,11 @@ describe("unittests:: tsserver:: with project references and tsbuild", () => {
184188 } ) ;
185189
186190 // Open temp file and verify all projects alive
187- service . closeClientFile ( tempFile . path ) ;
191+ closeFilesForSession ( [ tempFile ] , session ) ;
188192 openFilesForSession ( [ tempFile ] , session ) ;
189193
190194 // Close all files and open temp file, only inferred project should be alive
191- service . closeClientFile ( containerCompositeExecIndex . path ) ;
192- service . closeClientFile ( tempFile . path ) ;
195+ closeFilesForSession ( [ containerCompositeExecIndex , tempFile ] , session ) ;
193196 openFilesForSession ( [ tempFile ] , session ) ;
194197 baselineTsserverLogs ( "projectReferences" , `ancestor and project ref management` , session ) ;
195198 } ) ;
@@ -1044,48 +1047,46 @@ export function bar() {}`,
10441047 ...additionalFiles ,
10451048 ] ) ;
10461049 const session = new TestSession ( host ) ;
1047- const service = session . getProjectService ( ) ;
1048- service . openClientFile ( main . path ) ;
1049- return { session, service, host } ;
1050+ openFilesForSession ( [ main ] , session ) ;
1051+ return { session, host } ;
10501052 }
10511053
10521054 function verifySolutionScenario ( input : Setup ) {
1053- const { session, service } = setup ( input ) ;
1055+ const { session } = setup ( input ) ;
10541056
1055- const info = service . getScriptInfoForPath ( main . path as ts . Path ) ! ;
1057+ const info = session . getProjectService ( ) . getScriptInfoForPath ( main . path as ts . Path ) ! ;
10561058 session . logger . startGroup ( ) ;
10571059 session . logger . info ( `getDefaultProject for ${ main . path } : ${ info . getDefaultProject ( ) . projectName } ` ) ;
1058- session . logger . info ( `findDefaultConfiguredProject for ${ main . path } : ${ service . findDefaultConfiguredProject ( info ) ! . projectName } ` ) ;
1060+ session . logger . info ( `findDefaultConfiguredProject for ${ main . path } : ${ session . getProjectService ( ) . findDefaultConfiguredProject ( info ) ! . projectName } ` ) ;
10591061 session . logger . endGroup ( ) ;
10601062
10611063 // Verify errors
10621064 verifyGetErrRequest ( { session, files : [ main ] } ) ;
10631065
10641066 // Verify collection of script infos
1065- service . openClientFile ( dummyFilePath ) ;
1067+ openFilesForSession ( [ dummyFilePath ] , session ) ;
10661068
1067- service . closeClientFile ( main . path ) ;
1068- service . closeClientFile ( dummyFilePath ) ;
1069- service . openClientFile ( dummyFilePath ) ;
1069+ closeFilesForSession ( [ main , dummyFilePath ] , session ) ;
1070+ openFilesForSession ( [ dummyFilePath , main ] , session ) ;
10701071
1071- service . openClientFile ( main . path ) ;
1072- service . closeClientFile ( dummyFilePath ) ;
1073- service . openClientFile ( dummyFilePath ) ;
1072+ closeFilesForSession ( [ dummyFilePath ] , session ) ;
1073+ openFilesForSession ( [ dummyFilePath ] , session ) ;
10741074
10751075 // Verify Reload projects
1076- service . reloadProjects ( ) ;
1076+ session . executeCommandSeq < ts . server . protocol . ReloadProjectsRequest > ( {
1077+ command : ts . server . protocol . CommandTypes . ReloadProjects ,
1078+ } ) ;
10771079
10781080 // Find all refs
10791081 session . executeCommandSeq < ts . server . protocol . ReferencesRequest > ( {
10801082 command : ts . server . protocol . CommandTypes . References ,
10811083 arguments : protocolFileLocationFromSubstring ( main , "foo" , { index : 1 } ) ,
10821084 } ) . response as ts . server . protocol . ReferencesResponseBody ;
10831085
1084- service . closeClientFile ( main . path ) ;
1085- service . closeClientFile ( dummyFilePath ) ;
1086+ closeFilesForSession ( [ main , dummyFilePath ] , session ) ;
10861087
10871088 // Verify when declaration map references the file
1088- service . openClientFile ( fileResolvingToMainDts . path ) ;
1089+ openFilesForSession ( [ fileResolvingToMainDts ] , session ) ;
10891090
10901091 // Find all refs from dts include
10911092 session . executeCommandSeq < ts . server . protocol . ReferencesRequest > ( {
@@ -1117,25 +1118,24 @@ export function bar() {}`,
11171118 }
11181119
11191120 function verifyDisableReferencedProjectLoad ( input : Setup ) {
1120- const { session, service } = setup ( input ) ;
1121+ const { session } = setup ( input ) ;
11211122
1122- const info = service . getScriptInfoForPath ( main . path as ts . Path ) ! ;
1123+ const info = session . getProjectService ( ) . getScriptInfoForPath ( main . path as ts . Path ) ! ;
11231124 session . logger . startGroup ( ) ;
11241125 session . logger . info ( `getDefaultProject for ${ main . path } : ${ info . getDefaultProject ( ) . projectName } ` ) ;
1125- session . logger . info ( `findDefaultConfiguredProject for ${ main . path } : ${ service . findDefaultConfiguredProject ( info ) ?. projectName } ` ) ;
1126+ session . logger . info ( `findDefaultConfiguredProject for ${ main . path } : ${ session . getProjectService ( ) . findDefaultConfiguredProject ( info ) ?. projectName } ` ) ;
11261127 session . logger . endGroup ( ) ;
11271128
11281129 // Verify collection of script infos
1129- service . openClientFile ( dummyFilePath ) ;
1130-
1131- service . closeClientFile ( main . path ) ;
1132- service . closeClientFile ( dummyFilePath ) ;
1133- service . openClientFile ( dummyFilePath ) ;
1130+ openFilesForSession ( [ dummyFilePath ] , session ) ;
11341131
1135- service . openClientFile ( main . path ) ;
1132+ closeFilesForSession ( [ main , dummyFilePath ] , session ) ;
1133+ openFilesForSession ( [ dummyFilePath , main ] , session ) ;
11361134
11371135 // Verify Reload projects
1138- service . reloadProjects ( ) ;
1136+ session . executeCommandSeq < ts . server . protocol . ReloadProjectsRequest > ( {
1137+ command : ts . server . protocol . CommandTypes . ReloadProjects ,
1138+ } ) ;
11391139 baselineTsserverLogs ( "projectReferences" , input . scenario , session ) ;
11401140 }
11411141
0 commit comments