@@ -148,11 +148,6 @@ namespace ts {
148
148
return false ;
149
149
}
150
150
151
- /**
152
- * Compute the hash to store the shape of the file
153
- */
154
- export type ComputeHash = ( ( data : string ) => string ) | undefined ;
155
-
156
151
function getReferencedFilesFromImportedModuleSymbol ( symbol : Symbol ) : Path [ ] {
157
152
return mapDefined ( symbol . declarations , declaration => getSourceFileOfNode ( declaration ) ?. resolvedPath ) ;
158
153
}
@@ -262,11 +257,12 @@ namespace ts {
262
257
/**
263
258
* Creates the state of file references and signature for the new program from oldState if it is safe
264
259
*/
265
- export function create ( newProgram : Program , getCanonicalFileName : GetCanonicalFileName , oldState ?: Readonly < BuilderState > , disableUseFileVersionAsSignature ?: boolean ) : BuilderState {
260
+ export function create ( newProgram : Program , oldState ?: Readonly < BuilderState > , disableUseFileVersionAsSignature ?: boolean ) : BuilderState {
266
261
const fileInfos = new Map < Path , FileInfo > ( ) ;
267
262
const referencedMap = newProgram . getCompilerOptions ( ) . module !== ModuleKind . None ? createManyToManyPathMap ( ) : undefined ;
268
263
const exportedModulesMap = referencedMap ? createManyToManyPathMap ( ) : undefined ;
269
264
const useOldState = canReuseOldState ( referencedMap , oldState ) ;
265
+ const getCanonicalFileName = createGetCanonicalFileName ( newProgram . useCaseSensitiveFileNames ( ) ) ;
270
266
271
267
// Ensure source files have parent pointers set
272
268
newProgram . getTypeChecker ( ) ;
@@ -326,16 +322,14 @@ namespace ts {
326
322
programOfThisState : Program ,
327
323
path : Path ,
328
324
cancellationToken : CancellationToken | undefined ,
329
- computeHash : ComputeHash ,
330
- getCanonicalFileName : GetCanonicalFileName ,
325
+ host : HostForComputeHash ,
331
326
) : readonly SourceFile [ ] {
332
327
const result = getFilesAffectedByWithOldState (
333
328
state ,
334
329
programOfThisState ,
335
330
path ,
336
331
cancellationToken ,
337
- computeHash ,
338
- getCanonicalFileName ,
332
+ host ,
339
333
) ;
340
334
state . oldSignatures ?. clear ( ) ;
341
335
state . oldExportedModulesMap ?. clear ( ) ;
@@ -347,19 +341,18 @@ namespace ts {
347
341
programOfThisState : Program ,
348
342
path : Path ,
349
343
cancellationToken : CancellationToken | undefined ,
350
- computeHash : ComputeHash ,
351
- getCanonicalFileName : GetCanonicalFileName ,
344
+ host : HostForComputeHash ,
352
345
) : readonly SourceFile [ ] {
353
346
const sourceFile = programOfThisState . getSourceFileByPath ( path ) ;
354
347
if ( ! sourceFile ) {
355
348
return emptyArray ;
356
349
}
357
350
358
- if ( ! updateShapeSignature ( state , programOfThisState , sourceFile , cancellationToken , computeHash , getCanonicalFileName ) ) {
351
+ if ( ! updateShapeSignature ( state , programOfThisState , sourceFile , cancellationToken , host ) ) {
359
352
return [ sourceFile ] ;
360
353
}
361
354
362
- return ( state . referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit ) ( state , programOfThisState , sourceFile , cancellationToken , computeHash , getCanonicalFileName ) ;
355
+ return ( state . referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit ) ( state , programOfThisState , sourceFile , cancellationToken , host ) ;
363
356
}
364
357
365
358
export function updateSignatureOfFile ( state : BuilderState , signature : string | undefined , path : Path ) {
@@ -375,8 +368,7 @@ namespace ts {
375
368
programOfThisState : Program ,
376
369
sourceFile : SourceFile ,
377
370
cancellationToken : CancellationToken | undefined ,
378
- computeHash : ComputeHash ,
379
- getCanonicalFileName : GetCanonicalFileName ,
371
+ host : HostForComputeHash ,
380
372
useFileVersionAsSignature = state . useFileVersionAsSignature
381
373
) {
382
374
// If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
@@ -393,8 +385,8 @@ namespace ts {
393
385
latestSignature = computeSignatureWithDiagnostics (
394
386
sourceFile ,
395
387
text ,
396
- computeHash ,
397
- getCanonicalFileName ,
388
+ host ,
389
+ createGetCanonicalFileName ( programOfThisState . useCaseSensitiveFileNames ( ) ) ,
398
390
data ,
399
391
) ;
400
392
if ( latestSignature !== prevSignature ) {
@@ -590,8 +582,7 @@ namespace ts {
590
582
programOfThisState : Program ,
591
583
sourceFileWithUpdatedShape : SourceFile ,
592
584
cancellationToken : CancellationToken | undefined ,
593
- computeHash : ComputeHash ,
594
- getCanonicalFileName : GetCanonicalFileName ,
585
+ host : HostForComputeHash ,
595
586
) {
596
587
if ( isFileAffectingGlobalScope ( sourceFileWithUpdatedShape ) ) {
597
588
return getAllFilesExcludingDefaultLibraryFile ( state , programOfThisState , sourceFileWithUpdatedShape ) ;
@@ -615,7 +606,7 @@ namespace ts {
615
606
if ( ! seenFileNamesMap . has ( currentPath ) ) {
616
607
const currentSourceFile = programOfThisState . getSourceFileByPath ( currentPath ) ! ;
617
608
seenFileNamesMap . set ( currentPath , currentSourceFile ) ;
618
- if ( currentSourceFile && updateShapeSignature ( state , programOfThisState , currentSourceFile , cancellationToken , computeHash , getCanonicalFileName ) ) {
609
+ if ( currentSourceFile && updateShapeSignature ( state , programOfThisState , currentSourceFile , cancellationToken , host ) ) {
619
610
queue . push ( ...getReferencedByPaths ( state , currentSourceFile . resolvedPath ) ) ;
620
611
}
621
612
}
0 commit comments