Factor out procedure population from generators

Also fix bug in Lua generator where variables were not populated in the nameDB (only language with no variable initialization).
This commit is contained in:
Neil Fraser
2021-05-24 11:12:40 -07:00
committed by Neil Fraser
parent 9869269ce2
commit 43b65d2aa1
6 changed files with 34 additions and 40 deletions

View File

@@ -101,14 +101,8 @@ Blockly.Lua.init = function(workspace) {
this.nameDB_.reset();
}
this.nameDB_.setVariableMap(workspace.getVariableMap());
// Add user procedures.
var procedures = Blockly.Procedures.allProcedures(workspace);
// Flatten the return vs no-return procedure lists.
procedures = procedures[0].concat(procedures[1]);
for (var i = 0; i < procedures.length; i++) {
this.nameDB_.getName(procedures[i][0], Blockly.PROCEDURE_CATEGORY_NAME);
}
this.nameDB_.populateVariables(workspace);
this.nameDB_.populateProcedures(workspace);
this.isInitialized = true;
};