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

Function trySymbolTable

test/fixtures/snapshot/typescript.js:51918–51950  ·  view source on GitHub ↗
(symbols, ignoreQualification, isLocalNameLookup)

Source from the content-addressed store, hash-verified

51916 (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning));
51917 }
51918 function trySymbolTable(symbols, ignoreQualification, isLocalNameLookup) {
51919 // If symbol is directly available by its name in the symbol table
51920 if (isAccessible(symbols.get(symbol.escapedName), /*resolvedAliasSymbol*/ undefined, ignoreQualification)) {
51921 return [symbol];
51922 }
51923 // Check if symbol is any of the aliases in scope
51924 var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) {
51925 if (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */
51926 && symbolFromSymbolTable.escapedName !== "export=" /* InternalSymbolName.ExportEquals */
51927 && symbolFromSymbolTable.escapedName !== "default" /* InternalSymbolName.Default */
51928 && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration)))
51929 // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name
51930 && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration))
51931 // If we're looking up a local name to reference directly, omit namespace reexports, otherwise when we're trawling through an export list to make a dotted name, we can keep it
51932 && (isLocalNameLookup ? !ts.some(symbolFromSymbolTable.declarations, ts.isNamespaceReexportDeclaration) : true)
51933 // While exports are generally considered to be in scope, export-specifier declared symbols are _not_
51934 // See similar comment in `resolveName` for details
51935 && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */))) {
51936 var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable);
51937 var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification);
51938 if (candidate) {
51939 return candidate;
51940 }
51941 }
51942 if (symbolFromSymbolTable.escapedName === symbol.escapedName && symbolFromSymbolTable.exportSymbol) {
51943 if (isAccessible(getMergedSymbol(symbolFromSymbolTable.exportSymbol), /*aliasSymbol*/ undefined, ignoreQualification)) {
51944 return [symbol];
51945 }
51946 }
51947 });
51948 // If there's no result and we're looking at the global symbol table, treat `globalThis` like an alias and try to lookup thru that
51949 return result || (symbols === globals ? getCandidateListForSymbol(globalThisSymbol, globalThisSymbol, ignoreQualification) : undefined);
51950 }
51951 function getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification) {
51952 if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) {
51953 return [symbolFromSymbolTable];

Calls 6

isAccessibleFunction · 0.85
resolveAliasFunction · 0.85
getMergedSymbolFunction · 0.85
someMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…