From 2364aed7160e2f60227ca6dadaa63fa292eb5949 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Thu, 7 Jul 2016 15:23:20 -0700 Subject: [PATCH] Distinguish between allVariables and allUsedVariables --- core/variables.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/core/variables.js b/core/variables.js index ea354ec6b..d9af525cb 100644 --- a/core/variables.js +++ b/core/variables.js @@ -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.} 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.} 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.