* Back track through this found SourceFile and its ancestors to generate an array of * SourceFiles that form am import path between two SourceFiles.
()
| 159 | * SourceFiles that form am import path between two SourceFiles. |
| 160 | */ |
| 161 | toPath(): ts.SourceFile[] { |
| 162 | const array: ts.SourceFile[] = []; |
| 163 | let current: Found | null = this; |
| 164 | while (current !== null) { |
| 165 | array.push(current.sourceFile); |
| 166 | current = current.parent; |
| 167 | } |
| 168 | // Pushing and then reversing, O(n), rather than unshifting repeatedly, O(n^2), avoids |
| 169 | // manipulating the array on every iteration: https://stackoverflow.com/a/26370620 |
| 170 | return array.reverse(); |
| 171 | } |
| 172 | } |
no test coverage detected