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

Function isUsedInFunctionOrInstanceProperty

test/fixtures/snapshot/typescript.js:49497–49537  ·  view source on GitHub ↗
(usage, declaration)

Source from the content-addressed store, hash-verified

49495 return ts.isForInOrOfStatement(grandparent) && isSameScopeDescendentOf(usage, grandparent.expression, declContainer);
49496 }
49497 function isUsedInFunctionOrInstanceProperty(usage, declaration) {
49498 return !!ts.findAncestor(usage, function (current) {
49499 if (current === declContainer) {
49500 return "quit";
49501 }
49502 if (ts.isFunctionLike(current)) {
49503 return true;
49504 }
49505 if (ts.isClassStaticBlockDeclaration(current)) {
49506 return declaration.pos < usage.pos;
49507 }
49508 var propertyDeclaration = ts.tryCast(current.parent, ts.isPropertyDeclaration);
49509 if (propertyDeclaration) {
49510 var initializerOfProperty = propertyDeclaration.initializer === current;
49511 if (initializerOfProperty) {
49512 if (ts.isStatic(current.parent)) {
49513 if (declaration.kind === 169 /* SyntaxKind.MethodDeclaration */) {
49514 return true;
49515 }
49516 if (ts.isPropertyDeclaration(declaration) && ts.getContainingClass(usage) === ts.getContainingClass(declaration)) {
49517 var propName = declaration.name;
49518 if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) {
49519 var type = getTypeOfSymbol(getSymbolOfNode(declaration));
49520 var staticBlocks = ts.filter(declaration.parent.members, ts.isClassStaticBlockDeclaration);
49521 if (isPropertyInitializedInStaticBlocks(propName, type, staticBlocks, declaration.parent.pos, current.pos)) {
49522 return true;
49523 }
49524 }
49525 }
49526 }
49527 else {
49528 var isDeclarationInstanceProperty = declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(declaration);
49529 if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) {
49530 return true;
49531 }
49532 }
49533 }
49534 }
49535 return false;
49536 });
49537 }
49538 /** stopAtAnyPropertyDeclaration is used for detecting ES-standard class field use-before-def errors */
49539 function isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, stopAtAnyPropertyDeclaration) {
49540 // always legal if usage is after declaration

Callers 1

Calls 4

getTypeOfSymbolFunction · 0.85
getSymbolOfNodeFunction · 0.85
filterMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…