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

Function getVersionedSourceFileByPath

test/fixtures/snapshot/typescript.js:123606–123647  ·  view source on GitHub ↗
(fileName, path, languageVersionOrOptions, onError, shouldCreateNewSourceFile)

Source from the content-addressed store, hash-verified

123604 return directoryStructureHost.fileExists(fileName);
123605 }
123606 function getVersionedSourceFileByPath(fileName, path, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
123607 var hostSourceFile = sourceFilesCache.get(path);
123608 // No source file on the host
123609 if (isFileMissingOnHost(hostSourceFile)) {
123610 return undefined;
123611 }
123612 // Create new source file if requested or the versions dont match
123613 if (hostSourceFile === undefined || shouldCreateNewSourceFile || isFilePresenceUnknownOnHost(hostSourceFile)) {
123614 var sourceFile = getNewSourceFile(fileName, languageVersionOrOptions, onError);
123615 if (hostSourceFile) {
123616 if (sourceFile) {
123617 // Set the source file and create file watcher now that file was present on the disk
123618 hostSourceFile.sourceFile = sourceFile;
123619 hostSourceFile.version = sourceFile.version;
123620 if (!hostSourceFile.fileWatcher) {
123621 hostSourceFile.fileWatcher = watchFilePath(path, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, ts.WatchType.SourceFile);
123622 }
123623 }
123624 else {
123625 // There is no source file on host any more, close the watch, missing file paths will track it
123626 if (hostSourceFile.fileWatcher) {
123627 hostSourceFile.fileWatcher.close();
123628 }
123629 sourceFilesCache.set(path, false);
123630 }
123631 }
123632 else {
123633 if (sourceFile) {
123634 var fileWatcher = watchFilePath(path, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, ts.WatchType.SourceFile);
123635 sourceFilesCache.set(path, { sourceFile: sourceFile, version: sourceFile.version, fileWatcher: fileWatcher });
123636 }
123637 else {
123638 sourceFilesCache.set(path, false);
123639 }
123640 }
123641 if (sourceFile) {
123642 sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings());
123643 }
123644 return sourceFile;
123645 }
123646 return hostSourceFile.sourceFile;
123647 }
123648 function nextSourceFileVersion(path) {
123649 var hostSourceFile = sourceFilesCache.get(path);
123650 if (hostSourceFile !== undefined) {

Callers

nothing calls this directly

Calls 6

isFileMissingOnHostFunction · 0.85
watchFilePathFunction · 0.85
getMethod · 0.65
closeMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…