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

Method ConvertConditionalExpression

app/lib/code-to-blocks.js:171–187  ·  view source on GitHub ↗
(n, ctx)

Source from the content-addressed store, hash-verified

169 }
170
171 static ConvertConditionalExpression (n, ctx) {
172 const found = findOne(ctx.plan, x => fuzzyMatch(n, x[1]), 'Can\'t find the ternary expression')
173 const yes = convert(n.consequent, { ...ctx, nospace: true, context: 'value' })
174 const no = convert(n.alternate, { ...ctx, nospace: true, context: 'value' })
175
176 const o = {
177 type: found[0].type,
178 inputs: {
179 IF: { block: convert(n.test, ctx) },
180 },
181 }
182
183 if (yes) o.inputs.THEN = { block: yes }
184 if (no) o.inputs.ELSE = { block: no }
185
186 return o
187 }
188
189 static ConvertEmptyStatement (n, ctx) {
190 return null

Callers

nothing calls this directly

Calls 3

findOneFunction · 0.85
fuzzyMatchFunction · 0.85
convertFunction · 0.85

Tested by

no test coverage detected