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

Side by Side Diff: lib/src/js/printer.dart

Issue 1138793002: Tag closures with their types (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Rebase Created 5 years, 7 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of js_ast; 5 part of js_ast;
6 6
7 7
8 class JavaScriptPrintingOptions { 8 class JavaScriptPrintingOptions {
9 final bool shouldCompressOutput; 9 final bool shouldCompressOutput;
10 final bool minifyLocalVariables; 10 final bool minifyLocalVariables;
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 } else { 854 } else {
855 out("("); 855 out("(");
856 visitCommaSeparated(fun.params, PRIMARY, 856 visitCommaSeparated(fun.params, PRIMARY,
857 newInForInit: false, newAtStatementBegin: false); 857 newInForInit: false, newAtStatementBegin: false);
858 out(")"); 858 out(")");
859 } 859 }
860 spaceOut(); 860 spaceOut();
861 out("=>"); 861 out("=>");
862 if (fun.body is Expression) { 862 if (fun.body is Expression) {
863 spaceOut(); 863 spaceOut();
864 if (fun.body is ObjectInitializer) out("(");
Jennifer Messerly 2015/05/19 18:19:01 Lovely fix! Small suggestion: // Object initiali
Leaf 2015/05/19 22:31:13 Done.
864 visitNestedExpression(fun.body, ASSIGNMENT, 865 visitNestedExpression(fun.body, ASSIGNMENT,
865 newInForInit: false, newAtStatementBegin: false); 866 newInForInit: false, newAtStatementBegin: false);
867 if (fun.body is ObjectInitializer) out(")");
866 } else { 868 } else {
867 blockBody(fun.body, needsSeparation: false, needsNewline: false); 869 blockBody(fun.body, needsSeparation: false, needsNewline: false);
868 } 870 }
869 localNamer.leaveScope(); 871 localNamer.leaveScope();
870 if (fun.bindThisWorkaround) { 872 if (fun.bindThisWorkaround) {
871 out(").bind(this)"); 873 out(").bind(this)");
872 } 874 }
873 } 875 }
874 876
875 visitLiteralBool(LiteralBool node) { 877 visitLiteralBool(LiteralBool node) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 } 922 }
921 923
922 visitObjectInitializer(ObjectInitializer node) { 924 visitObjectInitializer(ObjectInitializer node) {
923 // Print all the properties on one line until we see a function-valued 925 // Print all the properties on one line until we see a function-valued
924 // property. Ideally, we would use a proper pretty-printer to make the 926 // property. Ideally, we would use a proper pretty-printer to make the
925 // decision based on layout. 927 // decision based on layout.
926 List<Property> properties = node.properties; 928 List<Property> properties = node.properties;
927 out("{"); 929 out("{");
928 indentMore(); 930 indentMore();
929 931
930 var isOneLiner = !properties.any((p) => p.value is FunctionExpression); 932 var isOneLiner = !(node.vertical ||
933 properties.any((p) => p.value is FunctionExpression));
931 for (int i = 0; i < properties.length; i++) { 934 for (int i = 0; i < properties.length; i++) {
932 if (i != 0) { 935 if (i != 0) {
933 out(","); 936 out(",");
934 if (isOneLiner) spaceOut(); 937 if (isOneLiner) spaceOut();
935 } 938 }
936 if (!isOneLiner) { 939 if (!isOneLiner) {
937 forceLine(); 940 forceLine();
938 indent(); 941 indent();
939 } 942 }
940 visit(properties[i]); 943 visit(properties[i]);
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 declare(node.name); 1437 declare(node.name);
1435 node.function.accept(this); 1438 node.function.accept(this);
1436 } 1439 }
1437 1440
1438 visitClassExpression(ClassExpression node) { 1441 visitClassExpression(ClassExpression node) {
1439 declare(node.name); 1442 declare(node.name);
1440 if (node.heritage != null) node.heritage.accept(this); 1443 if (node.heritage != null) node.heritage.accept(this);
1441 for (Method element in node.methods) element.accept(this); 1444 for (Method element in node.methods) element.accept(this);
1442 } 1445 }
1443 } 1446 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698