Remove global workspace references from variable and procedure utilities.

This commit is contained in:
Neil Fraser
2015-01-12 14:57:00 -08:00
parent 6cc26f07ac
commit 315a5fc762
8 changed files with 85 additions and 63 deletions

View File

@@ -39,14 +39,15 @@ goog.require('Blockly.Workspace');
Blockly.Procedures.NAME_TYPE = 'PROCEDURE';
/**
* Find all user-created procedure definitions.
* Find all user-created procedure definitions in a workspace.
* @param {!Blockly.Workspace} root Root workspace.
* @return {!Array.<!Array.<!Array>>} Pair of arrays, the
* first contains procedures without return variables, the second with.
* Each procedure is defined by a three-element list of name, parameter
* list, and return value boolean.
*/
Blockly.Procedures.allProcedures = function() {
var blocks = Blockly.mainWorkspace.getAllBlocks();
Blockly.Procedures.allProcedures = function(root) {
var blocks = root.getAllBlocks();
var proceduresReturn = [];
var proceduresNoReturn = [];
for (var x = 0; x < blocks.length; x++) {
@@ -207,7 +208,7 @@ Blockly.Procedures.flyoutCategory = function(blocks, gaps, margin, workspace) {
}
}
var tuple = Blockly.Procedures.allProcedures();
var tuple = Blockly.Procedures.allProcedures(workspace.targetWorkspace);
populateProcedures(tuple[0], 'procedures_callnoreturn');
populateProcedures(tuple[1], 'procedures_callreturn');
};