OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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:collection' show HashSet, Queue; | 5 import 'dart:collection' show HashSet, Queue; |
6 import 'package:analyzer/dart/element/element.dart' show LibraryElement; | 6 import 'package:analyzer/dart/element/element.dart' show LibraryElement; |
7 import 'package:analyzer/analyzer.dart' | 7 import 'package:analyzer/analyzer.dart' |
8 show AnalysisError, CompilationUnit, ErrorSeverity; | 8 show AnalysisError, CompilationUnit, ErrorSeverity; |
9 import 'package:analyzer/file_system/file_system.dart' show ResourceProvider; | 9 import 'package:analyzer/file_system/file_system.dart' show ResourceProvider; |
10 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; | 10 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 emitMetadata = args['emit-metadata'], | 238 emitMetadata = args['emit-metadata'], |
239 closure = args['closure-experimental'], | 239 closure = args['closure-experimental'], |
240 destructureNamedParams = args['destructure-named-params'], | 240 destructureNamedParams = args['destructure-named-params'], |
241 moduleFormat = parseModuleFormat(args['modules']), | 241 moduleFormat = parseModuleFormat(args['modules']), |
242 hoistInstanceCreation = args['hoist-instance-creation'], | 242 hoistInstanceCreation = args['hoist-instance-creation'], |
243 hoistSignatureTypes = args['hoist-signature-types'], | 243 hoistSignatureTypes = args['hoist-signature-types'], |
244 nameTypeTests = args['name-type-tests'], | 244 nameTypeTests = args['name-type-tests'], |
245 hoistTypeTests = args['hoist-type-tests'], | 245 hoistTypeTests = args['hoist-type-tests'], |
246 useAngular2Whitelist = args['unsafe-angular2-whitelist']; | 246 useAngular2Whitelist = args['unsafe-angular2-whitelist']; |
247 | 247 |
248 static ArgParser addArguments(ArgParser parser) => parser | 248 static void addArguments(ArgParser parser) { |
249 ..addFlag('summarize', help: 'emit an API summary file', defaultsTo: true) | 249 parser |
250 ..addOption('summary-extension', | 250 ..addFlag('summarize', help: 'emit an API summary file', defaultsTo: true) |
251 help: 'file extension for Dart summary files', defaultsTo: 'sum') | 251 ..addOption('summary-extension', |
252 ..addFlag('source-map', help: 'emit source mapping', defaultsTo: true) | 252 help: 'file extension for Dart summary files', |
253 ..addFlag('source-map-comment', | 253 defaultsTo: 'sum', |
254 help: 'adds a sourceMappingURL comment to the end of the JS,\n' | 254 hide: true) |
255 'disable if using X-SourceMap header', | 255 ..addFlag('source-map', help: 'emit source mapping', defaultsTo: true) |
256 defaultsTo: true) | 256 ..addFlag('source-map-comment', |
257 ..addOption('modules', | 257 help: 'adds a sourceMappingURL comment to the end of the JS,\n' |
258 help: 'module pattern to emit', | 258 'disable if using X-SourceMap header', |
259 allowed: ['es6', 'legacy', 'node'], | 259 defaultsTo: true, |
260 allowedHelp: { | 260 hide: true) |
261 'es6': 'es6 modules', | 261 ..addOption('modules', |
262 'legacy': 'a custom format used by dartdevc, similar to AMD', | 262 help: 'module pattern to emit', |
263 'node': 'node.js modules (https://nodejs.org/api/modules.html)' | 263 allowed: ['es6', 'legacy', 'node'], |
264 }, | 264 allowedHelp: { |
265 defaultsTo: 'legacy') | 265 'es6': 'es6 modules', |
266 ..addFlag('emit-metadata', | 266 'legacy': 'a custom format used by dartdevc, similar to AMD', |
267 help: 'emit metadata annotations queriable via mirrors', | 267 'node': 'node.js modules (https://nodejs.org/api/modules.html)' |
268 defaultsTo: false) | 268 }, |
269 ..addFlag('closure-experimental', | 269 defaultsTo: 'legacy') |
270 help: 'emit Closure Compiler-friendly code (experimental)', | 270 ..addFlag('emit-metadata', |
271 defaultsTo: false) | 271 help: 'emit metadata annotations queriable via mirrors', |
272 ..addFlag('destructure-named-params', | 272 defaultsTo: false) |
273 help: 'Destructure named parameters', defaultsTo: false) | 273 ..addFlag('closure-experimental', |
274 ..addFlag('unsafe-force-compile', | 274 help: 'emit Closure Compiler-friendly code (experimental)', |
275 help: 'Compile code even if it has errors. ಠ_ಠ\n' | 275 defaultsTo: false) |
276 'This has undefined behavior!', | 276 ..addFlag('destructure-named-params', |
277 defaultsTo: false) | 277 help: 'Destructure named parameters', defaultsTo: false, hide: true) |
278 ..addFlag('hoist-instance-creation', | 278 ..addFlag('unsafe-force-compile', |
279 help: 'Hoist the class type from generic instance creations', | 279 help: 'Compile code even if it has errors. ಠ_ಠ\n' |
280 defaultsTo: true) | 280 'This has undefined behavior!', |
281 ..addFlag('hoist-signature-types', | 281 defaultsTo: false, |
282 help: 'Hoist types from class signatures', defaultsTo: false) | 282 hide: true) |
283 ..addFlag('name-type-tests', | 283 ..addFlag('hoist-instance-creation', |
284 help: 'Name types used in type tests', defaultsTo: true) | 284 help: 'Hoist the class type from generic instance creations', |
285 ..addFlag('hoist-type-tests', | 285 defaultsTo: true, |
286 help: 'Hoist types used in type tests', defaultsTo: true) | 286 hide: true) |
287 ..addFlag('unsafe-angular2-whitelist', defaultsTo: false, hide: true); | 287 ..addFlag('hoist-signature-types', |
| 288 help: 'Hoist types from class signatures', |
| 289 defaultsTo: false, |
| 290 hide: true) |
| 291 ..addFlag('name-type-tests', |
| 292 help: 'Name types used in type tests', defaultsTo: true, hide: true) |
| 293 ..addFlag('hoist-type-tests', |
| 294 help: 'Hoist types used in type tests', defaultsTo: true, hide: true) |
| 295 ..addFlag('unsafe-angular2-whitelist', defaultsTo: false, hide: true); |
| 296 } |
288 } | 297 } |
289 | 298 |
290 /// A unit of Dart code that can be built into a single JavaScript module. | 299 /// A unit of Dart code that can be built into a single JavaScript module. |
291 class BuildUnit { | 300 class BuildUnit { |
292 /// The name of this module. | 301 /// The name of this module. |
293 final String name; | 302 final String name; |
294 | 303 |
295 /// Library root. All library names are relative to this path/prefix. | 304 /// Library root. All library names are relative to this path/prefix. |
296 final String libraryRoot; | 305 final String libraryRoot; |
297 | 306 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 367 |
359 var map = new Map.from(this.sourceMap); | 368 var map = new Map.from(this.sourceMap); |
360 List list = new List.from(map['sources']); | 369 List list = new List.from(map['sources']); |
361 map['sources'] = list; | 370 map['sources'] = list; |
362 for (int i = 0; i < list.length; i++) { | 371 for (int i = 0; i < list.length; i++) { |
363 list[i] = path.relative(list[i], from: dir); | 372 list[i] = path.relative(list[i], from: dir); |
364 } | 373 } |
365 return map; | 374 return map; |
366 } | 375 } |
367 } | 376 } |
OLD | NEW |