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

Function getThrowStatementOwner

test/fixtures/snapshot/typescript.js:135661–135676  ·  view source on GitHub ↗

* For lack of a better name, this function takes a throw statement and returns the * nearest ancestor that is a try-block (whose try statement has a catch clause), * function-block, or source file.

(throwStatement)

Source from the content-addressed store, hash-verified

135659 * function-block, or source file.
135660 */
135661 function getThrowStatementOwner(throwStatement) {
135662 var child = throwStatement;
135663 while (child.parent) {
135664 var parent = child.parent;
135665 if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SyntaxKind.SourceFile */) {
135666 return parent;
135667 }
135668 // A throw-statement is only owned by a try-statement if the try-statement has
135669 // a catch clause, and if the throw-statement occurs within the try block.
135670 if (ts.isTryStatement(parent) && parent.tryBlock === child && parent.catchClause) {
135671 return child;
135672 }
135673 child = parent;
135674 }
135675 return undefined;
135676 }
135677 function aggregateAllBreakAndContinueStatements(node) {
135678 return ts.isBreakOrContinueStatement(node) ? [node] : ts.isFunctionLike(node) ? undefined : flatMapChildren(node, aggregateAllBreakAndContinueStatements);
135679 }

Callers 1

getThrowOccurrencesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected