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

Function isPartOfClassBody

test/fixtures/snapshot/typescript.js:101580–101602  ·  view source on GitHub ↗
(declaration, node)

Source from the content-addressed store, hash-verified

101578 return node;
101579 }
101580 function isPartOfClassBody(declaration, node) {
101581 var currentNode = ts.getParseTreeNode(node);
101582 if (!currentNode || currentNode === declaration || currentNode.end <= declaration.pos || currentNode.pos >= declaration.end) {
101583 // if the node has no correlation to a parse tree node, its definitely not
101584 // part of the body.
101585 // if the node is outside of the document range of the declaration, its
101586 // definitely not part of the body.
101587 return false;
101588 }
101589 var blockScope = ts.getEnclosingBlockScopeContainer(declaration);
101590 while (currentNode) {
101591 if (currentNode === blockScope || currentNode === declaration) {
101592 // if we are in the enclosing block scope of the declaration, we are definitely
101593 // not inside the class body.
101594 return false;
101595 }
101596 if (ts.isClassElement(currentNode) && currentNode.parent === declaration) {
101597 return true;
101598 }
101599 currentNode = currentNode.parent;
101600 }
101601 return false;
101602 }
101603 /**
101604 * Substitutes `this` when contained within an arrow function.
101605 *

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected