| 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 /// Command line tool to run the checker on a Dart program. | 5 /// Command line tool to run the checker on a Dart program. |
| 6 library dev_compiler.src.compiler; | 6 library dev_compiler.src.compiler; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:collection'; | 9 import 'dart:collection'; |
| 10 import 'dart:convert' show JSON; | 10 import 'dart:convert' show JSON; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 import 'package:path/path.dart' as path; | 26 import 'package:path/path.dart' as path; |
| 27 | 27 |
| 28 import 'analysis_context.dart'; | 28 import 'analysis_context.dart'; |
| 29 import 'codegen/html_codegen.dart' as html_codegen; | 29 import 'codegen/html_codegen.dart' as html_codegen; |
| 30 import 'codegen/js_codegen.dart'; | 30 import 'codegen/js_codegen.dart'; |
| 31 import 'info.dart' | 31 import 'info.dart' |
| 32 show AnalyzerMessage, CheckerResults, LibraryInfo, LibraryUnit; | 32 show AnalyzerMessage, CheckerResults, LibraryInfo, LibraryUnit; |
| 33 import 'options.dart'; | 33 import 'options.dart'; |
| 34 import 'report.dart'; | 34 import 'report.dart'; |
| 35 import 'report/html_reporter.dart'; | 35 import 'report/html_reporter.dart'; |
| 36 import 'utils.dart' show isStrongModeError; |
| 36 | 37 |
| 37 /// Sets up the type checker logger to print a span that highlights error | 38 /// Sets up the type checker logger to print a span that highlights error |
| 38 /// messages. | 39 /// messages. |
| 39 StreamSubscription setupLogger(Level level, printFn) { | 40 StreamSubscription setupLogger(Level level, printFn) { |
| 40 Logger.root.level = level; | 41 Logger.root.level = level; |
| 41 return Logger.root.onRecord.listen((LogRecord rec) { | 42 return Logger.root.onRecord.listen((LogRecord rec) { |
| 42 printFn('${rec.level.name.toLowerCase()}: ${rec.message}'); | 43 printFn('${rec.level.name.toLowerCase()}: ${rec.message}'); |
| 43 }); | 44 }); |
| 44 } | 45 } |
| 45 | 46 |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 bool computeErrors(Source source) { | 448 bool computeErrors(Source source) { |
| 448 AnalysisContext errorContext = context; | 449 AnalysisContext errorContext = context; |
| 449 // TODO(jmesserly): should this be a fix somewhere in analyzer? | 450 // TODO(jmesserly): should this be a fix somewhere in analyzer? |
| 450 // otherwise we fail to find the parts. | 451 // otherwise we fail to find the parts. |
| 451 if (source.uri.scheme == 'dart') { | 452 if (source.uri.scheme == 'dart') { |
| 452 errorContext = context.sourceFactory.dartSdk.context; | 453 errorContext = context.sourceFactory.dartSdk.context; |
| 453 } | 454 } |
| 454 List<AnalysisError> errors = errorContext.computeErrors(source); | 455 List<AnalysisError> errors = errorContext.computeErrors(source); |
| 455 bool failure = false; | 456 bool failure = false; |
| 456 for (var error in errors) { | 457 for (var error in errors) { |
| 458 ErrorCode code = error.errorCode; |
| 457 // Always skip TODOs. | 459 // Always skip TODOs. |
| 458 if (error.errorCode.type == ErrorType.TODO) continue; | 460 if (code.type == ErrorType.TODO) continue; |
| 459 | 461 |
| 460 // TODO(jmesserly): for now, treat DDC errors as having a different | 462 // TODO(jmesserly): for now, treat DDC errors as having a different |
| 461 // error level from Analayzer ones. | 463 // error level from Analayzer ones. |
| 462 if (error.errorCode.name.startsWith('dev_compiler')) { | 464 if (isStrongModeError(code)) { |
| 463 reporter.onError(error); | 465 reporter.onError(error); |
| 464 if (error.errorCode.errorSeverity == ErrorSeverity.ERROR) { | 466 if (code.errorSeverity == ErrorSeverity.ERROR) { |
| 465 failure = true; | 467 failure = true; |
| 466 } | 468 } |
| 467 } else if (error.errorCode.errorSeverity.ordinal >= | 469 } else if (code.errorSeverity.ordinal >= ErrorSeverity.WARNING.ordinal) { |
| 468 ErrorSeverity.WARNING.ordinal) { | |
| 469 // All analyzer warnings or errors are errors for DDC. | 470 // All analyzer warnings or errors are errors for DDC. |
| 470 failure = true; | 471 failure = true; |
| 471 reporter.onError(error); | 472 reporter.onError(error); |
| 472 } else { | 473 } else { |
| 473 // Skip hints for now. | 474 // Skip hints for now. |
| 474 } | 475 } |
| 475 } | 476 } |
| 476 return failure; | 477 return failure; |
| 477 } | 478 } |
| 478 } | 479 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 'dart/_rtti.js', | 541 'dart/_rtti.js', |
| 541 'dart/_classes.js', | 542 'dart/_classes.js', |
| 542 'dart/_operations.js', | 543 'dart/_operations.js', |
| 543 'dart/_runtime.js', | 544 'dart/_runtime.js', |
| 544 ]; | 545 ]; |
| 545 files.addAll(corelibOrder.map(coreToFile)); | 546 files.addAll(corelibOrder.map(coreToFile)); |
| 546 return files; | 547 return files; |
| 547 }(); | 548 }(); |
| 548 | 549 |
| 549 final _log = new Logger('dev_compiler.src.compiler'); | 550 final _log = new Logger('dev_compiler.src.compiler'); |
| OLD | NEW |