Commit Graph

76 Commits

Author SHA1 Message Date
Neil Fraser
fb170b9052 Remove extra space in generator error message. 2021-06-11 12:12:14 -07:00
Neil Fraser
861a981cb6 Remove extra else clauses 2021-06-09 11:41:42 -07:00
Neil Fraser
e661c92a36 More JSDoc improvements 2021-05-27 21:30:26 -07:00
Neil Fraser
f64c11d74e Make JSDoc object nullability more strict.
Also make Blockly.utils.deprecation.warn apply to properties.
2021-05-27 21:30:26 -07:00
Neil Fraser
9869269ce2 Add procedures to name DB in init
This enables the generator for any block to see all variable names and procedure names in the whole program, including those that haven’t generated yet.
2021-05-27 21:30:26 -07:00
Neil Fraser
ecca5bf274 Use Object.values rather than loop
Only for JS, Lua, and PHP.  Dart and Python need extra logic to split out import statements.

Also use ‘this’ instead of fully qualified names in generators.
2021-05-27 21:30:26 -07:00
Neil Fraser
d919b0af21 Update JSDoc from Array.<> to Array<>
Same with Object.
2021-05-27 21:30:26 -07:00
Neil Fraser
b50cb5779f Set generator’s isInitialized to false in finish
Previously isInitialized would remain true after first generation.
Also move common init/finish code to parent class.
2021-05-27 21:30:26 -07:00
Neil Fraser
5d2c48e1ab Remove unused Blockly.Generator.NAME_TYPE 2021-05-27 21:30:26 -07:00
Neil Fraser
d519ab8f54 JSDoc improvements 2021-05-27 21:30:26 -07:00
Neil Fraser
2f2252f588 Rename variableDB_ to nameDB_
There is significant confusion in names and comments with regards to variables and procedures.  `Blockly.Generator.prototype.variableDB_` is a Blockly.Names database, not a variable map.  This rename introduces a getter and setter so deprecated references still work.  This commit also fixes some comments which are either outright wrong or misleading regarding variable and procedure names.
2021-05-27 21:30:26 -07:00
Sam El-Husseini
63d26dc186 Add extra requires check (#4677)
* Add extra requires check
2021-03-05 09:50:51 -08:00
Sam El-Husseini
f97730e83c Sort requires (#4658)
* Cleanup gulp method to sort requires
2021-02-25 17:17:42 -08:00
Rachel Fenichel
a392fcc57c More missing requireType calls 2021-02-17 11:32:54 -08:00
Monica Kozbial
6510e49162 Add warning to blockToCode (#4492)
* Add warning to blockToCode

* Address PR comments
2020-12-07 10:38:32 -08:00
Monica Kozbial
5a3b99a08c Updating JsDoc in response to comment (#4491) 2020-12-02 16:13:53 -08:00
Monica Kozbial
bbca82cffb Add info to JsDoc for blockToCode (#4490) 2020-12-02 15:27:48 -08:00
Sam El-Husseini
fba35d342c Add missing require Blockly.constants (#4366) 2020-10-12 17:56:42 -04:00
Beka Westberg
65bb33635d Add ignoring insertion markers in code gen 2020-05-02 07:37:58 -07:00
Neil Fraser
4e2f8e6e02 Use SPDX licences.
This is a followup to #3127.
At the time, SPDX licenses were pending approval by Google.
2020-02-11 13:27:20 -08:00
Neil Fraser
123f436e04 Add parens around inline assignments (#3381) 2019-10-31 15:17:35 -07:00
Sam El-Husseini
72c6aa8699 Block generator warnings (#3353) 2019-10-28 16:20:25 -07:00
Sam El-Husseini
a9cd25f2a4 Fix 6 warnings related to generators. (#3293) 2019-10-21 22:20:04 -04:00
Sam El-Husseini
664cc3d6cd Fix warnings related to number of arguments passed. (#3270) 2019-10-17 11:47:30 -05:00
Neil Fraser
b46a4fe286 Bring our license format up to date (#3127)
* Google changed from an Inc to an LLC.

This happened back in 2017 but we didn’t notice.  Officially we should update files from Inc to LLC when they are changed as part of regular edits, but this is a nightmare to remember for the next decade.

* Remove project description/titles from licenses

This is no longer part of Google’s header requirements.  Our existing descriptions were useless (“Visual Blocks Editor”) or grossly obselete (“Visual Blocks Language”).

* License no longer requires URL.

* Fix license regexps.
2019-10-02 14:46:56 -07:00
Neil Fraser
5650fe51a2 Typos. 2019-09-12 18:24:48 -07:00
Neil Fraser
5cf52c566a Fix a dozen compiler warnings. 2019-05-17 16:48:40 -07:00
Neil Fraser
05253d0766 Add prefix/suffix to orphaned value blocks.
Also respect suppressPrefixSuffix on loops when generating prefix/suffix with continue/break blocks.
2019-05-17 15:04:39 -07:00
Neil Fraser
ed0b5adcd1 Wrong language. 2019-05-17 15:04:39 -07:00
Neil Fraser
c0e14c3a7c Add method to suppress prefix/suffix from blocks.
This allows generators to have more control over the placement of suffix.  Needed for ‘if’ blocks and function calls which require their suffix code to be somewhere other than the end.
Also, add loop’s prefix to ‘break’ blocks, since the loop’s suffix will be the next statement hit.
Also, reuse procedures_callreturn generator for procedures_callnoreturn.
2019-05-14 17:19:31 -07:00
Neil Fraser
25adb40e66 Prefix and suffix edge cases for flow statements.
Call suffix code on break/continue before executing the break/continue.
Call prefix code for enclosing loop before executing continue.
2019-05-14 17:19:31 -07:00
Neil Fraser
0259f8bb48 Add extra suffix when generating if/return block.
Also fix loops in Lua.
2019-05-14 17:19:31 -07:00
Neil Fraser
ba18ae2159 Add STATEMENT_SUFFIX
Also remove need to manually indent INFINITE_LOOP_TRAP.  This is a breaking change for Python users of this property.  However, very few users of this property exist, given that the existing code breaks if the block ID has a $ in it (also fixed in this PR).
2019-05-14 17:19:31 -07:00
Neil Fraser
834fa64674 Use Element constants and ‘i’ variable.
I don’t care about whether we use the Element constants or the ubiquitously known 1 & 3 integers.  But we had a mix.
Also, ’x’ is usually used for horizontal location, ‘i’ is an iterator.
No functional change.
2019-05-02 09:56:37 -07:00
alschmiedt
1ca7d6a28b Clarifies what statementToCode does 2019-04-22 14:20:05 -07:00
alschmiedt
98a1c06e7a Changed jsdoc 2019-04-08 10:48:22 -07:00
alschmiedt
97d670c0ea Updates documentation 2019-04-05 12:00:04 -07:00
alschmiedt
4fca16730c core/generator.js 2019-04-05 11:59:05 -07:00
alschmiedt
f06bee4eca Fixes pull request comments 2018-11-27 09:55:15 -08:00
Abby Schmiedt
26a4774b35 Adds option to generate code for a single block 2018-11-21 09:00:29 -08:00
Neil Fraser
dce60fd152 Replace ReferenceError with Error.
Change to 4-space indentation rather than aligning with parent structure.
2018-07-11 12:20:02 -07:00
Neil Fraser
3909bd420a Remove all goog.asserts and goog.isXxx
First step to reducing Closure’s footprint.
2018-07-11 12:20:02 -07:00
Neil Fraser
662d79443f Add 'ordered' option to descendant getting functions. (#1786) 2018-04-17 11:41:03 -07:00
Rachel Fenichel
52e0241f66 Add argsIgnorePattern to the eslintrc 2018-04-06 13:29:22 -07:00
Andrew n marshall
dc7783ee01 Warn conflicts with Blockly.Generator.prototype (#1603)
Console warning if block prototypeName conflicts with Blockly.Generator.prototype.
2018-02-12 13:44:54 -08:00
Rachel Fenichel
13aa7bfb69 No-regex-spaces 2017-11-07 17:27:00 -08:00
Rachel Fenichel
22b018321c update generator comments 2016-12-09 22:10:36 -08:00
Rachel Fenichel
33d6f72b29 Merge pull request #650 from trodi/generator-docs
Add Generator functions to prototype + JSDoc
2016-12-09 17:46:47 -08:00
Neil Fraser
4cda20dbbf Fix speling. 2016-11-19 02:40:11 -08:00
Neil Fraser
ddf3b72a7f Prevent custom indents from getting into an infinite loop. 2016-10-31 11:32:04 -07:00