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

Function getSymbolsInScope

test/fixtures/snapshot/typescript.js:86063–86157  ·  view source on GitHub ↗
(location, meaning)

Source from the content-addressed store, hash-verified

86061 }
86062 // Language service support
86063 function getSymbolsInScope(location, meaning) {
86064 if (location.flags & 33554432 /* NodeFlags.InWithStatement */) {
86065 // We cannot answer semantic questions within a with block, do not proceed any further
86066 return [];
86067 }
86068 var symbols = ts.createSymbolTable();
86069 var isStaticSymbol = false;
86070 populateSymbols();
86071 symbols.delete("this" /* InternalSymbolName.This */); // Not a symbol, a keyword
86072 return symbolsToArray(symbols);
86073 function populateSymbols() {
86074 while (location) {
86075 if (location.locals && !isGlobalSourceFile(location)) {
86076 copySymbols(location.locals, meaning);
86077 }
86078 switch (location.kind) {
86079 case 305 /* SyntaxKind.SourceFile */:
86080 if (!ts.isExternalModule(location))
86081 break;
86082 // falls through
86083 case 261 /* SyntaxKind.ModuleDeclaration */:
86084 copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* SymbolFlags.ModuleMember */);
86085 break;
86086 case 260 /* SyntaxKind.EnumDeclaration */:
86087 copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* SymbolFlags.EnumMember */);
86088 break;
86089 case 226 /* SyntaxKind.ClassExpression */:
86090 var className = location.name;
86091 if (className) {
86092 copySymbol(location.symbol, meaning);
86093 }
86094 // this fall-through is necessary because we would like to handle
86095 // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration.
86096 // falls through
86097 case 257 /* SyntaxKind.ClassDeclaration */:
86098 case 258 /* SyntaxKind.InterfaceDeclaration */:
86099 // If we didn't come from static member of class or interface,
86100 // add the type parameters into the symbol table
86101 // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol.
86102 // Note: that the memberFlags come from previous iteration.
86103 if (!isStaticSymbol) {
86104 copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* SymbolFlags.Type */);
86105 }
86106 break;
86107 case 213 /* SyntaxKind.FunctionExpression */:
86108 var funcName = location.name;
86109 if (funcName) {
86110 copySymbol(location.symbol, meaning);
86111 }
86112 break;
86113 }
86114 if (ts.introducesArgumentsExoticObject(location)) {
86115 copySymbol(argumentsSymbol, meaning);
86116 }
86117 isStaticSymbol = ts.isStatic(location);
86118 location = location.parent;
86119 }
86120 copySymbols(globals, meaning);

Callers 1

createTypeCheckerFunction · 0.85

Calls 3

populateSymbolsFunction · 0.85
symbolsToArrayFunction · 0.85
deleteMethod · 0.65

Tested by

no test coverage detected