@@ -348,7 +348,7 @@ namespace ts {
348348 ? ( ( moduleNames : string [ ] , containingFile : string ) => host . resolveModuleNames ( moduleNames , containingFile ) )
349349 : ( ( moduleNames : string [ ] , containingFile : string ) => map ( moduleNames , moduleName => resolveModuleName ( moduleName , containingFile , options , host ) . resolvedModule ) ) ;
350350
351- let filesByName = createFileMap < SourceFile > ( getCanonicalFileName ) ;
351+ let filesByName = createFileMap < SourceFile > ( ) ;
352352 // stores 'filename -> file association' ignoring case
353353 // used to track cases when two file names differ only in casing
354354 let filesByNameIgnoreCase = host . useCaseSensitiveFileNames ( ) ? createFileMap < SourceFile > ( fileName => fileName . toLowerCase ( ) ) : undefined ;
@@ -384,7 +384,7 @@ namespace ts {
384384
385385 program = {
386386 getRootFileNames : ( ) => rootNames ,
387- getSourceFile : getSourceFile ,
387+ getSourceFile,
388388 getSourceFiles : ( ) => files ,
389389 getCompilerOptions : ( ) => options ,
390390 getSyntacticDiagnostics,
@@ -440,7 +440,7 @@ namespace ts {
440440
441441 // check if program source files has changed in the way that can affect structure of the program
442442 let newSourceFiles : SourceFile [ ] = [ ] ;
443- let normalizedAbsoluteFileNames : string [ ] = [ ] ;
443+ let filePaths : Path [ ] = [ ] ;
444444 let modifiedSourceFiles : SourceFile [ ] = [ ] ;
445445
446446 for ( let oldSourceFile of oldProgram . getSourceFiles ( ) ) {
@@ -449,8 +449,8 @@ namespace ts {
449449 return false ;
450450 }
451451
452- const normalizedAbsolutePath = getNormalizedAbsolutePath ( newSourceFile . fileName , currentDirectory ) ;
453- normalizedAbsoluteFileNames . push ( normalizedAbsolutePath ) ;
452+ newSourceFile . path = oldSourceFile . path ;
453+ filePaths . push ( newSourceFile . path ) ;
454454
455455 if ( oldSourceFile !== newSourceFile ) {
456456 if ( oldSourceFile . hasNoDefaultLib !== newSourceFile . hasNoDefaultLib ) {
@@ -474,7 +474,7 @@ namespace ts {
474474
475475 if ( resolveModuleNamesWorker ) {
476476 let moduleNames = map ( newSourceFile . imports , name => name . text ) ;
477- let resolutions = resolveModuleNamesWorker ( moduleNames , normalizedAbsolutePath ) ;
477+ let resolutions = resolveModuleNamesWorker ( moduleNames , getNormalizedAbsolutePath ( newSourceFile . fileName , currentDirectory ) ) ;
478478 // ensure that module resolution results are still correct
479479 for ( let i = 0 ; i < moduleNames . length ; ++ i ) {
480480 let newResolution = resolutions [ i ] ;
@@ -505,7 +505,7 @@ namespace ts {
505505
506506 // update fileName -> file mapping
507507 for ( let i = 0 , len = newSourceFiles . length ; i < len ; ++ i ) {
508- filesByName . set ( normalizedAbsoluteFileNames [ i ] , newSourceFiles [ i ] ) ;
508+ filesByName . set ( filePaths [ i ] , newSourceFiles [ i ] ) ;
509509 }
510510
511511 files = newSourceFiles ;
@@ -580,7 +580,7 @@ namespace ts {
580580 }
581581
582582 function getSourceFile ( fileName : string ) : SourceFile {
583- return filesByName . get ( getNormalizedAbsolutePath ( fileName , currentDirectory ) ) ;
583+ return filesByName . get ( toPath ( fileName , currentDirectory , getCanonicalFileName ) ) ;
584584 }
585585
586586 function getDiagnosticsHelper (
@@ -920,7 +920,7 @@ namespace ts {
920920 diagnostic = Diagnostics . File_0_has_unsupported_extension_The_only_supported_extensions_are_1 ;
921921 diagnosticArgument = [ fileName , "'" + supportedExtensions . join ( "', '" ) + "'" ] ;
922922 }
923- else if ( ! findSourceFile ( fileName , getNormalizedAbsolutePath ( fileName , currentDirectory ) , isDefaultLib , supportedExtensions , refFile , refPos , refEnd ) ) {
923+ else if ( ! findSourceFile ( fileName , toPath ( fileName , currentDirectory , getCanonicalFileName ) , isDefaultLib , supportedExtensions , refFile , refPos , refEnd ) ) {
924924 diagnostic = Diagnostics . File_0_not_found ;
925925 diagnosticArgument = [ fileName ] ;
926926 }
@@ -930,13 +930,13 @@ namespace ts {
930930 }
931931 }
932932 else {
933- let nonTsFile : SourceFile = options . allowNonTsExtensions && findSourceFile ( fileName , getNormalizedAbsolutePath ( fileName , currentDirectory ) , isDefaultLib , supportedExtensions , refFile , refPos , refEnd ) ;
933+ let nonTsFile : SourceFile = options . allowNonTsExtensions && findSourceFile ( fileName , toPath ( fileName , currentDirectory , getCanonicalFileName ) , isDefaultLib , supportedExtensions , refFile , refPos , refEnd ) ;
934934 if ( ! nonTsFile ) {
935935 if ( options . allowNonTsExtensions ) {
936936 diagnostic = Diagnostics . File_0_not_found ;
937937 diagnosticArgument = [ fileName ] ;
938938 }
939- else if ( ! forEach ( getSupportedExtensions ( options ) , extension => findSourceFile ( fileName + extension , getNormalizedAbsolutePath ( fileName + extension , currentDirectory ) , isDefaultLib , supportedExtensions , refFile , refPos , refEnd ) ) ) {
939+ else if ( ! forEach ( getSupportedExtensions ( options ) , extension => findSourceFile ( fileName + extension , toPath ( fileName + extension , currentDirectory , getCanonicalFileName ) , isDefaultLib , supportedExtensions , refFile , refPos , refEnd ) ) ) {
940940 // (TODO: shkamat) Should this message be different given we support multiple extensions
941941 diagnostic = Diagnostics . File_0_not_found ;
942942 fileName += ".ts" ;
@@ -966,7 +966,7 @@ namespace ts {
966966 }
967967
968968 // Get source file from normalized fileName
969- function findSourceFile ( fileName : string , normalizedAbsolutePath : string , isDefaultLib : boolean , supportedExtensions : string [ ] , refFile ?: SourceFile , refPos ?: number , refEnd ?: number ) : SourceFile {
969+ function findSourceFile ( fileName : string , normalizedAbsolutePath : Path , isDefaultLib : boolean , supportedExtensions : string [ ] , refFile ?: SourceFile , refPos ?: number , refEnd ?: number ) : SourceFile {
970970 if ( filesByName . contains ( normalizedAbsolutePath ) ) {
971971 const file = filesByName . get ( normalizedAbsolutePath ) ;
972972 // try to check if we've already seen this file but with a different casing in path
@@ -991,6 +991,8 @@ namespace ts {
991991
992992 filesByName . set ( normalizedAbsolutePath , file ) ;
993993 if ( file ) {
994+ file . path = normalizedAbsolutePath ;
995+
994996 if ( host . useCaseSensitiveFileNames ( ) ) {
995997 // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case
996998 const existingFile = filesByNameIgnoreCase . get ( normalizedAbsolutePath ) ;
@@ -1045,14 +1047,7 @@ namespace ts {
10451047 let resolution = resolutions [ i ] ;
10461048 setResolvedModule ( file , moduleNames [ i ] , resolution ) ;
10471049 if ( resolution && ! options . noResolve ) {
1048- const absoluteImportPath = isRootedDiskPath ( resolution . resolvedFileName )
1049- ? resolution . resolvedFileName
1050- : getNormalizedAbsolutePath ( resolution . resolvedFileName , currentDirectory ) ;
1051-
1052- // convert an absolute import path to path that is relative to current directory
1053- // this was host still can locate it but files names in user output will be shorter (and thus look nicer).
1054- const relativePath = getRelativePathToDirectoryOrUrl ( currentDirectory , absoluteImportPath , currentDirectory , getCanonicalFileName , false ) ;
1055- const importedFile = findSourceFile ( relativePath , absoluteImportPath , /* isDefaultLib */ false , supportedExtensions , file , skipTrivia ( file . text , file . imports [ i ] . pos ) , file . imports [ i ] . end ) ;
1050+ const importedFile = findSourceFile ( resolution . resolvedFileName , toPath ( resolution . resolvedFileName , currentDirectory , getCanonicalFileName ) , /* isDefaultLib */ false , supportedExtensions , file , skipTrivia ( file . text , file . imports [ i ] . pos ) , file . imports [ i ] . end ) ;
10561051
10571052 if ( importedFile && resolution . isExternalLibraryImport ) {
10581053 if ( ! isExternalModule ( importedFile ) ) {
0 commit comments