Skip to content

Commit

Permalink
CLI: Fixed computed array indexes not being renamed in static code, see
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Mar 24, 2017
1 parent 8d99815 commit 8a60174
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cli/targets/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function beautifyCode(code) {
estraverse.replace(ast, {
enter: function(node, parent) {
// rename short vars
if (node.type === "Identifier" && parent.property !== node && shortVars[node.name])
if (node.type === "Identifier" && (parent.property !== node || parent.computed) && shortVars[node.name])
return {
"type": "Identifier",
"name": shortVars[node.name]
Expand Down
10 changes: 5 additions & 5 deletions tests/data/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,39 +275,39 @@ $root.Package = (function() {
message.bin = {};
key = reader.string();
reader.pos++;
message.bin[k] = reader.string();
message.bin[key] = reader.string();
break;
case 12:
reader.skip().pos++;
if (message.scripts === $util.emptyObject)
message.scripts = {};
key = reader.string();
reader.pos++;
message.scripts[k] = reader.string();
message.scripts[key] = reader.string();
break;
case 13:
reader.skip().pos++;
if (message.dependencies === $util.emptyObject)
message.dependencies = {};
key = reader.string();
reader.pos++;
message.dependencies[k] = reader.string();
message.dependencies[key] = reader.string();
break;
case 14:
reader.skip().pos++;
if (message.optionalDependencies === $util.emptyObject)
message.optionalDependencies = {};
key = reader.string();
reader.pos++;
message.optionalDependencies[k] = reader.string();
message.optionalDependencies[key] = reader.string();
break;
case 15:
reader.skip().pos++;
if (message.devDependencies === $util.emptyObject)
message.devDependencies = {};
key = reader.string();
reader.pos++;
message.devDependencies[k] = reader.string();
message.devDependencies[key] = reader.string();
break;
case 17:
message.types = reader.string();
Expand Down
20 changes: 10 additions & 10 deletions tests/data/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6385,15 +6385,15 @@ $root.jspb = (function() {
message.mapStringString = {};
key = reader.string();
reader.pos++;
message.mapStringString[k] = reader.string();
message.mapStringString[key] = reader.string();
break;
case 2:
reader.skip().pos++;
if (message.mapStringInt32 === $util.emptyObject)
message.mapStringInt32 = {};
key = reader.string();
reader.pos++;
message.mapStringInt32[k] = reader.int32();
message.mapStringInt32[key] = reader.int32();
break;
case 3:
reader.skip().pos++;
Expand All @@ -6409,55 +6409,55 @@ $root.jspb = (function() {
message.mapStringBool = {};
key = reader.string();
reader.pos++;
message.mapStringBool[k] = reader.bool();
message.mapStringBool[key] = reader.bool();
break;
case 5:
reader.skip().pos++;
if (message.mapStringDouble === $util.emptyObject)
message.mapStringDouble = {};
key = reader.string();
reader.pos++;
message.mapStringDouble[k] = reader.double();
message.mapStringDouble[key] = reader.double();
break;
case 6:
reader.skip().pos++;
if (message.mapStringEnum === $util.emptyObject)
message.mapStringEnum = {};
key = reader.string();
reader.pos++;
message.mapStringEnum[k] = reader.uint32();
message.mapStringEnum[key] = reader.uint32();
break;
case 7:
reader.skip().pos++;
if (message.mapStringMsg === $util.emptyObject)
message.mapStringMsg = {};
key = reader.string();
reader.pos++;
message.mapStringMsg[k] = $root.jspb.test.MapValueMessageNoBinary.decode(reader, reader.uint32());
message.mapStringMsg[key] = $root.jspb.test.MapValueMessageNoBinary.decode(reader, reader.uint32());
break;
case 8:
reader.skip().pos++;
if (message.mapInt32String === $util.emptyObject)
message.mapInt32String = {};
key = reader.int32();
reader.pos++;
message.mapInt32String[k] = reader.string();
message.mapInt32String[key] = reader.string();
break;
case 9:
reader.skip().pos++;
if (message.mapInt64String === $util.emptyObject)
message.mapInt64String = {};
key = reader.int64();
reader.pos++;
message.mapInt64String[k] = reader.string();
message.mapInt64String[key] = reader.string();
break;
case 10:
reader.skip().pos++;
if (message.mapBoolString === $util.emptyObject)
message.mapBoolString = {};
key = reader.bool();
reader.pos++;
message.mapBoolString[k] = reader.string();
message.mapBoolString[key] = reader.string();
break;
case 11:
message.testMapFields = $root.jspb.test.TestMapFieldsNoBinary.decode(reader, reader.uint32());
Expand All @@ -6468,7 +6468,7 @@ $root.jspb = (function() {
message.mapStringTestmapfields = {};
key = reader.string();
reader.pos++;
message.mapStringTestmapfields[k] = $root.jspb.test.TestMapFieldsNoBinary.decode(reader, reader.uint32());
message.mapStringTestmapfields[key] = $root.jspb.test.TestMapFieldsNoBinary.decode(reader, reader.uint32());
break;
default:
reader.skipType(tag & 7);
Expand Down

0 comments on commit 8a60174

Please sign in to comment.