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

Function findModuleReferences

test/fixtures/snapshot/typescript.js:136504–136533  ·  view source on GitHub ↗
(program, sourceFiles, searchModuleSymbol)

Source from the content-addressed store, hash-verified

136502 });
136503 }
136504 function findModuleReferences(program, sourceFiles, searchModuleSymbol) {
136505 var refs = [];
136506 var checker = program.getTypeChecker();
136507 for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) {
136508 var referencingFile = sourceFiles_1[_i];
136509 var searchSourceFile = searchModuleSymbol.valueDeclaration;
136510 if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SyntaxKind.SourceFile */) {
136511 for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) {
136512 var ref = _b[_a];
136513 if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) {
136514 refs.push({ kind: "reference", referencingFile: referencingFile, ref: ref });
136515 }
136516 }
136517 for (var _c = 0, _d = referencingFile.typeReferenceDirectives; _c < _d.length; _c++) {
136518 var ref = _d[_c];
136519 var referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName, ref.resolutionMode || referencingFile.impliedNodeFormat);
136520 if (referenced !== undefined && referenced.resolvedFileName === searchSourceFile.fileName) {
136521 refs.push({ kind: "reference", referencingFile: referencingFile, ref: ref });
136522 }
136523 }
136524 }
136525 forEachImport(referencingFile, function (_importDecl, moduleSpecifier) {
136526 var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier);
136527 if (moduleSymbol === searchModuleSymbol) {
136528 refs.push({ kind: "import", literal: moduleSpecifier });
136529 }
136530 });
136531 }
136532 return refs;
136533 }
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) {

Callers

nothing calls this directly

Calls 3

forEachImportFunction · 0.85
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected