MCPcopy Index your code
hub / github.com/nodejs/node / getDirectImportsMap

Function getDirectImportsMap

test/fixtures/snapshot/typescript.js:136536–136555  ·  view source on GitHub ↗

Returns a map from a module symbol Id to all import statements that directly reference the module.

(sourceFiles, checker, cancellationToken)

Source from the content-addressed store, hash-verified

136534 FindAllReferences.findModuleReferences = findModuleReferences;
136535 /** Returns a map from a module symbol Id to all import statements that directly reference the module. */
136536 function getDirectImportsMap(sourceFiles, checker, cancellationToken) {
136537 var map = new ts.Map();
136538 for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) {
136539 var sourceFile = sourceFiles_2[_i];
136540 if (cancellationToken)
136541 cancellationToken.throwIfCancellationRequested();
136542 forEachImport(sourceFile, function (importDecl, moduleSpecifier) {
136543 var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier);
136544 if (moduleSymbol) {
136545 var id = ts.getSymbolId(moduleSymbol).toString();
136546 var imports = map.get(id);
136547 if (!imports) {
136548 map.set(id, imports = []);
136549 }
136550 imports.push(importDecl);
136551 }
136552 });
136553 }
136554 return map;
136555 }
136556 /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */
136557 function forEachPossibleImportOrExportStatement(sourceFileLike, action) {
136558 return ts.forEach(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) {

Callers 1

createImportTrackerFunction · 0.85

Calls 5

forEachImportFunction · 0.85
getMethod · 0.65
toStringMethod · 0.45
setMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected