| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /// A library for compiling Dart code and manipulating analyzer parse trees. | 5 /// A library for compiling Dart code and manipulating analyzer parse trees. |
| 6 library pub.dart; | 6 library pub.dart; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 bool checked: false, | 55 bool checked: false, |
| 56 bool minify: true, | 56 bool minify: true, |
| 57 bool verbose: false, | 57 bool verbose: false, |
| 58 Map<String, String> environment, | 58 Map<String, String> environment, |
| 59 String packageRoot, | 59 String packageRoot, |
| 60 bool analyzeAll: false, | 60 bool analyzeAll: false, |
| 61 bool suppressWarnings: false, | 61 bool suppressWarnings: false, |
| 62 bool suppressHints: false, | 62 bool suppressHints: false, |
| 63 bool suppressPackageWarnings: true, | 63 bool suppressPackageWarnings: true, |
| 64 bool terse: false, | 64 bool terse: false, |
| 65 bool includeSourceMapUrls: false, |
| 65 bool toDart: false}) { | 66 bool toDart: false}) { |
| 66 return syncFuture(() { | 67 return syncFuture(() { |
| 67 var options = <String>['--categories=Client,Server']; | 68 var options = <String>['--categories=Client,Server']; |
| 68 if (checked) options.add('--checked'); | 69 if (checked) options.add('--checked'); |
| 69 if (minify) options.add('--minify'); | 70 if (minify) options.add('--minify'); |
| 70 if (verbose) options.add('--verbose'); | 71 if (verbose) options.add('--verbose'); |
| 71 if (analyzeAll) options.add('--analyze-all'); | 72 if (analyzeAll) options.add('--analyze-all'); |
| 72 if (suppressWarnings) options.add('--suppress-warnings'); | 73 if (suppressWarnings) options.add('--suppress-warnings'); |
| 73 if (suppressHints) options.add('--suppress-hints'); | 74 if (suppressHints) options.add('--suppress-hints'); |
| 74 if (!suppressPackageWarnings) options.add('--show-package-warnings'); | 75 if (!suppressPackageWarnings) options.add('--show-package-warnings'); |
| 75 if (terse) options.add('--terse'); | 76 if (terse) options.add('--terse'); |
| 76 if (toDart) options.add('--output-type=dart'); | 77 if (toDart) options.add('--output-type=dart'); |
| 77 | 78 |
| 78 // Add the source map URLs. | 79 // Add the source map URLs. |
| 79 var sourceUrl = path.toUri(entrypoint); | 80 if (includeSourceMapUrls) { |
| 80 options.add("--out=$sourceUrl.js"); | 81 var sourceUrl = path.toUri(entrypoint); |
| 81 options.add("--source-map=$sourceUrl.js.map"); | 82 options.add("--out=$sourceUrl.js"); |
| 83 options.add("--source-map=$sourceUrl.js.map"); |
| 84 } |
| 82 | 85 |
| 83 if (environment == null) environment = {}; | 86 if (environment == null) environment = {}; |
| 84 if (commandLineOptions != null) options.addAll(commandLineOptions); | 87 if (commandLineOptions != null) options.addAll(commandLineOptions); |
| 85 | 88 |
| 86 if (packageRoot == null) { | 89 if (packageRoot == null) { |
| 87 packageRoot = path.join(path.dirname(entrypoint), 'packages'); | 90 packageRoot = path.join(path.dirname(entrypoint), 'packages'); |
| 88 } | 91 } |
| 89 | 92 |
| 90 return Chain.track(compiler.compile( | 93 return Chain.track(compiler.compile( |
| 91 path.toUri(entrypoint), | 94 path.toUri(entrypoint), |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 if (stack == null && error is Error) stack = error.stackTrace; | 204 if (stack == null && error is Error) stack = error.stackTrace; |
| 202 return { | 205 return { |
| 203 'type': error.runtimeType.toString(), | 206 'type': error.runtimeType.toString(), |
| 204 'message': getErrorMessage(error), | 207 'message': getErrorMessage(error), |
| 205 'stack': stack == null ? null : new Chain.forTrace(stack).toString() | 208 'stack': stack == null ? null : new Chain.forTrace(stack).toString() |
| 206 }; | 209 }; |
| 207 } | 210 } |
| 208 | 211 |
| 209 String toString() => "$message\n$stackTrace"; | 212 String toString() => "$message\n$stackTrace"; |
| 210 } | 213 } |
| OLD | NEW |