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

Function getSymbolAtLocation

test/fixtures/snapshot/typescript.js:86408–86530  ·  view source on GitHub ↗
(node, ignoreErrors)

Source from the content-addressed store, hash-verified

86406 }
86407 }
86408 function getSymbolAtLocation(node, ignoreErrors) {
86409 if (node.kind === 305 /* SyntaxKind.SourceFile */) {
86410 return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined;
86411 }
86412 var parent = node.parent;
86413 var grandParent = parent.parent;
86414 if (node.flags & 33554432 /* NodeFlags.InWithStatement */) {
86415 // We cannot answer semantic questions within a with block, do not proceed any further
86416 return undefined;
86417 }
86418 if (isDeclarationNameOrImportPropertyName(node)) {
86419 // This is a declaration, call getSymbolOfNode
86420 var parentSymbol = getSymbolOfNode(parent);
86421 return ts.isImportOrExportSpecifier(node.parent) && node.parent.propertyName === node
86422 ? getImmediateAliasedSymbol(parentSymbol)
86423 : parentSymbol;
86424 }
86425 else if (ts.isLiteralComputedPropertyDeclarationName(node)) {
86426 return getSymbolOfNode(parent.parent);
86427 }
86428 if (node.kind === 79 /* SyntaxKind.Identifier */) {
86429 if (isInRightSideOfImportOrExportAssignment(node)) {
86430 return getSymbolOfNameOrPropertyAccessExpression(node);
86431 }
86432 else if (parent.kind === 203 /* SyntaxKind.BindingElement */ &&
86433 grandParent.kind === 201 /* SyntaxKind.ObjectBindingPattern */ &&
86434 node === parent.propertyName) {
86435 var typeOfPattern = getTypeOfNode(grandParent);
86436 var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText);
86437 if (propertyDeclaration) {
86438 return propertyDeclaration;
86439 }
86440 }
86441 else if (ts.isMetaProperty(parent) && parent.name === node) {
86442 if (parent.keywordToken === 103 /* SyntaxKind.NewKeyword */ && ts.idText(node) === "target") {
86443 // `target` in `new.target`
86444 return checkNewTargetMetaProperty(parent).symbol;
86445 }
86446 // The `meta` in `import.meta` could be given `getTypeOfNode(parent).symbol` (the `ImportMeta` interface symbol), but
86447 // we have a fake expression type made for other reasons already, whose transient `meta`
86448 // member should more exactly be the kind of (declarationless) symbol we want.
86449 // (See #44364 and #45031 for relevant implementation PRs)
86450 if (parent.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && ts.idText(node) === "meta") {
86451 return getGlobalImportMetaExpressionType().members.get("meta");
86452 }
86453 // no other meta properties are valid syntax, thus no others should have symbols
86454 return undefined;
86455 }
86456 }
86457 switch (node.kind) {
86458 case 79 /* SyntaxKind.Identifier */:
86459 case 80 /* SyntaxKind.PrivateIdentifier */:
86460 case 206 /* SyntaxKind.PropertyAccessExpression */:
86461 case 161 /* SyntaxKind.QualifiedName */:
86462 if (!ts.isThisInTypeQuery(node)) {
86463 return getSymbolOfNameOrPropertyAccessExpression(node);
86464 }
86465 // falls through

Callers 10

createTypeCheckerFunction · 0.85
helperFunction · 0.85
_loop_31Function · 0.85
getTypeOfNodeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…