Allow for variable declarations in readonly-generated code#9659
Merged
Conversation
…[test all] When generating code directly from XML, we use a helper that initializes a new readonly blockspace, populates it with blocks, and generates code from there. We would formerly accomplish this by populating the user's working blockspace with the blocks, generating the code, and then replacing the user's original blockspace, but this had some problems. Unfortunately, the code generator, when scanning the code for variables whose declaration it wants to pull up into the top of the block, only considers the blocks in the main block space when looking for those variables. This can lead to problems, as with [course 4, stage 18][1] The simple fix is to have the generator directly scan for variables in the blocks that it's using. [1]: https://studio.code.org/s/course4/stage/18/puzzle/2
e3015c9 to
6b923cc
Compare
|
|
||
| /** | ||
| * Initialise the database of variable names. | ||
| * @param {Array.<Blockly.Block>} opt_blocks Optional blocks to query for |
Contributor
There was a problem hiding this comment.
Think you could bracket this like: [opt_blocks] to mark it optional in jsdoc
Contributor
|
LGTM |
Contributor
Author
|
(manually canceled test run since I forgot to [ci skip] my documentation change) Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When generating code directly from XML, we use a helper that initializes
a new readonly blockspace, populates it with blocks, and generates code
from there. We would formerly accomplish this by populating the user's
working blockspace with the blocks, generating the code, and then
replacing the user's original blockspace, but this had some problems.
Unfortunately, the code generator, when scanning the code for variables
whose declaration it wants to pull up into the top of the block, only
considers the blocks in the main block space when looking for those
variables. This can lead to problems, as with course 4, stage 18
The simple fix is to have the generator directly scan for variables in
the blocks that it's using.