Skip to content

Commit

Permalink
fix(generators): Fix minor inconsistencies in JS and Python
Browse files Browse the repository at this point in the history
The migration of the JavaScript and Python generators
inadvertently introduced some inconsistencies in the code,
e.g.:

- Incorrect import ordering.
- Putting executable code before the initial comment line that
  most generator functions begin with, and/or deleting or
  replacing these comments.
  -  N.B. however that these inline comments should have been
     JSDocs; a task to convert them has been added to google#7600.
  • Loading branch information
cpcallen committed Nov 12, 2023
1 parent a4f2fbe commit d934aa1
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion generators/javascript/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export function lists_create_with(
block: Block,
generator: JavascriptGenerator,
): [string, Order] {
const createWithBlock = block as CreateWithBlock;
// Create a list with any number of elements of any type.
const createWithBlock = block as CreateWithBlock;
const elements = new Array(createWithBlock.itemCount_);
for (let i = 0; i < createWithBlock.itemCount_; i++) {
elements[i] = generator.valueToCode(block, 'ADD' + i, Order.NONE) || 'null';
Expand Down
2 changes: 1 addition & 1 deletion generators/javascript/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function logic_compare(
block: Block,
generator: JavascriptGenerator,
): [string, Order] {
// Dictionary of OP comparison operators and their implementations.
// Comparison operator.
const OPERATORS = {
'EQ': '==',
'NEQ': '!=',
Expand Down
4 changes: 2 additions & 2 deletions generators/javascript/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
// Former goog.module ID: Blockly.JavaScript.texts

import type {Block} from '../../core/block.js';
import type {JoinMutatorBlock} from '../../blocks/text.js';
import type {JavascriptGenerator} from './javascript_generator.js';
import type {JoinMutatorBlock} from '../../blocks/text.js';
import {Order} from './javascript_generator.js';

/**
Expand Down Expand Up @@ -80,8 +80,8 @@ export function text_join(
block: Block,
generator: JavascriptGenerator,
): [string, Order] {
const joinBlock = block as JoinMutatorBlock;
// Create a string made up of any number of elements of any type.
const joinBlock = block as JoinMutatorBlock;
switch (joinBlock.itemCount_) {
case 0:
return ["''", Order.ATOMIC];
Expand Down
2 changes: 1 addition & 1 deletion generators/python/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export function lists_create_with(
block: Block,
generator: PythonGenerator,
): [string, Order] {
const createWithBlock = block as CreateWithBlock;
// Create a list with any number of elements of any type.
const createWithBlock = block as CreateWithBlock;
const elements = new Array(createWithBlock.itemCount_);
for (let i = 0; i < createWithBlock.itemCount_; i++) {
elements[i] = generator.valueToCode(block, 'ADD' + i, Order.NONE) || 'None';
Expand Down
2 changes: 1 addition & 1 deletion generators/python/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ export function text_join(
block: Block,
generator: PythonGenerator,
): [string, Order] {
const joinBlock = block as JoinMutatorBlock;
// Create a string made up of any number of elements of any type.
// Should we allow joining by '-' or ',' or any other characters?
const joinBlock = block as JoinMutatorBlock;
switch (joinBlock.itemCount_) {
case 0:
return ["''", Order.ATOMIC];
Expand Down

0 comments on commit d934aa1

Please sign in to comment.