MCPcopy Create free account
hub / github.com/microsoft/typescript-go / getProcessedFiles

Method getProcessedFiles

internal/compiler/filesparser.go:306–555  ·  view source on GitHub ↗
(loader *fileLoader)

Source from the content-addressed store, hash-verified

304}
305
306func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles {
307 totalFileCount := int(loader.totalFileCount.Load())
308 libFileCount := int(loader.libFileCount.Load())
309
310 var missingFiles []string
311 var duplicateSourceFiles []*DuplicateSourceFile
312 files := make([]*ast.SourceFile, 0, totalFileCount-libFileCount)
313 libFiles := make([]*ast.SourceFile, 0, totalFileCount) // totalFileCount here since we append files to it later to construct the final list
314
315 filesByPath := make(map[tspath.Path]*ast.SourceFile, totalFileCount)
316 // stores 'filename -> file association' ignoring case
317 // used to track cases when two file names differ only in casing
318 var tasksSeenByNameIgnoreCase map[string]*parseTask
319 if loader.comparePathsOptions.UseCaseSensitiveFileNames {
320 tasksSeenByNameIgnoreCase = make(map[string]*parseTask, totalFileCount)
321 }
322
323 includeProcessor := &includeProcessor{
324 fileIncludeReasons: make(map[tspath.Path][]*FileIncludeReason, totalFileCount),
325 }
326 var outputFileToProjectReferenceSource map[tspath.Path]string
327 if !loader.opts.canUseProjectReferenceSource() {
328 outputFileToProjectReferenceSource = make(map[tspath.Path]string, totalFileCount)
329 }
330 resolvedModules := make(map[tspath.Path]module.ModeAwareCache[*module.ResolvedModule], totalFileCount+1)
331 typeResolutionsInFile := make(map[tspath.Path]module.ModeAwareCache[*module.ResolvedTypeReferenceDirective], totalFileCount)
332 sourceFileMetaDatas := make(map[tspath.Path]ast.SourceFileMetaData, totalFileCount)
333 var jsxRuntimeImportSpecifiers map[tspath.Path]*jsxRuntimeImportSpecifier
334 var importHelpersImportSpecifiers map[tspath.Path]*ast.StringLiteralNode
335 var sourceFilesFoundSearchingNodeModules collections.Set[tspath.Path]
336 libFilesMap := make(map[tspath.Path]*LibFile, libFileCount)
337
338 var redirectTargetsMap map[tspath.Path][]string
339 var redirectFilesByPath map[tspath.Path]*redirectsFile
340 var packageIdToSourceFile map[module.PackageId]*ast.SourceFile
341 if !loader.opts.Config.CompilerOptions().DeduplicatePackages.IsFalse() {
342 redirectTargetsMap = make(map[tspath.Path][]string)
343 packageIdToSourceFile = make(map[module.PackageId]*ast.SourceFile)
344 }
345
346 var collectFiles func(tasks []*parseTask, seen map[*parseTaskData]string)
347 // recordedDuplicates tracks, per task data, the set of file-name casings that
348 // have already been recorded in duplicateSourceFiles. A file that is reached
349 // from multiple import sites is walked once per site, but each distinct casing
350 // is only parsed and acquired in the parse cache once. Recording the same casing
351 // as a duplicate more than once would cause it to be released more times than it
352 // was acquired when the snapshot is disposed, leaving a dangling cache entry that
353 // panics the next time it is referenced.
354 var recordedDuplicates map[*parseTaskData]*collections.Set[string]
355 collectFiles = func(tasks []*parseTask, seen map[*parseTaskData]string) {
356 for _, task := range tasks {
357 includeReason := task.includeReason
358 // Exclude automatic type directive tasks from include reason processing,
359 // as these are internal implementation details and should not contribute
360 // to the reasons for including files.
361 if task.redirectedParseTask == nil && !task.isForAutomaticTypeDirective {
362 if task.loadedTask != nil {
363 task = task.loadedTask

Callers 1

processAllProgramFilesFunction · 0.80

Calls 15

addIncludeReasonMethod · 0.95
ToFileNameLowerCaseFunction · 0.92
lenFunction · 0.85
IsFalseMethod · 0.80
ParseOptionsMethod · 0.80
sortLibsMethod · 0.80
CompilerOptionsMethod · 0.65
TraceMethod · 0.65
PathMethod · 0.65

Tested by

no test coverage detected