Fix compiler errors.

This commit is contained in:
Neil Fraser
2016-11-15 16:41:11 -08:00
parent e5d25bb686
commit c27841f8df
4 changed files with 42 additions and 39 deletions

View File

@@ -195,7 +195,7 @@ Blockly.Blocks['lists_create_with_container'] = {
Blockly.Blocks['lists_create_with_item'] = {
/**
* Mutator bolck for adding items.
* Mutator block for adding items.
* @this Blockly.Block
*/
init: function() {

View File

@@ -236,7 +236,7 @@ Blockly.Blocks['controls_if_if'] = {
Blockly.Blocks['controls_if_elseif'] = {
/**
* Mutator bolck for else-if condition.
* Mutator block for else-if condition.
* @this Blockly.Block
*/
init: function() {
@@ -268,6 +268,7 @@ Blockly.Blocks['controls_if_else'] = {
Blockly.Blocks['controls_ifelse'] = {
/**
* If/else block that does not use a mutator.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
@@ -303,7 +304,7 @@ Blockly.Blocks['controls_ifelse'] = {
"colour": Blockly.Blocks.logic.HUE,
"tooltip": Blockly.Msg.CONTROLS_IF_TOOLTIP_2,
"helpUrl": Blockly.Msg.CONTROLS_IF_HELPURL
});
});
}
};

View File

@@ -78,6 +78,7 @@ Blockly.utils.removeClass = function(element, className) {
} else {
element.removeAttribute('class');
}
return true;
};
/**

View File

@@ -301,45 +301,46 @@ Blockly.Workspace.prototype.getVariableUses = function(name) {
* @param {string} name Name of variable to delete.
*/
Blockly.Workspace.prototype.deleteVariable = function(name) {
var workspace = this;
var variableIndex = this.variableIndexOf(name);
if (variableIndex != -1) {
// Check whether this variable is a function parameter before deleting.
var uses = this.getVariableUses(name);
for (var i = 0, block; block = uses[i]; i++) {
if (block.type == 'procedures_defnoreturn' ||
block.type == 'procedures_defreturn') {
var procedureName = block.getFieldValue('NAME');
Blockly.alert(
Blockly.Msg.CANNOT_DELETE_VARIABLE_PROCEDURE.
replace('%1', name).
replace('%2', procedureName));
return;
}
if (variableIndex == -1) {
return;
}
// Check whether this variable is a function parameter before deleting.
var uses = this.getVariableUses(name);
for (var i = 0, block; block = uses[i]; i++) {
if (block.type == 'procedures_defnoreturn' ||
block.type == 'procedures_defreturn') {
var procedureName = block.getFieldValue('NAME');
Blockly.alert(
Blockly.Msg.CANNOT_DELETE_VARIABLE_PROCEDURE.
replace('%1', name).
replace('%2', procedureName));
return;
}
function doDeletion() {
Blockly.Events.setGroup(true);
for (var i = 0; i < uses.length; i++) {
uses[i].dispose(true, false);
}
Blockly.Events.setGroup(false);
workspace.variableList.splice(variableIndex, 1);
}
if (uses.length > 1) {
// Confirm before deleting multiple blocks.
Blockly.confirm(
Blockly.Msg.DELETE_VARIABLE_CONFIRMATION.replace('%1', uses.length).
replace('%2', name),
function(ok) {
if (ok) {
doDeletion();
}
});
} else {
// No confirmation necessary for a single block.
doDeletion();
}
var workspace = this;
function doDeletion() {
Blockly.Events.setGroup(true);
for (var i = 0; i < uses.length; i++) {
uses[i].dispose(true, false);
}
Blockly.Events.setGroup(false);
workspace.variableList.splice(variableIndex, 1);
}
if (uses.length > 1) {
// Confirm before deleting multiple blocks.
Blockly.confirm(
Blockly.Msg.DELETE_VARIABLE_CONFIRMATION.replace('%1', uses.length).
replace('%2', name),
function(ok) {
if (ok) {
doDeletion();
}
});
} else {
// No confirmation necessary for a single block.
doDeletion();
}
};