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 JSON; | 6 import 'dart:convert' show JSON; |
7 import 'dart:io' show File; | 7 import 'dart:io' show File; |
8 | 8 |
9 import 'package:analyzer/analyzer.dart' | 9 import 'package:analyzer/analyzer.dart' |
10 show AnalysisError, CompilationUnit, ErrorSeverity; | 10 show AnalysisError, CompilationUnit, ErrorSeverity; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 /// Whether to force compilation of code with static errors. | 260 /// Whether to force compilation of code with static errors. |
261 final bool unsafeForceCompile; | 261 final bool unsafeForceCompile; |
262 | 262 |
263 /// Whether to compile code in a more permissive REPL mode allowing access | 263 /// Whether to compile code in a more permissive REPL mode allowing access |
264 /// to private members across library boundaries. | 264 /// to private members across library boundaries. |
265 final bool replCompile; | 265 final bool replCompile; |
266 | 266 |
267 /// Whether to emit Closure Compiler-friendly code. | 267 /// Whether to emit Closure Compiler-friendly code. |
268 final bool closure; | 268 final bool closure; |
269 | 269 |
270 /// Hoist the types at instance creation sites. | |
271 final bool hoistInstanceCreation; | |
272 | |
273 /// Hoist types from class signatures. | |
274 final bool hoistSignatureTypes; | |
275 | |
276 /// Name types in type tests. | |
277 final bool nameTypeTests; | |
278 | |
279 /// Hoist types in type tests. | |
280 final bool hoistTypeTests; | |
281 | |
282 /// Enable ES6 destructuring of named parameters. Off by default. | 270 /// Enable ES6 destructuring of named parameters. Off by default. |
283 /// | 271 /// |
284 /// Older V8 versions do not accept default values with destructuring in | 272 /// Older V8 versions do not accept default values with destructuring in |
285 /// arrow functions yet (e.g. `({a} = {}) => 1`) but happily accepts them | 273 /// arrow functions yet (e.g. `({a} = {}) => 1`) but happily accepts them |
286 /// with regular functions (e.g. `function({a} = {}) { return 1 }`). | 274 /// with regular functions (e.g. `function({a} = {}) { return 1 }`). |
287 /// | 275 /// |
288 /// Supporting the syntax: | 276 /// Supporting the syntax: |
289 /// * Chrome Canary (51) | 277 /// * Chrome Canary (51) |
290 /// * Firefox | 278 /// * Firefox |
291 /// | 279 /// |
(...skipping 15 matching lines...) Expand all Loading... |
307 {this.sourceMap: true, | 295 {this.sourceMap: true, |
308 this.sourceMapComment: true, | 296 this.sourceMapComment: true, |
309 this.inlineSourceMap: false, | 297 this.inlineSourceMap: false, |
310 this.summarizeApi: true, | 298 this.summarizeApi: true, |
311 this.summaryExtension: 'sum', | 299 this.summaryExtension: 'sum', |
312 this.unsafeForceCompile: false, | 300 this.unsafeForceCompile: false, |
313 this.replCompile: false, | 301 this.replCompile: false, |
314 this.emitMetadata: false, | 302 this.emitMetadata: false, |
315 this.closure: false, | 303 this.closure: false, |
316 this.destructureNamedParams: false, | 304 this.destructureNamedParams: false, |
317 this.hoistInstanceCreation: true, | |
318 this.hoistSignatureTypes: false, | |
319 this.nameTypeTests: true, | |
320 this.hoistTypeTests: true, | |
321 this.bazelMapping: const {}, | 305 this.bazelMapping: const {}, |
322 this.summaryOutPath}); | 306 this.summaryOutPath}); |
323 | 307 |
324 CompilerOptions.fromArguments(ArgResults args) | 308 CompilerOptions.fromArguments(ArgResults args) |
325 : sourceMap = args['source-map'], | 309 : sourceMap = args['source-map'], |
326 sourceMapComment = args['source-map-comment'], | 310 sourceMapComment = args['source-map-comment'], |
327 inlineSourceMap = args['inline-source-map'], | 311 inlineSourceMap = args['inline-source-map'], |
328 summarizeApi = args['summarize'], | 312 summarizeApi = args['summarize'], |
329 summaryExtension = args['summary-extension'], | 313 summaryExtension = args['summary-extension'], |
330 unsafeForceCompile = args['unsafe-force-compile'], | 314 unsafeForceCompile = args['unsafe-force-compile'], |
331 replCompile = args['repl-compile'], | 315 replCompile = args['repl-compile'], |
332 emitMetadata = args['emit-metadata'], | 316 emitMetadata = args['emit-metadata'], |
333 closure = args['closure-experimental'], | 317 closure = args['closure-experimental'], |
334 destructureNamedParams = args['destructure-named-params'], | 318 destructureNamedParams = args['destructure-named-params'], |
335 hoistInstanceCreation = args['hoist-instance-creation'], | |
336 hoistSignatureTypes = args['hoist-signature-types'], | |
337 nameTypeTests = args['name-type-tests'], | |
338 hoistTypeTests = args['hoist-type-tests'], | |
339 bazelMapping = _parseBazelMappings(args['bazel-mapping']), | 319 bazelMapping = _parseBazelMappings(args['bazel-mapping']), |
340 summaryOutPath = args['summary-out']; | 320 summaryOutPath = args['summary-out']; |
341 | 321 |
342 static void addArguments(ArgParser parser, {bool hide: true}) { | 322 static void addArguments(ArgParser parser, {bool hide: true}) { |
343 parser | 323 parser |
344 ..addFlag('summarize', help: 'emit an API summary file', defaultsTo: true) | 324 ..addFlag('summarize', help: 'emit an API summary file', defaultsTo: true) |
345 ..addOption('summary-extension', | 325 ..addOption('summary-extension', |
346 help: 'file extension for Dart summary files', | 326 help: 'file extension for Dart summary files', |
347 defaultsTo: 'sum', | 327 defaultsTo: 'sum', |
348 hide: hide) | 328 hide: hide) |
(...skipping 16 matching lines...) Expand all Loading... |
365 ..addFlag('unsafe-force-compile', | 345 ..addFlag('unsafe-force-compile', |
366 help: 'Compile code even if it has errors. ಠ_ಠ\n' | 346 help: 'Compile code even if it has errors. ಠ_ಠ\n' |
367 'This has undefined behavior!', | 347 'This has undefined behavior!', |
368 defaultsTo: false, | 348 defaultsTo: false, |
369 hide: hide) | 349 hide: hide) |
370 ..addFlag('repl-compile', | 350 ..addFlag('repl-compile', |
371 help: 'Compile code more permissively when in REPL mode\n' | 351 help: 'Compile code more permissively when in REPL mode\n' |
372 'allowing access to private members across library boundaries.', | 352 'allowing access to private members across library boundaries.', |
373 defaultsTo: false, | 353 defaultsTo: false, |
374 hide: hide) | 354 hide: hide) |
375 ..addFlag('hoist-instance-creation', | |
376 help: 'Hoist the class type from generic instance creations', | |
377 defaultsTo: true, | |
378 hide: hide) | |
379 ..addFlag('hoist-signature-types', | |
380 help: 'Hoist types from class signatures', | |
381 defaultsTo: false, | |
382 hide: hide) | |
383 ..addFlag('name-type-tests', | |
384 help: 'Name types used in type tests', defaultsTo: true, hide: hide) | |
385 ..addFlag('hoist-type-tests', | |
386 help: 'Hoist types used in type tests', defaultsTo: true, hide: hide) | |
387 ..addOption('bazel-mapping', | 355 ..addOption('bazel-mapping', |
388 help: | 356 help: |
389 '--bazel-mapping=genfiles/to/library.dart,to/library.dart uses \n' | 357 '--bazel-mapping=genfiles/to/library.dart,to/library.dart uses \n' |
390 'to/library.dart as the path for library.dart in source maps.', | 358 'to/library.dart as the path for library.dart in source maps.', |
391 allowMultiple: true, | 359 allowMultiple: true, |
392 splitCommas: false, | 360 splitCommas: false, |
393 hide: hide) | 361 hide: hide) |
394 ..addOption('summary-out', | 362 ..addOption('summary-out', |
395 help: 'location to write the summary file', hide: hide); | 363 help: 'location to write the summary file', hide: hide); |
396 } | 364 } |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 case "dart": | 595 case "dart": |
628 case "package": | 596 case "package": |
629 case "file": | 597 case "file": |
630 // A valid URI. | 598 // A valid URI. |
631 return uri; | 599 return uri; |
632 default: | 600 default: |
633 // Assume a file path. | 601 // Assume a file path. |
634 return new Uri.file(path.absolute(source)); | 602 return new Uri.file(path.absolute(source)); |
635 } | 603 } |
636 } | 604 } |
OLD | NEW |