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

Unified Diff: pkg/js_ast/lib/src/printer.dart

Issue 1548793002: dart2js: format 'static' sections better. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/full_emitter/class_emitter.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/js_ast/lib/src/printer.dart
diff --git a/pkg/js_ast/lib/src/printer.dart b/pkg/js_ast/lib/src/printer.dart
index d5c1d9b57048ed6397487f0fff16830e6733f7eb..edd4189d3afd5e5b22713b05b6523aa2bb918421 100644
--- a/pkg/js_ast/lib/src/printer.dart
+++ b/pkg/js_ast/lib/src/printer.dart
@@ -1069,22 +1069,31 @@ 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 exitOneLinerMode(Expression value) {
+ return
+ value is Fun ||
+ value is ArrayInitializer && value.elements.any((e) => e is Fun);
+ }
+
+ bool isOneLiner = node.isOneLiner || shouldCompressOutput;
List<Property> properties = node.properties;
out("{");
indentMore();
for (int i = 0; i < properties.length; i++) {
+ Node value = properties[i].value;
+ if (isOneLiner && exitOneLinerMode(value)) isOneLiner = false;
if (i != 0) {
out(",");
- if (node.isOneLiner) spaceOut();
+ if (isOneLiner) spaceOut();
}
- if (!node.isOneLiner) {
+ if (!isOneLiner) {
forceLine();
indent();
}
visit(properties[i]);
}
indentLess();
- if (!node.isOneLiner && !properties.isEmpty) {
+ if (!isOneLiner && !properties.isEmpty) {
lineOut();
indent();
}
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/full_emitter/class_emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698