mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
Allow variables of different types to share the same name.
This commit is contained in:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user