@@ -10,6 +10,7 @@ import {
10
10
} from "../helpers/solutionBuilder" ;
11
11
import {
12
12
baselineTsserverLogs ,
13
+ closeFilesForSession ,
13
14
createHostWithSolutionBuild ,
14
15
openFilesForSession ,
15
16
protocolFileLocationFromSubstring ,
@@ -121,12 +122,16 @@ describe("unittests:: tsserver:: with project references and tsbuild", () => {
121
122
122
123
it ( "does not error on container only project" , ( ) => {
123
124
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
+ } ) ;
130
135
files . forEach ( f => {
131
136
const args : ts . server . protocol . FileRequestArgs = {
132
137
file : f . path ,
@@ -141,7 +146,7 @@ describe("unittests:: tsserver:: with project references and tsbuild", () => {
141
146
arguments : args ,
142
147
} ) ;
143
148
} ) ;
144
- const containerProject = service . configuredProjects . get ( containerConfig . path ) ! ;
149
+ const containerProject = session . getProjectService ( ) . configuredProjects . get ( containerConfig . path ) ! ;
145
150
session . executeCommandSeq < ts . server . protocol . CompilerOptionsDiagnosticsRequest > ( {
146
151
command : ts . server . protocol . CommandTypes . CompilerOptionsDiagnosticsFull ,
147
152
arguments : { projectFileName : containerProject . projectName } ,
@@ -168,7 +173,6 @@ describe("unittests:: tsserver:: with project references and tsbuild", () => {
168
173
} ;
169
174
const { session, containerCompositeExecIndex } = setup ( tempFile ) ;
170
175
openFilesForSession ( [ containerCompositeExecIndex ] , session ) ;
171
- const service = session . getProjectService ( ) ;
172
176
173
177
// Open temp file and verify all projects alive
174
178
openFilesForSession ( [ tempFile ] , session ) ;
@@ -184,12 +188,11 @@ describe("unittests:: tsserver:: with project references and tsbuild", () => {
184
188
} ) ;
185
189
186
190
// Open temp file and verify all projects alive
187
- service . closeClientFile ( tempFile . path ) ;
191
+ closeFilesForSession ( [ tempFile ] , session ) ;
188
192
openFilesForSession ( [ tempFile ] , session ) ;
189
193
190
194
// 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 ) ;
193
196
openFilesForSession ( [ tempFile ] , session ) ;
194
197
baselineTsserverLogs ( "projectReferences" , `ancestor and project ref management` , session ) ;
195
198
} ) ;
@@ -1044,48 +1047,46 @@ export function bar() {}`,
1044
1047
...additionalFiles ,
1045
1048
] ) ;
1046
1049
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 } ;
1050
1052
}
1051
1053
1052
1054
function verifySolutionScenario ( input : Setup ) {
1053
- const { session, service } = setup ( input ) ;
1055
+ const { session } = setup ( input ) ;
1054
1056
1055
- const info = service . getScriptInfoForPath ( main . path as ts . Path ) ! ;
1057
+ const info = session . getProjectService ( ) . getScriptInfoForPath ( main . path as ts . Path ) ! ;
1056
1058
session . logger . startGroup ( ) ;
1057
1059
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 } ` ) ;
1059
1061
session . logger . endGroup ( ) ;
1060
1062
1061
1063
// Verify errors
1062
1064
verifyGetErrRequest ( { session, files : [ main ] } ) ;
1063
1065
1064
1066
// Verify collection of script infos
1065
- service . openClientFile ( dummyFilePath ) ;
1067
+ openFilesForSession ( [ dummyFilePath ] , session ) ;
1066
1068
1067
- service . closeClientFile ( main . path ) ;
1068
- service . closeClientFile ( dummyFilePath ) ;
1069
- service . openClientFile ( dummyFilePath ) ;
1069
+ closeFilesForSession ( [ main , dummyFilePath ] , session ) ;
1070
+ openFilesForSession ( [ dummyFilePath , main ] , session ) ;
1070
1071
1071
- service . openClientFile ( main . path ) ;
1072
- service . closeClientFile ( dummyFilePath ) ;
1073
- service . openClientFile ( dummyFilePath ) ;
1072
+ closeFilesForSession ( [ dummyFilePath ] , session ) ;
1073
+ openFilesForSession ( [ dummyFilePath ] , session ) ;
1074
1074
1075
1075
// Verify Reload projects
1076
- service . reloadProjects ( ) ;
1076
+ session . executeCommandSeq < ts . server . protocol . ReloadProjectsRequest > ( {
1077
+ command : ts . server . protocol . CommandTypes . ReloadProjects ,
1078
+ } ) ;
1077
1079
1078
1080
// Find all refs
1079
1081
session . executeCommandSeq < ts . server . protocol . ReferencesRequest > ( {
1080
1082
command : ts . server . protocol . CommandTypes . References ,
1081
1083
arguments : protocolFileLocationFromSubstring ( main , "foo" , { index : 1 } ) ,
1082
1084
} ) . response as ts . server . protocol . ReferencesResponseBody ;
1083
1085
1084
- service . closeClientFile ( main . path ) ;
1085
- service . closeClientFile ( dummyFilePath ) ;
1086
+ closeFilesForSession ( [ main , dummyFilePath ] , session ) ;
1086
1087
1087
1088
// Verify when declaration map references the file
1088
- service . openClientFile ( fileResolvingToMainDts . path ) ;
1089
+ openFilesForSession ( [ fileResolvingToMainDts ] , session ) ;
1089
1090
1090
1091
// Find all refs from dts include
1091
1092
session . executeCommandSeq < ts . server . protocol . ReferencesRequest > ( {
@@ -1117,25 +1118,24 @@ export function bar() {}`,
1117
1118
}
1118
1119
1119
1120
function verifyDisableReferencedProjectLoad ( input : Setup ) {
1120
- const { session, service } = setup ( input ) ;
1121
+ const { session } = setup ( input ) ;
1121
1122
1122
- const info = service . getScriptInfoForPath ( main . path as ts . Path ) ! ;
1123
+ const info = session . getProjectService ( ) . getScriptInfoForPath ( main . path as ts . Path ) ! ;
1123
1124
session . logger . startGroup ( ) ;
1124
1125
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 } ` ) ;
1126
1127
session . logger . endGroup ( ) ;
1127
1128
1128
1129
// 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 ) ;
1134
1131
1135
- service . openClientFile ( main . path ) ;
1132
+ closeFilesForSession ( [ main , dummyFilePath ] , session ) ;
1133
+ openFilesForSession ( [ dummyFilePath , main ] , session ) ;
1136
1134
1137
1135
// Verify Reload projects
1138
- service . reloadProjects ( ) ;
1136
+ session . executeCommandSeq < ts . server . protocol . ReloadProjectsRequest > ( {
1137
+ command : ts . server . protocol . CommandTypes . ReloadProjects ,
1138
+ } ) ;
1139
1139
baselineTsserverLogs ( "projectReferences" , input . scenario , session ) ;
1140
1140
}
1141
1141
0 commit comments