MCPcopy Create free account
hub / github.com/codemix/contractual / leaveCollect

Function leaveCollect

lib/processor.js:203–233  ·  view source on GitHub ↗

* Invoked when `estraverse` leaves a node during the collection phase. * * @param {Object} options The options for the processor. * @param {Object} state The current state of the processor. * @param {Object} node The node being processed. * @param {Object} parent The parent node. * @

(options, state, node, parent)

Source from the content-addressed store, hash-verified

201 * @return {Object} The node, processed.
202 */
203function leaveCollect(options, state, node, parent) {
204 OBLIGATIONS.precondition(options && typeof options === 'object');
205 OBLIGATIONS.precondition(state && typeof state === 'object');
206 var __result;
207 main: {
208 if (node.type === 'LabeledStatement' && options.supported[node.label.name]) {
209 state.inLabel = node;
210 if (!node.body || node.body.type !== 'BlockStatement') {
211 node.body = {
212 type: 'BlockStatement',
213 body: node.body ? [node.body] : []
214 };
215 }
216 state.parent = parent;
217 state.labels.push(node);
218 } else if (state.labels.length && node === state.ast) {
219 node = processFunctionBody(node, options);
220 } else if (state.inLabel && parent === state.parent) {
221 state.inLabel.body.body.push(node);
222 __result = {
223 type: 'EmptyStatement',
224 deleteMe: true
225 };
226 break main;
227 }
228 __result = node;
229 break main;
230 }
231 OBLIGATIONS.postcondition(__result && typeof __result === 'object');
232 return __result;
233}
234/**
235 * Process a function body, after labels have been collected.
236 *

Callers

nothing calls this directly

Calls 1

processFunctionBodyFunction · 0.70

Tested by

no test coverage detected