| Index: sdk/lib/_internal/compiler/implementation/js/printer.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/js/printer.dart b/sdk/lib/_internal/compiler/implementation/js/printer.dart
|
| index 048dc71a00d20065768637dcd62e8c6dc5638a64..1cdfbf977d261038b16aa2db2738d62b738b044e 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/js/printer.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/js/printer.dart
|
| @@ -31,11 +31,16 @@ class Printer implements NodeVisitor {
|
| ? new MinifyRenamer() : new IdentityNamer();
|
| }
|
|
|
| - void spaceOut() {
|
| - if (!shouldCompressOutput) out(" ");
|
| + /// Always emit a newline, even under `enableMinification`.
|
| + void forceLine() {
|
| + out("\n");
|
| }
|
| + /// Emits a newline for readability.
|
| void lineOut() {
|
| - if (!shouldCompressOutput) out("\n");
|
| + if (!shouldCompressOutput) forceLine();
|
| + }
|
| + void spaceOut() {
|
| + if (!shouldCompressOutput) out(" ");
|
| }
|
|
|
| String lastAddedString = null;
|
| @@ -70,7 +75,8 @@ class Printer implements NodeVisitor {
|
| if (shouldCompressOutput) {
|
| pendingSemicolon = true;
|
| } else {
|
| - out(";\n");
|
| + out(";");
|
| + forceLine();
|
| }
|
| }
|
|
|
| @@ -672,8 +678,10 @@ class Printer implements NodeVisitor {
|
| return false;
|
| }
|
| }
|
| - // TODO(floitsch): normally we should also check that the field is not
|
| - // a reserved word.
|
| + // TODO(floitsch): normally we should also check that the field is not a
|
| + // reserved word. We don't generate fields with reserved word names except
|
| + // for 'super'.
|
| + if (field == '"super"') return false;
|
| return true;
|
| }
|
|
|
| @@ -758,15 +766,28 @@ class Printer implements NodeVisitor {
|
| }
|
|
|
| visitObjectInitializer(ObjectInitializer node) {
|
| - out("{");
|
| + // Print all the properties on one line until we see a function-valued
|
| + // property. Ideally, we would use a proper pretty-printer to make the
|
| + // decision based on layout.
|
| + bool onePerLine = false;
|
| List<Property> properties = node.properties;
|
| + out("{");
|
| + ++indentLevel;
|
| for (int i = 0; i < properties.length; i++) {
|
| + Expression value = properties[i].value;
|
| + if (value is Fun || value is NamedFunction) onePerLine = true;
|
| if (i != 0) {
|
| out(",");
|
| - spaceOut();
|
| + if (!onePerLine) spaceOut();
|
| + }
|
| + if (onePerLine) {
|
| + forceLine();
|
| + indent();
|
| }
|
| visitProperty(properties[i]);
|
| }
|
| + --indentLevel;
|
| + if (onePerLine) lineOut();
|
| out("}");
|
| }
|
|
|
|
|