OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dev_compiler.src.codegen.js_printer; | 5 library dev_compiler.src.codegen.js_printer; |
6 | 6 |
7 import 'dart:convert' show JSON, JsonEncoder; | 7 import 'dart:convert' show JSON, JsonEncoder; |
8 import 'dart:io' show Directory, File, Platform, Process; | 8 import 'dart:io' show Directory, File, Platform, Process; |
9 | 9 |
10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
(...skipping 16 matching lines...) Expand all Loading... |
27 JS.JavaScriptPrintingContext context; | 27 JS.JavaScriptPrintingContext context; |
28 if (emitSourceMaps) { | 28 if (emitSourceMaps) { |
29 var printer = new srcmaps.Printer(outFilename); | 29 var printer = new srcmaps.Printer(outFilename); |
30 context = new SourceMapPrintingContext(printer, outDir); | 30 context = new SourceMapPrintingContext(printer, outDir); |
31 } else { | 31 } else { |
32 context = new JS.SimpleJavaScriptPrintingContext(); | 32 context = new JS.SimpleJavaScriptPrintingContext(); |
33 } | 33 } |
34 | 34 |
35 var opts = new JS.JavaScriptPrintingOptions( | 35 var opts = new JS.JavaScriptPrintingOptions( |
36 allowKeywordsInProperties: true, | 36 allowKeywordsInProperties: true, |
| 37 allowSingleLineIfStatements: true, |
37 arrowFnBindThisWorkaround: arrowFnBindThisWorkaround); | 38 arrowFnBindThisWorkaround: arrowFnBindThisWorkaround); |
38 var jsNamer = new TemporaryNamer(jsTree); | 39 var jsNamer = new TemporaryNamer(jsTree); |
39 jsTree.accept(new JS.Printer(opts, context, localNamer: jsNamer)); | 40 jsTree.accept(new JS.Printer(opts, context, localNamer: jsNamer)); |
40 | 41 |
41 String text; | 42 String text; |
42 if (context is SourceMapPrintingContext) { | 43 if (context is SourceMapPrintingContext) { |
43 var printer = context.printer; | 44 var printer = context.printer; |
44 printer.add('//# sourceMappingURL=$outFilename.map\n'); | 45 printer.add('//# sourceMappingURL=$outFilename.map\n'); |
45 // Write output file and source map | 46 // Write output file and source map |
46 text = printer.text; | 47 text = printer.text; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 _currentTopLevelDeclaration == null; | 130 _currentTopLevelDeclaration == null; |
130 return; | 131 return; |
131 } | 132 } |
132 } | 133 } |
133 | 134 |
134 String _getIdentifier(AstNode node) { | 135 String _getIdentifier(AstNode node) { |
135 if (node is SimpleIdentifier) return node.name; | 136 if (node is SimpleIdentifier) return node.name; |
136 return null; | 137 return null; |
137 } | 138 } |
138 } | 139 } |
OLD | NEW |