mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-12 22:19:17 -04:00
Distinguish between allVariables and allUsedVariables
This commit is contained in:
parent
298990d809
commit
2364aed716
1 changed files with 19 additions and 2 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue