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

Function forEachFileNameOfModule

test/fixtures/snapshot/typescript.js:122219–122264  ·  view source on GitHub ↗
(importingFileName, importedFileName, host, preferSymlinks, cb)

Source from the content-addressed store, hash-verified

122217 });
122218 }
122219 function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
122220 var _a;
122221 var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
122222 var cwd = host.getCurrentDirectory();
122223 var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined;
122224 var importedPath = ts.toPath(importedFileName, cwd, getCanonicalFileName);
122225 var redirects = host.redirectTargetsMap.get(importedPath) || ts.emptyArray;
122226 var importedFileNames = __spreadArray(__spreadArray(__spreadArray([], (referenceRedirect ? [referenceRedirect] : ts.emptyArray), true), [importedFileName], false), redirects, true);
122227 var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); });
122228 var shouldFilterIgnoredPaths = !ts.every(targets, ts.containsIgnoredPath);
122229 if (!preferSymlinks) {
122230 // Symlinks inside ignored paths are already filtered out of the symlink cache,
122231 // so we only need to remove them from the realpath filenames.
122232 var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
122233 if (result_15)
122234 return result_15;
122235 }
122236 var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
122237 var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
122238 var result = symlinkedDirectories && ts.forEachAncestorDirectory(ts.getDirectoryPath(fullImportedFileName), function (realPathDirectory) {
122239 var symlinkDirectories = symlinkedDirectories.get(ts.ensureTrailingDirectorySeparator(ts.toPath(realPathDirectory, cwd, getCanonicalFileName)));
122240 if (!symlinkDirectories)
122241 return undefined; // Continue to ancestor directory
122242 // Don't want to a package to globally import from itself (importNameCodeFix_symlink_own_package.ts)
122243 if (ts.startsWithDirectory(importingFileName, realPathDirectory, getCanonicalFileName)) {
122244 return false; // Stop search, each ancestor directory will also hit this condition
122245 }
122246 return ts.forEach(targets, function (target) {
122247 if (!ts.startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) {
122248 return;
122249 }
122250 var relative = ts.getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName);
122251 for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
122252 var symlinkDirectory = symlinkDirectories_1[_i];
122253 var option = ts.resolvePath(symlinkDirectory, relative);
122254 var result_16 = cb(option, target === referenceRedirect);
122255 shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
122256 if (result_16)
122257 return result_16;
122258 }
122259 });
122260 });
122261 return result || (preferSymlinks
122262 ? ts.forEach(targets, function (p) { return shouldFilterIgnoredPaths && ts.containsIgnoredPath(p) ? undefined : cb(p, p === referenceRedirect); })
122263 : undefined);
122264 }
122265 moduleSpecifiers_1.forEachFileNameOfModule = forEachFileNameOfModule;
122266 /**
122267 * Looks for existing imports that use symlinks to this module.

Callers 1

getAllModulePathsWorkerFunction · 0.85

Calls 6

everyMethod · 0.80
getMethod · 0.65
mapMethod · 0.65
forEachMethod · 0.65
cbFunction · 0.50
callMethod · 0.45

Tested by

no test coverage detected