* Processes the provided switch case. * @param {SwitchCase[]} switchCases switch statement
(switchCases)
| 3387 | * @param {SwitchCase[]} switchCases switch statement |
| 3388 | */ |
| 3389 | walkSwitchCases(switchCases) { |
| 3390 | this.inBlockScope(() => { |
| 3391 | const len = switchCases.length; |
| 3392 | |
| 3393 | // we need to pre walk all statements first since we can have invalid code |
| 3394 | // import A from "module"; |
| 3395 | // switch(1) { |
| 3396 | // case 1: |
| 3397 | // console.log(A); // should fail at runtime |
| 3398 | // case 2: |
| 3399 | // const A = 1; |
| 3400 | // } |
| 3401 | for (let index = 0; index < len; index++) { |
| 3402 | const switchCase = switchCases[index]; |
| 3403 | |
| 3404 | if (switchCase.consequent.length > 0) { |
| 3405 | const prev = this.prevStatement; |
| 3406 | this.blockPreWalkStatements(switchCase.consequent); |
| 3407 | this.prevStatement = prev; |
| 3408 | } |
| 3409 | } |
| 3410 | |
| 3411 | for (let index = 0; index < len; index++) { |
| 3412 | const switchCase = switchCases[index]; |
| 3413 | |
| 3414 | if (switchCase.test) { |
| 3415 | this.walkExpression(switchCase.test); |
| 3416 | } |
| 3417 | |
| 3418 | if (switchCase.consequent.length > 0) { |
| 3419 | this.walkStatements(switchCase.consequent); |
| 3420 | this.scope.terminated = undefined; |
| 3421 | } |
| 3422 | } |
| 3423 | }); |
| 3424 | } |
| 3425 | |
| 3426 | /** |
| 3427 | * Pre walk catch clause. |
no test coverage detected