* Process a block statement in a function body, after labels have been collected. * * @param {Object} ast The `BlockStatement` to process. * @param {Object} parent The `FunctionExpression` or `FunctionDeclaration` that contains the block. * @param {Object} options The options for the pro
(ast, parent, options)
| 261 | * @return {Object} The processed node. |
| 262 | */ |
| 263 | function processBlockStatement(ast, parent, options) { |
| 264 | OBLIGATIONS.precondition(ast && typeof ast === 'object'); |
| 265 | OBLIGATIONS.precondition(ast.type === 'BlockStatement'); |
| 266 | OBLIGATIONS.precondition(parent && typeof parent === 'object'); |
| 267 | OBLIGATIONS.precondition(parent.type === 'FunctionDeclaration' || parent.type === 'FunctionExpression'); |
| 268 | OBLIGATIONS.precondition(options && typeof options === 'object'); |
| 269 | OBLIGATIONS.precondition(typeof options.supported === 'object'); |
| 270 | var __result; |
| 271 | var labels = {}; |
| 272 | __result = estraverse.replace(ast, { |
| 273 | enter: function (node, parent) { |
| 274 | if (node !== ast && (parent !== ast || node.type !== 'LabeledStatement' || !options.supported[node.label.name])) { |
| 275 | this.skip(); |
| 276 | } else if (node.type === 'LabeledStatement') { |
| 277 | labels[node.label.name] = node; |
| 278 | } |
| 279 | }, |
| 280 | leave: function (node) { |
| 281 | if (node === ast) { |
| 282 | return processLabels(ast, parent, labels, options); |
| 283 | } |
| 284 | } |
| 285 | }); |
| 286 | OBLIGATIONS.postcondition(__result && typeof __result === 'object'); |
| 287 | OBLIGATIONS.postcondition(__result.type === ast.type); |
| 288 | return __result; |
| 289 | } |
| 290 | /** |
| 291 | * Process a list of labels that are contained within the given `BlockStatement`. |
| 292 | * |
no test coverage detected