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

Function aggregateOwnedThrowStatements

test/fixtures/snapshot/typescript.js:135645–135655  ·  view source on GitHub ↗

* Aggregates all throw-statements within this node *without* crossing * into function boundaries and try-blocks with catch-clauses.

(node)

Source from the content-addressed store, hash-verified

135643 * into function boundaries and try-blocks with catch-clauses.
135644 */
135645 function aggregateOwnedThrowStatements(node) {
135646 if (ts.isThrowStatement(node)) {
135647 return [node];
135648 }
135649 else if (ts.isTryStatement(node)) {
135650 // Exceptions thrown within a try block lacking a catch clause are "owned" in the current context.
135651 return ts.concatenate(node.catchClause ? aggregateOwnedThrowStatements(node.catchClause) : node.tryBlock && aggregateOwnedThrowStatements(node.tryBlock), node.finallyBlock && aggregateOwnedThrowStatements(node.finallyBlock));
135652 }
135653 // Do not cross function boundaries.
135654 return ts.isFunctionLike(node) ? undefined : flatMapChildren(node, aggregateOwnedThrowStatements);
135655 }
135656 /**
135657 * For lack of a better name, this function takes a throw statement and returns the
135658 * nearest ancestor that is a try-block (whose try statement has a catch clause),

Callers 2

getThrowOccurrencesFunction · 0.85
getReturnOccurrencesFunction · 0.85

Calls 1

flatMapChildrenFunction · 0.85

Tested by

no test coverage detected