OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library dart2js.diagnostic_listener; | 5 library dart2js.diagnostic_listener; |
6 | 6 |
7 import '../options.dart' show | 7 import '../options.dart' show DiagnosticOptions; |
8 DiagnosticOptions; | 8 import 'source_span.dart' show SourceSpan; |
9 import 'source_span.dart' show | 9 import 'spannable.dart' show Spannable; |
10 SourceSpan; | 10 import '../elements/elements.dart' show Element; |
11 import 'spannable.dart' show | |
12 Spannable; | |
13 import '../elements/elements.dart' show | |
14 Element; | |
15 import 'messages.dart'; | 11 import 'messages.dart'; |
16 | 12 |
17 // TODO(johnniwinther): Rename and cleanup this interface. Add severity enum. | 13 // TODO(johnniwinther): Rename and cleanup this interface. Add severity enum. |
18 abstract class DiagnosticReporter { | 14 abstract class DiagnosticReporter { |
19 DiagnosticOptions get options; | 15 DiagnosticOptions get options; |
20 | 16 |
21 // TODO(karlklose): rename log to something like reportInfo. | 17 // TODO(karlklose): rename log to something like reportInfo. |
22 void log(message); | 18 void log(message); |
23 | 19 |
24 internalError(Spannable spannable, message); | 20 internalError(Spannable spannable, message); |
25 | 21 |
26 /// Creates a [SourceSpan] for [node] in scope of the current element. | 22 /// Creates a [SourceSpan] for [node] in scope of the current element. |
27 /// | 23 /// |
28 /// If [node] is a [Node] or [Token] we assert in checked mode that the | 24 /// If [node] is a [Node] or [Token] we assert in checked mode that the |
29 /// corresponding tokens can be found within the tokens of the current | 25 /// corresponding tokens can be found within the tokens of the current |
30 /// element. | 26 /// element. |
31 SourceSpan spanFromSpannable(Spannable node); | 27 SourceSpan spanFromSpannable(Spannable node); |
32 | 28 |
33 void reportErrorMessage( | 29 void reportErrorMessage(Spannable spannable, MessageKind messageKind, |
34 Spannable spannable, | |
35 MessageKind messageKind, | |
36 [Map arguments = const {}]) { | 30 [Map arguments = const {}]) { |
37 reportError(createMessage(spannable, messageKind, arguments)); | 31 reportError(createMessage(spannable, messageKind, arguments)); |
38 } | 32 } |
39 | 33 |
40 void reportError( | 34 void reportError(DiagnosticMessage message, |
41 DiagnosticMessage message, | |
42 [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]); | 35 [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]); |
43 | 36 |
44 void reportWarningMessage( | 37 void reportWarningMessage(Spannable spannable, MessageKind messageKind, |
45 Spannable spannable, | |
46 MessageKind messageKind, | |
47 [Map arguments = const {}]) { | 38 [Map arguments = const {}]) { |
48 reportWarning(createMessage(spannable, messageKind, arguments)); | 39 reportWarning(createMessage(spannable, messageKind, arguments)); |
49 } | 40 } |
50 | 41 |
51 void reportWarning( | 42 void reportWarning(DiagnosticMessage message, |
52 DiagnosticMessage message, | |
53 [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]); | 43 [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]); |
54 | 44 |
55 void reportHintMessage( | 45 void reportHintMessage(Spannable spannable, MessageKind messageKind, |
56 Spannable spannable, | |
57 MessageKind messageKind, | |
58 [Map arguments = const {}]) { | 46 [Map arguments = const {}]) { |
59 reportHint(createMessage(spannable, messageKind, arguments)); | 47 reportHint(createMessage(spannable, messageKind, arguments)); |
60 } | 48 } |
61 | 49 |
62 void reportHint( | 50 void reportHint(DiagnosticMessage message, |
63 DiagnosticMessage message, | |
64 [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]); | 51 [List<DiagnosticMessage> infos = const <DiagnosticMessage>[]]); |
65 | 52 |
66 | |
67 @deprecated | 53 @deprecated |
68 void reportInfo(Spannable node, MessageKind errorCode, | 54 void reportInfo(Spannable node, MessageKind errorCode, |
69 [Map arguments = const {}]); | 55 [Map arguments = const {}]); |
70 | 56 |
71 /// Set current element of this reporter to [element]. This is used for | 57 /// Set current element of this reporter to [element]. This is used for |
72 /// creating [SourceSpan] in [spanFromSpannable]. | 58 /// creating [SourceSpan] in [spanFromSpannable]. |
73 withCurrentElement(Element element, f()); | 59 withCurrentElement(Element element, f()); |
74 | 60 |
75 DiagnosticMessage createMessage( | 61 DiagnosticMessage createMessage(Spannable spannable, MessageKind messageKind, |
76 Spannable spannable, | |
77 MessageKind messageKind, | |
78 [Map arguments = const {}]); | 62 [Map arguments = const {}]); |
79 } | 63 } |
80 | 64 |
81 class DiagnosticMessage { | 65 class DiagnosticMessage { |
82 final SourceSpan sourceSpan; | 66 final SourceSpan sourceSpan; |
83 final Spannable spannable; | 67 final Spannable spannable; |
84 final Message message; | 68 final Message message; |
85 | 69 |
86 DiagnosticMessage(this.sourceSpan, this.spannable, this.message); | 70 DiagnosticMessage(this.sourceSpan, this.spannable, this.message); |
87 } | 71 } |
OLD | NEW |