Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: sdk/lib/_internal/compiler/implementation/js/printer.dart

Issue 80053004: Nicer pretty printing of jsAst object literals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 1cf97a3e180362ebf70e2e757a800bb55d6bb95a..bc29bfedfde91fc776ff8e25195d3a2b21dbd281 100644
--- a/sdk/lib/_internal/compiler/implementation/js/printer.dart
+++ b/sdk/lib/_internal/compiler/implementation/js/printer.dart
@@ -802,25 +802,26 @@ class Printer implements NodeVisitor {
// 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(",");
- if (!onePerLine) spaceOut();
+ if (node.isOneLiner) spaceOut();
}
- if (onePerLine) {
+ if (!node.isOneLiner) {
forceLine();
indent();
}
visitProperty(properties[i]);
}
--indentLevel;
- if (onePerLine) lineOut();
+ if (!node.isOneLiner && !properties.isEmpty) {
+ lineOut();
+ indent();
+ }
out("}");
}

Powered by Google App Engine
This is Rietveld 408576698