in src/editor/sandbox/handleLoop.js [37:66]
enter(node) {
switch (node.type) {
case 'WhileStatement':
case 'DoWhileStatement':
case 'ForStatement':
case 'ForInStatement':
case 'ForOfStatement':
// Gets the head and tail of the loop body
let { start, end } = node.body;
start++;
let pre = insertCode.setMonitor.replace('%d', loopID);
let aft = '';
// If the body of the loop is not enveloped by {} and is indented, we need to manually add {}
if (node.body.type !== 'BlockStatement') {
pre = '{' + pre;
aft = '}';
--start;
}
fragments.push({ pos: start, str: pre });
fragments.push({ pos: end, str: aft });
fragments.push({
pos: node.end,
str: insertCode.delMonitor.replace('%d', loopID)
});
++loopID;
break;
default:
break;
}
}