(w io.Writer, locale locale.Locale)
| 1844 | } |
| 1845 | |
| 1846 | func (p *Program) ExplainFiles(w io.Writer, locale locale.Locale) { |
| 1847 | toRelativeFileName := func(fileName string) string { |
| 1848 | return tspath.GetRelativePathFromDirectory(p.GetCurrentDirectory(), fileName, p.comparePathsOptions) |
| 1849 | } |
| 1850 | filesExplained := 0 |
| 1851 | explainFile := func(file ast.HasFileName) { |
| 1852 | fmt.Fprintln(w, toRelativeFileName(file.FileName())) |
| 1853 | for _, reason := range p.includeProcessor.fileIncludeReasons[file.Path()] { |
| 1854 | fmt.Fprintln(w, " ", reason.toDiagnostic(p, true).Localize(locale)) |
| 1855 | } |
| 1856 | for _, diag := range p.includeProcessor.explainRedirectAndImpliedFormat(p, file.Path(), toRelativeFileName) { |
| 1857 | fmt.Fprintln(w, " ", diag.Localize(locale)) |
| 1858 | } |
| 1859 | filesExplained++ |
| 1860 | } |
| 1861 | |
| 1862 | redirectFiles := slices.Collect(maps.Values(p.redirectFilesByPath)) |
| 1863 | slices.SortFunc(redirectFiles, func(a, b *redirectsFile) int { |
| 1864 | return a.index - b.index |
| 1865 | }) |
| 1866 | |
| 1867 | files := p.GetSourceFiles() |
| 1868 | sourceFileIndex := 0 |
| 1869 | explainSourceFiles := func(endIndex int) { |
| 1870 | for filesExplained < endIndex { |
| 1871 | explainFile(files[sourceFileIndex]) |
| 1872 | sourceFileIndex++ |
| 1873 | } |
| 1874 | } |
| 1875 | |
| 1876 | for _, redirectFile := range redirectFiles { |
| 1877 | // Explain all sourceFiles till we reach this redirectFile index |
| 1878 | explainSourceFiles(redirectFile.index) |
| 1879 | explainFile(redirectFile) |
| 1880 | } |
| 1881 | |
| 1882 | // Explain any remaining sourceFiles |
| 1883 | explainSourceFiles(len(files) + len(redirectFiles)) |
| 1884 | } |
| 1885 | |
| 1886 | func (p *Program) GetLibFileFromReference(ref *ast.FileReference) *ast.SourceFile { |
| 1887 | path, ok := tsoptions.GetLibFileName(ref.FileName) |
no test coverage detected