mirror of
https://github.com/google/blockly.git
synced 2026-01-06 00:20:37 +01:00
chore: update language generators to const and let (#5647)
* chore: update generators/javascript.js to const and let * chore: update generators/lua.js to const and let * chore: update generators/php.js to const and let * chore: update generators/python.js to const and let
This commit is contained in:
@@ -152,7 +152,7 @@ Blockly.PHP.init = function(workspace) {
|
||||
*/
|
||||
Blockly.PHP.finish = function(code) {
|
||||
// Convert the definitions dictionary into a list.
|
||||
var definitions = Blockly.utils.object.values(this.definitions_);
|
||||
const definitions = Blockly.utils.object.values(this.definitions_);
|
||||
// Call Blockly.Generator's finish.
|
||||
code = Object.getPrototypeOf(this).finish.call(this, code);
|
||||
this.isInitialized = false;
|
||||
@@ -193,7 +193,7 @@ Blockly.PHP.quote_ = function(string) {
|
||||
* @protected
|
||||
*/
|
||||
Blockly.PHP.multiline_quote_ = function (string) {
|
||||
var lines = string.split(/\n/g).map(this.quote_);
|
||||
const lines = string.split(/\n/g).map(this.quote_);
|
||||
// Join with the following, plus a newline:
|
||||
// . "\n" .
|
||||
// Newline escaping only works in double-quoted strings.
|
||||
@@ -211,20 +211,20 @@ Blockly.PHP.multiline_quote_ = function (string) {
|
||||
* @protected
|
||||
*/
|
||||
Blockly.PHP.scrub_ = function(block, code, opt_thisOnly) {
|
||||
var commentCode = '';
|
||||
let commentCode = '';
|
||||
// Only collect comments for blocks that aren't inline.
|
||||
if (!block.outputConnection || !block.outputConnection.targetConnection) {
|
||||
// Collect comment for this block.
|
||||
var comment = block.getCommentText();
|
||||
let comment = block.getCommentText();
|
||||
if (comment) {
|
||||
comment = Blockly.utils.string.wrap(comment, this.COMMENT_WRAP - 3);
|
||||
commentCode += this.prefixLines(comment, '// ') + '\n';
|
||||
}
|
||||
// Collect comments for all value arguments.
|
||||
// Don't collect comments for nested statements.
|
||||
for (var i = 0; i < block.inputList.length; i++) {
|
||||
for (let i = 0; i < block.inputList.length; i++) {
|
||||
if (block.inputList[i].type === Blockly.inputTypes.VALUE) {
|
||||
var childBlock = block.inputList[i].connection.targetBlock();
|
||||
const childBlock = block.inputList[i].connection.targetBlock();
|
||||
if (childBlock) {
|
||||
comment = this.allNestedComments(childBlock);
|
||||
if (comment) {
|
||||
@@ -234,8 +234,8 @@ Blockly.PHP.scrub_ = function(block, code, opt_thisOnly) {
|
||||
}
|
||||
}
|
||||
}
|
||||
var nextBlock = block.nextConnection && block.nextConnection.targetBlock();
|
||||
var nextCode = opt_thisOnly ? '' : this.blockToCode(nextBlock);
|
||||
const nextBlock = block.nextConnection && block.nextConnection.targetBlock();
|
||||
const nextCode = opt_thisOnly ? '' : this.blockToCode(nextBlock);
|
||||
return commentCode + code + nextCode;
|
||||
};
|
||||
|
||||
@@ -250,25 +250,25 @@ Blockly.PHP.scrub_ = function(block, code, opt_thisOnly) {
|
||||
*/
|
||||
Blockly.PHP.getAdjusted = function(block, atId, opt_delta, opt_negate,
|
||||
opt_order) {
|
||||
var delta = opt_delta || 0;
|
||||
var order = opt_order || this.ORDER_NONE;
|
||||
let delta = opt_delta || 0;
|
||||
let order = opt_order || this.ORDER_NONE;
|
||||
if (block.workspace.options.oneBasedIndex) {
|
||||
delta--;
|
||||
}
|
||||
var defaultAtIndex = block.workspace.options.oneBasedIndex ? '1' : '0';
|
||||
let defaultAtIndex = block.workspace.options.oneBasedIndex ? '1' : '0';
|
||||
let outerOrder = order;
|
||||
let innerOrder;
|
||||
if (delta > 0) {
|
||||
var at = this.valueToCode(block, atId,
|
||||
this.ORDER_ADDITION) || defaultAtIndex;
|
||||
outerOrder = this.ORDER_ADDITION;
|
||||
innerOrder = this.ORDER_ADDITION;
|
||||
} else if (delta < 0) {
|
||||
var at = this.valueToCode(block, atId,
|
||||
this.ORDER_SUBTRACTION) || defaultAtIndex;
|
||||
outerOrder = this.ORDER_SUBTRACTION;
|
||||
innerOrder = this.ORDER_SUBTRACTION;
|
||||
} else if (opt_negate) {
|
||||
var at = this.valueToCode(block, atId,
|
||||
this.ORDER_UNARY_NEGATION) || defaultAtIndex;
|
||||
} else {
|
||||
var at = this.valueToCode(block, atId, order) ||
|
||||
defaultAtIndex;
|
||||
outerOrder = this.ORDER_UNARY_NEGATION;
|
||||
innerOrder = this.ORDER_UNARY_NEGATION;
|
||||
}
|
||||
let at = this.valueToCode(block, atId, outerOrder) || defaultAtIndex;
|
||||
|
||||
if (Blockly.isNumber(at)) {
|
||||
// If the index is a naked number, adjust it right now.
|
||||
@@ -280,10 +280,8 @@ Blockly.PHP.getAdjusted = function(block, atId, opt_delta, opt_negate,
|
||||
// If the index is dynamic, adjust it in code.
|
||||
if (delta > 0) {
|
||||
at = at + ' + ' + delta;
|
||||
var innerOrder = this.ORDER_ADDITION;
|
||||
} else if (delta < 0) {
|
||||
at = at + ' - ' + -delta;
|
||||
var innerOrder = this.ORDER_SUBTRACTION;
|
||||
}
|
||||
if (opt_negate) {
|
||||
if (delta) {
|
||||
@@ -291,7 +289,6 @@ Blockly.PHP.getAdjusted = function(block, atId, opt_delta, opt_negate,
|
||||
} else {
|
||||
at = '-' + at;
|
||||
}
|
||||
var innerOrder = this.ORDER_UNARY_NEGATION;
|
||||
}
|
||||
innerOrder = Math.floor(innerOrder);
|
||||
order = Math.floor(order);
|
||||
|
||||
Reference in New Issue
Block a user