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

Function findSourceFileWorker

test/fixtures/snapshot/typescript.js:118211–118356  ·  view source on GitHub ↗
(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId)

Source from the content-addressed store, hash-verified

118209 };
118210 }
118211 function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
118212 var path = toPath(fileName);
118213 if (useSourceOfProjectReferenceRedirect) {
118214 var source = getSourceOfProjectReferenceRedirect(path);
118215 // If preserveSymlinks is true, module resolution wont jump the symlink
118216 // but the resolved real path may be the .d.ts from project reference
118217 // Note:: Currently we try the real path only if the
118218 // file is from node_modules to avoid having to run real path on all file paths
118219 if (!source &&
118220 host.realpath &&
118221 options.preserveSymlinks &&
118222 ts.isDeclarationFileName(fileName) &&
118223 ts.stringContains(fileName, ts.nodeModulesPathPart)) {
118224 var realPath = toPath(host.realpath(fileName));
118225 if (realPath !== path)
118226 source = getSourceOfProjectReferenceRedirect(realPath);
118227 }
118228 if (source) {
118229 var file_1 = ts.isString(source) ?
118230 findSourceFile(source, isDefaultLib, ignoreNoDefaultLib, reason, packageId) :
118231 undefined;
118232 if (file_1)
118233 addFileToFilesByName(file_1, path, /*redirectedPath*/ undefined);
118234 return file_1;
118235 }
118236 }
118237 var originalFileName = fileName;
118238 if (filesByName.has(path)) {
118239 var file_2 = filesByName.get(path);
118240 addFileIncludeReason(file_2 || undefined, reason);
118241 // try to check if we've already seen this file but with a different casing in path
118242 // NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected
118243 if (file_2 && options.forceConsistentCasingInFileNames) {
118244 var checkedName = file_2.fileName;
118245 var isRedirect = toPath(checkedName) !== toPath(fileName);
118246 if (isRedirect) {
118247 fileName = getProjectReferenceRedirect(fileName) || fileName;
118248 }
118249 // Check if it differs only in drive letters its ok to ignore that error:
118250 var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory);
118251 var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory);
118252 if (checkedAbsolutePath !== inputAbsolutePath) {
118253 reportFileNamesDifferOnlyInCasingError(fileName, file_2, reason);
118254 }
118255 }
118256 // If the file was previously found via a node_modules search, but is now being processed as a root file,
118257 // then everything it sucks in may also be marked incorrectly, and needs to be checked again.
118258 if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) {
118259 sourceFilesFoundSearchingNodeModules.set(file_2.path, false);
118260 if (!options.noResolve) {
118261 processReferencedFiles(file_2, isDefaultLib);
118262 processTypeReferenceDirectives(file_2);
118263 }
118264 if (!options.noLib) {
118265 processLibReferenceDirectives(file_2);
118266 }
118267 modulesWithElidedImports.set(file_2.path, false);
118268 processImportedModules(file_2);

Callers 1

findSourceFileFunction · 0.85

Calls 15

toPathFunction · 0.85
findSourceFileFunction · 0.85
addFileToFilesByNameFunction · 0.85
addFileIncludeReasonFunction · 0.85
processReferencedFilesFunction · 0.85
processImportedModulesFunction · 0.85
isReferencedFileFunction · 0.85

Tested by

no test coverage detected