| OLD | NEW |
| 1 // Copyright (c) 2016, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library fletchc.fletch_diagnostic_reporter; | 5 library dartino_compiler.dartino_diagnostic_reporter; |
| 6 | 6 |
| 7 import 'package:compiler/src/tokens/token.dart' show | 7 import 'package:compiler/src/tokens/token.dart' show |
| 8 Token; | 8 Token; |
| 9 | 9 |
| 10 import 'package:compiler/src/compiler.dart' show | 10 import 'package:compiler/src/compiler.dart' show |
| 11 CompilerDiagnosticReporter; | 11 CompilerDiagnosticReporter; |
| 12 | 12 |
| 13 import 'package:compiler/src/diagnostics/diagnostic_listener.dart' show | 13 import 'package:compiler/src/diagnostics/diagnostic_listener.dart' show |
| 14 DiagnosticOptions; | 14 DiagnosticOptions; |
| 15 | 15 |
| 16 import 'package:compiler/src/diagnostics/source_span.dart' show | 16 import 'package:compiler/src/diagnostics/source_span.dart' show |
| 17 SourceSpan; | 17 SourceSpan; |
| 18 | 18 |
| 19 import 'package:compiler/src/diagnostics/diagnostic_listener.dart' show | 19 import 'package:compiler/src/diagnostics/diagnostic_listener.dart' show |
| 20 DiagnosticMessage; | 20 DiagnosticMessage; |
| 21 | 21 |
| 22 import 'fletch_compiler_implementation.dart' show | 22 import 'dartino_compiler_implementation.dart' show |
| 23 FletchCompilerImplementation; | 23 DartinoCompilerImplementation; |
| 24 | 24 |
| 25 import 'package:compiler/src/diagnostics/messages.dart' show | 25 import 'package:compiler/src/diagnostics/messages.dart' show |
| 26 MessageKind; | 26 MessageKind; |
| 27 | 27 |
| 28 import 'please_report_crash.dart' show | 28 import 'please_report_crash.dart' show |
| 29 crashReportRequested, | 29 crashReportRequested, |
| 30 requestBugReportOnCompilerCrashMessage; | 30 requestBugReportOnCompilerCrashMessage; |
| 31 | 31 |
| 32 class FletchDiagnosticReporter extends CompilerDiagnosticReporter { | 32 class DartinoDiagnosticReporter extends CompilerDiagnosticReporter { |
| 33 FletchDiagnosticReporter( | 33 DartinoDiagnosticReporter( |
| 34 FletchCompilerImplementation compiler, | 34 DartinoCompilerImplementation compiler, |
| 35 DiagnosticOptions options) | 35 DiagnosticOptions options) |
| 36 : super(compiler, options); | 36 : super(compiler, options); |
| 37 | 37 |
| 38 FletchCompilerImplementation get compiler => super.compiler; | 38 DartinoCompilerImplementation get compiler => super.compiler; |
| 39 | 39 |
| 40 @override | 40 @override |
| 41 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { | 41 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { |
| 42 // Note: Except for last line, this method is copied from | 42 // Note: Except for last line, this method is copied from |
| 43 // third_party/dart/pkg/compiler/lib/src/compiler.dart | 43 // third_party/dart/pkg/compiler/lib/src/compiler.dart |
| 44 if (begin == null || end == null) { | 44 if (begin == null || end == null) { |
| 45 // TODO(ahe): We can almost always do better. Often it is only | 45 // TODO(ahe): We can almost always do better. Often it is only |
| 46 // end that is null. Otherwise, we probably know the current | 46 // end that is null. Otherwise, we probably know the current |
| 47 // URI. | 47 // URI. |
| 48 throw 'Cannot find tokens to produce error message.'; | 48 throw 'Cannot find tokens to produce error message.'; |
| 49 } | 49 } |
| 50 if (uri == null && currentElement != null) { | 50 if (uri == null && currentElement != null) { |
| 51 uri = currentElement.compilationUnit.script.resourceUri; | 51 uri = currentElement.compilationUnit.script.resourceUri; |
| 52 } | 52 } |
| 53 return compiler.incrementalCompiler.createSourceSpan( | 53 return compiler.incrementalCompiler.createSourceSpan( |
| 54 begin, end, uri, currentElement); | 54 begin, end, uri, currentElement); |
| 55 } | 55 } |
| 56 | 56 |
| 57 @override | 57 @override |
| 58 void reportError(DiagnosticMessage message, | 58 void reportError(DiagnosticMessage message, |
| 59 [List<DiagnosticMessage> infos = const <DiagnosticMessage> []]) { | 59 [List<DiagnosticMessage> infos = const <DiagnosticMessage> []]) { |
| 60 if (message.message.kind == | 60 if (message.message.kind == |
| 61 MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND) { | 61 MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND) { |
| 62 const String noMirrors = | 62 const String noMirrors = |
| 63 "Fletch doesn't support 'dart:mirrors'. See https://goo.gl/Kwrd0O"; | 63 "Dartino doesn't support 'dart:mirrors'. See https://goo.gl/Kwrd0O"; |
| 64 message = createMessage(message.spannable, | 64 message = createMessage(message.spannable, |
| 65 MessageKind.GENERIC, | 65 MessageKind.GENERIC, |
| 66 {'text': message}); | 66 {'text': message}); |
| 67 } | 67 } |
| 68 super.reportError(message, infos); | 68 super.reportError(message, infos); |
| 69 } | 69 } |
| 70 | 70 |
| 71 @override | 71 @override |
| 72 void pleaseReportCrash() { | 72 void pleaseReportCrash() { |
| 73 if (crashReportRequested) return; | 73 if (crashReportRequested) return; |
| 74 crashReportRequested = true; | 74 crashReportRequested = true; |
| 75 print(requestBugReportOnCompilerCrashMessage); | 75 print(requestBugReportOnCompilerCrashMessage); |
| 76 } | 76 } |
| 77 | 77 |
| 78 static FletchDiagnosticReporter createInstance( | 78 static DartinoDiagnosticReporter createInstance( |
| 79 FletchCompilerImplementation compiler, | 79 DartinoCompilerImplementation compiler, |
| 80 DiagnosticOptions options) { | 80 DiagnosticOptions options) { |
| 81 return new FletchDiagnosticReporter(compiler, options); | 81 return new DartinoDiagnosticReporter(compiler, options); |
| 82 } | 82 } |
| 83 } | 83 } |
| OLD | NEW |