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

Function resolveNamesWithLocalCache

test/fixtures/snapshot/typescript.js:121377–121501  ·  view source on GitHub ↗
(_a)

Source from the content-addressed store, hash-verified

121375 return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode);
121376 }
121377 function resolveNamesWithLocalCache(_a) {
121378 var _b, _c, _d;
121379 var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges, containingSourceFile = _a.containingSourceFile, containingSourceFileMode = _a.containingSourceFileMode;
121380 var path = resolutionHost.toPath(containingFile);
121381 var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path);
121382 var dirPath = ts.getDirectoryPath(path);
121383 var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
121384 var perDirectoryResolution = perDirectoryCache.get(dirPath);
121385 if (!perDirectoryResolution) {
121386 perDirectoryResolution = ts.createModeAwareCache();
121387 perDirectoryCache.set(dirPath, perDirectoryResolution);
121388 }
121389 var resolvedModules = [];
121390 var compilerOptions = resolutionHost.getCompilationSettings();
121391 var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
121392 // All the resolutions in this file are invalidated if this file wasn't resolved using same redirect
121393 var program = resolutionHost.getCurrentProgram();
121394 var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
121395 var unmatchedRedirects = oldRedirect ?
121396 !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
121397 !!redirectedReference;
121398 var seenNamesInFile = ts.createModeAwareCache();
121399 var i = 0;
121400 for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
121401 var entry = names_5[_i];
121402 var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
121403 // Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
121404 // they require calculating the mode for a given import from it's position in the resolution table, since a given
121405 // import's syntax may override the file's default mode.
121406 // Type references instead supply a `containingSourceFileMode` and a non-string entry which contains
121407 // a default file mode override if applicable.
121408 var mode = !ts.isString(entry) ? ts.getModeForFileReference(entry, containingSourceFileMode) :
121409 containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined;
121410 i++;
121411 var resolution = resolutionsInFile.get(name, mode);
121412 // Resolution is valid if it is present and not invalidated
121413 if (!seenNamesInFile.has(name, mode) &&
121414 unmatchedRedirects || !resolution || resolution.isInvalidated ||
121415 // If the name is unresolved import that was invalidated, recalculate
121416 (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
121417 var existingResolution = resolution;
121418 var resolutionInDirectory = perDirectoryResolution.get(name, mode);
121419 if (resolutionInDirectory) {
121420 resolution = resolutionInDirectory;
121421 var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost;
121422 if (ts.isTraceEnabled(compilerOptions, host)) {
121423 var resolved = getResolutionWithResolvedFileName(resolution);
121424 ts.trace(host, loader === resolveModuleName ?
121425 (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
121426 resolved.packagetId ?
121427 ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 :
121428 ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
121429 ts.Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved :
121430 (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ?
121431 resolved.packagetId ?
121432 ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 :
121433 ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 :
121434 ts.Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved, name, containingFile, ts.getDirectoryPath(containingFile), resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName, (resolved === null || resolved === void 0 ? void 0 : resolved.packagetId) && ts.packageIdToString(resolved.packagetId));

Callers 2

resolveModuleNamesFunction · 0.85

Calls 15

resolutionIsSymlinkFunction · 0.85
resolutionIsEqualToFunction · 0.85
assertMethod · 0.80
loaderFunction · 0.70
getMethod · 0.65
hasMethod · 0.65
forEachMethod · 0.65
deleteMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…