OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.src.generated.error; | 5 library analyzer.src.error.codes; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'package:analyzer/error/error.dart'; |
8 | |
9 import 'package:analyzer/dart/ast/ast.dart' show AstNode; | |
10 import 'package:analyzer/dart/ast/token.dart'; | |
11 import 'package:analyzer/dart/element/element.dart'; | |
12 import 'package:analyzer/dart/element/type.dart'; | |
13 import 'package:analyzer/source/error_processor.dart'; | |
14 import 'package:analyzer/src/dart/element/element.dart'; | 8 import 'package:analyzer/src/dart/element/element.dart'; |
15 import 'package:analyzer/src/dart/element/type.dart'; | |
16 import 'package:analyzer/src/dart/scanner/scanner.dart' show ScannerErrorCode; | |
17 import 'package:analyzer/src/generated/generated/shared_messages.dart' | 9 import 'package:analyzer/src/generated/generated/shared_messages.dart' |
18 as shared_messages; | 10 as shared_messages; |
19 import 'package:analyzer/src/generated/java_core.dart'; | |
20 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | |
21 import 'package:analyzer/src/generated/source.dart'; | |
22 import 'package:analyzer/src/task/model.dart'; | |
23 import 'package:analyzer/task/model.dart'; | |
24 import 'package:source_span/source_span.dart'; | |
25 | |
26 /** | |
27 * The descriptor used to associate error processors with analysis contexts in | |
28 * configuration data. | |
29 */ | |
30 final ListResultDescriptor<ErrorProcessor> CONFIGURED_ERROR_PROCESSORS = | |
31 new ListResultDescriptorImpl('configured.errors', const <ErrorProcessor>[]); | |
32 | |
33 /** | |
34 * An error discovered during the analysis of some Dart code. | |
35 * | |
36 * See [AnalysisErrorListener]. | |
37 */ | |
38 class AnalysisError { | |
39 /** | |
40 * An empty array of errors used when no errors are expected. | |
41 */ | |
42 static const List<AnalysisError> NO_ERRORS = const <AnalysisError>[]; | |
43 | |
44 /** | |
45 * A [Comparator] that sorts by the name of the file that the [AnalysisError] | |
46 * was found. | |
47 */ | |
48 static Comparator<AnalysisError> FILE_COMPARATOR = | |
49 (AnalysisError o1, AnalysisError o2) => | |
50 o1.source.shortName.compareTo(o2.source.shortName); | |
51 | |
52 /** | |
53 * A [Comparator] that sorts error codes first by their severity (errors | |
54 * first, warnings second), and then by the error code type. | |
55 */ | |
56 static Comparator<AnalysisError> ERROR_CODE_COMPARATOR = | |
57 (AnalysisError o1, AnalysisError o2) { | |
58 ErrorCode errorCode1 = o1.errorCode; | |
59 ErrorCode errorCode2 = o2.errorCode; | |
60 ErrorSeverity errorSeverity1 = errorCode1.errorSeverity; | |
61 ErrorSeverity errorSeverity2 = errorCode2.errorSeverity; | |
62 if (errorSeverity1 == errorSeverity2) { | |
63 ErrorType errorType1 = errorCode1.type; | |
64 ErrorType errorType2 = errorCode2.type; | |
65 return errorType1.compareTo(errorType2); | |
66 } else { | |
67 return errorSeverity2.compareTo(errorSeverity1); | |
68 } | |
69 }; | |
70 | |
71 /** | |
72 * The error code associated with the error. | |
73 */ | |
74 final ErrorCode errorCode; | |
75 | |
76 /** | |
77 * The localized error message. | |
78 */ | |
79 String _message; | |
80 | |
81 /** | |
82 * The correction to be displayed for this error, or `null` if there is no | |
83 * correction information for this error. | |
84 */ | |
85 String _correction; | |
86 | |
87 /** | |
88 * The source in which the error occurred, or `null` if unknown. | |
89 */ | |
90 final Source source; | |
91 | |
92 /** | |
93 * The character offset from the beginning of the source (zero based) where | |
94 * the error occurred. | |
95 */ | |
96 int offset = 0; | |
97 | |
98 /** | |
99 * The number of characters from the offset to the end of the source which | |
100 * encompasses the compilation error. | |
101 */ | |
102 int length = 0; | |
103 | |
104 /** | |
105 * A flag indicating whether this error can be shown to be a non-issue because | |
106 * of the result of type propagation. | |
107 */ | |
108 bool isStaticOnly = false; | |
109 | |
110 /** | |
111 * Initialize a newly created analysis error. The error is associated with the | |
112 * given [source] and is located at the given [offset] with the given | |
113 * [length]. The error will have the given [errorCode] and the list of | |
114 * [arguments] will be used to complete the message. | |
115 */ | |
116 AnalysisError(this.source, this.offset, this.length, this.errorCode, | |
117 [List<Object> arguments]) { | |
118 this._message = formatList(errorCode.message, arguments); | |
119 String correctionTemplate = errorCode.correction; | |
120 if (correctionTemplate != null) { | |
121 this._correction = formatList(correctionTemplate, arguments); | |
122 } | |
123 } | |
124 | |
125 /** | |
126 * Initialize a newly created analysis error with given values. | |
127 */ | |
128 AnalysisError.forValues(this.source, this.offset, this.length, this.errorCode, | |
129 this._message, this._correction); | |
130 | |
131 /** | |
132 * Return the template used to create the correction to be displayed for this | |
133 * error, or `null` if there is no correction information for this error. The | |
134 * correction should indicate how the user can fix the error. | |
135 */ | |
136 String get correction => _correction; | |
137 | |
138 @override | |
139 int get hashCode { | |
140 int hashCode = offset; | |
141 hashCode ^= (_message != null) ? _message.hashCode : 0; | |
142 hashCode ^= (source != null) ? source.hashCode : 0; | |
143 return hashCode; | |
144 } | |
145 | |
146 /** | |
147 * Return the message to be displayed for this error. The message should | |
148 * indicate what is wrong and why it is wrong. | |
149 */ | |
150 String get message => _message; | |
151 | |
152 @override | |
153 bool operator ==(Object other) { | |
154 if (identical(other, this)) { | |
155 return true; | |
156 } | |
157 // prepare other AnalysisError | |
158 if (other is AnalysisError) { | |
159 // Quick checks. | |
160 if (!identical(errorCode, other.errorCode)) { | |
161 return false; | |
162 } | |
163 if (offset != other.offset || length != other.length) { | |
164 return false; | |
165 } | |
166 if (isStaticOnly != other.isStaticOnly) { | |
167 return false; | |
168 } | |
169 // Deep checks. | |
170 if (_message != other._message) { | |
171 return false; | |
172 } | |
173 if (source != other.source) { | |
174 return false; | |
175 } | |
176 // OK | |
177 return true; | |
178 } | |
179 return false; | |
180 } | |
181 | |
182 /** | |
183 * Return the value of the given [property], or `null` if the given property | |
184 * is not defined for this error. | |
185 */ | |
186 Object/*=V*/ getProperty/*<V>*/(ErrorProperty/*<V>*/ property) => null; | |
187 | |
188 @override | |
189 String toString() { | |
190 StringBuffer buffer = new StringBuffer(); | |
191 buffer.write((source != null) ? source.fullName : "<unknown source>"); | |
192 buffer.write("("); | |
193 buffer.write(offset); | |
194 buffer.write(".."); | |
195 buffer.write(offset + length - 1); | |
196 buffer.write("): "); | |
197 //buffer.write("(" + lineNumber + ":" + columnNumber + "): "); | |
198 buffer.write(_message); | |
199 return buffer.toString(); | |
200 } | |
201 | |
202 /** | |
203 * Merge all of the errors in the lists in the given list of [errorLists] into | |
204 * a single list of errors. | |
205 */ | |
206 static List<AnalysisError> mergeLists(List<List<AnalysisError>> errorLists) { | |
207 Set<AnalysisError> errors = new HashSet<AnalysisError>(); | |
208 for (List<AnalysisError> errorList in errorLists) { | |
209 errors.addAll(errorList); | |
210 } | |
211 return errors.toList(); | |
212 } | |
213 } | |
214 | |
215 /** | |
216 * An object that listen for [AnalysisError]s being produced by the analysis | |
217 * engine. | |
218 */ | |
219 abstract class AnalysisErrorListener { | |
220 /** | |
221 * An error listener that ignores errors that are reported to it. | |
222 */ | |
223 static final AnalysisErrorListener NULL_LISTENER = | |
224 new AnalysisErrorListener_NULL_LISTENER(); | |
225 | |
226 /** | |
227 * This method is invoked when an [error] has been found by the analysis | |
228 * engine. | |
229 */ | |
230 void onError(AnalysisError error); | |
231 } | |
232 | |
233 /** | |
234 * An [AnalysisErrorListener] that ignores error. | |
235 */ | |
236 class AnalysisErrorListener_NULL_LISTENER implements AnalysisErrorListener { | |
237 @override | |
238 void onError(AnalysisError event) { | |
239 // Ignore errors | |
240 } | |
241 } | |
242 | |
243 /** | |
244 * An [AnalysisError] that can have arbitrary properties associated with it. | |
245 */ | |
246 class AnalysisErrorWithProperties extends AnalysisError { | |
247 /** | |
248 * The properties associated with this error. | |
249 */ | |
250 HashMap<ErrorProperty, Object> _propertyMap = | |
251 new HashMap<ErrorProperty, Object>(); | |
252 | |
253 /** | |
254 * Initialize a newly created analysis error. The error is associated with the | |
255 * given [source] and is located at the given [offset] with the given | |
256 * [length]. The error will have the given [errorCode] and the list of | |
257 * [arguments] will be used to complete the message. | |
258 */ | |
259 AnalysisErrorWithProperties( | |
260 Source source, int offset, int length, ErrorCode errorCode, | |
261 [List<Object> arguments]) | |
262 : super(source, offset, length, errorCode, arguments); | |
263 | |
264 @override | |
265 Object/*=V*/ getProperty/*<V>*/(ErrorProperty/*<V>*/ property) => | |
266 _propertyMap[property] as Object/*=V*/; | |
267 | |
268 /** | |
269 * Set the value of the given [property] to the given [value]. Using a value | |
270 * of `null` will effectively remove the property from this error. | |
271 */ | |
272 void setProperty/*<V>*/(ErrorProperty/*<V>*/ property, Object/*=V*/ value) { | |
273 _propertyMap[property] = value; | |
274 } | |
275 } | |
276 | 11 |
277 /** | 12 /** |
278 * The error codes used for errors in analysis options files. The convention for | 13 * The error codes used for errors in analysis options files. The convention for |
279 * this class is for the name of the error code to indicate the problem that | 14 * this class is for the name of the error code to indicate the problem that |
280 * caused the error to be generated and for the error message to explain what is | 15 * caused the error to be generated and for the error message to explain what is |
281 * wrong and, when appropriate, how the problem can be corrected. | 16 * wrong and, when appropriate, how the problem can be corrected. |
282 */ | 17 */ |
283 class AnalysisOptionsErrorCode extends ErrorCode { | 18 class AnalysisOptionsErrorCode extends ErrorCode { |
284 /** | 19 /** |
285 * An error code indicating that there is a syntactic error in the file. | 20 * An error code indicating that there is a syntactic error in the file. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 : super(name, message, correction); | 104 : super(name, message, correction); |
370 | 105 |
371 @override | 106 @override |
372 ErrorSeverity get errorSeverity => ErrorSeverity.WARNING; | 107 ErrorSeverity get errorSeverity => ErrorSeverity.WARNING; |
373 | 108 |
374 @override | 109 @override |
375 ErrorType get type => ErrorType.STATIC_WARNING; | 110 ErrorType get type => ErrorType.STATIC_WARNING; |
376 } | 111 } |
377 | 112 |
378 /** | 113 /** |
379 * An [AnalysisErrorListener] that keeps track of whether any error has been | |
380 * reported to it. | |
381 */ | |
382 class BooleanErrorListener implements AnalysisErrorListener { | |
383 /** | |
384 * A flag indicating whether an error has been reported to this listener. | |
385 */ | |
386 bool _errorReported = false; | |
387 | |
388 /** | |
389 * Return `true` if an error has been reported to this listener. | |
390 */ | |
391 bool get errorReported => _errorReported; | |
392 | |
393 @override | |
394 void onError(AnalysisError error) { | |
395 _errorReported = true; | |
396 } | |
397 } | |
398 | |
399 /** | |
400 * The error codes used for compile time errors caused by constant evaluation | 114 * The error codes used for compile time errors caused by constant evaluation |
401 * that would throw an exception when run in checked mode. The client of the | 115 * that would throw an exception when run in checked mode. The client of the |
402 * analysis engine is responsible for determining how these errors should be | 116 * analysis engine is responsible for determining how these errors should be |
403 * presented to the user (for example, a command-line compiler might elect to | 117 * presented to the user (for example, a command-line compiler might elect to |
404 * treat these errors differently depending whether it is compiling it "checked" | 118 * treat these errors differently depending whether it is compiling it "checked" |
405 * mode). | 119 * mode). |
406 */ | 120 */ |
407 class CheckedModeCompileTimeErrorCode extends ErrorCode { | 121 class CheckedModeCompileTimeErrorCode extends ErrorCode { |
408 // TODO(paulberry): improve the text of these error messages so that it's | 122 // TODO(paulberry): improve the text of these error messages so that it's |
409 // clear to the user that the error is coming from constant evaluation (and | 123 // clear to the user that the error is coming from constant evaluation (and |
(...skipping 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2472 : super(name, message, correction); | 2186 : super(name, message, correction); |
2473 | 2187 |
2474 @override | 2188 @override |
2475 ErrorSeverity get errorSeverity => ErrorType.COMPILE_TIME_ERROR.severity; | 2189 ErrorSeverity get errorSeverity => ErrorType.COMPILE_TIME_ERROR.severity; |
2476 | 2190 |
2477 @override | 2191 @override |
2478 ErrorType get type => ErrorType.COMPILE_TIME_ERROR; | 2192 ErrorType get type => ErrorType.COMPILE_TIME_ERROR; |
2479 } | 2193 } |
2480 | 2194 |
2481 /** | 2195 /** |
2482 * An error code associated with an [AnalysisError]. | |
2483 * | |
2484 * Generally, we want to provide messages that consist of three sentences. From | |
2485 * the user's perspective these sentences should explain: | |
2486 * 1. what is wrong, | |
2487 * 2. why is it wrong, and | |
2488 * 3. how do I fix it. | |
2489 * However, we combine the first two in the [message] and the last in the | |
2490 * [correction]. | |
2491 */ | |
2492 abstract class ErrorCode { | |
2493 /** | |
2494 * Engine error code values. | |
2495 */ | |
2496 static const List<ErrorCode> values = const [ | |
2497 // | |
2498 // Manually generated. FWIW, this get's you most of the way there: | |
2499 // | |
2500 // > grep 'static const .*Code' (error.dart|parser|scanner.dart) | |
2501 // | awk '{print $3"."$4","}' | |
2502 // | |
2503 // error.dart: | |
2504 // | |
2505 AnalysisOptionsErrorCode.PARSE_ERROR, | |
2506 AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUES, | |
2507 AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE, | |
2508 AnalysisOptionsWarningCode.UNSUPPORTED_VALUE, | |
2509 AnalysisOptionsWarningCode.UNRECOGNIZED_ERROR_CODE, | |
2510 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH, | |
2511 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH, | |
2512 CheckedModeCompileTimeErrorCode.CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE, | |
2513 CheckedModeCompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE, | |
2514 CheckedModeCompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE, | |
2515 CheckedModeCompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE, | |
2516 CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH, | |
2517 CompileTimeErrorCode.ACCESS_PRIVATE_ENUM_FIELD, | |
2518 CompileTimeErrorCode.AMBIGUOUS_EXPORT, | |
2519 CompileTimeErrorCode.ANNOTATION_WITH_NON_CLASS, | |
2520 CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_NON_PARAMETER, | |
2521 CompileTimeErrorCode.ASYNC_FOR_IN_WRONG_CONTEXT, | |
2522 CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT, | |
2523 CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, | |
2524 CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_NAME, | |
2525 CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME, | |
2526 CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME, | |
2527 CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS, | |
2528 CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCEPTION, | |
2529 CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD, | |
2530 CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER, | |
2531 CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD, | |
2532 CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD, | |
2533 CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_CLASS, | |
2534 CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER, | |
2535 CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION, | |
2536 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST, | |
2537 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN, | |
2538 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER, | |
2539 CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD, | |
2540 CompileTimeErrorCode.CONST_DEFERRED_CLASS, | |
2541 CompileTimeErrorCode.CONST_FORMAL_PARAMETER, | |
2542 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE, | |
2543 CompileTimeErrorCode | |
2544 .CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY, | |
2545 CompileTimeErrorCode.CONST_INSTANCE_FIELD, | |
2546 CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS, | |
2547 CompileTimeErrorCode.CONST_NOT_INITIALIZED, | |
2548 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL, | |
2549 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING, | |
2550 CompileTimeErrorCode.CONST_EVAL_TYPE_INT, | |
2551 CompileTimeErrorCode.CONST_EVAL_TYPE_NUM, | |
2552 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION, | |
2553 CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE, | |
2554 CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS, | |
2555 CompileTimeErrorCode.CONST_WITH_NON_CONST, | |
2556 CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT, | |
2557 CompileTimeErrorCode.CONST_WITH_NON_TYPE, | |
2558 CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS, | |
2559 CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR, | |
2560 CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT, | |
2561 CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS, | |
2562 CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER, | |
2563 CompileTimeErrorCode.DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR, | |
2564 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, | |
2565 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME, | |
2566 CompileTimeErrorCode.DUPLICATE_DEFINITION, | |
2567 CompileTimeErrorCode.DUPLICATE_DEFINITION_INHERITANCE, | |
2568 CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT, | |
2569 CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY, | |
2570 CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY, | |
2571 CompileTimeErrorCode.EXTENDS_ENUM, | |
2572 CompileTimeErrorCode.EXTENDS_NON_CLASS, | |
2573 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, | |
2574 CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS, | |
2575 CompileTimeErrorCode.EXTRA_ARGUMENT_TO_ASSERT, | |
2576 CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS, | |
2577 CompileTimeErrorCode.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS, | |
2578 CompileTimeErrorCode.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER, | |
2579 CompileTimeErrorCode.FINAL_INITIALIZED_MULTIPLE_TIMES, | |
2580 CompileTimeErrorCode.FIELD_INITIALIZER_FACTORY_CONSTRUCTOR, | |
2581 CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, | |
2582 CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR, | |
2583 CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME, | |
2584 CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS, | |
2585 CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS, | |
2586 CompileTimeErrorCode.IMPLEMENTS_DYNAMIC, | |
2587 CompileTimeErrorCode.IMPLEMENTS_ENUM, | |
2588 CompileTimeErrorCode.IMPLEMENTS_NON_CLASS, | |
2589 CompileTimeErrorCode.IMPLEMENTS_REPEATED, | |
2590 CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS, | |
2591 CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER, | |
2592 CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, | |
2593 CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY, | |
2594 CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES, | |
2595 CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTENT_FIELD, | |
2596 CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD, | |
2597 CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD, | |
2598 CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD, | |
2599 CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_FACTORY, | |
2600 CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC, | |
2601 CompileTimeErrorCode.INSTANTIATE_ENUM, | |
2602 CompileTimeErrorCode.INVALID_ANNOTATION, | |
2603 CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY, | |
2604 CompileTimeErrorCode.INVALID_IDENTIFIER_IN_ASYNC, | |
2605 CompileTimeErrorCode.INVALID_MODIFIER_ON_CONSTRUCTOR, | |
2606 CompileTimeErrorCode.INVALID_MODIFIER_ON_SETTER, | |
2607 CompileTimeErrorCode.INVALID_CONSTANT, | |
2608 CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME, | |
2609 CompileTimeErrorCode.INVALID_FACTORY_NAME_NOT_A_CLASS, | |
2610 CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS, | |
2611 CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_LIST, | |
2612 CompileTimeErrorCode.INVALID_TYPE_ARGUMENT_IN_CONST_MAP, | |
2613 CompileTimeErrorCode.INVALID_URI, | |
2614 CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE, | |
2615 CompileTimeErrorCode.LABEL_UNDEFINED, | |
2616 CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME, | |
2617 CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME, | |
2618 CompileTimeErrorCode.MISSING_CONST_IN_LIST_LITERAL, | |
2619 CompileTimeErrorCode.MISSING_CONST_IN_MAP_LITERAL, | |
2620 CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR, | |
2621 CompileTimeErrorCode.MIXIN_DEFERRED_CLASS, | |
2622 CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS, | |
2623 CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT, | |
2624 CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS, | |
2625 CompileTimeErrorCode.MIXIN_OF_ENUM, | |
2626 CompileTimeErrorCode.MIXIN_OF_NON_CLASS, | |
2627 CompileTimeErrorCode.MIXIN_REFERENCES_SUPER, | |
2628 CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS, | |
2629 CompileTimeErrorCode.MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS, | |
2630 CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS, | |
2631 CompileTimeErrorCode.NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS, | |
2632 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT, | |
2633 CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT, | |
2634 CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT, | |
2635 CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION, | |
2636 CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY, | |
2637 CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE, | |
2638 CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY, | |
2639 CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT, | |
2640 CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY, | |
2641 CompileTimeErrorCode.NON_CONSTANT_MAP_KEY, | |
2642 CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY, | |
2643 CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE, | |
2644 CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY, | |
2645 CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCTOR, | |
2646 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER, | |
2647 CompileTimeErrorCode | |
2648 .NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY, | |
2649 CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS, | |
2650 CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR, | |
2651 CompileTimeErrorCode.OBJECT_CANNOT_EXTEND_ANOTHER_CLASS, | |
2652 CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR, | |
2653 CompileTimeErrorCode.PART_OF_NON_PART, | |
2654 CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, | |
2655 CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, | |
2656 CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER, | |
2657 CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT, | |
2658 CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT, | |
2659 CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT, | |
2660 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE, | |
2661 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS, | |
2662 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS, | |
2663 CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_WITH, | |
2664 CompileTimeErrorCode.REDIRECT_TO_MISSING_CONSTRUCTOR, | |
2665 CompileTimeErrorCode.REDIRECT_TO_NON_CLASS, | |
2666 CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONSTRUCTOR, | |
2667 CompileTimeErrorCode.REDIRECT_GENERATIVE_TO_MISSING_CONSTRUCTOR, | |
2668 CompileTimeErrorCode.REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR, | |
2669 CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION, | |
2670 CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH, | |
2671 CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR, | |
2672 CompileTimeErrorCode.RETURN_IN_GENERATOR, | |
2673 CompileTimeErrorCode.SHARED_DEFERRED_PREFIX, | |
2674 CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT, | |
2675 CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR, | |
2676 CompileTimeErrorCode.SUPER_INITIALIZER_IN_OBJECT, | |
2677 CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, | |
2678 CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, | |
2679 CompileTimeErrorCode.UNDEFINED_CLASS, | |
2680 CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER, | |
2681 CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT, | |
2682 CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER, | |
2683 CompileTimeErrorCode.URI_DOES_NOT_EXIST, | |
2684 CompileTimeErrorCode.URI_WITH_INTERPOLATION, | |
2685 CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR, | |
2686 CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINUS, | |
2687 CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_SETTER, | |
2688 CompileTimeErrorCode.YIELD_EACH_IN_NON_GENERATOR, | |
2689 CompileTimeErrorCode.YIELD_IN_NON_GENERATOR, | |
2690 HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, | |
2691 HintCode.CAN_BE_NULL_AFTER_NULL_AWARE, | |
2692 HintCode.DEAD_CODE, | |
2693 HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH, | |
2694 HintCode.DEAD_CODE_ON_CATCH_SUBTYPE, | |
2695 HintCode.DEPRECATED_MEMBER_USE, | |
2696 HintCode.DUPLICATE_IMPORT, | |
2697 HintCode.DIVISION_OPTIMIZATION, | |
2698 HintCode.INVALID_FACTORY_ANNOTATION, | |
2699 HintCode.INVALID_FACTORY_METHOD_DECL, | |
2700 HintCode.INVALID_FACTORY_METHOD_IMPL, | |
2701 HintCode.IS_DOUBLE, | |
2702 HintCode.IS_INT, | |
2703 HintCode.IS_NOT_DOUBLE, | |
2704 HintCode.IS_NOT_INT, | |
2705 HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION, | |
2706 HintCode.INVALID_ASSIGNMENT, | |
2707 HintCode.INVALID_USE_OF_PROTECTED_MEMBER, | |
2708 HintCode.MISSING_JS_LIB_ANNOTATION, | |
2709 HintCode.MISSING_REQUIRED_PARAM, | |
2710 HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS, | |
2711 HintCode.MISSING_RETURN, | |
2712 HintCode.NULL_AWARE_IN_CONDITION, | |
2713 HintCode.OVERRIDE_ON_NON_OVERRIDING_GETTER, | |
2714 HintCode.OVERRIDE_ON_NON_OVERRIDING_FIELD, | |
2715 HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD, | |
2716 HintCode.OVERRIDE_ON_NON_OVERRIDING_SETTER, | |
2717 HintCode.OVERRIDE_EQUALS_BUT_NOT_HASH_CODE, | |
2718 HintCode.TYPE_CHECK_IS_NOT_NULL, | |
2719 HintCode.TYPE_CHECK_IS_NULL, | |
2720 HintCode.UNDEFINED_GETTER, | |
2721 HintCode.UNDEFINED_HIDDEN_NAME, | |
2722 HintCode.UNDEFINED_METHOD, | |
2723 HintCode.UNDEFINED_OPERATOR, | |
2724 HintCode.UNDEFINED_SETTER, | |
2725 HintCode.UNDEFINED_SHOWN_NAME, | |
2726 HintCode.UNNECESSARY_CAST, | |
2727 HintCode.UNNECESSARY_NO_SUCH_METHOD, | |
2728 HintCode.UNNECESSARY_TYPE_CHECK_FALSE, | |
2729 HintCode.UNNECESSARY_TYPE_CHECK_TRUE, | |
2730 HintCode.UNUSED_ELEMENT, | |
2731 HintCode.UNUSED_FIELD, | |
2732 HintCode.UNUSED_IMPORT, | |
2733 HintCode.UNUSED_CATCH_CLAUSE, | |
2734 HintCode.UNUSED_CATCH_STACK, | |
2735 HintCode.UNUSED_LOCAL_VARIABLE, | |
2736 HintCode.UNUSED_SHOWN_NAME, | |
2737 HintCode.USE_OF_VOID_RESULT, | |
2738 HintCode.FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE, | |
2739 HintCode.FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE, | |
2740 HintCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT, | |
2741 HtmlErrorCode.PARSE_ERROR, | |
2742 HtmlWarningCode.INVALID_URI, | |
2743 HtmlWarningCode.URI_DOES_NOT_EXIST, | |
2744 StaticTypeWarningCode.EXPECTED_ONE_LIST_TYPE_ARGUMENTS, | |
2745 StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS, | |
2746 StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE, | |
2747 StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, | |
2748 StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE, | |
2749 StaticTypeWarningCode.INACCESSIBLE_SETTER, | |
2750 StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE, | |
2751 StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER, | |
2752 StaticTypeWarningCode.INVALID_ASSIGNMENT, | |
2753 StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, | |
2754 StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION_EXPRESSION, | |
2755 StaticTypeWarningCode.NON_BOOL_CONDITION, | |
2756 StaticTypeWarningCode.NON_BOOL_EXPRESSION, | |
2757 StaticTypeWarningCode.NON_BOOL_NEGATION_EXPRESSION, | |
2758 StaticTypeWarningCode.NON_BOOL_OPERAND, | |
2759 StaticTypeWarningCode.NON_NULLABLE_FIELD_NOT_INITIALIZED, | |
2760 StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT, | |
2761 StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, | |
2762 StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS, | |
2763 StaticTypeWarningCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND, | |
2764 StaticTypeWarningCode.UNDEFINED_ENUM_CONSTANT, | |
2765 StaticTypeWarningCode.UNDEFINED_FUNCTION, | |
2766 StaticTypeWarningCode.UNDEFINED_GETTER, | |
2767 StaticTypeWarningCode.UNDEFINED_METHOD, | |
2768 StaticTypeWarningCode.UNDEFINED_METHOD_WITH_CONSTRUCTOR, | |
2769 StaticTypeWarningCode.UNDEFINED_OPERATOR, | |
2770 StaticTypeWarningCode.UNDEFINED_SETTER, | |
2771 StaticTypeWarningCode.UNDEFINED_SUPER_GETTER, | |
2772 StaticTypeWarningCode.UNDEFINED_SUPER_METHOD, | |
2773 StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR, | |
2774 StaticTypeWarningCode.UNDEFINED_SUPER_SETTER, | |
2775 StaticTypeWarningCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER, | |
2776 StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS, | |
2777 StaticTypeWarningCode.YIELD_OF_INVALID_TYPE, | |
2778 StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE, | |
2779 StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE, | |
2780 StaticWarningCode.AMBIGUOUS_IMPORT, | |
2781 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, | |
2782 StaticWarningCode.ASSIGNMENT_TO_CONST, | |
2783 StaticWarningCode.ASSIGNMENT_TO_FINAL, | |
2784 StaticWarningCode.ASSIGNMENT_TO_FINAL_NO_SETTER, | |
2785 StaticWarningCode.ASSIGNMENT_TO_FUNCTION, | |
2786 StaticWarningCode.ASSIGNMENT_TO_METHOD, | |
2787 StaticWarningCode.ASSIGNMENT_TO_TYPE, | |
2788 StaticWarningCode.CASE_BLOCK_NOT_TERMINATED, | |
2789 StaticWarningCode.CAST_TO_NON_TYPE, | |
2790 StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER, | |
2791 StaticWarningCode.CONFLICTING_DART_IMPORT, | |
2792 StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER, | |
2793 StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER, | |
2794 StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER2, | |
2795 StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER, | |
2796 StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER, | |
2797 StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER, | |
2798 StaticWarningCode.CONST_WITH_ABSTRACT_CLASS, | |
2799 StaticWarningCode.EQUAL_KEYS_IN_MAP, | |
2800 StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAMED, | |
2801 StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS, | |
2802 StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION, | |
2803 StaticWarningCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR, | |
2804 StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE, | |
2805 StaticWarningCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE, | |
2806 StaticWarningCode.FINAL_NOT_INITIALIZED, | |
2807 StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_1, | |
2808 StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_2, | |
2809 StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS, | |
2810 StaticWarningCode.FUNCTION_WITHOUT_CALL, | |
2811 StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAMED, | |
2812 StaticWarningCode.IMPORT_OF_NON_LIBRARY, | |
2813 StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD, | |
2814 StaticWarningCode.INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC, | |
2815 StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE, | |
2816 StaticWarningCode.INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE, | |
2817 StaticWarningCode.INVALID_METHOD_OVERRIDE_TYPE_PARAMETERS, | |
2818 StaticWarningCode.INVALID_METHOD_OVERRIDE_TYPE_PARAMETER_BOUND, | |
2819 StaticWarningCode.INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE, | |
2820 StaticWarningCode.INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE, | |
2821 StaticWarningCode.INVALID_METHOD_OVERRIDE_RETURN_TYPE, | |
2822 StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED, | |
2823 StaticWarningCode.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL, | |
2824 StaticWarningCode.INVALID_OVERRIDE_NAMED, | |
2825 StaticWarningCode.INVALID_OVERRIDE_POSITIONAL, | |
2826 StaticWarningCode.INVALID_OVERRIDE_REQUIRED, | |
2827 StaticWarningCode.INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE, | |
2828 StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE, | |
2829 StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE, | |
2830 StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE, | |
2831 StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES, | |
2832 StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE, | |
2833 StaticWarningCode.MIXED_RETURN_TYPES, | |
2834 StaticWarningCode.NEW_WITH_ABSTRACT_CLASS, | |
2835 StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS, | |
2836 StaticWarningCode.NEW_WITH_NON_TYPE, | |
2837 StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR, | |
2838 StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT, | |
2839 StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS, | |
2840 StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR, | |
2841 StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE, | |
2842 StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE, | |
2843 StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO, | |
2844 StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, | |
2845 StaticWarningCode.NON_VOID_RETURN_FOR_OPERATOR, | |
2846 StaticWarningCode.NON_VOID_RETURN_FOR_SETTER, | |
2847 StaticWarningCode.NOT_A_TYPE, | |
2848 StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS, | |
2849 StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, | |
2850 StaticWarningCode.REDIRECT_TO_INVALID_FUNCTION_TYPE, | |
2851 StaticWarningCode.REDIRECT_TO_INVALID_RETURN_TYPE, | |
2852 StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR, | |
2853 StaticWarningCode.REDIRECT_TO_NON_CLASS, | |
2854 StaticWarningCode.RETURN_WITHOUT_VALUE, | |
2855 StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMBER, | |
2856 StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE, | |
2857 StaticWarningCode.TYPE_ANNOTATION_DEFERRED_CLASS, | |
2858 StaticWarningCode.TYPE_TEST_WITH_NON_TYPE, | |
2859 StaticWarningCode.TYPE_TEST_WITH_UNDEFINED_NAME, | |
2860 StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC, | |
2861 StaticWarningCode.UNDEFINED_CLASS, | |
2862 StaticWarningCode.UNDEFINED_CLASS_BOOLEAN, | |
2863 StaticWarningCode.UNDEFINED_GETTER, | |
2864 StaticWarningCode.UNDEFINED_IDENTIFIER, | |
2865 StaticWarningCode.UNDEFINED_NAMED_PARAMETER, | |
2866 StaticWarningCode.UNDEFINED_SETTER, | |
2867 StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER, | |
2868 StaticWarningCode.UNDEFINED_SUPER_GETTER, | |
2869 StaticWarningCode.UNDEFINED_SUPER_SETTER, | |
2870 StaticWarningCode.VOID_RETURN_FOR_GETTER, | |
2871 StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH, | |
2872 StrongModeCode.ASSIGNMENT_CAST, | |
2873 StrongModeCode.DOWN_CAST_COMPOSITE, | |
2874 StrongModeCode.DOWN_CAST_IMPLICIT, | |
2875 StrongModeCode.DYNAMIC_CAST, | |
2876 StrongModeCode.DYNAMIC_INVOKE, | |
2877 StrongModeCode.IMPLICIT_DYNAMIC_FIELD, | |
2878 StrongModeCode.IMPLICIT_DYNAMIC_FUNCTION, | |
2879 StrongModeCode.IMPLICIT_DYNAMIC_INVOKE, | |
2880 StrongModeCode.IMPLICIT_DYNAMIC_LIST_LITERAL, | |
2881 StrongModeCode.IMPLICIT_DYNAMIC_MAP_LITERAL, | |
2882 StrongModeCode.IMPLICIT_DYNAMIC_METHOD, | |
2883 StrongModeCode.IMPLICIT_DYNAMIC_PARAMETER, | |
2884 StrongModeCode.IMPLICIT_DYNAMIC_RETURN, | |
2885 StrongModeCode.IMPLICIT_DYNAMIC_TYPE, | |
2886 StrongModeCode.IMPLICIT_DYNAMIC_VARIABLE, | |
2887 StrongModeCode.INFERRED_TYPE, | |
2888 StrongModeCode.INFERRED_TYPE_ALLOCATION, | |
2889 StrongModeCode.INFERRED_TYPE_CLOSURE, | |
2890 StrongModeCode.INFERRED_TYPE_LITERAL, | |
2891 StrongModeCode.INVALID_FIELD_OVERRIDE, | |
2892 StrongModeCode.INVALID_METHOD_OVERRIDE, | |
2893 StrongModeCode.INVALID_METHOD_OVERRIDE_FROM_BASE, | |
2894 StrongModeCode.INVALID_METHOD_OVERRIDE_FROM_MIXIN, | |
2895 StrongModeCode.INVALID_PARAMETER_DECLARATION, | |
2896 StrongModeCode.INVALID_SUPER_INVOCATION, | |
2897 StrongModeCode.NON_GROUND_TYPE_CHECK_INFO, | |
2898 StrongModeCode.STATIC_TYPE_ERROR, | |
2899 StrongModeCode.UNSAFE_BLOCK_CLOSURE_INFERENCE, | |
2900 | |
2901 TodoCode.TODO, | |
2902 | |
2903 // | |
2904 // parser.dart: | |
2905 // | |
2906 ParserErrorCode.ABSTRACT_CLASS_MEMBER, | |
2907 ParserErrorCode.ABSTRACT_ENUM, | |
2908 ParserErrorCode.ABSTRACT_STATIC_METHOD, | |
2909 ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION, | |
2910 ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE, | |
2911 ParserErrorCode.ABSTRACT_TYPEDEF, | |
2912 ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT, | |
2913 ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER, | |
2914 ParserErrorCode.ASYNC_NOT_SUPPORTED, | |
2915 ParserErrorCode.BREAK_OUTSIDE_OF_LOOP, | |
2916 ParserErrorCode.CLASS_IN_CLASS, | |
2917 ParserErrorCode.COLON_IN_PLACE_OF_IN, | |
2918 ParserErrorCode.CONST_AND_FINAL, | |
2919 ParserErrorCode.CONST_AND_VAR, | |
2920 ParserErrorCode.CONST_CLASS, | |
2921 ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY, | |
2922 ParserErrorCode.CONST_ENUM, | |
2923 ParserErrorCode.CONST_FACTORY, | |
2924 ParserErrorCode.CONST_METHOD, | |
2925 ParserErrorCode.CONST_TYPEDEF, | |
2926 ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, | |
2927 ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP, | |
2928 ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE, | |
2929 ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, | |
2930 ParserErrorCode.DIRECTIVE_AFTER_DECLARATION, | |
2931 ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, | |
2932 ParserErrorCode.DUPLICATED_MODIFIER, | |
2933 ParserErrorCode.EMPTY_ENUM_BODY, | |
2934 ParserErrorCode.ENUM_IN_CLASS, | |
2935 ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND, | |
2936 ParserErrorCode.EXPECTED_CASE_OR_DEFAULT, | |
2937 ParserErrorCode.EXPECTED_CLASS_MEMBER, | |
2938 ParserErrorCode.EXPECTED_EXECUTABLE, | |
2939 ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL, | |
2940 ParserErrorCode.EXPECTED_STRING_LITERAL, | |
2941 ParserErrorCode.EXPECTED_TOKEN, | |
2942 ParserErrorCode.EXPECTED_TYPE_NAME, | |
2943 ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, | |
2944 ParserErrorCode.EXTERNAL_AFTER_CONST, | |
2945 ParserErrorCode.EXTERNAL_AFTER_FACTORY, | |
2946 ParserErrorCode.EXTERNAL_AFTER_STATIC, | |
2947 ParserErrorCode.EXTERNAL_CLASS, | |
2948 ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, | |
2949 ParserErrorCode.EXTERNAL_ENUM, | |
2950 ParserErrorCode.EXTERNAL_FIELD, | |
2951 ParserErrorCode.EXTERNAL_GETTER_WITH_BODY, | |
2952 ParserErrorCode.EXTERNAL_METHOD_WITH_BODY, | |
2953 ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY, | |
2954 ParserErrorCode.EXTERNAL_SETTER_WITH_BODY, | |
2955 ParserErrorCode.EXTERNAL_TYPEDEF, | |
2956 ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION, | |
2957 ParserErrorCode.FACTORY_WITH_INITIALIZERS, | |
2958 ParserErrorCode.FACTORY_WITHOUT_BODY, | |
2959 ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, | |
2960 ParserErrorCode.FINAL_AND_VAR, | |
2961 ParserErrorCode.FINAL_CLASS, | |
2962 ParserErrorCode.FINAL_CONSTRUCTOR, | |
2963 ParserErrorCode.FINAL_ENUM, | |
2964 ParserErrorCode.FINAL_METHOD, | |
2965 ParserErrorCode.FINAL_TYPEDEF, | |
2966 ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, | |
2967 ParserErrorCode.GETTER_IN_FUNCTION, | |
2968 ParserErrorCode.GETTER_WITH_PARAMETERS, | |
2969 ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE, | |
2970 ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS, | |
2971 ParserErrorCode.IMPLEMENTS_BEFORE_WITH, | |
2972 ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, | |
2973 ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH, | |
2974 ParserErrorCode.INVALID_AWAIT_IN_FOR, | |
2975 ParserErrorCode.INVALID_CODE_POINT, | |
2976 ParserErrorCode.INVALID_COMMENT_REFERENCE, | |
2977 ParserErrorCode.INVALID_HEX_ESCAPE, | |
2978 ParserErrorCode.INVALID_LITERAL_IN_CONFIGURATION, | |
2979 ParserErrorCode.INVALID_OPERATOR, | |
2980 ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, | |
2981 ParserErrorCode.INVALID_STAR_AFTER_ASYNC, | |
2982 ParserErrorCode.INVALID_SYNC, | |
2983 ParserErrorCode.INVALID_UNICODE_ESCAPE, | |
2984 ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST, | |
2985 ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER, | |
2986 ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, | |
2987 ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER, | |
2988 ParserErrorCode.MISSING_CATCH_OR_FINALLY, | |
2989 ParserErrorCode.MISSING_CLASS_BODY, | |
2990 ParserErrorCode.MISSING_CLOSING_PARENTHESIS, | |
2991 ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE, | |
2992 ParserErrorCode.MISSING_ENUM_BODY, | |
2993 ParserErrorCode.MISSING_EXPRESSION_IN_INITIALIZER, | |
2994 ParserErrorCode.MISSING_EXPRESSION_IN_THROW, | |
2995 ParserErrorCode.MISSING_FUNCTION_BODY, | |
2996 ParserErrorCode.MISSING_FUNCTION_PARAMETERS, | |
2997 ParserErrorCode.MISSING_METHOD_PARAMETERS, | |
2998 ParserErrorCode.MISSING_GET, | |
2999 ParserErrorCode.MISSING_IDENTIFIER, | |
3000 ParserErrorCode.MISSING_INITIALIZER, | |
3001 ParserErrorCode.MISSING_KEYWORD_OPERATOR, | |
3002 ParserErrorCode.MISSING_NAME_IN_LIBRARY_DIRECTIVE, | |
3003 ParserErrorCode.MISSING_NAME_IN_PART_OF_DIRECTIVE, | |
3004 ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT, | |
3005 ParserErrorCode.MISSING_STAR_AFTER_SYNC, | |
3006 ParserErrorCode.MISSING_STATEMENT, | |
3007 ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, | |
3008 ParserErrorCode.MISSING_TYPEDEF_PARAMETERS, | |
3009 ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, | |
3010 ParserErrorCode.MIXED_PARAMETER_GROUPS, | |
3011 ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES, | |
3012 ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES, | |
3013 ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES, | |
3014 ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS, | |
3015 ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES, | |
3016 ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS, | |
3017 ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, | |
3018 ParserErrorCode.MULTIPLE_WITH_CLAUSES, | |
3019 ParserErrorCode.NAMED_FUNCTION_EXPRESSION, | |
3020 ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, | |
3021 ParserErrorCode.NATIVE_CLAUSE_IN_NON_SDK_CODE, | |
3022 ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE, | |
3023 ParserErrorCode.NON_CONSTRUCTOR_FACTORY, | |
3024 ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME, | |
3025 ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, | |
3026 ParserErrorCode.NON_STRING_LITERAL_AS_URI, | |
3027 ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, | |
3028 ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS, | |
3029 ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT, | |
3030 ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, | |
3031 ParserErrorCode.REDIRECTING_CONSTRUCTOR_WITH_BODY, | |
3032 ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR, | |
3033 ParserErrorCode.SETTER_IN_FUNCTION, | |
3034 ParserErrorCode.STATIC_AFTER_CONST, | |
3035 ParserErrorCode.STATIC_AFTER_FINAL, | |
3036 ParserErrorCode.STATIC_AFTER_VAR, | |
3037 ParserErrorCode.STATIC_CONSTRUCTOR, | |
3038 ParserErrorCode.STATIC_GETTER_WITHOUT_BODY, | |
3039 ParserErrorCode.STATIC_OPERATOR, | |
3040 ParserErrorCode.STATIC_SETTER_WITHOUT_BODY, | |
3041 ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION, | |
3042 ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE, | |
3043 ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES, | |
3044 ParserErrorCode.TOP_LEVEL_OPERATOR, | |
3045 ParserErrorCode.TYPEDEF_IN_CLASS, | |
3046 ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP, | |
3047 ParserErrorCode.UNEXPECTED_TOKEN, | |
3048 ParserErrorCode.WITH_BEFORE_EXTENDS, | |
3049 ParserErrorCode.WITH_WITHOUT_EXTENDS, | |
3050 ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER, | |
3051 ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER, | |
3052 ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, | |
3053 ParserErrorCode.VAR_AND_TYPE, | |
3054 ParserErrorCode.VAR_AS_TYPE_NAME, | |
3055 ParserErrorCode.VAR_CLASS, | |
3056 ParserErrorCode.VAR_ENUM, | |
3057 ParserErrorCode.VAR_RETURN_TYPE, | |
3058 ParserErrorCode.VAR_TYPEDEF, | |
3059 ParserErrorCode.VOID_PARAMETER, | |
3060 ParserErrorCode.VOID_VARIABLE, | |
3061 | |
3062 // | |
3063 // scanner.dart: | |
3064 // | |
3065 ScannerErrorCode.ILLEGAL_CHARACTER, | |
3066 ScannerErrorCode.MISSING_DIGIT, | |
3067 ScannerErrorCode.MISSING_HEX_DIGIT, | |
3068 ScannerErrorCode.MISSING_QUOTE, | |
3069 ScannerErrorCode.UNABLE_GET_CONTENT, | |
3070 ScannerErrorCode.UNTERMINATED_MULTI_LINE_COMMENT, | |
3071 ScannerErrorCode.UNTERMINATED_STRING_LITERAL, | |
3072 ]; | |
3073 | |
3074 /** | |
3075 * The lazy initialized map from [uniqueName] to the [ErrorCode] instance. | |
3076 */ | |
3077 static HashMap<String, ErrorCode> _uniqueNameToCodeMap; | |
3078 | |
3079 /** | |
3080 * An empty list of error codes. | |
3081 */ | |
3082 static const List<ErrorCode> EMPTY_LIST = const <ErrorCode>[]; | |
3083 | |
3084 /** | |
3085 * The name of the error code. | |
3086 */ | |
3087 final String name; | |
3088 | |
3089 /** | |
3090 * The template used to create the message to be displayed for this error. The | |
3091 * message should indicate what is wrong and why it is wrong. | |
3092 */ | |
3093 final String message; | |
3094 | |
3095 /** | |
3096 * The template used to create the correction to be displayed for this error, | |
3097 * or `null` if there is no correction information for this error. The | |
3098 * correction should indicate how the user can fix the error. | |
3099 */ | |
3100 final String correction; | |
3101 | |
3102 /** | |
3103 * Initialize a newly created error code to have the given [name]. The message | |
3104 * associated with the error will be created from the given [message] | |
3105 * template. The correction associated with the error will be created from the | |
3106 * given [correction] template. | |
3107 */ | |
3108 const ErrorCode(this.name, this.message, [this.correction]); | |
3109 | |
3110 /** | |
3111 * The severity of the error. | |
3112 */ | |
3113 ErrorSeverity get errorSeverity; | |
3114 | |
3115 /** | |
3116 * The type of the error. | |
3117 */ | |
3118 ErrorType get type; | |
3119 | |
3120 /** | |
3121 * The unique name of this error code. | |
3122 */ | |
3123 String get uniqueName => "$runtimeType.$name"; | |
3124 | |
3125 @override | |
3126 String toString() => uniqueName; | |
3127 | |
3128 /** | |
3129 * Return the [ErrorCode] with the given [uniqueName], or `null` if not | |
3130 * found. | |
3131 */ | |
3132 static ErrorCode byUniqueName(String uniqueName) { | |
3133 if (_uniqueNameToCodeMap == null) { | |
3134 _uniqueNameToCodeMap = new HashMap<String, ErrorCode>(); | |
3135 for (ErrorCode errorCode in values) { | |
3136 _uniqueNameToCodeMap[errorCode.uniqueName] = errorCode; | |
3137 } | |
3138 } | |
3139 return _uniqueNameToCodeMap[uniqueName]; | |
3140 } | |
3141 } | |
3142 | |
3143 /** | |
3144 * The properties that can be associated with an [AnalysisError]. | |
3145 */ | |
3146 class ErrorProperty<V> extends Enum<ErrorProperty> { | |
3147 /** | |
3148 * A property whose value is a list of [FieldElement]s that are final, but | |
3149 * not initialized by a constructor. | |
3150 */ | |
3151 static const ErrorProperty<List<FieldElement>> NOT_INITIALIZED_FIELDS = | |
3152 const ErrorProperty<List<FieldElement>>('NOT_INITIALIZED_FIELDS', 0); | |
3153 | |
3154 /** | |
3155 * A property whose value is the name of the library that is used by all | |
3156 * of the "part of" directives, so should be used in the "library" directive. | |
3157 * Is `null` if there is no a single name used by all of the parts. | |
3158 */ | |
3159 static const ErrorProperty<String> PARTS_LIBRARY_NAME = | |
3160 const ErrorProperty<String>('PARTS_LIBRARY_NAME', 1); | |
3161 | |
3162 /** | |
3163 * A property whose value is a list of [ExecutableElement] that should | |
3164 * be but are not implemented by a concrete class. | |
3165 */ | |
3166 static const ErrorProperty<List<ExecutableElement>> UNIMPLEMENTED_METHODS = | |
3167 const ErrorProperty<List<ExecutableElement>>('UNIMPLEMENTED_METHODS', 2); | |
3168 | |
3169 static const List<ErrorProperty> values = const [ | |
3170 NOT_INITIALIZED_FIELDS, | |
3171 PARTS_LIBRARY_NAME, | |
3172 UNIMPLEMENTED_METHODS | |
3173 ]; | |
3174 | |
3175 const ErrorProperty(String name, int ordinal) : super(name, ordinal); | |
3176 } | |
3177 | |
3178 /** | |
3179 * An object used to create analysis errors and report then to an error | |
3180 * listener. | |
3181 */ | |
3182 class ErrorReporter { | |
3183 /** | |
3184 * The error listener to which errors will be reported. | |
3185 */ | |
3186 final AnalysisErrorListener _errorListener; | |
3187 | |
3188 /** | |
3189 * The default source to be used when reporting errors. | |
3190 */ | |
3191 final Source _defaultSource; | |
3192 | |
3193 /** | |
3194 * The source to be used when reporting errors. | |
3195 */ | |
3196 Source _source; | |
3197 | |
3198 /** | |
3199 * Initialize a newly created error reporter that will report errors to the | |
3200 * given [_errorListener]. Errors will be reported against the | |
3201 * [_defaultSource] unless another source is provided later. | |
3202 */ | |
3203 ErrorReporter(this._errorListener, this._defaultSource) { | |
3204 if (_errorListener == null) { | |
3205 throw new ArgumentError("An error listener must be provided"); | |
3206 } else if (_defaultSource == null) { | |
3207 throw new ArgumentError("A default source must be provided"); | |
3208 } | |
3209 this._source = _defaultSource; | |
3210 } | |
3211 | |
3212 Source get source => _source; | |
3213 | |
3214 /** | |
3215 * Set the source to be used when reporting errors to the given [source]. | |
3216 * Setting the source to `null` will cause the default source to be used. | |
3217 */ | |
3218 void set source(Source source) { | |
3219 this._source = source ?? _defaultSource; | |
3220 } | |
3221 | |
3222 /** | |
3223 * Creates an error with properties with the given [errorCode] and | |
3224 * [arguments]. The [node] is used to compute the location of the error. | |
3225 */ | |
3226 AnalysisErrorWithProperties newErrorWithProperties( | |
3227 ErrorCode errorCode, AstNode node, List<Object> arguments) => | |
3228 new AnalysisErrorWithProperties( | |
3229 _source, node.offset, node.length, errorCode, arguments); | |
3230 | |
3231 /** | |
3232 * Report the given [error]. | |
3233 */ | |
3234 void reportError(AnalysisError error) { | |
3235 _errorListener.onError(error); | |
3236 } | |
3237 | |
3238 /** | |
3239 * Report an error with the given [errorCode] and [arguments]. The [element] | |
3240 * is used to compute the location of the error. | |
3241 */ | |
3242 void reportErrorForElement(ErrorCode errorCode, Element element, | |
3243 [List<Object> arguments]) { | |
3244 int length = 0; | |
3245 if (element is ImportElement) { | |
3246 length = 6; // 'import'.length | |
3247 } else if (element is ExportElement) { | |
3248 length = 6; // 'export'.length | |
3249 } else { | |
3250 length = element.nameLength; | |
3251 } | |
3252 reportErrorForOffset(errorCode, element.nameOffset, length, arguments); | |
3253 } | |
3254 | |
3255 /** | |
3256 * Report an error with the given [errorCode] and [arguments]. | |
3257 * The [node] is used to compute the location of the error. | |
3258 * | |
3259 * If the arguments contain the names of two or more types, the method | |
3260 * [reportTypeErrorForNode] should be used and the types | |
3261 * themselves (rather than their names) should be passed as arguments. | |
3262 */ | |
3263 void reportErrorForNode(ErrorCode errorCode, AstNode node, | |
3264 [List<Object> arguments]) { | |
3265 reportErrorForOffset(errorCode, node.offset, node.length, arguments); | |
3266 } | |
3267 | |
3268 /** | |
3269 * Report an error with the given [errorCode] and [arguments]. The location of | |
3270 * the error is specified by the given [offset] and [length]. | |
3271 */ | |
3272 void reportErrorForOffset(ErrorCode errorCode, int offset, int length, | |
3273 [List<Object> arguments]) { | |
3274 _errorListener.onError( | |
3275 new AnalysisError(_source, offset, length, errorCode, arguments)); | |
3276 } | |
3277 | |
3278 /** | |
3279 * Report an error with the given [errorCode] and [arguments]. The location of | |
3280 * the error is specified by the given [span]. | |
3281 */ | |
3282 void reportErrorForSpan(ErrorCode errorCode, SourceSpan span, | |
3283 [List<Object> arguments]) { | |
3284 reportErrorForOffset(errorCode, span.start.offset, span.length, arguments); | |
3285 } | |
3286 | |
3287 /** | |
3288 * Report an error with the given [errorCode] and [arguments]. The [token] is | |
3289 * used to compute the location of the error. | |
3290 */ | |
3291 void reportErrorForToken(ErrorCode errorCode, Token token, | |
3292 [List<Object> arguments]) { | |
3293 reportErrorForOffset(errorCode, token.offset, token.length, arguments); | |
3294 } | |
3295 | |
3296 /** | |
3297 * Report an error with the given [errorCode] and [arguments]. The [node] is | |
3298 * used to compute the location of the error. The arguments are expected to | |
3299 * contain two or more types. Convert the types into strings by using the | |
3300 * display names of the types, unless there are two or more types with the | |
3301 * same names, in which case the extended display names of the types will be | |
3302 * used in order to clarify the message. | |
3303 * | |
3304 * If there are not two or more types in the argument list, the method | |
3305 * [reportErrorForNode] should be used instead. | |
3306 */ | |
3307 void reportTypeErrorForNode( | |
3308 ErrorCode errorCode, AstNode node, List<Object> arguments) { | |
3309 _convertTypeNames(arguments); | |
3310 reportErrorForOffset(errorCode, node.offset, node.length, arguments); | |
3311 } | |
3312 | |
3313 /** | |
3314 * Given an array of [arguments] that is expected to contain two or more | |
3315 * types, convert the types into strings by using the display names of the | |
3316 * types, unless there are two or more types with the same names, in which | |
3317 * case the extended display names of the types will be used in order to | |
3318 * clarify the message. | |
3319 */ | |
3320 void _convertTypeNames(List<Object> arguments) { | |
3321 String displayName(DartType type) { | |
3322 if (type is FunctionType) { | |
3323 String name = type.name; | |
3324 if (name != null && name.length > 0) { | |
3325 StringBuffer buffer = new StringBuffer(); | |
3326 buffer.write(name); | |
3327 (type as TypeImpl).appendTo(buffer); | |
3328 return buffer.toString(); | |
3329 } | |
3330 } | |
3331 return type.displayName; | |
3332 } | |
3333 | |
3334 if (_hasEqualTypeNames(arguments)) { | |
3335 int count = arguments.length; | |
3336 for (int i = 0; i < count; i++) { | |
3337 Object argument = arguments[i]; | |
3338 if (argument is DartType) { | |
3339 Element element = argument.element; | |
3340 if (element == null) { | |
3341 arguments[i] = displayName(argument); | |
3342 } else { | |
3343 arguments[i] = | |
3344 element.getExtendedDisplayName(displayName(argument)); | |
3345 } | |
3346 } | |
3347 } | |
3348 } else { | |
3349 int count = arguments.length; | |
3350 for (int i = 0; i < count; i++) { | |
3351 Object argument = arguments[i]; | |
3352 if (argument is DartType) { | |
3353 arguments[i] = displayName(argument); | |
3354 } | |
3355 } | |
3356 } | |
3357 } | |
3358 | |
3359 /** | |
3360 * Return `true` if the given array of [arguments] contains two or more types | |
3361 * with the same display name. | |
3362 */ | |
3363 bool _hasEqualTypeNames(List<Object> arguments) { | |
3364 int count = arguments.length; | |
3365 HashSet<String> typeNames = new HashSet<String>(); | |
3366 for (int i = 0; i < count; i++) { | |
3367 Object argument = arguments[i]; | |
3368 if (argument is DartType && !typeNames.add(argument.displayName)) { | |
3369 return true; | |
3370 } | |
3371 } | |
3372 return false; | |
3373 } | |
3374 } | |
3375 | |
3376 /** | |
3377 * The severity of an [ErrorCode]. | |
3378 */ | |
3379 class ErrorSeverity extends Enum<ErrorSeverity> { | |
3380 /** | |
3381 * The severity representing a non-error. This is never used for any error | |
3382 * code, but is useful for clients. | |
3383 */ | |
3384 static const ErrorSeverity NONE = const ErrorSeverity('NONE', 0, " ", "none"); | |
3385 | |
3386 /** | |
3387 * The severity representing an informational level analysis issue. | |
3388 */ | |
3389 static const ErrorSeverity INFO = const ErrorSeverity('INFO', 1, "I", "info"); | |
3390 | |
3391 /** | |
3392 * The severity representing a warning. Warnings can become errors if the `-We
rror` command | |
3393 * line flag is specified. | |
3394 */ | |
3395 static const ErrorSeverity WARNING = | |
3396 const ErrorSeverity('WARNING', 2, "W", "warning"); | |
3397 | |
3398 /** | |
3399 * The severity representing an error. | |
3400 */ | |
3401 static const ErrorSeverity ERROR = | |
3402 const ErrorSeverity('ERROR', 3, "E", "error"); | |
3403 | |
3404 static const List<ErrorSeverity> values = const [NONE, INFO, WARNING, ERROR]; | |
3405 | |
3406 /** | |
3407 * The name of the severity used when producing machine output. | |
3408 */ | |
3409 final String machineCode; | |
3410 | |
3411 /** | |
3412 * The name of the severity used when producing readable output. | |
3413 */ | |
3414 final String displayName; | |
3415 | |
3416 /** | |
3417 * Initialize a newly created severity with the given names. | |
3418 * | |
3419 * Parameters: | |
3420 * 0: the name of the severity used when producing machine output | |
3421 * 1: the name of the severity used when producing readable output | |
3422 */ | |
3423 const ErrorSeverity( | |
3424 String name, int ordinal, this.machineCode, this.displayName) | |
3425 : super(name, ordinal); | |
3426 | |
3427 /** | |
3428 * Return the severity constant that represents the greatest severity. | |
3429 */ | |
3430 ErrorSeverity max(ErrorSeverity severity) => | |
3431 this.ordinal >= severity.ordinal ? this : severity; | |
3432 } | |
3433 | |
3434 /** | |
3435 * The type of an [ErrorCode]. | |
3436 */ | |
3437 class ErrorType extends Enum<ErrorType> { | |
3438 /** | |
3439 * Task (todo) comments in user code. | |
3440 */ | |
3441 static const ErrorType TODO = const ErrorType('TODO', 0, ErrorSeverity.INFO); | |
3442 | |
3443 /** | |
3444 * Extra analysis run over the code to follow best practices, which are not in | |
3445 * the Dart Language Specification. | |
3446 */ | |
3447 static const ErrorType HINT = const ErrorType('HINT', 1, ErrorSeverity.INFO); | |
3448 | |
3449 /** | |
3450 * Compile-time errors are errors that preclude execution. A compile time | |
3451 * error must be reported by a Dart compiler before the erroneous code is | |
3452 * executed. | |
3453 */ | |
3454 static const ErrorType COMPILE_TIME_ERROR = | |
3455 const ErrorType('COMPILE_TIME_ERROR', 2, ErrorSeverity.ERROR); | |
3456 | |
3457 /** | |
3458 * Checked mode compile-time errors are errors that preclude execution in | |
3459 * checked mode. | |
3460 */ | |
3461 static const ErrorType CHECKED_MODE_COMPILE_TIME_ERROR = const ErrorType( | |
3462 'CHECKED_MODE_COMPILE_TIME_ERROR', 3, ErrorSeverity.ERROR); | |
3463 | |
3464 /** | |
3465 * Static warnings are those warnings reported by the static checker. They | |
3466 * have no effect on execution. Static warnings must be provided by Dart | |
3467 * compilers used during development. | |
3468 */ | |
3469 static const ErrorType STATIC_WARNING = | |
3470 const ErrorType('STATIC_WARNING', 4, ErrorSeverity.WARNING); | |
3471 | |
3472 /** | |
3473 * Many, but not all, static warnings relate to types, in which case they are | |
3474 * known as static type warnings. | |
3475 */ | |
3476 static const ErrorType STATIC_TYPE_WARNING = | |
3477 const ErrorType('STATIC_TYPE_WARNING', 5, ErrorSeverity.WARNING); | |
3478 | |
3479 /** | |
3480 * Syntactic errors are errors produced as a result of input that does not | |
3481 * conform to the grammar. | |
3482 */ | |
3483 static const ErrorType SYNTACTIC_ERROR = | |
3484 const ErrorType('SYNTACTIC_ERROR', 6, ErrorSeverity.ERROR); | |
3485 | |
3486 /** | |
3487 * Lint warnings describe style and best practice recommendations that can be | |
3488 * used to formalize a project's style guidelines. | |
3489 */ | |
3490 static const ErrorType LINT = const ErrorType('LINT', 7, ErrorSeverity.INFO); | |
3491 | |
3492 static const List<ErrorType> values = const [ | |
3493 TODO, | |
3494 HINT, | |
3495 COMPILE_TIME_ERROR, | |
3496 CHECKED_MODE_COMPILE_TIME_ERROR, | |
3497 STATIC_WARNING, | |
3498 STATIC_TYPE_WARNING, | |
3499 SYNTACTIC_ERROR, | |
3500 LINT | |
3501 ]; | |
3502 | |
3503 /** | |
3504 * The severity of this type of error. | |
3505 */ | |
3506 final ErrorSeverity severity; | |
3507 | |
3508 /** | |
3509 * Initialize a newly created error type to have the given [name] and | |
3510 * [severity]. | |
3511 */ | |
3512 const ErrorType(String name, int ordinal, this.severity) | |
3513 : super(name, ordinal); | |
3514 | |
3515 String get displayName => name.toLowerCase().replaceAll('_', ' '); | |
3516 } | |
3517 | |
3518 /** | |
3519 * The hints and coding recommendations for best practices which are not | 2196 * The hints and coding recommendations for best practices which are not |
3520 * mentioned in the Dart Language Specification. | 2197 * mentioned in the Dart Language Specification. |
3521 */ | 2198 */ |
3522 class HintCode extends ErrorCode { | 2199 class HintCode extends ErrorCode { |
3523 /** | 2200 /** |
3524 * This hint is generated anywhere where the | 2201 * This hint is generated anywhere where the |
3525 * [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE] would have been generated, | 2202 * [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE] would have been generated, |
3526 * if we used propagated information for the warnings. | 2203 * if we used propagated information for the warnings. |
3527 * | 2204 * |
3528 * Parameters: | 2205 * Parameters: |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4288 * static types of both of <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> may | 2965 * static types of both of <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> may |
4289 * not be assigned to bool. | 2966 * not be assigned to bool. |
4290 * | 2967 * |
4291 * Parameters: | 2968 * Parameters: |
4292 * 0: the lexeme of the logical operator | 2969 * 0: the lexeme of the logical operator |
4293 */ | 2970 */ |
4294 static const StaticTypeWarningCode NON_BOOL_OPERAND = | 2971 static const StaticTypeWarningCode NON_BOOL_OPERAND = |
4295 const StaticTypeWarningCode('NON_BOOL_OPERAND', | 2972 const StaticTypeWarningCode('NON_BOOL_OPERAND', |
4296 "The operands of the '{0}' operator must be assignable to 'bool'"); | 2973 "The operands of the '{0}' operator must be assignable to 'bool'"); |
4297 | 2974 |
4298 /** | |
4299 * | |
4300 */ | |
4301 static const StaticTypeWarningCode NON_NULLABLE_FIELD_NOT_INITIALIZED = | 2975 static const StaticTypeWarningCode NON_NULLABLE_FIELD_NOT_INITIALIZED = |
4302 const StaticTypeWarningCode('NON_NULLABLE_FIELD_NOT_INITIALIZED', | 2976 const StaticTypeWarningCode('NON_NULLABLE_FIELD_NOT_INITIALIZED', |
4303 "Variable '{0}' of non-nullable type '{1}' must be initialized"); | 2977 "Variable '{0}' of non-nullable type '{1}' must be initialized"); |
4304 | 2978 |
4305 /** | 2979 /** |
4306 * 15.8 Parameterized Types: It is a static type warning if <i>A<sub>i</sub>, | 2980 * 15.8 Parameterized Types: It is a static type warning if <i>A<sub>i</sub>, |
4307 * 1 <= i <= n</i> does not denote a type in the enclosing lexical scope
. | 2981 * 1 <= i <= n</i> does not denote a type in the enclosing lexical scope
. |
4308 */ | 2982 */ |
4309 static const StaticTypeWarningCode NON_TYPE_AS_TYPE_ARGUMENT = | 2983 static const StaticTypeWarningCode NON_TYPE_AS_TYPE_ARGUMENT = |
4310 const StaticTypeWarningCode('NON_TYPE_AS_TYPE_ARGUMENT', | 2984 const StaticTypeWarningCode('NON_TYPE_AS_TYPE_ARGUMENT', |
(...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6140 * Initialize a newly created error code to have the given [name]. | 4814 * Initialize a newly created error code to have the given [name]. |
6141 */ | 4815 */ |
6142 const TodoCode(String name) : super(name, "{0}"); | 4816 const TodoCode(String name) : super(name, "{0}"); |
6143 | 4817 |
6144 @override | 4818 @override |
6145 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; | 4819 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; |
6146 | 4820 |
6147 @override | 4821 @override |
6148 ErrorType get type => ErrorType.TODO; | 4822 ErrorType get type => ErrorType.TODO; |
6149 } | 4823 } |
OLD | NEW |