@@ -88,7 +88,7 @@ namespace ts {
88
88
releaseDocumentWithKey ( path : Path , key : DocumentRegistryBucketKey ) : void ;
89
89
90
90
/*@internal */
91
- hasDocument ( path : Path ) : boolean ;
91
+ getLanguageServiceRefCounts ( path : Path ) : [ string , number | undefined ] [ ] ;
92
92
93
93
reportStats ( ) : string ;
94
94
}
@@ -188,9 +188,10 @@ namespace ts {
188
188
if ( ! entry && externalCache ) {
189
189
const sourceFile = externalCache . getDocument ( key , path ) ;
190
190
if ( sourceFile ) {
191
+ Debug . assert ( acquiring ) ;
191
192
entry = {
192
193
sourceFile,
193
- languageServiceRefCount : 1
194
+ languageServiceRefCount : 0
194
195
} ;
195
196
bucket . set ( path , entry ) ;
196
197
}
@@ -229,6 +230,7 @@ namespace ts {
229
230
entry . languageServiceRefCount ++ ;
230
231
}
231
232
}
233
+ Debug . assert ( entry . languageServiceRefCount !== 0 ) ;
232
234
233
235
return entry . sourceFile ;
234
236
}
@@ -252,8 +254,11 @@ namespace ts {
252
254
}
253
255
}
254
256
255
- function hasDocument ( path : Path ) {
256
- return ! ! forEachEntry ( buckets , bucket => bucket . has ( path ) ) ;
257
+ function getLanguageServiceRefCounts ( path : Path ) {
258
+ return arrayFrom ( buckets . entries ( ) , ( [ key , bucket ] ) : [ string , number | undefined ] => {
259
+ const entry = bucket . get ( path ) ;
260
+ return [ key , entry && entry . languageServiceRefCount ] ;
261
+ } ) ;
257
262
}
258
263
259
264
return {
@@ -263,7 +268,7 @@ namespace ts {
263
268
updateDocumentWithKey,
264
269
releaseDocument,
265
270
releaseDocumentWithKey,
266
- hasDocument ,
271
+ getLanguageServiceRefCounts ,
267
272
reportStats,
268
273
getKeyForCompilationSettings
269
274
} ;
0 commit comments