Distinguish between allVariables and allUsedVariables

This commit is contained in:
Rachel Fenichel 2016-07-07 15:23:20 -07:00
parent 298990d809
commit 2364aed716

View file

@ -37,11 +37,12 @@ goog.require('goog.string');
Blockly.Variables.NAME_TYPE = 'VARIABLE';
/**
* Find all user-created variables.
* Find all user-created variables that are in use in the workspace.
* For use by generators.
* @param {!Blockly.Block|!Blockly.Workspace} root Root block or workspace.
* @return {!Array.<string>} Array of variable names.
*/
Blockly.Variables.allVariables = function(root) {
Blockly.Variables.allUsedVariables = function(root) {
var blocks;
if (root.getDescendants) {
// Root is Block.
@ -74,6 +75,22 @@ Blockly.Variables.allVariables = function(root) {
return variableList;
};
/**
* Find all variables that the user has created through the workspace or
* toolbox. For use by generators.
* @param {!Blockly.Workspace} root The workspace to inspect.
* @return {!Array.<string>} Array of variable names.
*/
Blockly.Variables.allVariables = function(root) {
if (root.getDescendants) {
// Root is Block.
console.warn('Deprecated call to Blockly.Variables.allVariables ' +
'with a block instead of a workspace. You may want ' +
'Blockly.Variables.allUsedVariables');
}
return root.variableList;
};
/**
* Find all instances of the specified variable and rename them.
* @param {string} oldName Variable to rename.