| 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 'dart:convert' show BASE64, JSON, UTF8; | 6 import 'dart:convert' show BASE64, JSON, UTF8; |
| 7 import 'dart:io' show File; | 7 import 'dart:io' show File; |
| 8 import 'package:analyzer/dart/element/element.dart' show LibraryElement; | 8 import 'package:analyzer/dart/element/element.dart' show LibraryElement; |
| 9 import 'package:analyzer/analyzer.dart' | 9 import 'package:analyzer/analyzer.dart' |
| 10 show AnalysisError, CompilationUnit, ErrorSeverity; | 10 show AnalysisError, CompilationUnit, ErrorSeverity; |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 closure = args['closure-experimental'], | 298 closure = args['closure-experimental'], |
| 299 destructureNamedParams = args['destructure-named-params'], | 299 destructureNamedParams = args['destructure-named-params'], |
| 300 hoistInstanceCreation = args['hoist-instance-creation'], | 300 hoistInstanceCreation = args['hoist-instance-creation'], |
| 301 hoistSignatureTypes = args['hoist-signature-types'], | 301 hoistSignatureTypes = args['hoist-signature-types'], |
| 302 nameTypeTests = args['name-type-tests'], | 302 nameTypeTests = args['name-type-tests'], |
| 303 hoistTypeTests = args['hoist-type-tests'], | 303 hoistTypeTests = args['hoist-type-tests'], |
| 304 useAngular2Whitelist = args['unsafe-angular2-whitelist'], | 304 useAngular2Whitelist = args['unsafe-angular2-whitelist'], |
| 305 bazelMapping = _parseBazelMappings(args['bazel-mapping']), | 305 bazelMapping = _parseBazelMappings(args['bazel-mapping']), |
| 306 summaryOutPath = args['summary-out']; | 306 summaryOutPath = args['summary-out']; |
| 307 | 307 |
| 308 static void addArguments(ArgParser parser) { | 308 static void addArguments(ArgParser parser, {bool hide: true}) { |
| 309 parser | 309 parser |
| 310 ..addFlag('summarize', help: 'emit an API summary file', defaultsTo: true) | 310 ..addFlag('summarize', help: 'emit an API summary file', defaultsTo: true) |
| 311 ..addOption('summary-extension', | 311 ..addOption('summary-extension', |
| 312 help: 'file extension for Dart summary files', | 312 help: 'file extension for Dart summary files', |
| 313 defaultsTo: 'sum', | 313 defaultsTo: 'sum', |
| 314 hide: true) | 314 hide: hide) |
| 315 ..addFlag('source-map', help: 'emit source mapping', defaultsTo: true) | 315 ..addFlag('source-map', help: 'emit source mapping', defaultsTo: true) |
| 316 ..addFlag('source-map-comment', | 316 ..addFlag('source-map-comment', |
| 317 help: 'adds a sourceMappingURL comment to the end of the JS,\n' | 317 help: 'adds a sourceMappingURL comment to the end of the JS,\n' |
| 318 'disable if using X-SourceMap header', | 318 'disable if using X-SourceMap header', |
| 319 defaultsTo: true, | 319 defaultsTo: true, |
| 320 hide: true) | 320 hide: hide) |
| 321 ..addFlag('inline-source-map', | 321 ..addFlag('inline-source-map', |
| 322 help: 'emit source mapping inline', defaultsTo: false) | 322 help: 'emit source mapping inline', defaultsTo: false) |
| 323 ..addFlag('emit-metadata', | 323 ..addFlag('emit-metadata', |
| 324 help: 'emit metadata annotations queriable via mirrors', | 324 help: 'emit metadata annotations queriable via mirrors', |
| 325 defaultsTo: false) | 325 defaultsTo: false) |
| 326 ..addFlag('closure-experimental', | 326 ..addFlag('closure-experimental', |
| 327 help: 'emit Closure Compiler-friendly code (experimental)', | 327 help: 'emit Closure Compiler-friendly code (experimental)', |
| 328 defaultsTo: false) | 328 defaultsTo: false) |
| 329 ..addFlag('destructure-named-params', | 329 ..addFlag('destructure-named-params', |
| 330 help: 'Destructure named parameters', defaultsTo: false, hide: true) | 330 help: 'Destructure named parameters', defaultsTo: false, hide: hide) |
| 331 ..addFlag('unsafe-force-compile', | 331 ..addFlag('unsafe-force-compile', |
| 332 help: 'Compile code even if it has errors. ಠ_ಠ\n' | 332 help: 'Compile code even if it has errors. ಠ_ಠ\n' |
| 333 'This has undefined behavior!', | 333 'This has undefined behavior!', |
| 334 defaultsTo: false, | 334 defaultsTo: false, |
| 335 hide: true) | 335 hide: hide) |
| 336 ..addFlag('repl-compile', | 336 ..addFlag('repl-compile', |
| 337 help: 'Compile code more permissively when in REPL mode allowing ' | 337 help: 'Compile code more permissively when in REPL mode\n' |
| 338 'access to private members across library boundaries.', | 338 'allowing access to private members across library boundaries.', |
| 339 defaultsTo: false, | 339 defaultsTo: false, |
| 340 hide: true) | 340 hide: hide) |
| 341 ..addFlag('hoist-instance-creation', | 341 ..addFlag('hoist-instance-creation', |
| 342 help: 'Hoist the class type from generic instance creations', | 342 help: 'Hoist the class type from generic instance creations', |
| 343 defaultsTo: true, | 343 defaultsTo: true, |
| 344 hide: true) | 344 hide: hide) |
| 345 ..addFlag('hoist-signature-types', | 345 ..addFlag('hoist-signature-types', |
| 346 help: 'Hoist types from class signatures', | 346 help: 'Hoist types from class signatures', |
| 347 defaultsTo: false, | 347 defaultsTo: false, |
| 348 hide: true) | 348 hide: hide) |
| 349 ..addFlag('name-type-tests', | 349 ..addFlag('name-type-tests', |
| 350 help: 'Name types used in type tests', defaultsTo: true, hide: true) | 350 help: 'Name types used in type tests', defaultsTo: true, hide: hide) |
| 351 ..addFlag('hoist-type-tests', | 351 ..addFlag('hoist-type-tests', |
| 352 help: 'Hoist types used in type tests', defaultsTo: true, hide: true) | 352 help: 'Hoist types used in type tests', defaultsTo: true, hide: hide) |
| 353 ..addFlag('unsafe-angular2-whitelist', defaultsTo: false, hide: true) | 353 ..addFlag('unsafe-angular2-whitelist', defaultsTo: false, hide: hide) |
| 354 ..addOption('bazel-mapping', | 354 ..addOption('bazel-mapping', |
| 355 help: | 355 help: |
| 356 '--bazel-mapping=genfiles/to/library.dart,to/library.dart uses \n' | 356 '--bazel-mapping=genfiles/to/library.dart,to/library.dart uses \n' |
| 357 'to/library.dart as the path for library.dart in source maps.', | 357 'to/library.dart as the path for library.dart in source maps.', |
| 358 allowMultiple: true, | 358 allowMultiple: true, |
| 359 splitCommas: false, | 359 splitCommas: false, |
| 360 hide: true) | 360 hide: hide) |
| 361 ..addOption('summary-out', | 361 ..addOption('summary-out', |
| 362 help: 'location to write the summary file', hide: true); | 362 help: 'location to write the summary file', hide: hide); |
| 363 } | 363 } |
| 364 | 364 |
| 365 static Map<String, String> _parseBazelMappings(Iterable argument) { | 365 static Map<String, String> _parseBazelMappings(Iterable argument) { |
| 366 var mappings = <String, String>{}; | 366 var mappings = <String, String>{}; |
| 367 for (var mapping in argument) { | 367 for (var mapping in argument) { |
| 368 var splitMapping = mapping.split(','); | 368 var splitMapping = mapping.split(','); |
| 369 if (splitMapping.length >= 2) { | 369 if (splitMapping.length >= 2) { |
| 370 mappings[path.absolute(splitMapping[0])] = splitMapping[1]; | 370 mappings[path.absolute(splitMapping[0])] = splitMapping[1]; |
| 371 } | 371 } |
| 372 } | 372 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 // Fall back to a relative path. | 554 // Fall back to a relative path. |
| 555 return path.toUri(path.relative(path.fromUri(uri), from: dir)).toString(); | 555 return path.toUri(path.relative(path.fromUri(uri), from: dir)).toString(); |
| 556 } | 556 } |
| 557 | 557 |
| 558 for (int i = 0; i < list.length; i++) { | 558 for (int i = 0; i < list.length; i++) { |
| 559 list[i] = transformUri(list[i]); | 559 list[i] = transformUri(list[i]); |
| 560 } | 560 } |
| 561 map['file'] = transformUri(map['file']); | 561 map['file'] = transformUri(map['file']); |
| 562 return map; | 562 return map; |
| 563 } | 563 } |
| OLD | NEW |