Chromium Code Reviews

Side by Side Diff: pkg/fletchc/lib/src/fletch_diagnostic_reporter.dart

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « pkg/fletchc/lib/src/fletch_context.dart ('k') | pkg/fletchc/lib/src/fletch_enqueuer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE.md file.
4
5 library fletchc.fletch_diagnostic_reporter;
6
7 import 'package:compiler/src/tokens/token.dart' show
8 Token;
9
10 import 'package:compiler/src/compiler.dart' show
11 CompilerDiagnosticReporter;
12
13 import 'package:compiler/src/diagnostics/diagnostic_listener.dart' show
14 DiagnosticOptions;
15
16 import 'package:compiler/src/diagnostics/source_span.dart' show
17 SourceSpan;
18
19 import 'package:compiler/src/diagnostics/diagnostic_listener.dart' show
20 DiagnosticMessage;
21
22 import 'fletch_compiler_implementation.dart' show
23 FletchCompilerImplementation;
24
25 import 'package:compiler/src/diagnostics/messages.dart' show
26 MessageKind;
27
28 import 'please_report_crash.dart' show
29 crashReportRequested,
30 requestBugReportOnCompilerCrashMessage;
31
32 class FletchDiagnosticReporter extends CompilerDiagnosticReporter {
33 FletchDiagnosticReporter(
34 FletchCompilerImplementation compiler,
35 DiagnosticOptions options)
36 : super(compiler, options);
37
38 FletchCompilerImplementation get compiler => super.compiler;
39
40 @override
41 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) {
42 // Note: Except for last line, this method is copied from
43 // third_party/dart/pkg/compiler/lib/src/compiler.dart
44 if (begin == null || end == null) {
45 // TODO(ahe): We can almost always do better. Often it is only
46 // end that is null. Otherwise, we probably know the current
47 // URI.
48 throw 'Cannot find tokens to produce error message.';
49 }
50 if (uri == null && currentElement != null) {
51 uri = currentElement.compilationUnit.script.resourceUri;
52 }
53 return compiler.incrementalCompiler.createSourceSpan(
54 begin, end, uri, currentElement);
55 }
56
57 @override
58 void reportError(DiagnosticMessage message,
59 [List<DiagnosticMessage> infos = const <DiagnosticMessage> []]) {
60 if (message.message.kind ==
61 MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND) {
62 const String noMirrors =
63 "Fletch doesn't support 'dart:mirrors'. See https://goo.gl/Kwrd0O";
64 message = createMessage(message.spannable,
65 MessageKind.GENERIC,
66 {'text': message});
67 }
68 super.reportError(message, infos);
69 }
70
71 @override
72 void pleaseReportCrash() {
73 if (crashReportRequested) return;
74 crashReportRequested = true;
75 print(requestBugReportOnCompilerCrashMessage);
76 }
77
78 static FletchDiagnosticReporter createInstance(
79 FletchCompilerImplementation compiler,
80 DiagnosticOptions options) {
81 return new FletchDiagnosticReporter(compiler, options);
82 }
83 }
OLDNEW
« no previous file with comments | « pkg/fletchc/lib/src/fletch_context.dart ('k') | pkg/fletchc/lib/src/fletch_enqueuer.dart » ('j') | no next file with comments »

Powered by Google App Engine