Calls `action` for each import, re-export, or require() in a file.
(sourceFile, action)
| 136561 | } |
| 136562 | /** Calls `action` for each import, re-export, or require() in a file. */ |
| 136563 | function forEachImport(sourceFile, action) { |
| 136564 | if (sourceFile.externalModuleIndicator || sourceFile.imports !== undefined) { |
| 136565 | for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { |
| 136566 | var i = _a[_i]; |
| 136567 | action(ts.importFromModuleSpecifier(i), i); |
| 136568 | } |
| 136569 | } |
| 136570 | else { |
| 136571 | forEachPossibleImportOrExportStatement(sourceFile, function (statement) { |
| 136572 | switch (statement.kind) { |
| 136573 | case 272 /* SyntaxKind.ExportDeclaration */: |
| 136574 | case 266 /* SyntaxKind.ImportDeclaration */: { |
| 136575 | var decl = statement; |
| 136576 | if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { |
| 136577 | action(decl, decl.moduleSpecifier); |
| 136578 | } |
| 136579 | break; |
| 136580 | } |
| 136581 | case 265 /* SyntaxKind.ImportEqualsDeclaration */: { |
| 136582 | var decl = statement; |
| 136583 | if (isExternalModuleImportEquals(decl)) { |
| 136584 | action(decl, decl.moduleReference.expression); |
| 136585 | } |
| 136586 | break; |
| 136587 | } |
| 136588 | } |
| 136589 | }); |
| 136590 | } |
| 136591 | } |
| 136592 | /** |
| 136593 | * Given a local reference, we might notice that it's an import/export and recursively search for references of that. |
| 136594 | * If at an import, look locally for the symbol it imports. |
no test coverage detected