( opts ProgramOptions, singleThreaded bool, )
| 120 | } |
| 121 | |
| 122 | func processAllProgramFiles( |
| 123 | opts ProgramOptions, |
| 124 | singleThreaded bool, |
| 125 | ) processedFiles { |
| 126 | compilerOptions := opts.Config.CompilerOptions() |
| 127 | rootFiles := opts.Config.FileNames() |
| 128 | supportedExtensions := tsoptions.GetSupportedExtensions(compilerOptions, nil /*extraFileExtensions*/) |
| 129 | supportedExtensionsWithJsonIfResolveJsonModule := tsoptions.GetSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions) |
| 130 | var maxNodeModuleJsDepth int |
| 131 | if p := opts.Config.CompilerOptions().MaxNodeModuleJsDepth; p != nil { |
| 132 | maxNodeModuleJsDepth = *p |
| 133 | } |
| 134 | loader := fileLoader{ |
| 135 | opts: opts, |
| 136 | defaultLibraryPath: tspath.GetNormalizedAbsolutePath(opts.Host.DefaultLibraryPath(), opts.Host.GetCurrentDirectory()), |
| 137 | comparePathsOptions: tspath.ComparePathsOptions{ |
| 138 | UseCaseSensitiveFileNames: opts.Host.FS().UseCaseSensitiveFileNames(), |
| 139 | CurrentDirectory: opts.Host.GetCurrentDirectory(), |
| 140 | }, |
| 141 | filesParser: &filesParser{ |
| 142 | wg: core.NewWorkGroup(singleThreaded), |
| 143 | maxDepth: maxNodeModuleJsDepth, |
| 144 | }, |
| 145 | rootTasks: make([]*parseTask, 0, len(rootFiles)+len(compilerOptions.Lib)), |
| 146 | supportedExtensions: supportedExtensions, |
| 147 | supportedExtensionsWithJsonIfResolveJsonModule: supportedExtensionsWithJsonIfResolveJsonModule, |
| 148 | } |
| 149 | loader.addProjectReferenceTasks(singleThreaded) |
| 150 | loader.resolver = module.NewResolver(loader.projectReferenceFileMapper.host, compilerOptions, opts.TypingsLocation, opts.ProjectName) |
| 151 | if opts.Tracing != nil { |
| 152 | defer opts.Tracing.Push(tracing.PhaseProgram, "processRootFiles", map[string]any{"count": len(rootFiles)}, false)() |
| 153 | } |
| 154 | for index, rootFile := range rootFiles { |
| 155 | loader.addRootFileTask(rootFile, nil, &FileIncludeReason{kind: fileIncludeKindRootFile, data: index}) |
| 156 | } |
| 157 | if len(rootFiles) > 0 && compilerOptions.NoLib.IsFalseOrUnknown() { |
| 158 | if compilerOptions.Lib == nil { |
| 159 | name := tsoptions.GetDefaultLibFileName(compilerOptions) |
| 160 | libFile := loader.pathForLibFile(name) |
| 161 | loader.addRootTask(libFile.path, libFile, &FileIncludeReason{kind: fileIncludeKindLibFile}) |
| 162 | |
| 163 | } else { |
| 164 | for index, lib := range compilerOptions.Lib { |
| 165 | if name, ok := tsoptions.GetLibFileName(lib); ok { |
| 166 | libFile := loader.pathForLibFile(name) |
| 167 | loader.addRootTask(libFile.path, libFile, &FileIncludeReason{kind: fileIncludeKindLibFile, data: index}) |
| 168 | } |
| 169 | // !!! error on unknown name |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | if len(rootFiles) > 0 { |
| 175 | loader.addAutomaticTypeDirectiveTasks() |
| 176 | } |
| 177 | |
| 178 | loader.filesParser.parse(&loader, loader.rootTasks) |
| 179 |
no test coverage detected