Skip to content

Commit 7c1ae9a

Browse files
committed
Respond to PR comments
1 parent 7d242b7 commit 7c1ae9a

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/blocks/mrc_mechanism.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const MECHANISM_FUNCTION = {
6666
* Returns the state of this block as a JSON serializable object.
6767
*/
6868
saveExtraState: function (this: MechanismBlock): MechanismExtraState {
69-
let extraState: MechanismExtraState = {
69+
const extraState: MechanismExtraState = {
7070
};
7171
extraState.params = [];
7272
this.mrcArgs.forEach((arg) => {
@@ -103,7 +103,7 @@ const MECHANISM_FUNCTION = {
103103
*/
104104
updateBlock_: function(this: MechanismBlock): void {
105105
// Add input sockets for the arguments.
106-
for (let i = 0; i < this.mrcArgs.length; i++) {
106+
for (const i = 0; i < this.mrcArgs.length; i++) {
107107
const input = this.appendValueInput('ARG' + i)
108108
.setAlign(Blockly.inputs.Align.RIGHT)
109109
.appendField(this.mrcArgs[i].name);
@@ -129,15 +129,15 @@ export const pythonFromBlock = function (
129129
let code = 'self.mechanisms["' + mechanismBlock.getFieldValue('NAME') + '"] = '
130130
+ mechanismBlock.getFieldValue('TYPE') + '('
131131

132-
for (let i = 0; i < mechanismBlock.mrcArgs.length; i++) {
133-
let fieldName = 'ARG' + i;
132+
for (const i = 0; i < mechanismBlock.mrcArgs.length; i++) {
133+
const fieldName = 'ARG' + i;
134134
if(i != 0){
135135
code += ', '
136136
}
137137
code += mechanismBlock.mrcArgs[i].name + ' = ' + generator.valueToCode(mechanismBlock, fieldName, Order.NONE);
138138
}
139139

140-
code += ')' + "\n"
140+
code += ')' + "\n";
141141

142142
return code
143143
}

src/editor/extended_python_generator.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,11 @@ export class ExtendedPythonGenerator extends PythonGenerator {
178178
definitions.push(def);
179179
}
180180
}
181-
// Call Blockly.CodeGenerator's finish.
181+
// Call Blockly.CodeGenerator's finish. This is required to be done this way
182+
// because we derive from PythonGenerator which dervies from CodeGenerator
183+
// This section except for the class_def part is all copied from Blockly's
184+
// PythonGenerator. It can't be derived because it needs the class insertion
185+
// in the middle.
182186
code = Blockly.CodeGenerator.prototype.finish(code);
183187
this.isInitialized = false;
184188

@@ -189,7 +193,8 @@ export class ExtendedPythonGenerator extends PythonGenerator {
189193

190194
this.nameDB_!.reset();
191195
const allDefs = imports.join('\n') + '\n\n' + definitions.join('\n\n');
192-
return allDefs.replace(/\n\n+/g, '\n\n').replace(/\n*$/, '\n\n\n') + class_def + this.prefixLines(code, this.INDENT);
196+
return allDefs.replace(/\n\n+/g, '\n\n').replace(/\n*$/, '\n\n\n') + class_def +
197+
this.prefixLines(code, this.INDENT);
193198
}
194199
}
195200

0 commit comments

Comments
 (0)