| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 /// Helper classes and methods to adapt between `package:compiler` and | 5 /// Helper classes and methods to adapt between `package:compiler` and |
| 6 /// `package:front_end` APIs. | 6 /// `package:front_end` APIs. |
| 7 library compiler.kernel.front_end_adapter; | 7 library compiler.kernel.front_end_adapter; |
| 8 | 8 |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 | 10 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 /// Report a [message] received from the front-end, using dart2js's | 77 /// Report a [message] received from the front-end, using dart2js's |
| 78 /// [DiagnosticReporter]. | 78 /// [DiagnosticReporter]. |
| 79 void reportFrontEndMessage( | 79 void reportFrontEndMessage( |
| 80 DiagnosticReporter reporter, fe.CompilationMessage message) { | 80 DiagnosticReporter reporter, fe.CompilationMessage message) { |
| 81 // TODO(sigmund): translate message kinds using message.dart2jsCode | 81 // TODO(sigmund): translate message kinds using message.dart2jsCode |
| 82 MessageKind kind = MessageKind.GENERIC; | 82 MessageKind kind = MessageKind.GENERIC; |
| 83 switch (message.severity) { | 83 switch (message.severity) { |
| 84 case fe.Severity.internalProblem: |
| 85 throw message.message; |
| 84 case fe.Severity.error: | 86 case fe.Severity.error: |
| 85 case fe.Severity.internalProblem: | |
| 86 reporter.reportErrorMessage( | 87 reporter.reportErrorMessage( |
| 87 NO_LOCATION_SPANNABLE, kind, {'text': message.message}); | 88 NO_LOCATION_SPANNABLE, kind, {'text': message.message}); |
| 88 break; | 89 break; |
| 89 case fe.Severity.warning: | 90 case fe.Severity.warning: |
| 90 reporter.reportWarningMessage( | 91 reporter.reportWarningMessage( |
| 91 NO_LOCATION_SPANNABLE, kind, {'text': message.message}); | 92 NO_LOCATION_SPANNABLE, kind, {'text': message.message}); |
| 92 break; | 93 break; |
| 93 case fe.Severity.nit: | 94 case fe.Severity.nit: |
| 94 reporter.reportHintMessage( | 95 reporter.reportHintMessage( |
| 95 NO_LOCATION_SPANNABLE, kind, {'text': message.message}); | 96 NO_LOCATION_SPANNABLE, kind, {'text': message.message}); |
| 96 break; | 97 break; |
| 97 default: | 98 default: |
| 98 throw new UnimplementedError('unhandled severity ${message.severity}'); | 99 throw new UnimplementedError('unhandled severity ${message.severity}'); |
| 99 } | 100 } |
| 100 } | 101 } |
| OLD | NEW |