propagateVisitedness implements two rules for extending the coverage report: - If a node is visited, all its ancestors are visited. - If a node is visited, and it has only one child, then the child is visited.
(root *cel.Ast, coverageStats map[int64]set, state interpreter.EvalState)
| 1070 | // - If a node is visited, all its ancestors are visited. |
| 1071 | // - If a node is visited, and it has only one child, then the child is visited. |
| 1072 | func propagateVisitedness(root *cel.Ast, coverageStats map[int64]set, state interpreter.EvalState) { |
| 1073 | if root == nil || coverageStats == nil { |
| 1074 | return |
| 1075 | } |
| 1076 | // Propagate visitedness upwards for ancestors. |
| 1077 | ast.PostOrderVisit(root.NativeRep().Expr(), parentVisitor{coverageStats: coverageStats, evalState: state}) |
| 1078 | // Propagate visitedness downwards for single-child nodes. |
| 1079 | ast.PostOrderVisit(root.NativeRep().Expr(), childrenVisitor{coverageStats: coverageStats, evalState: state}) |
| 1080 | } |
| 1081 | |
| 1082 | // childrenVisitor is a visitor that populates the coverageStats for the child nodes of a given expression. |
| 1083 | type childrenVisitor struct { |
no test coverage detected