( info Info, importedFileName string, host ModuleSpecifierGenerationHost, compilerOptions *core.CompilerOptions, options ModuleSpecifierOptions, )
| 196 | } |
| 197 | |
| 198 | func getAllModulePathsWorker( |
| 199 | info Info, |
| 200 | importedFileName string, |
| 201 | host ModuleSpecifierGenerationHost, |
| 202 | compilerOptions *core.CompilerOptions, |
| 203 | options ModuleSpecifierOptions, |
| 204 | ) []ModulePath { |
| 205 | allFileNames := make(map[string]ModulePath) |
| 206 | paths := GetEachFileNameOfModule(info.ImportingSourceFileName, importedFileName, host, true) |
| 207 | for _, p := range paths { |
| 208 | allFileNames[p.FileName] = p |
| 209 | } |
| 210 | |
| 211 | useCaseSensitiveFileNames := info.UseCaseSensitiveFileNames |
| 212 | comparePaths := func(a, b ModulePath) int { |
| 213 | return comparePathsByRedirect(a, b, useCaseSensitiveFileNames) |
| 214 | } |
| 215 | |
| 216 | // Sort by paths closest to importing file Name directory |
| 217 | sortedPaths := make([]ModulePath, 0, len(paths)) |
| 218 | for directory := info.SourceDirectory; len(allFileNames) != 0; { |
| 219 | directoryStart := tspath.EnsureTrailingDirectorySeparator(directory) |
| 220 | var pathsInDirectory []ModulePath |
| 221 | for fileName, p := range allFileNames { |
| 222 | if strings.HasPrefix(fileName, directoryStart) { |
| 223 | pathsInDirectory = append(pathsInDirectory, p) |
| 224 | delete(allFileNames, fileName) |
| 225 | } |
| 226 | } |
| 227 | if len(pathsInDirectory) > 0 { |
| 228 | slices.SortFunc(pathsInDirectory, comparePaths) |
| 229 | sortedPaths = append(sortedPaths, pathsInDirectory...) |
| 230 | } |
| 231 | newDirectory := tspath.GetDirectoryPath(directory) |
| 232 | if newDirectory == directory { |
| 233 | break |
| 234 | } |
| 235 | directory = newDirectory |
| 236 | } |
| 237 | if len(allFileNames) > 0 { |
| 238 | remainingPaths := slices.Collect(maps.Values(allFileNames)) |
| 239 | slices.SortFunc(remainingPaths, comparePaths) |
| 240 | sortedPaths = append(sortedPaths, remainingPaths...) |
| 241 | } |
| 242 | return sortedPaths |
| 243 | } |
| 244 | |
| 245 | // containsIgnoredPath checks if a path contains patterns that should be ignored. |
| 246 | // This is a local helper that duplicates tspath.ContainsIgnoredPath for performance. |
no test coverage detected