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

Function createProgram

test/fixtures/snapshot/typescript.js:116605–119249  ·  view source on GitHub ↗
(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics)

Source from the content-addressed store, hash-verified

116603 };
116604 }
116605 function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
116606 var _a, _b, _c, _d;
116607 var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217
116608 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
116609 var oldProgram = createProgramOptions.oldProgram;
116610 var processingDefaultLibFiles;
116611 var processingOtherFiles;
116612 var files;
116613 var symlinks;
116614 var commonSourceDirectory;
116615 var typeChecker;
116616 var classifiableNames;
116617 var ambientModuleNameToUnmodifiedFileName = new ts.Map();
116618 var fileReasons = ts.createMultiMap();
116619 var cachedBindAndCheckDiagnosticsForFile = {};
116620 var cachedDeclarationDiagnosticsForFile = {};
116621 var resolvedTypeReferenceDirectives = ts.createModeAwareCache();
116622 var fileProcessingDiagnostics;
116623 // The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules.
116624 // This works as imported modules are discovered recursively in a depth first manner, specifically:
116625 // - For each root file, findSourceFile is called.
116626 // - This calls processImportedModules for each module imported in the source file.
116627 // - This calls resolveModuleNames, and then calls findSourceFile for each resolved module.
116628 // As all these operations happen - and are nested - within the createProgram call, they close over the below variables.
116629 // The current resolution depth is tracked by incrementing/decrementing as the depth first search progresses.
116630 var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
116631 var currentNodeModulesDepth = 0;
116632 // If a module has some of its imports skipped due to being at the depth limit under node_modules, then track
116633 // this, as it may be imported at a shallower depth later, and then it will need its skipped imports processed.
116634 var modulesWithElidedImports = new ts.Map();
116635 // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled.
116636 var sourceFilesFoundSearchingNodeModules = new ts.Map();
116637 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true);
116638 ts.performance.mark("beforeProgram");
116639 var host = createProgramOptions.host || createCompilerHost(options);
116640 var configParsingHost = parseConfigHostFromCompilerHostLike(host);
116641 var skipDefaultLib = options.noLib;
116642 var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); });
116643 var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName());
116644 var programDiagnostics = ts.createDiagnosticCollection();
116645 var currentDirectory = host.getCurrentDirectory();
116646 var supportedExtensions = ts.getSupportedExtensions(options);
116647 var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
116648 // Map storing if there is emit blocking diagnostics for given input
116649 var hasEmitBlockingDiagnostics = new ts.Map();
116650 var _compilerOptionsObjectLiteralSyntax;
116651 var moduleResolutionCache;
116652 var typeReferenceDirectiveResolutionCache;
116653 var actualResolveModuleNamesWorker;
116654 var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
116655 if (host.resolveModuleNames) {
116656 actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
116657 // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
116658 if (!resolved || resolved.extension !== undefined) {
116659 return resolved;
116660 }
116661 var withExtension = ts.clone(resolved);
116662 withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);

Callers 4

createIncrementalProgramFunction · 0.85
synchronizeProgramFunction · 0.85
createNewProgramFunction · 0.85
executeStepsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…