| OLD | NEW |
| 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 typedef String Renamer(Name); | 8 typedef String Renamer(Name); |
| 9 | 9 |
| 10 class JavaScriptPrintingOptions { | 10 class JavaScriptPrintingOptions { |
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 @override | 926 @override |
| 927 void visitAccess(PropertyAccess access) { | 927 void visitAccess(PropertyAccess access) { |
| 928 visitNestedExpression(access.receiver, CALL, | 928 visitNestedExpression(access.receiver, CALL, |
| 929 newInForInit: inForInit, | 929 newInForInit: inForInit, |
| 930 newAtStatementBegin: atStatementBegin); | 930 newAtStatementBegin: atStatementBegin); |
| 931 Node selector = access.selector; | 931 Node selector = access.selector; |
| 932 if (selector is LiteralString) { | 932 if (selector is LiteralString) { |
| 933 LiteralString selectorString = selector; | 933 LiteralString selectorString = selector; |
| 934 String fieldWithQuotes = selectorString.value; | 934 String fieldWithQuotes = selectorString.value; |
| 935 if (isValidJavaScriptId(fieldWithQuotes)) { | 935 if (isValidJavaScriptId(fieldWithQuotes)) { |
| 936 if (access.receiver is LiteralNumber) out(" ", isWhitespace: true); | 936 if (access.receiver is LiteralNumber && |
| 937 lastCharCode != charCodes.$CLOSE_PAREN) { |
| 938 out(" ", isWhitespace: true); |
| 939 } |
| 937 out("."); | 940 out("."); |
| 938 startNode(selector); | 941 startNode(selector); |
| 939 out(fieldWithQuotes.substring(1, fieldWithQuotes.length - 1)); | 942 out(fieldWithQuotes.substring(1, fieldWithQuotes.length - 1)); |
| 940 endNode(selector); | 943 endNode(selector); |
| 941 return; | 944 return; |
| 942 } | 945 } |
| 943 } else if (selector is Name) { | 946 } else if (selector is Name) { |
| 944 if (access.receiver is LiteralNumber) out(" ", isWhitespace: true); | 947 if (access.receiver is LiteralNumber && |
| 948 lastCharCode != charCodes.$CLOSE_PAREN) { |
| 949 out(" ", isWhitespace: true); |
| 950 } |
| 945 out("."); | 951 out("."); |
| 946 startNode(selector); | 952 startNode(selector); |
| 947 selector.accept(this); | 953 selector.accept(this); |
| 948 endNode(selector); | 954 endNode(selector); |
| 949 return; | 955 return; |
| 950 } | 956 } |
| 951 out("["); | 957 out("["); |
| 952 visitNestedExpression(selector, EXPRESSION, | 958 visitNestedExpression(selector, EXPRESSION, |
| 953 newInForInit: false, newAtStatementBegin: false); | 959 newInForInit: false, newAtStatementBegin: false); |
| 954 out("]"); | 960 out("]"); |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1480 context.enterNode(node, position); | 1486 context.enterNode(node, position); |
| 1481 } | 1487 } |
| 1482 } | 1488 } |
| 1483 | 1489 |
| 1484 EnterExitNode exitNode(JavaScriptPrintingContext context, int position) { | 1490 EnterExitNode exitNode(JavaScriptPrintingContext context, int position) { |
| 1485 // Enter must happen before exit. | 1491 // Enter must happen before exit. |
| 1486 addToNode(context, position); | 1492 addToNode(context, position); |
| 1487 context.exitNode(node, startPosition, position, closingPosition); | 1493 context.exitNode(node, startPosition, position, closingPosition); |
| 1488 return parent; | 1494 return parent; |
| 1489 } | 1495 } |
| 1490 } | 1496 } |
| OLD | NEW |