mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-22 22:12:28 -05:00
Rename util function to be more descriptive. Refactor parameters to remove unused code.
This commit is contained in:
parent
7faddb6c8f
commit
d91c19434f
3 changed files with 6 additions and 7 deletions
|
@ -515,7 +515,7 @@ class Target extends EventEmitter {
|
|||
// for all references for a given ID instead of doing the below..?
|
||||
this.blocks.getAllVariableAndListReferences()[idToBeMerged];
|
||||
|
||||
VariableUtil.mergeVariables(idToBeMerged, idToMergeWith, referencesToChange, optNewName);
|
||||
VariableUtil.updateVariableIdentifiers(referencesToChange, idToMergeWith, optNewName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1160,7 +1160,7 @@ const replaceUnsafeCharsInVariableIds = function (targets) {
|
|||
// We're calling this on the stage target because we need a
|
||||
// target to call on but this shouldn't matter because we're passing
|
||||
// in all the varRefs we want to operate on
|
||||
VariableUtil.mergeVariables(id, newId, allVarRefs);
|
||||
VariableUtil.updateVariableIdentifiers(allVarRefs[id], newId);
|
||||
}
|
||||
return targets;
|
||||
};
|
||||
|
|
|
@ -25,18 +25,17 @@ class VariableUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Merge variable references with another variable.
|
||||
* @param {string} idToBeMerged ID of the variable whose references need to be updated
|
||||
* @param {string} idToMergeWith ID of the variable that the old references should be replaced with
|
||||
* Give all variable references provided a new id and possibly new name.
|
||||
* @param {Array<object>} referencesToUpdate Context of the change, the object containing variable
|
||||
* references to update.
|
||||
* @param {string} newId ID of the variable that the old references should be replaced with
|
||||
* @param {?string} optNewName New variable name to merge with. The old
|
||||
* variable name in the references being updated should be replaced with this new name.
|
||||
* If this parameter is not provided or is '', no name change occurs.
|
||||
*/
|
||||
static mergeVariables (idToBeMerged, idToMergeWith, referencesToUpdate, optNewName) {
|
||||
static updateVariableIdentifiers (referencesToUpdate, newId, optNewName) {
|
||||
referencesToUpdate.map(ref => {
|
||||
ref.referencingField.id = idToMergeWith;
|
||||
ref.referencingField.id = newId;
|
||||
if (optNewName) {
|
||||
ref.referencingField.value = optNewName;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue