mirror of
https://github.com/google/blockly.git
synced 2026-01-06 16:40:07 +01:00
Add method to suppress prefix/suffix from blocks.
This allows generators to have more control over the placement of suffix. Needed for ‘if’ blocks and function calls which require their suffix code to be somewhere other than the end. Also, add loop’s prefix to ‘break’ blocks, since the loop’s suffix will be the next statement hit. Also, reuse procedures_callreturn generator for procedures_callnoreturn.
This commit is contained in:
@@ -305,6 +305,12 @@ Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN = {
|
||||
elseifCount_: 0,
|
||||
elseCount_: 0,
|
||||
|
||||
/**
|
||||
* Don't automatically add STATEMENT_PREFIX and STATEMENT_SUFFIX to generated
|
||||
* code. These will be handled manually in this block's generators.
|
||||
*/
|
||||
suppressPrefixSuffix: true,
|
||||
|
||||
/**
|
||||
* Create XML to represent the number of else-if and else inputs.
|
||||
* @return {Element} XML storage element.
|
||||
|
||||
@@ -302,8 +302,19 @@ Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN = {
|
||||
* To add a new loop type add this to your code:
|
||||
* Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN.LOOP_TYPES.push('custom_loop');
|
||||
*/
|
||||
LOOP_TYPES: ['controls_repeat', 'controls_repeat_ext', 'controls_forEach',
|
||||
'controls_for', 'controls_whileUntil'],
|
||||
LOOP_TYPES: [
|
||||
'controls_repeat',
|
||||
'controls_repeat_ext',
|
||||
'controls_forEach',
|
||||
'controls_for',
|
||||
'controls_whileUntil'
|
||||
],
|
||||
|
||||
/**
|
||||
* Don't automatically add STATEMENT_PREFIX and STATEMENT_SUFFIX to generated
|
||||
* code. These will be handled manually in this block's generators.
|
||||
*/
|
||||
suppressPrefixSuffix: true,
|
||||
|
||||
/**
|
||||
* Is the given block enclosed (at any level) by a loop?
|
||||
|
||||
@@ -642,6 +642,12 @@ Blockly.Blocks['procedures_callnoreturn'] = {
|
||||
this.previousEnabledState_ = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Don't automatically add STATEMENT_PREFIX and STATEMENT_SUFFIX to generated
|
||||
* code. These will be handled manually in this block's generators.
|
||||
*/
|
||||
suppressPrefixSuffix: true,
|
||||
|
||||
/**
|
||||
* Returns the name of the procedure this block calls.
|
||||
* @return {string} Procedure name.
|
||||
|
||||
Reference in New Issue
Block a user