mirror of
https://github.com/google/blockly.git
synced 2026-01-11 19:07:08 +01:00
Block generator warnings (#3353)
This commit is contained in:
@@ -351,7 +351,7 @@ Blockly.Generator.prototype.injectId = function(msg, block) {
|
||||
/**
|
||||
* Comma-separated list of reserved words.
|
||||
* @type {string}
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
Blockly.Generator.prototype.RESERVED_WORDS_ = '';
|
||||
|
||||
@@ -370,7 +370,7 @@ Blockly.Generator.prototype.addReservedWords = function(words) {
|
||||
* legitimately appear in a function definition (or comment), and it must
|
||||
* not confuse the regular expression parser.
|
||||
* @type {string}
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
Blockly.Generator.prototype.FUNCTION_NAME_PLACEHOLDER_ = '{leCUI8hutHZI4480Dc}';
|
||||
|
||||
@@ -411,7 +411,7 @@ Blockly.Generator.prototype.variableDB_;
|
||||
* @param {!Array.<string>} code A list of statements. Use ' ' for indents.
|
||||
* @return {string} The actual name of the new function. This may differ
|
||||
* from desiredName if the former has already been taken by the user.
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
Blockly.Generator.prototype.provideFunction_ = function(desiredName, code) {
|
||||
if (!this.definitions_[desiredName]) {
|
||||
|
||||
@@ -76,7 +76,6 @@ Blockly.Names.prototype.reset = function() {
|
||||
/**
|
||||
* Set the variable map that maps from variable name to variable object.
|
||||
* @param {!Blockly.VariableMap} map The map to track.
|
||||
* @package
|
||||
*/
|
||||
Blockly.Names.prototype.setVariableMap = function(map) {
|
||||
this.variableMap_ = map;
|
||||
@@ -84,7 +83,8 @@ Blockly.Names.prototype.setVariableMap = function(map) {
|
||||
|
||||
/**
|
||||
* Get the name for a user-defined variable, based on its ID.
|
||||
* This should only be used for variables of type Blockly.Variables.NAME_TYPE.
|
||||
* This should only be used for variables of type
|
||||
* Blockly.VARIABLE_CATEGORY_NAME.
|
||||
* @param {string} id The ID to look up in the variable map.
|
||||
* @return {?string} The name of the referenced variable, or null if there was
|
||||
* no variable map or the variable was not found in the map.
|
||||
@@ -113,7 +113,6 @@ Blockly.Names.prototype.getNameForUserVariable_ = function(id) {
|
||||
* @param {string} type The type of entity in Blockly
|
||||
* ('VARIABLE', 'PROCEDURE', 'BUILTIN', etc...).
|
||||
* @return {string} An entity name that is legal in the exported language.
|
||||
* @suppress {deprecated} Suppress deprecated Blockly.Variables.NAME_TYPE.
|
||||
*/
|
||||
Blockly.Names.prototype.getName = function(name, type) {
|
||||
if (type == Blockly.VARIABLE_CATEGORY_NAME) {
|
||||
|
||||
@@ -43,7 +43,7 @@ Blockly.Dart['controls_repeat_ext'] = function(block) {
|
||||
'count', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
var endVar = repeats;
|
||||
if (!repeats.match(/^\w+$/) && !Blockly.isNumber(repeats)) {
|
||||
var endVar = Blockly.Dart.variableDB_.getDistinctName(
|
||||
endVar = Blockly.Dart.variableDB_.getDistinctName(
|
||||
'repeat_end', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += 'var ' + endVar + ' = ' + repeats + ';\n';
|
||||
}
|
||||
@@ -102,13 +102,13 @@ Blockly.Dart['controls_for'] = function(block) {
|
||||
// Cache non-trivial values to variables to prevent repeated look-ups.
|
||||
var startVar = argument0;
|
||||
if (!argument0.match(/^\w+$/) && !Blockly.isNumber(argument0)) {
|
||||
var startVar = Blockly.Dart.variableDB_.getDistinctName(
|
||||
startVar = Blockly.Dart.variableDB_.getDistinctName(
|
||||
variable0 + '_start', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += 'var ' + startVar + ' = ' + argument0 + ';\n';
|
||||
}
|
||||
var endVar = argument1;
|
||||
if (!argument1.match(/^\w+$/) && !Blockly.isNumber(argument1)) {
|
||||
var endVar = Blockly.Dart.variableDB_.getDistinctName(
|
||||
endVar = Blockly.Dart.variableDB_.getDistinctName(
|
||||
variable0 + '_end', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += 'var ' + endVar + ' = ' + argument1 + ';\n';
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ Blockly.JavaScript['lists_setIndex'] = function(block) {
|
||||
* @param {string} listName Name of the list, used to calculate length.
|
||||
* @param {string} where The method of indexing, selected by dropdown in Blockly
|
||||
* @param {string=} opt_at The optional offset when indexing from start/end.
|
||||
* @return {string} Index expression.
|
||||
* @return {string|undefined} Index expression.
|
||||
* @private
|
||||
*/
|
||||
Blockly.JavaScript.lists.getIndex_ = function(listName, where, opt_at) {
|
||||
|
||||
@@ -43,7 +43,7 @@ Blockly.JavaScript['controls_repeat_ext'] = function(block) {
|
||||
'count', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
var endVar = repeats;
|
||||
if (!repeats.match(/^\w+$/) && !Blockly.isNumber(repeats)) {
|
||||
var endVar = Blockly.JavaScript.variableDB_.getDistinctName(
|
||||
endVar = Blockly.JavaScript.variableDB_.getDistinctName(
|
||||
'repeat_end', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += 'var ' + endVar + ' = ' + repeats + ';\n';
|
||||
}
|
||||
@@ -109,7 +109,7 @@ Blockly.JavaScript['controls_for'] = function(block) {
|
||||
}
|
||||
var endVar = argument1;
|
||||
if (!argument1.match(/^\w+$/) && !Blockly.isNumber(argument1)) {
|
||||
var endVar = Blockly.JavaScript.variableDB_.getDistinctName(
|
||||
endVar = Blockly.JavaScript.variableDB_.getDistinctName(
|
||||
variable0 + '_end', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += 'var ' + endVar + ' = ' + argument1 + ';\n';
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ Blockly.JavaScript['text_charAt'] = function(block) {
|
||||
* @param {string} stringName Name of the string, used to calculate length.
|
||||
* @param {string} where The method of indexing, selected by dropdown in Blockly
|
||||
* @param {string=} opt_at The optional offset when indexing from start/end.
|
||||
* @return {string} Index expression.
|
||||
* @return {string|undefined} Index expression.
|
||||
* @private
|
||||
*/
|
||||
Blockly.JavaScript.text.getIndex_ = function(stringName, where, opt_at) {
|
||||
|
||||
@@ -114,7 +114,7 @@ Blockly.Lua['lists_indexOf'] = function(block) {
|
||||
* @param {string} listName Name of the list, used to calculate length.
|
||||
* @param {string} where The method of indexing, selected by dropdown in Blockly
|
||||
* @param {string=} opt_at The optional offset when indexing from start/end.
|
||||
* @return {string} Index expression.
|
||||
* @return {string|undefined} Index expression.
|
||||
* @private
|
||||
*/
|
||||
Blockly.Lua.lists.getIndex_ = function(listName, where, opt_at) {
|
||||
@@ -374,6 +374,6 @@ Blockly.Lua['lists_reverse'] = function(block) {
|
||||
' end',
|
||||
' return reversed',
|
||||
'end']);
|
||||
var code = 'list_reverse(' + list + ')';
|
||||
var code = functionName + '(' + list + ')';
|
||||
return [code, Blockly.Lua.ORDER_HIGH];
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@ Blockly.PHP['controls_repeat_ext'] = function(block) {
|
||||
'count', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
var endVar = repeats;
|
||||
if (!repeats.match(/^\w+$/) && !Blockly.isNumber(repeats)) {
|
||||
var endVar = Blockly.PHP.variableDB_.getDistinctName(
|
||||
endVar = Blockly.PHP.variableDB_.getDistinctName(
|
||||
'repeat_end', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += endVar + ' = ' + repeats + ';\n';
|
||||
}
|
||||
@@ -108,7 +108,7 @@ Blockly.PHP['controls_for'] = function(block) {
|
||||
}
|
||||
var endVar = argument1;
|
||||
if (!argument1.match(/^\w+$/) && !Blockly.isNumber(argument1)) {
|
||||
var endVar = Blockly.PHP.variableDB_.getDistinctName(
|
||||
endVar = Blockly.PHP.variableDB_.getDistinctName(
|
||||
variable0 + '_end', Blockly.VARIABLE_CATEGORY_NAME);
|
||||
code += endVar + ' = ' + argument1 + ';\n';
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ Blockly.Python['math_single'] = function(block) {
|
||||
var arg;
|
||||
if (operator == 'NEG') {
|
||||
// Negation is a special case given its different operator precedence.
|
||||
var code = Blockly.Python.valueToCode(block, 'NUM',
|
||||
code = Blockly.Python.valueToCode(block, 'NUM',
|
||||
Blockly.Python.ORDER_UNARY_SIGN) || '0';
|
||||
return ['-' + code, Blockly.Python.ORDER_UNARY_SIGN];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user