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

Function forEachSymbolTableInScope

test/fixtures/snapshot/typescript.js:51814–51867  ·  view source on GitHub ↗
(enclosingDeclaration, callback)

Source from the content-addressed store, hash-verified

51812 return typeCopy;
51813 }
51814 function forEachSymbolTableInScope(enclosingDeclaration, callback) {
51815 var result;
51816 var _loop_8 = function (location) {
51817 // Locals of a source file are not in scope (because they get merged into the global symbol table)
51818 if (location.locals && !isGlobalSourceFile(location)) {
51819 if (result = callback(location.locals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true, location)) {
51820 return { value: result };
51821 }
51822 }
51823 switch (location.kind) {
51824 case 305 /* SyntaxKind.SourceFile */:
51825 if (!ts.isExternalOrCommonJsModule(location)) {
51826 break;
51827 }
51828 // falls through
51829 case 261 /* SyntaxKind.ModuleDeclaration */:
51830 var sym = getSymbolOfNode(location);
51831 // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten
51832 // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred
51833 // to one another anyway)
51834 if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true, location)) {
51835 return { value: result };
51836 }
51837 break;
51838 case 257 /* SyntaxKind.ClassDeclaration */:
51839 case 226 /* SyntaxKind.ClassExpression */:
51840 case 258 /* SyntaxKind.InterfaceDeclaration */:
51841 // Type parameters are bound into `members` lists so they can merge across declarations
51842 // This is troublesome, since in all other respects, they behave like locals :cries:
51843 // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol
51844 // lookup logic in terms of `resolveName` would be nice
51845 // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals
51846 // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would
51847 // trigger resolving late-bound names, which we may already be in the process of doing while we're here!
51848 var table_1;
51849 // TODO: Should this filtered table be cached in some way?
51850 (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) {
51851 if (memberSymbol.flags & (788968 /* SymbolFlags.Type */ & ~67108864 /* SymbolFlags.Assignment */)) {
51852 (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol);
51853 }
51854 });
51855 if (table_1 && (result = callback(table_1, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ false, location))) {
51856 return { value: result };
51857 }
51858 break;
51859 }
51860 };
51861 for (var location = enclosingDeclaration; location; location = location.parent) {
51862 var state_2 = _loop_8(location);
51863 if (typeof state_2 === "object")
51864 return state_2.value;
51865 }
51866 return callback(globals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true);
51867 }
51868 function getQualifiedLeftMeaning(rightMeaning) {
51869 // If we are looking in value space, the parent meaning is value, other wise it is namespace
51870 return rightMeaning === 111551 /* SymbolFlags.Value */ ? 111551 /* SymbolFlags.Value */ : 1920 /* SymbolFlags.Namespace */;

Callers 3

getContainersOfSymbolFunction · 0.85
getAccessibleSymbolChainFunction · 0.85
needsQualificationFunction · 0.85

Calls 2

_loop_8Function · 0.85
callbackFunction · 0.70

Tested by

no test coverage detected