* 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)
| 543 | * @returns {void} |
| 544 | */ |
| 545 | function 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); |
no test coverage detected
searching dependent graphs…