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 import 'dart:convert' show JSON, JsonEncoder; | 5 import 'dart:convert' show JSON, JsonEncoder; |
6 import 'dart:io' show Directory, File, Platform, Process; | 6 import 'dart:io' show Directory, File, Platform, Process; |
7 | 7 |
8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
9 import 'package:path/path.dart' as path; | 9 import 'package:path/path.dart' as path; |
10 import 'package:source_maps/source_maps.dart' as srcmaps show Printer; | 10 import 'package:source_maps/source_maps.dart' as srcmaps show Printer; |
(...skipping 14 matching lines...) Expand all Loading... |
25 JS.JavaScriptPrintingContext context; | 25 JS.JavaScriptPrintingContext context; |
26 if (emitSourceMaps) { | 26 if (emitSourceMaps) { |
27 var printer = new srcmaps.Printer(outFilename); | 27 var printer = new srcmaps.Printer(outFilename); |
28 context = | 28 context = |
29 new SourceMapPrintingContext(printer, outDir, inputDir, serverUri); | 29 new SourceMapPrintingContext(printer, outDir, inputDir, serverUri); |
30 } else { | 30 } else { |
31 context = new JS.SimpleJavaScriptPrintingContext(); | 31 context = new JS.SimpleJavaScriptPrintingContext(); |
32 } | 32 } |
33 | 33 |
34 var opts = new JS.JavaScriptPrintingOptions( | 34 var opts = new JS.JavaScriptPrintingOptions( |
35 allowKeywordsInProperties: true, allowSingleLineIfStatements: true); | 35 shouldEmitTypes: true, |
| 36 allowKeywordsInProperties: true, |
| 37 allowSingleLineIfStatements: true); |
36 var jsNamer = new TemporaryNamer(jsTree); | 38 var jsNamer = new TemporaryNamer(jsTree); |
37 jsTree.accept(new JS.Printer(opts, context, localNamer: jsNamer)); | 39 jsTree.accept(new JS.Printer(opts, context, localNamer: jsNamer)); |
38 | 40 |
39 String text; | 41 String text; |
40 if (context is SourceMapPrintingContext) { | 42 if (context is SourceMapPrintingContext) { |
41 var printer = context.printer; | 43 var printer = context.printer; |
42 printer.add('//# sourceMappingURL=$outFilename.map\n'); | 44 printer.add('//# sourceMappingURL=$outFilename.map\n'); |
43 // Write output file and source map | 45 // Write output file and source map |
44 text = printer.text; | 46 text = printer.text; |
45 var sourceMap = JSON.decode(printer.map); | 47 var sourceMap = JSON.decode(printer.map); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 _currentTopLevelDeclaration == null; | 144 _currentTopLevelDeclaration == null; |
143 return; | 145 return; |
144 } | 146 } |
145 } | 147 } |
146 | 148 |
147 String _getIdentifier(AstNode node) { | 149 String _getIdentifier(AstNode node) { |
148 if (node is SimpleIdentifier) return node.name; | 150 if (node is SimpleIdentifier) return node.name; |
149 return null; | 151 return null; |
150 } | 152 } |
151 } | 153 } |
OLD | NEW |