MCPcopy Create free account
hub / github.com/codecombat/codecombat / nextify

Function nextify

app/lib/code-to-blocks.js:666–698  ·  view source on GitHub ↗
(arr, ctx)

Source from the content-addressed store, hash-verified

664}
665
666function nextify (arr, ctx) {
667 let result
668 let target
669
670 for (const e of arr) {
671 if (e === null) continue
672 if (!result) {
673 result = [e]
674 target = e
675 } else if (target.type === 'procedures_defnoreturn' || e.type === 'procedures_defnoreturn') {
676 result.push(e)
677 target = e
678 } else if (target.end === e.start - 1) {
679 target.next = { block: e }
680 target = e
681 } else {
682 if (ctx.isJunior) {
683 // Hook the block up directly, don't preserve any newlines
684 target.next = { block: e }
685 target = e
686 } else if (ctx.nospace) {
687 // Preserve newlines (I think so that we can support CodeCombat levels that don't want to delete them, but I don't actually remember why we do this)
688 target.next = { block: { type: 'newline', next: { block: e } } }
689 target = e
690 } else {
691 // console.log('BREAK', e.loc, target.loc)
692 result.push(e)
693 target = e
694 }
695 }
696 }
697 return result
698}
699
700function prepareBlockIntelligence ({ toolbox, blocklyState, workspace }) {
701 const plan = []

Callers 2

convertFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected