(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap)
| 51870 | return rightMeaning === 111551 /* SymbolFlags.Value */ ? 111551 /* SymbolFlags.Value */ : 1920 /* SymbolFlags.Namespace */; |
| 51871 | } |
| 51872 | function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { |
| 51873 | if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = new ts.Map(); } |
| 51874 | if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { |
| 51875 | return undefined; |
| 51876 | } |
| 51877 | var links = getSymbolLinks(symbol); |
| 51878 | var cache = (links.accessibleChainCache || (links.accessibleChainCache = new ts.Map())); |
| 51879 | // Go from enclosingDeclaration to the first scope we check, so the cache is keyed off the scope and thus shared more |
| 51880 | var firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, function (_, __, ___, node) { return node; }); |
| 51881 | var key = "".concat(useOnlyExternalAliasing ? 0 : 1, "|").concat(firstRelevantLocation && getNodeId(firstRelevantLocation), "|").concat(meaning); |
| 51882 | if (cache.has(key)) { |
| 51883 | return cache.get(key); |
| 51884 | } |
| 51885 | var id = getSymbolId(symbol); |
| 51886 | var visitedSymbolTables = visitedSymbolTablesMap.get(id); |
| 51887 | if (!visitedSymbolTables) { |
| 51888 | visitedSymbolTablesMap.set(id, visitedSymbolTables = []); |
| 51889 | } |
| 51890 | var result = forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); |
| 51891 | cache.set(key, result); |
| 51892 | return result; |
| 51893 | /** |
| 51894 | * @param {ignoreQualification} boolean Set when a symbol is being looked for through the exports of another symbol (meaning we have a route to qualify it already) |
| 51895 | */ |
| 51896 | function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification, isLocalNameLookup) { |
| 51897 | if (!ts.pushIfUnique(visitedSymbolTables, symbols)) { |
| 51898 | return undefined; |
| 51899 | } |
| 51900 | var result = trySymbolTable(symbols, ignoreQualification, isLocalNameLookup); |
| 51901 | visitedSymbolTables.pop(); |
| 51902 | return result; |
| 51903 | } |
| 51904 | function canQualifySymbol(symbolFromSymbolTable, meaning) { |
| 51905 | // If the symbol is equivalent and doesn't need further qualification, this symbol is accessible |
| 51906 | return !needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning) || |
| 51907 | // If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too |
| 51908 | !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap); |
| 51909 | } |
| 51910 | function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) { |
| 51911 | return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) && |
| 51912 | // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) |
| 51913 | // and if symbolFromSymbolTable or alias resolution matches the symbol, |
| 51914 | // check the symbol can be qualified, it is only then this symbol is accessible |
| 51915 | !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && |
| 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 |
no test coverage detected