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 engine.error; | 5 library engine.error; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'ast.dart' show AstNode; | 9 import 'ast.dart' show AstNode; |
10 import 'element.dart'; | 10 import 'element.dart'; |
(...skipping 10 matching lines...) Loading... |
21 /** | 21 /** |
22 * An empty array of errors used when no errors are expected. | 22 * An empty array of errors used when no errors are expected. |
23 */ | 23 */ |
24 static const List<AnalysisError> NO_ERRORS = const <AnalysisError>[]; | 24 static const List<AnalysisError> NO_ERRORS = const <AnalysisError>[]; |
25 | 25 |
26 /** | 26 /** |
27 * A [Comparator] that sorts by the name of the file that the [AnalysisError] | 27 * A [Comparator] that sorts by the name of the file that the [AnalysisError] |
28 * was found. | 28 * was found. |
29 */ | 29 */ |
30 static Comparator<AnalysisError> FILE_COMPARATOR = (AnalysisError o1, | 30 static Comparator<AnalysisError> FILE_COMPARATOR = (AnalysisError o1, |
31 AnalysisError o2) => o1.source.shortName.compareTo(o2.source.shortName); | 31 AnalysisError o2) => |
| 32 o1.source.shortName.compareTo(o2.source.shortName); |
32 | 33 |
33 /** | 34 /** |
34 * A [Comparator] that sorts error codes first by their severity (errors | 35 * A [Comparator] that sorts error codes first by their severity (errors |
35 * first, warnings second), and then by the the error code type. | 36 * first, warnings second), and then by the the error code type. |
36 */ | 37 */ |
37 static Comparator<AnalysisError> ERROR_CODE_COMPARATOR = (AnalysisError o1, | 38 static Comparator<AnalysisError> ERROR_CODE_COMPARATOR = |
38 AnalysisError o2) { | 39 (AnalysisError o1, AnalysisError o2) { |
39 ErrorCode errorCode1 = o1.errorCode; | 40 ErrorCode errorCode1 = o1.errorCode; |
40 ErrorCode errorCode2 = o2.errorCode; | 41 ErrorCode errorCode2 = o2.errorCode; |
41 ErrorSeverity errorSeverity1 = errorCode1.errorSeverity; | 42 ErrorSeverity errorSeverity1 = errorCode1.errorSeverity; |
42 ErrorSeverity errorSeverity2 = errorCode2.errorSeverity; | 43 ErrorSeverity errorSeverity2 = errorCode2.errorSeverity; |
43 ErrorType errorType1 = errorCode1.type; | |
44 ErrorType errorType2 = errorCode2.type; | |
45 if (errorSeverity1 == errorSeverity2) { | 44 if (errorSeverity1 == errorSeverity2) { |
| 45 ErrorType errorType1 = errorCode1.type; |
| 46 ErrorType errorType2 = errorCode2.type; |
46 return errorType1.compareTo(errorType2); | 47 return errorType1.compareTo(errorType2); |
47 } else { | 48 } else { |
48 return errorSeverity2.compareTo(errorSeverity1); | 49 return errorSeverity2.compareTo(errorSeverity1); |
49 } | 50 } |
50 }; | 51 }; |
51 | 52 |
52 /** | 53 /** |
53 * The error code associated with the error. | 54 * The error code associated with the error. |
54 */ | 55 */ |
55 final ErrorCode errorCode; | 56 final ErrorCode errorCode; |
(...skipping 17 matching lines...) Loading... |
73 /** | 74 /** |
74 * The character offset from the beginning of the source (zero based) where | 75 * The character offset from the beginning of the source (zero based) where |
75 * the error occurred. | 76 * the error occurred. |
76 */ | 77 */ |
77 int offset = 0; | 78 int offset = 0; |
78 | 79 |
79 /** | 80 /** |
80 * The number of characters from the offset to the end of the source which | 81 * The number of characters from the offset to the end of the source which |
81 * encompasses the compilation error. | 82 * encompasses the compilation error. |
82 */ | 83 */ |
83 int _length = 0; | 84 int length = 0; |
84 | 85 |
85 /** | 86 /** |
86 * A flag indicating whether this error can be shown to be a non-issue because | 87 * A flag indicating whether this error can be shown to be a non-issue because |
87 * of the result of type propagation. | 88 * of the result of type propagation. |
88 */ | 89 */ |
89 bool isStaticOnly = false; | 90 bool isStaticOnly = false; |
90 | 91 |
91 /** | 92 /** |
92 * Initialize a newly created analysis error. The error is associated with the | 93 * Initialize a newly created analysis error. The error is associated with the |
93 * given [source] and is located at the given [offset] with the given | 94 * given [source] and is located at the given [offset] with the given |
94 * [length]. The error will have the given [errorCode] and the list of | 95 * [length]. The error will have the given [errorCode] and the list of |
95 * [arguments] will be used to complete the message. | 96 * [arguments] will be used to complete the message. |
96 */ | 97 */ |
97 AnalysisError(this.source, this.offset, int length, this.errorCode, | 98 AnalysisError(this.source, this.offset, this.length, this.errorCode, |
98 [List<Object> arguments]) { | 99 [List<Object> arguments]) { |
99 this._length = length; | |
100 this._message = formatList(errorCode.message, arguments); | 100 this._message = formatList(errorCode.message, arguments); |
101 String correctionTemplate = errorCode.correction; | 101 String correctionTemplate = errorCode.correction; |
102 if (correctionTemplate != null) { | 102 if (correctionTemplate != null) { |
103 this._correction = formatList(correctionTemplate, arguments); | 103 this._correction = formatList(correctionTemplate, arguments); |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 /** | 107 /** |
108 * Initialize a newly created analysis error for the specified [source]. The | 108 * Initialize a newly created analysis error for the specified [source]. The |
109 * error will have the given [errorCode] and the list of [arguments] will be | 109 * error will have the given [errorCode] and the list of [arguments] will be |
(...skipping 24 matching lines...) Loading... |
134 | 134 |
135 @override | 135 @override |
136 int get hashCode { | 136 int get hashCode { |
137 int hashCode = offset; | 137 int hashCode = offset; |
138 hashCode ^= (_message != null) ? _message.hashCode : 0; | 138 hashCode ^= (_message != null) ? _message.hashCode : 0; |
139 hashCode ^= (source != null) ? source.hashCode : 0; | 139 hashCode ^= (source != null) ? source.hashCode : 0; |
140 return hashCode; | 140 return hashCode; |
141 } | 141 } |
142 | 142 |
143 /** | 143 /** |
144 * Return the length of the error location, that is, the number of characters | |
145 * from the offset to the end of the source which encompasses the compilation | |
146 * error. | |
147 */ | |
148 int get length => _length; | |
149 | |
150 /** | |
151 * Return the message to be displayed for this error. The message should | 144 * Return the message to be displayed for this error. The message should |
152 * indicate what is wrong and why it is wrong. | 145 * indicate what is wrong and why it is wrong. |
153 */ | 146 */ |
154 String get message => _message; | 147 String get message => _message; |
155 | 148 |
156 @override | 149 @override |
157 bool operator ==(Object obj) { | 150 bool operator ==(Object obj) { |
158 if (identical(obj, this)) { | 151 if (identical(obj, this)) { |
159 return true; | 152 return true; |
160 } | 153 } |
161 // prepare other AnalysisError | 154 // prepare other AnalysisError |
162 if (obj is! AnalysisError) { | 155 if (obj is! AnalysisError) { |
163 return false; | 156 return false; |
164 } | 157 } |
165 AnalysisError other = obj as AnalysisError; | 158 AnalysisError other = obj as AnalysisError; |
166 // Quick checks. | 159 // Quick checks. |
167 if (!identical(errorCode, other.errorCode)) { | 160 if (!identical(errorCode, other.errorCode)) { |
168 return false; | 161 return false; |
169 } | 162 } |
170 if (offset != other.offset || _length != other._length) { | 163 if (offset != other.offset || length != other.length) { |
171 return false; | 164 return false; |
172 } | 165 } |
173 if (isStaticOnly != other.isStaticOnly) { | 166 if (isStaticOnly != other.isStaticOnly) { |
174 return false; | 167 return false; |
175 } | 168 } |
176 // Deep checks. | 169 // Deep checks. |
177 if (_message != other._message) { | 170 if (_message != other._message) { |
178 return false; | 171 return false; |
179 } | 172 } |
180 if (source != other.source) { | 173 if (source != other.source) { |
181 return false; | 174 return false; |
182 } | 175 } |
183 // OK | 176 // OK |
184 return true; | 177 return true; |
185 } | 178 } |
186 | 179 |
187 /** | 180 /** |
188 * Return the value of the given [property], or `null` if the given property | 181 * Return the value of the given [property], or `null` if the given property |
189 * is not defined for this error. | 182 * is not defined for this error. |
190 */ | 183 */ |
191 Object getProperty(ErrorProperty property) => null; | 184 Object getProperty(ErrorProperty property) => null; |
192 | 185 |
193 @override | 186 @override |
194 String toString() { | 187 String toString() { |
195 StringBuffer buffer = new StringBuffer(); | 188 StringBuffer buffer = new StringBuffer(); |
196 buffer.write((source != null) ? source.fullName : "<unknown source>"); | 189 buffer.write((source != null) ? source.fullName : "<unknown source>"); |
197 buffer.write("("); | 190 buffer.write("("); |
198 buffer.write(offset); | 191 buffer.write(offset); |
199 buffer.write(".."); | 192 buffer.write(".."); |
200 buffer.write(offset + _length - 1); | 193 buffer.write(offset + length - 1); |
201 buffer.write("): "); | 194 buffer.write("): "); |
202 //buffer.write("(" + lineNumber + ":" + columnNumber + "): "); | 195 //buffer.write("(" + lineNumber + ":" + columnNumber + "): "); |
203 buffer.write(_message); | 196 buffer.write(_message); |
204 return buffer.toString(); | 197 return buffer.toString(); |
205 } | 198 } |
206 | 199 |
207 /** | 200 /** |
208 * Merge all of the errors in the lists in the given list of [errorLists] into | 201 * Merge all of the errors in the lists in the given list of [errorLists] into |
209 * a single list of errors. | 202 * a single list of errors. |
210 */ | 203 */ |
(...skipping 391 matching lines...) Loading... |
602 const CompileTimeErrorCode('CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD', | 595 const CompileTimeErrorCode('CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD', |
603 "'{0}' cannot be used to name a constructor and a method in this class
"); | 596 "'{0}' cannot be used to name a constructor and a method in this class
"); |
604 | 597 |
605 /** | 598 /** |
606 * 7. Classes: It is a compile time error if a generic class declares a type | 599 * 7. Classes: It is a compile time error if a generic class declares a type |
607 * variable with the same name as the class or any of its members or | 600 * variable with the same name as the class or any of its members or |
608 * constructors. | 601 * constructors. |
609 */ | 602 */ |
610 static const CompileTimeErrorCode CONFLICTING_TYPE_VARIABLE_AND_CLASS = | 603 static const CompileTimeErrorCode CONFLICTING_TYPE_VARIABLE_AND_CLASS = |
611 const CompileTimeErrorCode('CONFLICTING_TYPE_VARIABLE_AND_CLASS', | 604 const CompileTimeErrorCode('CONFLICTING_TYPE_VARIABLE_AND_CLASS', |
612 "'{0}' cannot be used to name a type varaible in a class with the same
name"); | 605 "'{0}' cannot be used to name a type variable in a class with the same
name"); |
613 | 606 |
614 /** | 607 /** |
615 * 7. Classes: It is a compile time error if a generic class declares a type | 608 * 7. Classes: It is a compile time error if a generic class declares a type |
616 * variable with the same name as the class or any of its members or | 609 * variable with the same name as the class or any of its members or |
617 * constructors. | 610 * constructors. |
618 */ | 611 */ |
619 static const CompileTimeErrorCode CONFLICTING_TYPE_VARIABLE_AND_MEMBER = | 612 static const CompileTimeErrorCode CONFLICTING_TYPE_VARIABLE_AND_MEMBER = |
620 const CompileTimeErrorCode('CONFLICTING_TYPE_VARIABLE_AND_MEMBER', | 613 const CompileTimeErrorCode('CONFLICTING_TYPE_VARIABLE_AND_MEMBER', |
621 "'{0}' cannot be used to name a type varaible and member in this class
"); | 614 "'{0}' cannot be used to name a type variable and member in this class
"); |
622 | 615 |
623 /** | 616 /** |
624 * 12.11.2 Const: It is a compile-time error if evaluation of a constant | 617 * 12.11.2 Const: It is a compile-time error if evaluation of a constant |
625 * object results in an uncaught exception being thrown. | 618 * object results in an uncaught exception being thrown. |
626 */ | 619 */ |
627 static const CompileTimeErrorCode CONST_CONSTRUCTOR_THROWS_EXCEPTION = | 620 static const CompileTimeErrorCode CONST_CONSTRUCTOR_THROWS_EXCEPTION = |
628 const CompileTimeErrorCode('CONST_CONSTRUCTOR_THROWS_EXCEPTION', | 621 const CompileTimeErrorCode('CONST_CONSTRUCTOR_THROWS_EXCEPTION', |
629 "'const' constructors cannot throw exceptions"); | 622 "'const' constructors cannot throw exceptions"); |
630 | 623 |
631 /** | 624 /** |
(...skipping 929 matching lines...) Loading... |
1561 * * The static type of <i>e</i> is an enumerated typed with elements | 1554 * * The static type of <i>e</i> is an enumerated typed with elements |
1562 * <i>id<sub>1</sub></i>, …, <i>id<sub>n</sub></i>. | 1555 * <i>id<sub>1</sub></i>, …, <i>id<sub>n</sub></i>. |
1563 * * The sets {<i>e<sub>1</sub></i>, …, <i>e<sub>k</sub></i>} and | 1556 * * The sets {<i>e<sub>1</sub></i>, …, <i>e<sub>k</sub></i>} and |
1564 * {<i>id<sub>1</sub></i>, …, <i>id<sub>n</sub></i>} are not the | 1557 * {<i>id<sub>1</sub></i>, …, <i>id<sub>n</sub></i>} are not the |
1565 * same. | 1558 * same. |
1566 * | 1559 * |
1567 * Parameters: | 1560 * Parameters: |
1568 * 0: the name of the constant that is missing | 1561 * 0: the name of the constant that is missing |
1569 */ | 1562 */ |
1570 static const CompileTimeErrorCode MISSING_ENUM_CONSTANT_IN_SWITCH = | 1563 static const CompileTimeErrorCode MISSING_ENUM_CONSTANT_IN_SWITCH = |
1571 const CompileTimeErrorCode('MISSING_ENUM_CONSTANT_IN_SWITCH', | 1564 const CompileTimeErrorCode( |
| 1565 'MISSING_ENUM_CONSTANT_IN_SWITCH', |
1572 "Missing case clause for '{0}'", | 1566 "Missing case clause for '{0}'", |
1573 "Add a case clause for the missing constant or add a default clause.")
; | 1567 "Add a case clause for the missing constant or add a default clause.")
; |
1574 | 1568 |
1575 /** | 1569 /** |
1576 * 9 Mixins: It is a compile-time error if a declared or derived mixin | 1570 * 9 Mixins: It is a compile-time error if a declared or derived mixin |
1577 * explicitly declares a constructor. | 1571 * explicitly declares a constructor. |
1578 * | 1572 * |
1579 * Parameters: | 1573 * Parameters: |
1580 * 0: the name of the mixin that is invalid | 1574 * 0: the name of the mixin that is invalid |
1581 */ | 1575 */ |
(...skipping 15 matching lines...) Loading... |
1597 "This class cannot mixin the deferred class '{0}'"); | 1591 "This class cannot mixin the deferred class '{0}'"); |
1598 | 1592 |
1599 /** | 1593 /** |
1600 * Not yet in the spec, but consistent with VM behavior. It is a | 1594 * Not yet in the spec, but consistent with VM behavior. It is a |
1601 * compile-time error if all of the constructors of a mixin's base class have | 1595 * compile-time error if all of the constructors of a mixin's base class have |
1602 * at least one optional parameter (since only constructors that lack | 1596 * at least one optional parameter (since only constructors that lack |
1603 * optional parameters can be forwarded to the mixin). See | 1597 * optional parameters can be forwarded to the mixin). See |
1604 * https://code.google.com/p/dart/issues/detail?id=15101#c4 | 1598 * https://code.google.com/p/dart/issues/detail?id=15101#c4 |
1605 */ | 1599 */ |
1606 static const CompileTimeErrorCode MIXIN_HAS_NO_CONSTRUCTORS = | 1600 static const CompileTimeErrorCode MIXIN_HAS_NO_CONSTRUCTORS = |
1607 const CompileTimeErrorCode('MIXIN_HAS_NO_CONSTRUCTORS', | 1601 const CompileTimeErrorCode( |
| 1602 'MIXIN_HAS_NO_CONSTRUCTORS', |
1608 "This mixin application is invalid because all of the constructors " | 1603 "This mixin application is invalid because all of the constructors " |
1609 "in the base class '{0}' have optional parameters."); | 1604 "in the base class '{0}' have optional parameters."); |
1610 | 1605 |
1611 /** | 1606 /** |
1612 * 9 Mixins: It is a compile-time error if a mixin is derived from a class | 1607 * 9 Mixins: It is a compile-time error if a mixin is derived from a class |
1613 * whose superclass is not Object. | 1608 * whose superclass is not Object. |
1614 * | 1609 * |
1615 * Parameters: | 1610 * Parameters: |
1616 * 0: the name of the mixin that is invalid | 1611 * 0: the name of the mixin that is invalid |
1617 */ | 1612 */ |
(...skipping 736 matching lines...) Loading... |
2354 : super(name, message, correction); | 2349 : super(name, message, correction); |
2355 | 2350 |
2356 @override | 2351 @override |
2357 ErrorSeverity get errorSeverity => ErrorType.COMPILE_TIME_ERROR.severity; | 2352 ErrorSeverity get errorSeverity => ErrorType.COMPILE_TIME_ERROR.severity; |
2358 | 2353 |
2359 @override | 2354 @override |
2360 ErrorType get type => ErrorType.COMPILE_TIME_ERROR; | 2355 ErrorType get type => ErrorType.COMPILE_TIME_ERROR; |
2361 } | 2356 } |
2362 | 2357 |
2363 /** | 2358 /** |
| 2359 * An error listener that can be enabled or disabled while executing a function. |
| 2360 */ |
| 2361 class DisablableErrorListener implements AnalysisErrorListener { |
| 2362 /** |
| 2363 * The listener to which errors will be reported if this listener is enabled. |
| 2364 */ |
| 2365 final AnalysisErrorListener baseListener; |
| 2366 |
| 2367 /** |
| 2368 * A flag indicating whether this listener is currently enabled. |
| 2369 */ |
| 2370 bool enabled = true; |
| 2371 |
| 2372 /** |
| 2373 * Initialize a newly created listener to report errors to the given |
| 2374 * [baseListener]. |
| 2375 */ |
| 2376 DisablableErrorListener(this.baseListener); |
| 2377 |
| 2378 /** |
| 2379 * Disable the processing of errors while evaluating the given [function]. |
| 2380 * Return the value returned by the function. |
| 2381 */ |
| 2382 dynamic disableWhile(dynamic function()) { |
| 2383 bool wasEnabled = enabled; |
| 2384 try { |
| 2385 enabled = false; |
| 2386 return function(); |
| 2387 } finally { |
| 2388 enabled = wasEnabled; |
| 2389 } |
| 2390 } |
| 2391 |
| 2392 /** |
| 2393 * Disable the processing of errors while evaluating the given [function]. |
| 2394 * Return the value returned by the function. |
| 2395 */ |
| 2396 dynamic enableWhile(dynamic function()) { |
| 2397 bool wasEnabled = enabled; |
| 2398 try { |
| 2399 enabled = true; |
| 2400 return function(); |
| 2401 } finally { |
| 2402 enabled = wasEnabled; |
| 2403 } |
| 2404 } |
| 2405 |
| 2406 @override |
| 2407 void onError(AnalysisError error) { |
| 2408 if (enabled) { |
| 2409 baseListener.onError(error); |
| 2410 } |
| 2411 } |
| 2412 } |
| 2413 |
| 2414 /** |
2364 * An error code associated with an [AnalysisError]. | 2415 * An error code associated with an [AnalysisError]. |
2365 * | 2416 * |
2366 * Generally, we want to provide messages that consist of three sentences. From | 2417 * Generally, we want to provide messages that consist of three sentences. From |
2367 * the user's perspective these sentences should explain: | 2418 * the user's perspective these sentences should explain: |
2368 * 1. what is wrong, | 2419 * 1. what is wrong, |
2369 * 2. why is it wrong, and | 2420 * 2. why is it wrong, and |
2370 * 3. how do I fix it. | 2421 * 3. how do I fix it. |
2371 * However, we combine the first two in the [message] and the last in the | 2422 * However, we combine the first two in the [message] and the last in the |
2372 * [correction]. | 2423 * [correction]. |
2373 */ | 2424 */ |
(...skipping 137 matching lines...) Loading... |
2511 * Report the given [error]. | 2562 * Report the given [error]. |
2512 */ | 2563 */ |
2513 void reportError(AnalysisError error) { | 2564 void reportError(AnalysisError error) { |
2514 _errorListener.onError(error); | 2565 _errorListener.onError(error); |
2515 } | 2566 } |
2516 | 2567 |
2517 /** | 2568 /** |
2518 * Report an error with the given [errorCode] and [arguments]. The [element] | 2569 * Report an error with the given [errorCode] and [arguments]. The [element] |
2519 * is used to compute the location of the error. | 2570 * is used to compute the location of the error. |
2520 */ | 2571 */ |
2521 void reportErrorForElement( | 2572 void reportErrorForElement(ErrorCode errorCode, Element element, |
2522 ErrorCode errorCode, Element element, List<Object> arguments) { | 2573 [List<Object> arguments]) { |
2523 String displayName = element.displayName; | |
2524 int length = 0; | 2574 int length = 0; |
2525 if (displayName != null) { | 2575 if (element is ImportElement) { |
2526 length = displayName.length; | |
2527 } else if (element is ImportElement) { | |
2528 length = 6; // 'import'.length | 2576 length = 6; // 'import'.length |
2529 } else if (element is ExportElement) { | 2577 } else if (element is ExportElement) { |
2530 length = 6; // 'export'.length | 2578 length = 6; // 'export'.length |
| 2579 } else { |
| 2580 length = element.nameLength; |
2531 } | 2581 } |
2532 reportErrorForOffset(errorCode, element.nameOffset, length, arguments); | 2582 reportErrorForOffset(errorCode, element.nameOffset, length, arguments); |
2533 } | 2583 } |
2534 | 2584 |
2535 /** | 2585 /** |
2536 * Report an error with the given [errorCode] and [arguments]. | 2586 * Report an error with the given [errorCode] and [arguments]. |
2537 * The [node] is used to compute the location of the error. | 2587 * The [node] is used to compute the location of the error. |
2538 * | 2588 * |
2539 * If the arguments contain the names of two or more types, the method | 2589 * If the arguments contain the names of two or more types, the method |
2540 * [reportTypeErrorForNode] should be used and the types | 2590 * [reportTypeErrorForNode] should be used and the types |
(...skipping 345 matching lines...) Loading... |
2886 | 2936 |
2887 /** | 2937 /** |
2888 * Generate a hint for methods or functions that have a return type, but do | 2938 * Generate a hint for methods or functions that have a return type, but do |
2889 * not have a non-void return statement on all branches. At the end of methods | 2939 * not have a non-void return statement on all branches. At the end of methods |
2890 * or functions with no return, Dart implicitly returns `null`, avoiding these | 2940 * or functions with no return, Dart implicitly returns `null`, avoiding these |
2891 * implicit returns is considered a best practice. | 2941 * implicit returns is considered a best practice. |
2892 * | 2942 * |
2893 * Parameters: | 2943 * Parameters: |
2894 * 0: the name of the declared return type | 2944 * 0: the name of the declared return type |
2895 */ | 2945 */ |
2896 static const HintCode MISSING_RETURN = const HintCode('MISSING_RETURN', | 2946 static const HintCode MISSING_RETURN = const HintCode( |
| 2947 'MISSING_RETURN', |
2897 "This function declares a return type of '{0}', but does not end with a re
turn statement", | 2948 "This function declares a return type of '{0}', but does not end with a re
turn statement", |
2898 "Either add a return statement or change the return type to 'void'"); | 2949 "Either add a return statement or change the return type to 'void'"); |
2899 | 2950 |
2900 /** | 2951 /** |
2901 * A getter with the override annotation does not override an existing getter. | 2952 * A getter with the override annotation does not override an existing getter. |
2902 */ | 2953 */ |
2903 static const HintCode OVERRIDE_ON_NON_OVERRIDING_GETTER = const HintCode( | 2954 static const HintCode OVERRIDE_ON_NON_OVERRIDING_GETTER = const HintCode( |
2904 'OVERRIDE_ON_NON_OVERRIDING_GETTER', | 2955 'OVERRIDE_ON_NON_OVERRIDING_GETTER', |
2905 "Getter does not override an inherited getter"); | 2956 "Getter does not override an inherited getter"); |
2906 | 2957 |
(...skipping 131 matching lines...) Loading... |
3038 "The exception variable '{0}' is not used, so the 'catch' clause can be re
moved"); | 3089 "The exception variable '{0}' is not used, so the 'catch' clause can be re
moved"); |
3039 | 3090 |
3040 /** | 3091 /** |
3041 * Unused catch stack trace variables. | 3092 * Unused catch stack trace variables. |
3042 */ | 3093 */ |
3043 static const HintCode UNUSED_CATCH_STACK = const HintCode( | 3094 static const HintCode UNUSED_CATCH_STACK = const HintCode( |
3044 'UNUSED_CATCH_STACK', | 3095 'UNUSED_CATCH_STACK', |
3045 "The stack trace variable '{0}' is not used and can be removed"); | 3096 "The stack trace variable '{0}' is not used and can be removed"); |
3046 | 3097 |
3047 /** | 3098 /** |
3048 * Unused local variables are local varaibles which are never read. | 3099 * Unused local variables are local variables which are never read. |
3049 */ | 3100 */ |
3050 static const HintCode UNUSED_LOCAL_VARIABLE = const HintCode( | 3101 static const HintCode UNUSED_LOCAL_VARIABLE = const HintCode( |
3051 'UNUSED_LOCAL_VARIABLE', | 3102 'UNUSED_LOCAL_VARIABLE', |
3052 "The value of the local variable '{0}' is not used"); | 3103 "The value of the local variable '{0}' is not used"); |
3053 | 3104 |
3054 /** | 3105 /** |
3055 * Hint for cases where the source expects a method or function to return a | 3106 * Hint for cases where the source expects a method or function to return a |
3056 * non-void result, but the method or function signature returns void. | 3107 * non-void result, but the method or function signature returns void. |
3057 * | 3108 * |
3058 * Parameters: | 3109 * Parameters: |
(...skipping 670 matching lines...) Loading... |
3729 * 2. If <i>N</i> is referenced as a function, getter or setter, a | 3780 * 2. If <i>N</i> is referenced as a function, getter or setter, a |
3730 * <i>NoSuchMethodError</i> is raised. | 3781 * <i>NoSuchMethodError</i> is raised. |
3731 * 3. If <i>N</i> is referenced as a type, it is treated as a malformed type. | 3782 * 3. If <i>N</i> is referenced as a type, it is treated as a malformed type. |
3732 * | 3783 * |
3733 * Parameters: | 3784 * Parameters: |
3734 * 0: the name of the ambiguous type | 3785 * 0: the name of the ambiguous type |
3735 * 1: the name of the first library that the type is found | 3786 * 1: the name of the first library that the type is found |
3736 * 2: the name of the second library that the type is found | 3787 * 2: the name of the second library that the type is found |
3737 */ | 3788 */ |
3738 static const StaticWarningCode AMBIGUOUS_IMPORT = const StaticWarningCode( | 3789 static const StaticWarningCode AMBIGUOUS_IMPORT = const StaticWarningCode( |
3739 'AMBIGUOUS_IMPORT', "The name '{0}' is defined in the libraries {1}", | 3790 'AMBIGUOUS_IMPORT', |
| 3791 "The name '{0}' is defined in the libraries {1}", |
3740 "Consider using 'as prefix' for one of the import directives " | 3792 "Consider using 'as prefix' for one of the import directives " |
3741 "or hiding the name from all but one of the imports."); | 3793 "or hiding the name from all but one of the imports."); |
3742 | 3794 |
3743 /** | 3795 /** |
3744 * 12.11.1 New: It is a static warning if the static type of <i>a<sub>i</sub>, | 3796 * 12.11.1 New: It is a static warning if the static type of <i>a<sub>i</sub>, |
3745 * 1 <= i <= n+ k</i> may not be assigned to the type of the | 3797 * 1 <= i <= n+ k</i> may not be assigned to the type of the |
3746 * corresponding formal parameter of the constructor <i>T.id</i> (respectively | 3798 * corresponding formal parameter of the constructor <i>T.id</i> (respectively |
3747 * <i>T</i>). | 3799 * <i>T</i>). |
3748 * | 3800 * |
3749 * 12.11.2 Const: It is a static warning if the static type of | 3801 * 12.11.2 Const: It is a static warning if the static type of |
(...skipping 203 matching lines...) Loading... |
3953 * Parameters: | 4005 * Parameters: |
3954 * 0: the uri pointing to a first library | 4006 * 0: the uri pointing to a first library |
3955 * 1: the uri pointing to a second library | 4007 * 1: the uri pointing to a second library |
3956 * 2:e the shared name of the exported libraries | 4008 * 2:e the shared name of the exported libraries |
3957 */ | 4009 */ |
3958 static const StaticWarningCode EXPORT_DUPLICATED_LIBRARY_NAMED = | 4010 static const StaticWarningCode EXPORT_DUPLICATED_LIBRARY_NAMED = |
3959 const StaticWarningCode('EXPORT_DUPLICATED_LIBRARY_NAMED', | 4011 const StaticWarningCode('EXPORT_DUPLICATED_LIBRARY_NAMED', |
3960 "The exported libraries '{0}' and '{1}' cannot have the same name '{2}
'"); | 4012 "The exported libraries '{0}' and '{1}' cannot have the same name '{2}
'"); |
3961 | 4013 |
3962 /** | 4014 /** |
3963 * 14.2 Exports: It is a static warning to export two different libraries with | |
3964 * the same name. | |
3965 * | |
3966 * Parameters: | |
3967 * 0: the uri pointing to a first library | |
3968 * 1: the uri pointing to a second library | |
3969 */ | |
3970 static const StaticWarningCode EXPORT_DUPLICATED_LIBRARY_UNNAMED = | |
3971 const StaticWarningCode('EXPORT_DUPLICATED_LIBRARY_UNNAMED', | |
3972 "The exported libraries '{0}' and '{1}' cannot both be unnamed"); | |
3973 | |
3974 /** | |
3975 * 12.14.2 Binding Actuals to Formals: It is a static warning if <i>m < | 4015 * 12.14.2 Binding Actuals to Formals: It is a static warning if <i>m < |
3976 * h</i> or if <i>m > n</i>. | 4016 * h</i> or if <i>m > n</i>. |
3977 * | 4017 * |
3978 * Parameters: | 4018 * Parameters: |
3979 * 0: the maximum number of positional arguments | 4019 * 0: the maximum number of positional arguments |
3980 * 1: the actual number of positional arguments given | 4020 * 1: the actual number of positional arguments given |
3981 * | 4021 * |
3982 * See [NOT_ENOUGH_REQUIRED_ARGUMENTS]. | 4022 * See [NOT_ENOUGH_REQUIRED_ARGUMENTS]. |
3983 */ | 4023 */ |
3984 static const StaticWarningCode EXTRA_POSITIONAL_ARGUMENTS = | 4024 static const StaticWarningCode EXTRA_POSITIONAL_ARGUMENTS = |
(...skipping 135 matching lines...) Loading... |
4120 * Parameters: | 4160 * Parameters: |
4121 * 0: the uri pointing to a first library | 4161 * 0: the uri pointing to a first library |
4122 * 1: the uri pointing to a second library | 4162 * 1: the uri pointing to a second library |
4123 * 2: the shared name of the imported libraries | 4163 * 2: the shared name of the imported libraries |
4124 */ | 4164 */ |
4125 static const StaticWarningCode IMPORT_DUPLICATED_LIBRARY_NAMED = | 4165 static const StaticWarningCode IMPORT_DUPLICATED_LIBRARY_NAMED = |
4126 const StaticWarningCode('IMPORT_DUPLICATED_LIBRARY_NAMED', | 4166 const StaticWarningCode('IMPORT_DUPLICATED_LIBRARY_NAMED', |
4127 "The imported libraries '{0}' and '{1}' cannot have the same name '{2}
'"); | 4167 "The imported libraries '{0}' and '{1}' cannot have the same name '{2}
'"); |
4128 | 4168 |
4129 /** | 4169 /** |
4130 * 14.1 Imports: It is a static warning to import two different libraries with | |
4131 * the same name. | |
4132 * | |
4133 * Parameters: | |
4134 * 0: the uri pointing to a first library | |
4135 * 1: the uri pointing to a second library | |
4136 */ | |
4137 static const StaticWarningCode IMPORT_DUPLICATED_LIBRARY_UNNAMED = | |
4138 const StaticWarningCode('IMPORT_DUPLICATED_LIBRARY_UNNAMED', | |
4139 "The imported libraries '{0}' and '{1}' cannot both be unnamed"); | |
4140 | |
4141 /** | |
4142 * 14.1 Imports: It is a static warning if the specified URI of a deferred | 4170 * 14.1 Imports: It is a static warning if the specified URI of a deferred |
4143 * import does not refer to a library declaration. | 4171 * import does not refer to a library declaration. |
4144 * | 4172 * |
4145 * Parameters: | 4173 * Parameters: |
4146 * 0: the uri pointing to a non-library declaration | 4174 * 0: the uri pointing to a non-library declaration |
4147 * | 4175 * |
4148 * See [CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]. | 4176 * See [CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]. |
4149 */ | 4177 */ |
4150 static const StaticWarningCode IMPORT_OF_NON_LIBRARY = | 4178 static const StaticWarningCode IMPORT_OF_NON_LIBRARY = |
4151 const StaticWarningCode('IMPORT_OF_NON_LIBRARY', | 4179 const StaticWarningCode('IMPORT_OF_NON_LIBRARY', |
(...skipping 818 matching lines...) Loading... |
4970 * Initialize a newly created error code to have the given [name]. | 4998 * Initialize a newly created error code to have the given [name]. |
4971 */ | 4999 */ |
4972 const TodoCode(String name) : super(name, "{0}"); | 5000 const TodoCode(String name) : super(name, "{0}"); |
4973 | 5001 |
4974 @override | 5002 @override |
4975 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; | 5003 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; |
4976 | 5004 |
4977 @override | 5005 @override |
4978 ErrorType get type => ErrorType.TODO; | 5006 ErrorType get type => ErrorType.TODO; |
4979 } | 5007 } |
OLD | NEW |