(statement *ast.Node)
| 535 | } |
| 536 | |
| 537 | func getBreakOrContinueOwner(statement *ast.Node) *ast.Node { |
| 538 | return ast.FindAncestorOrQuit(statement, func(node *ast.Node) ast.FindAncestorResult { |
| 539 | switch node.Kind { |
| 540 | case ast.KindSwitchStatement: |
| 541 | if statement.Kind == ast.KindContinueStatement { |
| 542 | return ast.FindAncestorFalse |
| 543 | } |
| 544 | fallthrough |
| 545 | case ast.KindForStatement, |
| 546 | ast.KindForInStatement, |
| 547 | ast.KindForOfStatement, |
| 548 | ast.KindWhileStatement, |
| 549 | ast.KindDoStatement: |
| 550 | // If the statement is labeled, check if the node is labeled by the statement's label. |
| 551 | if statement.Label() == nil || isLabeledBy(node, statement.Label().Text()) { |
| 552 | return ast.FindAncestorTrue |
| 553 | } |
| 554 | return ast.FindAncestorFalse |
| 555 | default: |
| 556 | // Don't cross function boundaries. |
| 557 | if ast.IsFunctionLike(node) { |
| 558 | return ast.FindAncestorQuit |
| 559 | } |
| 560 | return ast.FindAncestorFalse |
| 561 | } |
| 562 | }) |
| 563 | } |
| 564 | |
| 565 | // Whether or not a 'node' is preceded by a label of the given string. |
| 566 | // Note: 'node' cannot be a SourceFile. |
no test coverage detected