MCPcopy Create free account
hub / github.com/nodejs/node / getExportInfos

Function getExportInfos

test/fixtures/snapshot/typescript.js:153608–153641  ·  view source on GitHub ↗
(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences)

Source from the content-addressed store, hash-verified

153606 }
153607 // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
153608 function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
153609 var _a;
153610 // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once.
153611 // Maps symbol id to info for modules providing that symbol (original export + re-exports).
153612 var originalSymbolToExportInfos = ts.createMultiMap();
153613 var packageJsonFilter = ts.createPackageJsonImportFilter(fromFile, preferences, host);
153614 var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host);
153615 var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
153616 return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host);
153617 });
153618 function addSymbol(moduleSymbol, toFile, exportedSymbol, exportKind, program, isFromPackageJson) {
153619 var moduleSpecifierResolutionHost = getModuleSpecifierResolutionHost(isFromPackageJson);
153620 if (toFile && ts.isImportableFile(program, fromFile, toFile, preferences, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) ||
153621 !toFile && packageJsonFilter.allowsImportingAmbientModule(moduleSymbol, moduleSpecifierResolutionHost)) {
153622 var checker = program.getTypeChecker();
153623 originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { symbol: exportedSymbol, moduleSymbol: moduleSymbol, moduleFileName: toFile === null || toFile === void 0 ? void 0 : toFile.fileName, exportKind: exportKind, targetFlags: ts.skipAlias(exportedSymbol, checker).flags, isFromPackageJson: isFromPackageJson });
153624 }
153625 }
153626 ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
153627 var checker = program.getTypeChecker();
153628 cancellationToken.throwIfCancellationRequested();
153629 var compilerOptions = program.getCompilerOptions();
153630 var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
153631 if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
153632 addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson);
153633 }
153634 // check exports with the same name
153635 var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol);
153636 if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) {
153637 addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* ExportKind.Named */, program, isFromPackageJson);
153638 }
153639 });
153640 return originalSymbolToExportInfos;
153641 }
153642 function getExportEqualsImportKind(importingFile, compilerOptions, forceImportKeyword) {
153643 var allowSyntheticDefaults = ts.getAllowSyntheticDefaultImports(compilerOptions);
153644 var isJS = ts.isInJSFile(importingFile);

Callers 1

Calls 4

symbolHasMeaningFunction · 0.85
addSymbolFunction · 0.85
callMethod · 0.45

Tested by

no test coverage detected