@@ -867,11 +867,15 @@ namespace ts {
867
867
forEachResolvedProjectReference
868
868
} ) ;
869
869
870
+ tracing . push ( tracing . Phase . Program , "shouldProgramCreateNewSourceFiles" , { hasOldProgram : ! ! oldProgram } ) ;
870
871
const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles ( oldProgram , options ) ;
872
+ tracing . pop ( ) ;
871
873
// We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks
872
874
// `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`.
873
875
let structureIsReused : StructureIsReused ;
876
+ tracing . push ( tracing . Phase . Program , "tryReuseStructureFromOldProgram" , { } ) ;
874
877
structureIsReused = tryReuseStructureFromOldProgram ( ) ; // eslint-disable-line prefer-const
878
+ tracing . pop ( ) ;
875
879
if ( structureIsReused !== StructureIsReused . Completely ) {
876
880
processingDefaultLibFiles = [ ] ;
877
881
processingOtherFiles = [ ] ;
@@ -907,19 +911,23 @@ namespace ts {
907
911
}
908
912
}
909
913
914
+ tracing . push ( tracing . Phase . Program , "processRootFiles" , { count : rootNames . length } ) ;
910
915
forEach ( rootNames , name => processRootFile ( name , /*isDefaultLib*/ false , /*ignoreNoDefaultLib*/ false ) ) ;
916
+ tracing . pop ( ) ;
911
917
912
918
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
913
919
const typeReferences : string [ ] = rootNames . length ? getAutomaticTypeDirectiveNames ( options , host ) : emptyArray ;
914
920
915
921
if ( typeReferences . length ) {
922
+ tracing . push ( tracing . Phase . Program , "processTypeReferences" , { count : typeReferences . length } ) ;
916
923
// This containingFilename needs to match with the one used in managed-side
917
924
const containingDirectory = options . configFilePath ? getDirectoryPath ( options . configFilePath ) : host . getCurrentDirectory ( ) ;
918
925
const containingFilename = combinePaths ( containingDirectory , inferredTypesContainingFile ) ;
919
926
const resolutions = resolveTypeReferenceDirectiveNamesWorker ( typeReferences , containingFilename ) ;
920
927
for ( let i = 0 ; i < typeReferences . length ; i ++ ) {
921
928
processTypeReferenceDirective ( typeReferences [ i ] , resolutions [ i ] ) ;
922
929
}
930
+ tracing . pop ( ) ;
923
931
}
924
932
925
933
// Do not process the default library if:
@@ -1041,21 +1049,25 @@ namespace ts {
1041
1049
if ( ! moduleNames . length ) return emptyArray ;
1042
1050
const containingFileName = getNormalizedAbsolutePath ( containingFile . originalFileName , currentDirectory ) ;
1043
1051
const redirectedReference = getRedirectReferenceForResolution ( containingFile ) ;
1052
+ tracing . push ( tracing . Phase . Program , "resolveModuleNamesWorker" , { containingFileName } ) ;
1044
1053
performance . mark ( "beforeResolveModule" ) ;
1045
1054
const result = actualResolveModuleNamesWorker ( moduleNames , containingFileName , reusedNames , redirectedReference ) ;
1046
1055
performance . mark ( "afterResolveModule" ) ;
1047
1056
performance . measure ( "ResolveModule" , "beforeResolveModule" , "afterResolveModule" ) ;
1057
+ tracing . pop ( ) ;
1048
1058
return result ;
1049
1059
}
1050
1060
1051
1061
function resolveTypeReferenceDirectiveNamesWorker ( typeDirectiveNames : string [ ] , containingFile : string | SourceFile ) : readonly ( ResolvedTypeReferenceDirective | undefined ) [ ] {
1052
1062
if ( ! typeDirectiveNames . length ) return [ ] ;
1053
- performance . mark ( "beforeResolveTypeReference" ) ;
1054
1063
const containingFileName = ! isString ( containingFile ) ? getNormalizedAbsolutePath ( containingFile . originalFileName , currentDirectory ) : containingFile ;
1055
1064
const redirectedReference = ! isString ( containingFile ) ? getRedirectReferenceForResolution ( containingFile ) : undefined ;
1065
+ tracing . push ( tracing . Phase . Program , "resolveTypeReferenceDirectiveNamesWorker" , { containingFileName } ) ;
1066
+ performance . mark ( "beforeResolveTypeReference" ) ;
1056
1067
const result = actualResolveTypeReferenceDirectiveNamesWorker ( typeDirectiveNames , containingFileName , redirectedReference ) ;
1057
1068
performance . mark ( "afterResolveTypeReference" ) ;
1058
1069
performance . measure ( "ResolveTypeReference" , "beforeResolveTypeReference" , "afterResolveTypeReference" ) ;
1070
+ tracing . pop ( ) ;
1059
1071
return result ;
1060
1072
}
1061
1073
@@ -2426,6 +2438,17 @@ namespace ts {
2426
2438
2427
2439
// Get source file from normalized fileName
2428
2440
function findSourceFile ( fileName : string , path : Path , isDefaultLib : boolean , ignoreNoDefaultLib : boolean , refFile : RefFile | undefined , packageId : PackageId | undefined ) : SourceFile | undefined {
2441
+ tracing . push ( tracing . Phase . Program , "findSourceFile" , {
2442
+ fileName,
2443
+ isDefaultLib : isDefaultLib || undefined ,
2444
+ refKind : refFile ? ( RefFileKind as any ) [ refFile . kind ] : undefined ,
2445
+ } ) ;
2446
+ const result = findSourceFileWorker ( fileName , path , isDefaultLib , ignoreNoDefaultLib , refFile , packageId ) ;
2447
+ tracing . pop ( ) ;
2448
+ return result ;
2449
+ }
2450
+
2451
+ function findSourceFileWorker ( fileName : string , path : Path , isDefaultLib : boolean , ignoreNoDefaultLib : boolean , refFile : RefFile | undefined , packageId : PackageId | undefined ) : SourceFile | undefined {
2429
2452
if ( useSourceOfProjectReferenceRedirect ) {
2430
2453
let source = getSourceOfProjectReferenceRedirect ( fileName ) ;
2431
2454
// If preserveSymlinks is true, module resolution wont jump the symlink
@@ -2750,6 +2773,16 @@ namespace ts {
2750
2773
resolvedTypeReferenceDirective ?: ResolvedTypeReferenceDirective ,
2751
2774
refFile ?: RefFile
2752
2775
) : void {
2776
+ tracing . push ( tracing . Phase . Program , "processTypeReferenceDirective" , { directive : typeReferenceDirective , hasResolved : ! ! resolveModuleNamesReusingOldState , refKind : refFile ?. kind , refPath : refFile ?. file . path } ) ;
2777
+ processTypeReferenceDirectiveWorker ( typeReferenceDirective , resolvedTypeReferenceDirective , refFile ) ;
2778
+ tracing . pop ( ) ;
2779
+ }
2780
+
2781
+ function processTypeReferenceDirectiveWorker (
2782
+ typeReferenceDirective : string ,
2783
+ resolvedTypeReferenceDirective ?: ResolvedTypeReferenceDirective ,
2784
+ refFile ?: RefFile
2785
+ ) : void {
2753
2786
2754
2787
// If we already found this library as a primary reference - nothing to do
2755
2788
const previousResolution = resolvedTypeReferenceDirectives . get ( typeReferenceDirective ) ;
0 commit comments