Allow variables of different types to share the same name.

This commit is contained in:
Rachel Fenichel
2017-11-29 14:37:34 -08:00
parent 733a629f06
commit 779be46a92
10 changed files with 214 additions and 111 deletions

View File

@@ -259,6 +259,23 @@ Blockly.Blocks['procedures_defnoreturn'] = {
getVars: function() {
return this.arguments_;
},
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
* @this Blockly.Block
*/
getVarModels: function() {
var vars = [];
for (var i = 0, argName; argName = this.arguments_[i]; i++) {
// TODO (#1199): When we switch to tracking variables by ID,
// update this.
var model = this.workspace.getVariable(argName, '');
if (model) {
vars.push(model);
}
}
return vars;
},
/**
* Notification that a variable is renaming.
* If the name matches one of this block's variables, rename it.
@@ -376,6 +393,7 @@ Blockly.Blocks['procedures_defreturn'] = {
return [this.getFieldValue('NAME'), this.arguments_, true];
},
getVars: Blockly.Blocks['procedures_defnoreturn'].getVars,
getVarModels: Blockly.Blocks['procedures_defnoreturn'].getVarModels,
renameVar: Blockly.Blocks['procedures_defnoreturn'].renameVar,
customContextMenu: Blockly.Blocks['procedures_defnoreturn'].customContextMenu,
callType_: 'procedures_callreturn'