MCPcopy
hub / github.com/eslint/eslint / processCodePathToExit

Function processCodePathToExit

lib/linter/code-path-analysis/code-path-analyzer.js:545–663  ·  view source on GitHub ↗

* Updates the code path due to the type of a given node in leaving. * @param {CodePathAnalyzer} analyzer The instance. * @param {ASTNode} node The current AST node. * @returns {void}

(analyzer, node)

Source from the content-addressed store, hash-verified

543 * @returns {void}
544 */
545function processCodePathToExit(analyzer, node) {
546 const codePath = analyzer.codePath;
547 const state = CodePath.getState(codePath);
548 let dontForward = false;
549
550 switch (node.type) {
551 case "ChainExpression":
552 state.popChainContext();
553 break;
554
555 case "IfStatement":
556 case "ConditionalExpression":
557 state.popChoiceContext();
558 break;
559
560 case "LogicalExpression":
561 if (isHandledLogicalOperator(node.operator)) {
562 state.popChoiceContext();
563 }
564 break;
565
566 case "AssignmentExpression":
567 if (isLogicalAssignmentOperator(node.operator)) {
568 state.popChoiceContext();
569 }
570 break;
571
572 case "SwitchStatement":
573 state.popSwitchContext();
574 break;
575
576 case "SwitchCase":
577 /*
578 * This is the same as the process at the 1st `consequent` node in
579 * `preprocess` function.
580 * Must do if this `consequent` is empty.
581 */
582 if (node.consequent.length === 0) {
583 state.makeSwitchCaseBody(true, !node.test);
584 }
585 if (state.forkContext.reachable) {
586 dontForward = true;
587 }
588 break;
589
590 case "TryStatement":
591 state.popTryContext();
592 break;
593
594 case "BreakStatement":
595 forwardCurrentToHead(analyzer, node);
596 state.makeBreak(node.label && node.label.name);
597 dontForward = true;
598 break;
599
600 case "ContinueStatement":
601 forwardCurrentToHead(analyzer, node);
602 state.makeContinue(node.label && node.label.name);

Callers 1

leaveNodeMethod · 0.85

Calls 15

isHandledLogicalOperatorFunction · 0.85
forwardCurrentToHeadFunction · 0.85
isIdentifierReferenceFunction · 0.85
getStateMethod · 0.80
popChainContextMethod · 0.80
popChoiceContextMethod · 0.80
popSwitchContextMethod · 0.80
makeSwitchCaseBodyMethod · 0.80
popTryContextMethod · 0.80
makeBreakMethod · 0.80
makeContinueMethod · 0.80
makeReturnMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…