Created separate file for VariableMap#1079
Created separate file for VariableMap#1079marisaleung merged 5 commits intoRaspberryPiFoundation:developfrom
Conversation
|
Unit tests are failing, since you added a new file. Please rebuild and add only blockly_uncompressed.js to this PR. |
|
Done
…On Wed, May 3, 2017 at 2:28 PM, Rachel Fenichel ***@***.***> wrote:
Unit tests are failing, since you added a new file.
Please rebuild and add only blockly_uncompressed.js to this PR.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1079 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AZ_e9KZu3KTz6wEO8wwt_NI8iJTKbbf6ks5r2PFngaJpZM4NP9cK>
.
|
rachel-fenichel
left a comment
There was a problem hiding this comment.
Some nits but generally looks good to me.
Can any of the workspace tests be moved into a new test file, now that you've moved a bunch of the logic to be internal to VariableMap?
Github says you've got merge markers left in your uncompressed file.
core/variable_map.js
Outdated
| this.createVariable(newName, ''); | ||
| console.log('Tried to rename an non-existent variable.'); | ||
| } | ||
| else if (variableIndex == newVariableIndex || |
There was a problem hiding this comment.
Nit: Move the else if onto the previous line
core/variable_map.js
Outdated
| + variable.getId() + '" which conflicts with the passed in ' + | ||
| 'id, "' + opt_id + '".'); | ||
| } | ||
| return; |
There was a problem hiding this comment.
This is the case where nothing went wrong but the variable already existed, correct? If so, add a comment: "// The variable already exists and has the same id and type."
core/variable_map.js
Outdated
| this.variableMap_[opt_type] = [variable]; | ||
| } | ||
| // Else append the variable to the preexisting list. | ||
| else { |
There was a problem hiding this comment.
nit: else should share a line with the previous closing brace. You can just put the comment inside here, or else remove it.
core/variable_map.js
Outdated
| */ | ||
| Blockly.VariableMap.prototype.deleteVariable = function(variable) { | ||
| var type = variable.type; | ||
| for (var i = 0, tempVar; tempVar = this.variableMap_[type][i]; i++) { |
There was a problem hiding this comment.
Store this.variableMap_[type] in a variable outside of the loop for clarity.
core/variable_map.js
Outdated
| Blockly.VariableMap.prototype.deleteVariable = function(variable) { | ||
| var type = variable.type; | ||
| for (var i = 0, tempVar; tempVar = this.variableMap_[type][i]; i++) { | ||
| if (Blockly.Names.equals(tempVar.name, variable.name)) { |
There was a problem hiding this comment.
Why not check by id? Then you don't have to depend on additional blockly code--it's just a string comparison.
core/variable_map.js
Outdated
| var type = variable.type; | ||
| for (var i = 0, tempVar; tempVar = this.variableMap_[type][i]; i++) { | ||
| if (Blockly.Names.equals(tempVar.name, variable.name)) { | ||
| delete this.variableMap_[type][i]; |
There was a problem hiding this comment.
I think you don't need to call delete--it should get handled by gc once it's removed from the list, and variableModel doesn't have any special disposal code.
core/variable_map.js
Outdated
| * Find the variable by the given name and return it. Return null if it is not | ||
| * found. | ||
| * @param {!string} name The name to check for. | ||
| * @return {?Blockly.VariableModel} the variable with the given name. |
There was a problem hiding this comment.
the variable with the given name, or null if it was not found.
core/variable_map.js
Outdated
| }; | ||
|
|
||
| /** | ||
| * Find the variable with the specified type. If type is null, return list of |
There was a problem hiding this comment.
"Get a list containing all of the variables of a specified type. If type is null, ..."
|
Review status: 0 of 6 files reviewed at latest revision, 8 unresolved discussions, some commit checks failed. core/variable_map.js, line 80 at r1 (raw file): Previously, rachel-fenichel (Rachel Fenichel) wrote…
Done. core/variable_map.js, line 115 at r1 (raw file): Previously, rachel-fenichel (Rachel Fenichel) wrote…
Done. core/variable_map.js, line 129 at r1 (raw file): Previously, rachel-fenichel (Rachel Fenichel) wrote…
Done. core/variable_map.js, line 140 at r1 (raw file): Previously, rachel-fenichel (Rachel Fenichel) wrote…
Done. core/variable_map.js, line 141 at r1 (raw file): Previously, rachel-fenichel (Rachel Fenichel) wrote…
Good point. core/variable_map.js, line 142 at r1 (raw file): Previously, rachel-fenichel (Rachel Fenichel) wrote…
You are right. Took it out. core/variable_map.js, line 153 at r1 (raw file): Previously, rachel-fenichel (Rachel Fenichel) wrote…
Done. core/variable_map.js, line 188 at r1 (raw file): Previously, rachel-fenichel (Rachel Fenichel) wrote…
Done. Comments from Reviewable |
|
All tests that just pass through workspace to variable_map functions have been put into a separate file called "variable_map_tests.js". |
|
Reviewed 1 of 4 files at r1, 4 of 4 files at r2. Comments from Reviewable |
This change is