Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: pkg/analyzer/lib/src/generated/error.dart

Issue 259773005: New analyzer snapshot. Sorted unit members. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/lib/src/generated/html.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.error; 8 library engine.error;
9 9
10 import 'java_core.dart'; 10 import 'java_core.dart';
11 import 'source.dart'; 11 import 'source.dart';
12 import 'scanner.dart' show Token; 12 import 'scanner.dart' show Token;
13 import 'ast.dart' show AstNode; 13 import 'ast.dart' show AstNode;
14 import 'element.dart' show Element; 14 import 'element.dart' show Element;
15 15
16 /** 16 /**
17 * The enumeration `PubSuggestionCode` defines the suggestions used for reportin g deviations 17 * Instances of the class `AnalysisError` represent an error discovered during t he analysis of
18 * from pub best practices. The convention for this class is for the name of the bad practice to 18 * some Dart code.
19 * indicate the problem that caused the suggestion to be generated and for the m essage to explain 19 *
20 * what is wrong and, when appropriate, how the situation can be corrected. 20 * @see AnalysisErrorListener
21 */ 21 */
22 class PubSuggestionCode extends Enum<PubSuggestionCode> implements ErrorCode { 22 class AnalysisError {
23 /** 23 /**
24 * It is a bad practice for a source file in a package "lib" directory hierarc hy to traverse 24 * An empty array of errors used when no errors are expected.
25 * outside that directory hierarchy. For example, a source file in the "lib" d irectory should not 25 */
26 * contain a directive such as `import '../web/some.dart'` which references a file outside 26 static List<AnalysisError> NO_ERRORS = new List<AnalysisError>(0);
27 * the lib directory. 27
28 */ 28 /**
29 static const PubSuggestionCode FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE = const PubSuggestionCode.con1('FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE', 0, "A file in the 'lib' directory hierarchy should not reference a file outside that hierarchy"); 29 * A [Comparator] that sorts by the name of the file that the [AnalysisError] was
30 30 * found.
31 /** 31 */
32 * It is a bad practice for a source file ouside a package "lib" directory hie rarchy to traverse 32 static Comparator<AnalysisError> FILE_COMPARATOR = (AnalysisError o1, Analysis Error o2) => o1.source.shortName.compareTo(o2.source.shortName);
33 * into that directory hierarchy. For example, a source file in the "web" dire ctory should not 33
34 * contain a directive such as `import '../lib/some.dart'` which references a file inside 34 /**
35 * the lib directory. 35 * A [Comparator] that sorts error codes first by their severity (errors first , warnings
36 */ 36 * second), and then by the the error code type.
37 static const PubSuggestionCode FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE = const PubSuggestionCode.con1('FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE', 1, "A file outside the 'lib' directory hierarchy should not reference a file in side that hierarchy. Use a package: reference instead."); 37 */
38 38 static Comparator<AnalysisError> ERROR_CODE_COMPARATOR = (AnalysisError o1, An alysisError o2) {
39 /** 39 ErrorCode errorCode1 = o1.errorCode;
40 * It is a bad practice for a package import to reference anything outside the given package, or 40 ErrorCode errorCode2 = o2.errorCode;
41 * more generally, it is bad practice for a package import to contain a "..". For example, a 41 ErrorSeverity errorSeverity1 = errorCode1.errorSeverity;
42 * source file should not contain a directive such as `import 'package:foo/../ some.dart'`. 42 ErrorSeverity errorSeverity2 = errorCode2.errorSeverity;
43 */ 43 ErrorType errorType1 = errorCode1.type;
44 static const PubSuggestionCode PACKAGE_IMPORT_CONTAINS_DOT_DOT = const PubSugg estionCode.con1('PACKAGE_IMPORT_CONTAINS_DOT_DOT', 2, "A package import should n ot contain '..'"); 44 ErrorType errorType2 = errorCode2.type;
45 45 if (errorSeverity1 == errorSeverity2) {
46 static const List<PubSuggestionCode> values = const [ 46 return errorType1.compareTo(errorType2);
47 FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE, 47 } else {
48 FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE, 48 return errorSeverity2.compareTo(errorSeverity1);
49 PACKAGE_IMPORT_CONTAINS_DOT_DOT]; 49 }
50 };
51
52 /**
53 * The error code associated with the error.
54 */
55 final ErrorCode errorCode;
56
57 /**
58 * The localized error message.
59 */
60 String _message;
61
62 /**
63 * The correction to be displayed for this error, or `null` if there is no cor rection
64 * information for this error.
65 */
66 String _correction;
67
68 /**
69 * The source in which the error occurred, or `null` if unknown.
70 */
71 Source source;
72
73 /**
74 * The character offset from the beginning of the source (zero based) where th e error occurred.
75 */
76 int _offset = 0;
77
78 /**
79 * The number of characters from the offset to the end of the source which enc ompasses the
80 * compilation error.
81 */
82 int _length = 0;
83
84 /**
85 * A flag indicating whether this error can be shown to be a non-issue because of the result of
86 * type propagation.
87 */
88 bool isStaticOnly = false;
89
90 /**
91 * Initialize a newly created analysis error for the specified source. The err or has no location
92 * information.
93 *
94 * @param source the source for which the exception occurred
95 * @param errorCode the error code to be associated with this error
96 * @param arguments the arguments used to build the error message
97 */
98 AnalysisError.con1(this.source, this.errorCode, List<Object> arguments) {
99 this._message = JavaString.format(errorCode.message, arguments);
100 }
101
102 /**
103 * Initialize a newly created analysis error for the specified source at the g iven location.
104 *
105 * @param source the source for which the exception occurred
106 * @param offset the offset of the location of the error
107 * @param length the length of the location of the error
108 * @param errorCode the error code to be associated with this error
109 * @param arguments the arguments used to build the error message
110 */
111 AnalysisError.con2(this.source, int offset, int length, this.errorCode, List<O bject> arguments) {
112 this._offset = offset;
113 this._length = length;
114 this._message = JavaString.format(errorCode.message, arguments);
115 String correctionTemplate = errorCode.correction;
116 if (correctionTemplate != null) {
117 this._correction = JavaString.format(correctionTemplate, arguments);
118 }
119 }
120
121 @override
122 bool operator ==(Object obj) {
123 if (identical(obj, this)) {
124 return true;
125 }
126 // prepare other AnalysisError
127 if (obj is! AnalysisError) {
128 return false;
129 }
130 AnalysisError other = obj as AnalysisError;
131 // Quick checks.
132 if (!identical(errorCode, other.errorCode)) {
133 return false;
134 }
135 if (_offset != other._offset || _length != other._length) {
136 return false;
137 }
138 if (isStaticOnly != other.isStaticOnly) {
139 return false;
140 }
141 // Deep checks.
142 if (_message != other._message) {
143 return false;
144 }
145 if (source != other.source) {
146 return false;
147 }
148 // OK
149 return true;
150 }
151
152 /**
153 * Return the correction to be displayed for this error, or `null` if there is no correction
154 * information for this error. The correction should indicate how the user can fix the error.
155 *
156 * @return the template used to create the correction to be displayed for this error
157 */
158 String get correction => _correction;
159
160 /**
161 * Return the number of characters from the offset to the end of the source wh ich encompasses the
162 * compilation error.
163 *
164 * @return the length of the error location
165 */
166 int get length => _length;
167
168 /**
169 * Return the message to be displayed for this error. The message should indic ate what is wrong
170 * and why it is wrong.
171 *
172 * @return the message to be displayed for this error
173 */
174 String get message => _message;
175
176 /**
177 * Return the character offset from the beginning of the source (zero based) w here the error
178 * occurred.
179 *
180 * @return the offset to the start of the error location
181 */
182 int get offset => _offset;
183
184 /**
185 * Return the value of the given property, or `null` if the given property is not defined
186 * for this error.
187 *
188 * @param property the property whose value is to be returned
189 * @return the value of the given property
190 */
191 Object getProperty(ErrorProperty property) => null;
192
193 @override
194 int get hashCode {
195 int hashCode = _offset;
196 hashCode ^= (_message != null) ? _message.hashCode : 0;
197 hashCode ^= (source != null) ? source.hashCode : 0;
198 return hashCode;
199 }
200
201 @override
202 String toString() {
203 JavaStringBuilder builder = new JavaStringBuilder();
204 builder.append((source != null) ? source.fullName : "<unknown source>");
205 builder.append("(");
206 builder.append(_offset);
207 builder.append("..");
208 builder.append(_offset + _length - 1);
209 builder.append("): ");
210 //builder.append("(" + lineNumber + ":" + columnNumber + "): ");
211 builder.append(_message);
212 return builder.toString();
213 }
214 }
215
216 /**
217 * The interface `AnalysisErrorListener` defines the behavior of objects that li sten for
218 * [AnalysisError] being produced by the analysis engine.
219 */
220 abstract class AnalysisErrorListener {
221 /**
222 * An error listener that ignores errors that are reported to it.
223 */
224 static final AnalysisErrorListener NULL_LISTENER = new AnalysisErrorListener_N ULL_LISTENER();
225
226 /**
227 * This method is invoked when an error has been found by the analysis engine.
228 *
229 * @param error the error that was just found (not `null`)
230 */
231 void onError(AnalysisError error);
232 }
233
234 class AnalysisErrorListener_NULL_LISTENER implements AnalysisErrorListener {
235 @override
236 void onError(AnalysisError event) {
237 }
238 }
239
240 /**
241 * Instances of the class `AnalysisErrorWithProperties`
242 */
243 class AnalysisErrorWithProperties extends AnalysisError {
244 /**
245 * The properties associated with this error.
246 */
247 Map<ErrorProperty, Object> _propertyMap = new Map<ErrorProperty, Object>();
248
249 /**
250 * Initialize a newly created analysis error for the specified source. The err or has no location
251 * information.
252 *
253 * @param source the source for which the exception occurred
254 * @param errorCode the error code to be associated with this error
255 * @param arguments the arguments used to build the error message
256 */
257 AnalysisErrorWithProperties.con1(Source source, ErrorCode errorCode, List<Obje ct> arguments) : super.con1(source, errorCode, arguments);
258
259 /**
260 * Initialize a newly created analysis error for the specified source at the g iven location.
261 *
262 * @param source the source for which the exception occurred
263 * @param offset the offset of the location of the error
264 * @param length the length of the location of the error
265 * @param errorCode the error code to be associated with this error
266 * @param arguments the arguments used to build the error message
267 */
268 AnalysisErrorWithProperties.con2(Source source, int offset, int length, ErrorC ode errorCode, List<Object> arguments) : super.con2(source, offset, length, erro rCode, arguments);
269
270 @override
271 Object getProperty(ErrorProperty property) => _propertyMap[property];
272
273 /**
274 * Set the value of the given property to the given value. Using a value of `n ull` will
275 * effectively remove the property from this error.
276 *
277 * @param property the property whose value is to be returned
278 * @param value the new value of the given property
279 */
280 void setProperty(ErrorProperty property, Object value) {
281 _propertyMap[property] = value;
282 }
283 }
284
285 /**
286 * The enumeration `AngularCode` defines Angular specific problems.
287 */
288 class AngularCode extends Enum<AngularCode> implements ErrorCode {
289 static const AngularCode CANNOT_PARSE_SELECTOR = const AngularCode('CANNOT_PAR SE_SELECTOR', 0, "The selector '%s' cannot be parsed");
290
291 static const AngularCode INVALID_FORMATTER_NAME = const AngularCode('INVALID_F ORMATTER_NAME', 1, "Formatter name must be a simple identifier");
292
293 static const AngularCode INVALID_PROPERTY_KIND = const AngularCode('INVALID_PR OPERTY_KIND', 2, "Unknown property binding kind '%s', use one of the '@', '=>', '=>!' or '<=>'");
294
295 static const AngularCode INVALID_PROPERTY_FIELD = const AngularCode('INVALID_P ROPERTY_FIELD', 3, "Unknown property field '%s'");
296
297 static const AngularCode INVALID_PROPERTY_MAP = const AngularCode('INVALID_PRO PERTY_MAP', 4, "Argument 'map' must be a constant map literal");
298
299 static const AngularCode INVALID_PROPERTY_NAME = const AngularCode('INVALID_PR OPERTY_NAME', 5, "Property name must be a string literal");
300
301 static const AngularCode INVALID_PROPERTY_SPEC = const AngularCode('INVALID_PR OPERTY_SPEC', 6, "Property binding specification must be a string literal");
302
303 static const AngularCode INVALID_REPEAT_SYNTAX = const AngularCode('INVALID_RE PEAT_SYNTAX', 7, "Expected statement in form '_item_ in _collection_ [tracked by _id_]'");
304
305 static const AngularCode INVALID_REPEAT_ITEM_SYNTAX = const AngularCode('INVAL ID_REPEAT_ITEM_SYNTAX', 8, "Item must by identifier or in '(_key_, _value_)' pai r.");
306
307 static const AngularCode INVALID_URI = const AngularCode('INVALID_URI', 9, "In valid URI syntax: '%s'");
308
309 static const AngularCode MISSING_FORMATTER_COLON = const AngularCode('MISSING_ FORMATTER_COLON', 10, "Missing ':' before formatter argument");
310
311 static const AngularCode MISSING_NAME = const AngularCode('MISSING_NAME', 11, "Argument 'name' must be provided");
312
313 static const AngularCode MISSING_PUBLISH_AS = const AngularCode('MISSING_PUBLI SH_AS', 12, "Argument 'publishAs' must be provided");
314
315 static const AngularCode MISSING_SELECTOR = const AngularCode('MISSING_SELECTO R', 13, "Argument 'selector' must be provided");
316
317 static const AngularCode URI_DOES_NOT_EXIST = const AngularCode('URI_DOES_NOT_ EXIST', 14, "Target of URI does not exist: '%s'");
318
319 static const List<AngularCode> values = const [
320 CANNOT_PARSE_SELECTOR,
321 INVALID_FORMATTER_NAME,
322 INVALID_PROPERTY_KIND,
323 INVALID_PROPERTY_FIELD,
324 INVALID_PROPERTY_MAP,
325 INVALID_PROPERTY_NAME,
326 INVALID_PROPERTY_SPEC,
327 INVALID_REPEAT_SYNTAX,
328 INVALID_REPEAT_ITEM_SYNTAX,
329 INVALID_URI,
330 MISSING_FORMATTER_COLON,
331 MISSING_NAME,
332 MISSING_PUBLISH_AS,
333 MISSING_SELECTOR,
334 URI_DOES_NOT_EXIST];
50 335
51 /** 336 /**
52 * The template used to create the message to be displayed for this error. 337 * The template used to create the message to be displayed for this error.
53 */ 338 */
54 final String message; 339 final String message;
55 340
56 /** 341 /**
57 * The template used to create the correction to be displayed for this error, or `null` if
58 * there is no correction information for this error.
59 */
60 final String correction;
61
62 /**
63 * Initialize a newly created error code to have the given message. 342 * Initialize a newly created error code to have the given message.
64 * 343 *
65 * @param message the message template used to create the message to be displa yed for the error 344 * @param message the message template used to create the message to be displa yed for the error
66 */ 345 */
67 const PubSuggestionCode.con1(String name, int ordinal, String message) : this. con2(name, ordinal, message, null); 346 const AngularCode(String name, int ordinal, this.message) : super(name, ordina l);
68 347
69 /** 348 @override
70 * Initialize a newly created error code to have the given message and correct ion. 349 String get correction => null;
71 * 350
72 * @param message the template used to create the message to be displayed for the error 351 @override
73 * @param correction the template used to create the correction to be displaye d for the error 352 ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
74 */ 353
75 const PubSuggestionCode.con2(String name, int ordinal, this.message, this.corr ection) : super(name, ordinal); 354 @override
76 355 ErrorType get type => ErrorType.ANGULAR;
77 @override 356 }
78 ErrorSeverity get errorSeverity => ErrorType.PUB_SUGGESTION.severity; 357
79 358 /**
80 @override 359 * Instances of the class `BooleanErrorListener` implement a listener that keeps track of
81 ErrorType get type => ErrorType.PUB_SUGGESTION; 360 * whether an error has been reported to it.
82 } 361 */
83 362 class BooleanErrorListener implements AnalysisErrorListener {
84 /** 363 /**
85 * The enumeration `HtmlWarningCode` defines the error codes used for warnings i n HTML files. 364 * A flag indicating whether an error has been reported to this listener.
86 * The convention for this class is for the name of the error code to indicate t he problem that 365 */
87 * caused the error to be generated and for the error message to explain what is wrong and, when 366 bool _errorReported = false;
88 * appropriate, how the problem can be corrected. 367
89 */ 368 /**
90 class HtmlWarningCode extends Enum<HtmlWarningCode> implements ErrorCode { 369 * Return `true` if an error has been reported to this listener.
91 /** 370 *
92 * An error code indicating that the value of the 'src' attribute of a Dart sc ript tag is not a 371 * @return `true` if an error has been reported to this listener
93 * valid URI. 372 */
94 * 373 bool get errorReported => _errorReported;
95 * @param uri the URI that is invalid 374
96 */ 375 @override
97 static const HtmlWarningCode INVALID_URI = const HtmlWarningCode.con1('INVALID _URI', 0, "Invalid URI syntax: '%s'"); 376 void onError(AnalysisError error) {
98 377 _errorReported = true;
99 /** 378 }
100 * An error code indicating that the value of the 'src' attribute of a Dart sc ript tag references 379 }
101 * a file that does not exist. 380
102 * 381 /**
103 * @param uri the URI pointing to a non-existent file
104 */
105 static const HtmlWarningCode URI_DOES_NOT_EXIST = const HtmlWarningCode.con1(' URI_DOES_NOT_EXIST', 1, "Target of URI does not exist: '%s'");
106
107 static const List<HtmlWarningCode> values = const [INVALID_URI, URI_DOES_NOT_E XIST];
108
109 /**
110 * The template used to create the message to be displayed for this error.
111 */
112 final String message;
113
114 /**
115 * The template used to create the correction to be displayed for this error, or `null` if
116 * there is no correction information for this error.
117 */
118 final String correction;
119
120 /**
121 * Initialize a newly created error code to have the given message.
122 *
123 * @param message the message template used to create the message to be displa yed for the error
124 */
125 const HtmlWarningCode.con1(String name, int ordinal, String message) : this.co n2(name, ordinal, message, null);
126
127 /**
128 * Initialize a newly created error code to have the given message and correct ion.
129 *
130 * @param message the template used to create the message to be displayed for the error
131 * @param correction the template used to create the correction to be displaye d for the error
132 */
133 const HtmlWarningCode.con2(String name, int ordinal, this.message, this.correc tion) : super(name, ordinal);
134
135 @override
136 ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
137
138 @override
139 ErrorType get type => ErrorType.STATIC_WARNING;
140 }
141
142 /**
143 * The enumeration `CompileTimeErrorCode` defines the error codes used for compi le time 382 * The enumeration `CompileTimeErrorCode` defines the error codes used for compi le time
144 * errors. The convention for this class is for the name of the error code to in dicate the problem 383 * errors. The convention for this class is for the name of the error code to in dicate the problem
145 * that caused the error to be generated and for the error message to explain wh at is wrong and, 384 * that caused the error to be generated and for the error message to explain wh at is wrong and,
146 * when appropriate, how the problem can be corrected. 385 * when appropriate, how the problem can be corrected.
147 */ 386 */
148 class CompileTimeErrorCode extends Enum<CompileTimeErrorCode> implements ErrorCo de { 387 class CompileTimeErrorCode extends Enum<CompileTimeErrorCode> implements ErrorCo de {
149 /** 388 /**
150 * 14.2 Exports: It is a compile-time error if a name <i>N</i> is re-exported by a library 389 * 14.2 Exports: It is a compile-time error if a name <i>N</i> is re-exported by a library
151 * <i>L</i> and <i>N</i> is introduced into the export namespace of <i>L</i> b y more than one 390 * <i>L</i> and <i>N</i> is introduced into the export namespace of <i>L</i> b y more than one
152 * export, unless each all exports refer to same declaration for the name N. 391 * export, unless each all exports refer to same declaration for the name N.
(...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 const CompileTimeErrorCode.con2(String name, int ordinal, this.message, this.c orrection) : super(name, ordinal); 1757 const CompileTimeErrorCode.con2(String name, int ordinal, this.message, this.c orrection) : super(name, ordinal);
1519 1758
1520 @override 1759 @override
1521 ErrorSeverity get errorSeverity => ErrorType.COMPILE_TIME_ERROR.severity; 1760 ErrorSeverity get errorSeverity => ErrorType.COMPILE_TIME_ERROR.severity;
1522 1761
1523 @override 1762 @override
1524 ErrorType get type => ErrorType.COMPILE_TIME_ERROR; 1763 ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
1525 } 1764 }
1526 1765
1527 /** 1766 /**
1528 * The enumeration `TodoCode` defines the single TODO `ErrorCode`. 1767 * The interface `ErrorCode` defines the behavior common to objects representing error codes
1529 */ 1768 * associated with [AnalysisError].
1530 class TodoCode extends Enum<TodoCode> implements ErrorCode { 1769 *
1531 /** 1770 * Generally, we want to provide messages that consist of three sentences: 1. wh at is wrong, 2. why
1532 * The single enum of TodoCode. 1771 * is it wrong, and 3. how do I fix it. However, we combine the first two in the result of
1533 */ 1772 * [getMessage] and the last in the result of [getCorrection].
1534 static const TodoCode TODO = const TodoCode('TODO', 0); 1773 */
1535 1774 abstract class ErrorCode {
1536 static const List<TodoCode> values = const [TODO]; 1775 /**
1537 1776 * Return the template used to create the correction to be displayed for this error, or
1538 /** 1777 * `null` if there is no correction information for this error. The correction should
1539 * This matches the two common Dart task styles 1778 * indicate how the user can fix the error.
1540 * 1779 *
1541 * * TODO: 1780 * @return the template used to create the correction to be displayed for this error
1542 * * TODO(username): 1781 */
1543 * 1782 String get correction;
1544 * As well as 1783
1545 * * TODO 1784 /**
1546 * 1785 * Return the severity of this error.
1547 * But not 1786 *
1548 * * todo 1787 * @return the severity of this error
1549 * * TODOS 1788 */
1550 */ 1789 ErrorSeverity get errorSeverity;
1551 static RegExp TODO_REGEX = new RegExp("([\\s/\\*])((TODO[^\\w\\d][^\\r\\n]*)|( TODO:?\$))"); 1790
1552 1791 /**
1553 const TodoCode(String name, int ordinal) : super(name, ordinal); 1792 * Return the template used to create the message to be displayed for this err or. The message
1554 1793 * should indicate what is wrong and why it is wrong.
1555 @override 1794 *
1556 String get correction => null; 1795 * @return the template used to create the message to be displayed for this er ror
1557 1796 */
1558 @override 1797 String get message;
1559 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; 1798
1560 1799 /**
1561 @override 1800 * Return the type of the error.
1562 String get message => "%s"; 1801 *
1563 1802 * @return the type of the error
1564 @override 1803 */
1565 ErrorType get type => ErrorType.TODO; 1804 ErrorType get type;
1805 }
1806
1807 /**
1808 * The enumeration `ErrorProperty` defines the properties that can be associated with an
1809 * [AnalysisError].
1810 */
1811 class ErrorProperty extends Enum<ErrorProperty> {
1812 /**
1813 * A property whose value is an array of [ExecutableElement] that should
1814 * be but are not implemented by a concrete class.
1815 */
1816 static const ErrorProperty UNIMPLEMENTED_METHODS = const ErrorProperty('UNIMPL EMENTED_METHODS', 0);
1817
1818 static const List<ErrorProperty> values = const [UNIMPLEMENTED_METHODS];
1819
1820 const ErrorProperty(String name, int ordinal) : super(name, ordinal);
1566 } 1821 }
1567 1822
1568 /** 1823 /**
1569 * Instances of the class `ErrorReporter` wrap an error listener with utility me thods used to 1824 * Instances of the class `ErrorReporter` wrap an error listener with utility me thods used to
1570 * create the errors being reported. 1825 * create the errors being reported.
1571 */ 1826 */
1572 class ErrorReporter { 1827 class ErrorReporter {
1573 /** 1828 /**
1574 * The error listener to which errors will be reported. 1829 * The error listener to which errors will be reported.
1575 */ 1830 */
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 * the default source to be used. 1923 * the default source to be used.
1669 * 1924 *
1670 * @param source the source to be used when reporting errors 1925 * @param source the source to be used when reporting errors
1671 */ 1926 */
1672 void set source(Source source) { 1927 void set source(Source source) {
1673 this._source = source == null ? _defaultSource : source; 1928 this._source = source == null ? _defaultSource : source;
1674 } 1929 }
1675 } 1930 }
1676 1931
1677 /** 1932 /**
1678 * The enumeration `PolymerCode` defines Polymer specific problems. 1933 * Instances of the enumeration `ErrorSeverity` represent the severity of an [Er rorCode]
1679 */ 1934 * .
1680 class PolymerCode extends Enum<PolymerCode> implements ErrorCode { 1935 */
1681 static const PolymerCode ATTRIBUTE_FIELD_NOT_PUBLISHED = const PolymerCode('AT TRIBUTE_FIELD_NOT_PUBLISHED', 0, "Field '%s' in '%s' must be @published"); 1936 class ErrorSeverity extends Enum<ErrorSeverity> {
1682 1937 /**
1683 static const PolymerCode DUPLICATE_ATTRIBUTE_DEFINITION = const PolymerCode('D UPLICATE_ATTRIBUTE_DEFINITION', 1, "The attribute '%s' is already defined"); 1938 * The severity representing a non-error. This is never used for any error cod e, but is useful for
1684 1939 * clients.
1685 static const PolymerCode EMPTY_ATTRIBUTES = const PolymerCode('EMPTY_ATTRIBUTE S', 2, "Empty 'attributes' attribute is useless"); 1940 */
1686 1941 static const ErrorSeverity NONE = const ErrorSeverity('NONE', 0, " ", "none");
1687 static const PolymerCode INVALID_ATTRIBUTE_NAME = const PolymerCode('INVALID_A TTRIBUTE_NAME', 3, "'%s' is not a valid name for a custom element attribute"); 1942
1688 1943 /**
1689 static const PolymerCode INVALID_TAG_NAME = const PolymerCode('INVALID_TAG_NAM E', 4, "'%s' is not a valid name for a custom element"); 1944 * The severity representing an informational level analysis issue.
1690 1945 */
1691 static const PolymerCode MISSING_TAG_NAME = const PolymerCode('MISSING_TAG_NAM E', 5, "Missing tag name of the custom element. Please include an attribute like name='your-tag-name'"); 1946 static const ErrorSeverity INFO = const ErrorSeverity('INFO', 1, "I", "info");
1692 1947
1693 static const PolymerCode UNDEFINED_ATTRIBUTE_FIELD = const PolymerCode('UNDEFI NED_ATTRIBUTE_FIELD', 6, "There is no such field '%s' in '%s'"); 1948 /**
1694 1949 * The severity representing a warning. Warnings can become errors if the `-We rror` command
1695 static const List<PolymerCode> values = const [ 1950 * line flag is specified.
1696 ATTRIBUTE_FIELD_NOT_PUBLISHED, 1951 */
1697 DUPLICATE_ATTRIBUTE_DEFINITION, 1952 static const ErrorSeverity WARNING = const ErrorSeverity('WARNING', 2, "W", "w arning");
1698 EMPTY_ATTRIBUTES, 1953
1699 INVALID_ATTRIBUTE_NAME, 1954 /**
1700 INVALID_TAG_NAME, 1955 * The severity representing an error.
1701 MISSING_TAG_NAME, 1956 */
1702 UNDEFINED_ATTRIBUTE_FIELD]; 1957 static const ErrorSeverity ERROR = const ErrorSeverity('ERROR', 3, "E", "error ");
1703 1958
1704 /** 1959 static const List<ErrorSeverity> values = const [NONE, INFO, WARNING, ERROR];
1705 * The template used to create the message to be displayed for this error. 1960
1706 */ 1961 /**
1707 final String message; 1962 * The name of the severity used when producing machine output.
1708 1963 */
1709 /** 1964 final String machineCode;
1710 * Initialize a newly created error code to have the given message. 1965
1711 * 1966 /**
1712 * @param message the message template used to create the message to be displa yed for the error 1967 * The name of the severity used when producing readable output.
1713 */ 1968 */
1714 const PolymerCode(String name, int ordinal, this.message) : super(name, ordina l); 1969 final String displayName;
1715 1970
1716 @override 1971 /**
1717 String get correction => null; 1972 * Initialize a newly created severity with the given names.
1718 1973 *
1719 @override 1974 * @param machineCode the name of the severity used when producing machine out put
1720 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; 1975 * @param displayName the name of the severity used when producing readable ou tput
1721 1976 */
1722 @override 1977 const ErrorSeverity(String name, int ordinal, this.machineCode, this.displayNa me) : super(name, ordinal);
1723 ErrorType get type => ErrorType.POLYMER; 1978
1724 } 1979 /**
1725 1980 * Return the severity constant that represents the greatest severity.
1726 /** 1981 *
1727 * Instances of the class `AnalysisError` represent an error discovered during t he analysis of 1982 * @param severity the severity being compared against
1728 * some Dart code. 1983 * @return the most sever of this or the given severity
1729 * 1984 */
1730 * @see AnalysisErrorListener 1985 ErrorSeverity max(ErrorSeverity severity) => this.ordinal >= severity.ordinal ? this : severity;
1731 */ 1986 }
1732 class AnalysisError { 1987
1733 /** 1988 /**
1734 * An empty array of errors used when no errors are expected.
1735 */
1736 static List<AnalysisError> NO_ERRORS = new List<AnalysisError>(0);
1737
1738 /**
1739 * A [Comparator] that sorts by the name of the file that the [AnalysisError] was
1740 * found.
1741 */
1742 static Comparator<AnalysisError> FILE_COMPARATOR = (AnalysisError o1, Analysis Error o2) => o1.source.shortName.compareTo(o2.source.shortName);
1743
1744 /**
1745 * A [Comparator] that sorts error codes first by their severity (errors first , warnings
1746 * second), and then by the the error code type.
1747 */
1748 static Comparator<AnalysisError> ERROR_CODE_COMPARATOR = (AnalysisError o1, An alysisError o2) {
1749 ErrorCode errorCode1 = o1.errorCode;
1750 ErrorCode errorCode2 = o2.errorCode;
1751 ErrorSeverity errorSeverity1 = errorCode1.errorSeverity;
1752 ErrorSeverity errorSeverity2 = errorCode2.errorSeverity;
1753 ErrorType errorType1 = errorCode1.type;
1754 ErrorType errorType2 = errorCode2.type;
1755 if (errorSeverity1 == errorSeverity2) {
1756 return errorType1.compareTo(errorType2);
1757 } else {
1758 return errorSeverity2.compareTo(errorSeverity1);
1759 }
1760 };
1761
1762 /**
1763 * The error code associated with the error.
1764 */
1765 final ErrorCode errorCode;
1766
1767 /**
1768 * The localized error message.
1769 */
1770 String _message;
1771
1772 /**
1773 * The correction to be displayed for this error, or `null` if there is no cor rection
1774 * information for this error.
1775 */
1776 String _correction;
1777
1778 /**
1779 * The source in which the error occurred, or `null` if unknown.
1780 */
1781 Source source;
1782
1783 /**
1784 * The character offset from the beginning of the source (zero based) where th e error occurred.
1785 */
1786 int _offset = 0;
1787
1788 /**
1789 * The number of characters from the offset to the end of the source which enc ompasses the
1790 * compilation error.
1791 */
1792 int _length = 0;
1793
1794 /**
1795 * A flag indicating whether this error can be shown to be a non-issue because of the result of
1796 * type propagation.
1797 */
1798 bool isStaticOnly = false;
1799
1800 /**
1801 * Initialize a newly created analysis error for the specified source. The err or has no location
1802 * information.
1803 *
1804 * @param source the source for which the exception occurred
1805 * @param errorCode the error code to be associated with this error
1806 * @param arguments the arguments used to build the error message
1807 */
1808 AnalysisError.con1(this.source, this.errorCode, List<Object> arguments) {
1809 this._message = JavaString.format(errorCode.message, arguments);
1810 }
1811
1812 /**
1813 * Initialize a newly created analysis error for the specified source at the g iven location.
1814 *
1815 * @param source the source for which the exception occurred
1816 * @param offset the offset of the location of the error
1817 * @param length the length of the location of the error
1818 * @param errorCode the error code to be associated with this error
1819 * @param arguments the arguments used to build the error message
1820 */
1821 AnalysisError.con2(this.source, int offset, int length, this.errorCode, List<O bject> arguments) {
1822 this._offset = offset;
1823 this._length = length;
1824 this._message = JavaString.format(errorCode.message, arguments);
1825 String correctionTemplate = errorCode.correction;
1826 if (correctionTemplate != null) {
1827 this._correction = JavaString.format(correctionTemplate, arguments);
1828 }
1829 }
1830
1831 @override
1832 bool operator ==(Object obj) {
1833 if (identical(obj, this)) {
1834 return true;
1835 }
1836 // prepare other AnalysisError
1837 if (obj is! AnalysisError) {
1838 return false;
1839 }
1840 AnalysisError other = obj as AnalysisError;
1841 // Quick checks.
1842 if (!identical(errorCode, other.errorCode)) {
1843 return false;
1844 }
1845 if (_offset != other._offset || _length != other._length) {
1846 return false;
1847 }
1848 if (isStaticOnly != other.isStaticOnly) {
1849 return false;
1850 }
1851 // Deep checks.
1852 if (_message != other._message) {
1853 return false;
1854 }
1855 if (source != other.source) {
1856 return false;
1857 }
1858 // OK
1859 return true;
1860 }
1861
1862 /**
1863 * Return the correction to be displayed for this error, or `null` if there is no correction
1864 * information for this error. The correction should indicate how the user can fix the error.
1865 *
1866 * @return the template used to create the correction to be displayed for this error
1867 */
1868 String get correction => _correction;
1869
1870 /**
1871 * Return the number of characters from the offset to the end of the source wh ich encompasses the
1872 * compilation error.
1873 *
1874 * @return the length of the error location
1875 */
1876 int get length => _length;
1877
1878 /**
1879 * Return the message to be displayed for this error. The message should indic ate what is wrong
1880 * and why it is wrong.
1881 *
1882 * @return the message to be displayed for this error
1883 */
1884 String get message => _message;
1885
1886 /**
1887 * Return the character offset from the beginning of the source (zero based) w here the error
1888 * occurred.
1889 *
1890 * @return the offset to the start of the error location
1891 */
1892 int get offset => _offset;
1893
1894 /**
1895 * Return the value of the given property, or `null` if the given property is not defined
1896 * for this error.
1897 *
1898 * @param property the property whose value is to be returned
1899 * @return the value of the given property
1900 */
1901 Object getProperty(ErrorProperty property) => null;
1902
1903 @override
1904 int get hashCode {
1905 int hashCode = _offset;
1906 hashCode ^= (_message != null) ? _message.hashCode : 0;
1907 hashCode ^= (source != null) ? source.hashCode : 0;
1908 return hashCode;
1909 }
1910
1911 @override
1912 String toString() {
1913 JavaStringBuilder builder = new JavaStringBuilder();
1914 builder.append((source != null) ? source.fullName : "<unknown source>");
1915 builder.append("(");
1916 builder.append(_offset);
1917 builder.append("..");
1918 builder.append(_offset + _length - 1);
1919 builder.append("): ");
1920 //builder.append("(" + lineNumber + ":" + columnNumber + "): ");
1921 builder.append(_message);
1922 return builder.toString();
1923 }
1924 }
1925
1926 /**
1927 * Instances of the class `AnalysisErrorWithProperties`
1928 */
1929 class AnalysisErrorWithProperties extends AnalysisError {
1930 /**
1931 * The properties associated with this error.
1932 */
1933 Map<ErrorProperty, Object> _propertyMap = new Map<ErrorProperty, Object>();
1934
1935 /**
1936 * Initialize a newly created analysis error for the specified source. The err or has no location
1937 * information.
1938 *
1939 * @param source the source for which the exception occurred
1940 * @param errorCode the error code to be associated with this error
1941 * @param arguments the arguments used to build the error message
1942 */
1943 AnalysisErrorWithProperties.con1(Source source, ErrorCode errorCode, List<Obje ct> arguments) : super.con1(source, errorCode, arguments);
1944
1945 /**
1946 * Initialize a newly created analysis error for the specified source at the g iven location.
1947 *
1948 * @param source the source for which the exception occurred
1949 * @param offset the offset of the location of the error
1950 * @param length the length of the location of the error
1951 * @param errorCode the error code to be associated with this error
1952 * @param arguments the arguments used to build the error message
1953 */
1954 AnalysisErrorWithProperties.con2(Source source, int offset, int length, ErrorC ode errorCode, List<Object> arguments) : super.con2(source, offset, length, erro rCode, arguments);
1955
1956 @override
1957 Object getProperty(ErrorProperty property) => _propertyMap[property];
1958
1959 /**
1960 * Set the value of the given property to the given value. Using a value of `n ull` will
1961 * effectively remove the property from this error.
1962 *
1963 * @param property the property whose value is to be returned
1964 * @param value the new value of the given property
1965 */
1966 void setProperty(ErrorProperty property, Object value) {
1967 _propertyMap[property] = value;
1968 }
1969 }
1970
1971 /**
1972 * Instances of the enumeration `ErrorType` represent the type of an [ErrorCode] . 1989 * Instances of the enumeration `ErrorType` represent the type of an [ErrorCode] .
1973 */ 1990 */
1974 class ErrorType extends Enum<ErrorType> { 1991 class ErrorType extends Enum<ErrorType> {
1975 /** 1992 /**
1976 * Task (todo) comments in user code. 1993 * Task (todo) comments in user code.
1977 */ 1994 */
1978 static const ErrorType TODO = const ErrorType('TODO', 0, ErrorSeverity.INFO); 1995 static const ErrorType TODO = const ErrorType('TODO', 0, ErrorSeverity.INFO);
1979 1996
1980 /** 1997 /**
1981 * Extra analysis run over the code to follow best practices, which are not in the Dart Language 1998 * Extra analysis run over the code to follow best practices, which are not in the Dart Language
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 * Initialize a newly created error type to have the given severity. 2059 * Initialize a newly created error type to have the given severity.
2043 * 2060 *
2044 * @param severity the severity of this type of error 2061 * @param severity the severity of this type of error
2045 */ 2062 */
2046 const ErrorType(String name, int ordinal, this.severity) : super(name, ordinal ); 2063 const ErrorType(String name, int ordinal, this.severity) : super(name, ordinal );
2047 2064
2048 String get displayName => name.toLowerCase().replaceAll('_', ' '); 2065 String get displayName => name.toLowerCase().replaceAll('_', ' ');
2049 } 2066 }
2050 2067
2051 /** 2068 /**
2052 * The interface `ErrorCode` defines the behavior common to objects representing error codes 2069 * The enumeration `HintCode` defines the hints and coding recommendations for b est practices
2053 * associated with [AnalysisError]. 2070 * which are not mentioned in the Dart Language Specification.
2054 *
2055 * Generally, we want to provide messages that consist of three sentences: 1. wh at is wrong, 2. why
2056 * is it wrong, and 3. how do I fix it. However, we combine the first two in the result of
2057 * [getMessage] and the last in the result of [getCorrection].
2058 */ 2071 */
2059 abstract class ErrorCode { 2072 class HintCode extends Enum<HintCode> implements ErrorCode {
2060 /** 2073 /**
2061 * Return the template used to create the correction to be displayed for this error, or 2074 * This hint is generated anywhere where the
2062 * `null` if there is no correction information for this error. The correction should 2075 * [StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE] would have been generated, if we used
2063 * indicate how the user can fix the error. 2076 * propagated information for the warnings.
2064 * 2077 *
2065 * @return the template used to create the correction to be displayed for this error 2078 * @param actualType the name of the actual argument type
2066 */ 2079 * @param expectedType the name of the expected type
2067 String get correction; 2080 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE
2068 2081 */
2069 /** 2082 static const HintCode ARGUMENT_TYPE_NOT_ASSIGNABLE = const HintCode.con1('ARGU MENT_TYPE_NOT_ASSIGNABLE', 0, "The argument type '%s' cannot be assigned to the parameter type '%s'");
2070 * Return the severity of this error. 2083
2071 * 2084 /**
2072 * @return the severity of this error 2085 * Dead code is code that is never reached, this can happen for instance if a statement follows a
2073 */ 2086 * return statement.
2074 ErrorSeverity get errorSeverity; 2087 */
2075 2088 static const HintCode DEAD_CODE = const HintCode.con1('DEAD_CODE', 1, "Dead co de");
2076 /** 2089
2077 * Return the template used to create the message to be displayed for this err or. The message 2090 /**
2078 * should indicate what is wrong and why it is wrong. 2091 * Dead code is code that is never reached. This case covers cases where the u ser has catch
2079 * 2092 * clauses after `catch (e)` or `on Object catch (e)`.
2080 * @return the template used to create the message to be displayed for this er ror 2093 */
2081 */ 2094 static const HintCode DEAD_CODE_CATCH_FOLLOWING_CATCH = const HintCode.con1('D EAD_CODE_CATCH_FOLLOWING_CATCH', 2, "Dead code, catch clauses after a 'catch (e) ' or an 'on Object catch (e)' are never reached");
2082 String get message; 2095
2083 2096 /**
2084 /** 2097 * Dead code is code that is never reached. This case covers cases where the u ser has an on-catch
2085 * Return the type of the error. 2098 * clause such as `on A catch (e)`, where a supertype of `A` was already caugh t.
2086 * 2099 *
2087 * @return the type of the error 2100 * @param subtypeName name of the subtype
2088 */ 2101 * @param supertypeName name of the supertype
2089 ErrorType get type; 2102 */
2090 } 2103 static const HintCode DEAD_CODE_ON_CATCH_SUBTYPE = const HintCode.con1('DEAD_C ODE_ON_CATCH_SUBTYPE', 3, "Dead code, this on-catch block will never be executed since '%s' is a subtype of '%s'");
2091 2104
2092 /** 2105 /**
2093 * Instances of the enumeration `ErrorSeverity` represent the severity of an [Er rorCode] 2106 * Deprecated members should not be invoked or used.
2094 * . 2107 *
2095 */ 2108 * @param memberName the name of the member
2096 class ErrorSeverity extends Enum<ErrorSeverity> { 2109 */
2097 /** 2110 static const HintCode DEPRECATED_MEMBER_USE = const HintCode.con1('DEPRECATED_ MEMBER_USE', 4, "'%s' is deprecated");
2098 * The severity representing a non-error. This is never used for any error cod e, but is useful for 2111
2099 * clients. 2112 /**
2100 */ 2113 * Duplicate imports.
2101 static const ErrorSeverity NONE = const ErrorSeverity('NONE', 0, " ", "none"); 2114 */
2102 2115 static const HintCode DUPLICATE_IMPORT = const HintCode.con1('DUPLICATE_IMPORT ', 5, "Duplicate import");
2103 /** 2116
2104 * The severity representing an informational level analysis issue. 2117 /**
2105 */ 2118 * Hint to use the ~/ operator.
2106 static const ErrorSeverity INFO = const ErrorSeverity('INFO', 1, "I", "info"); 2119 */
2107 2120 static const HintCode DIVISION_OPTIMIZATION = const HintCode.con1('DIVISION_OP TIMIZATION', 6, "The operator x ~/ y is more efficient than (x / y).toInt()");
2108 /** 2121
2109 * The severity representing a warning. Warnings can become errors if the `-We rror` command 2122 /**
2110 * line flag is specified. 2123 * Hint for the `x is double` type checks.
2111 */ 2124 */
2112 static const ErrorSeverity WARNING = const ErrorSeverity('WARNING', 2, "W", "w arning"); 2125 static const HintCode IS_DOUBLE = const HintCode.con1('IS_DOUBLE', 7, "When co mpiled to JS, this test might return true when the left hand side is an int");
2113 2126
2114 /** 2127 /**
2115 * The severity representing an error. 2128 * Hint for the `x is int` type checks.
2116 */ 2129 */
2117 static const ErrorSeverity ERROR = const ErrorSeverity('ERROR', 3, "E", "error "); 2130 static const HintCode IS_INT = const HintCode.con1('IS_INT', 8, "When compiled to JS, this test might return true when the left hand side is a double");
2118 2131
2119 static const List<ErrorSeverity> values = const [NONE, INFO, WARNING, ERROR]; 2132 /**
2120 2133 * Hint for the `x is! double` type checks.
2121 /** 2134 */
2122 * The name of the severity used when producing machine output. 2135 static const HintCode IS_NOT_DOUBLE = const HintCode.con1('IS_NOT_DOUBLE', 9, "When compiled to JS, this test might return false when the left hand side is an int");
2123 */ 2136
2124 final String machineCode; 2137 /**
2125 2138 * Hint for the `x is! int` type checks.
2126 /** 2139 */
2127 * The name of the severity used when producing readable output. 2140 static const HintCode IS_NOT_INT = const HintCode.con1('IS_NOT_INT', 10, "When compiled to JS, this test might return false when the left hand side is a doubl e");
2128 */ 2141
2129 final String displayName; 2142 /**
2130 2143 * This hint is generated anywhere where the [StaticTypeWarningCode#INVALID_AS SIGNMENT]
2131 /** 2144 * would have been generated, if we used propagated information for the warnin gs.
2132 * Initialize a newly created severity with the given names.
2133 *
2134 * @param machineCode the name of the severity used when producing machine out put
2135 * @param displayName the name of the severity used when producing readable ou tput
2136 */
2137 const ErrorSeverity(String name, int ordinal, this.machineCode, this.displayNa me) : super(name, ordinal);
2138
2139 /**
2140 * Return the severity constant that represents the greatest severity.
2141 *
2142 * @param severity the severity being compared against
2143 * @return the most sever of this or the given severity
2144 */
2145 ErrorSeverity max(ErrorSeverity severity) => this.ordinal >= severity.ordinal ? this : severity;
2146 }
2147
2148 /**
2149 * The interface `AnalysisErrorListener` defines the behavior of objects that li sten for
2150 * [AnalysisError] being produced by the analysis engine.
2151 */
2152 abstract class AnalysisErrorListener {
2153 /**
2154 * An error listener that ignores errors that are reported to it.
2155 */
2156 static final AnalysisErrorListener NULL_LISTENER = new AnalysisErrorListener_N ULL_LISTENER();
2157
2158 /**
2159 * This method is invoked when an error has been found by the analysis engine.
2160 *
2161 * @param error the error that was just found (not `null`)
2162 */
2163 void onError(AnalysisError error);
2164 }
2165
2166 class AnalysisErrorListener_NULL_LISTENER implements AnalysisErrorListener {
2167 @override
2168 void onError(AnalysisError event) {
2169 }
2170 }
2171
2172 /**
2173 * The enumeration `StaticTypeWarningCode` defines the error codes used for stat ic type
2174 * warnings. The convention for this class is for the name of the error code to indicate the problem
2175 * that caused the error to be generated and for the error message to explain wh at is wrong and,
2176 * when appropriate, how the problem can be corrected.
2177 */
2178 class StaticTypeWarningCode extends Enum<StaticTypeWarningCode> implements Error Code {
2179 /**
2180 * 12.7 Lists: A fresh instance (7.6.1) <i>a</i>, of size <i>n</i>, whose clas s implements the
2181 * built-in class <i>List&lt;E></i> is allocated.
2182 *
2183 * @param numTypeArgument the number of provided type arguments
2184 */
2185 static const StaticTypeWarningCode EXPECTED_ONE_LIST_TYPE_ARGUMENTS = const St aticTypeWarningCode.con1('EXPECTED_ONE_LIST_TYPE_ARGUMENTS', 0, "List literal re quires exactly one type arguments or none, but %d found");
2186
2187 /**
2188 * 12.8 Maps: A fresh instance (7.6.1) <i>m</i>, of size <i>n</i>, whose class implements the
2189 * built-in class <i>Map&lt;K, V></i> is allocated.
2190 *
2191 * @param numTypeArgument the number of provided type arguments
2192 */
2193 static const StaticTypeWarningCode EXPECTED_TWO_MAP_TYPE_ARGUMENTS = const Sta ticTypeWarningCode.con1('EXPECTED_TWO_MAP_TYPE_ARGUMENTS', 1, "Map literal requi res exactly two type arguments or none, but %d found");
2194
2195 /**
2196 * 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>. It is a static type
2197 * warning if <i>T</i> does not have an accessible instance setter named <i>v= </i>.
2198 *
2199 * @see #UNDEFINED_SETTER
2200 */
2201 static const StaticTypeWarningCode INACCESSIBLE_SETTER = const StaticTypeWarni ngCode.con1('INACCESSIBLE_SETTER', 2, "");
2202
2203 /**
2204 * 8.1.1 Inheritance and Overriding: However, if the above rules would cause m ultiple members
2205 * <i>m<sub>1</sub>, &hellip;, m<sub>k</sub></i> with the same name <i>n</i> t hat would be
2206 * inherited (because identically named members existed in several superinterf aces) then at most
2207 * one member is inherited.
2208 *
2209 * If the static types <i>T<sub>1</sub>, &hellip;, T<sub>k</sub></i> of the me mbers
2210 * <i>m<sub>1</sub>, &hellip;, m<sub>k</sub></i> are not identical, then there must be a member
2211 * <i>m<sub>x</sub></i> such that <i>T<sub>x</sub> &lt;: T<sub>i</sub>, 1 &lt; = x &lt;= k</i> for
2212 * all <i>i, 1 &lt;= i &lt;= k</i>, or a static type warning occurs. The membe r that is inherited
2213 * is <i>m<sub>x</sub></i>, if it exists; otherwise:
2214 * * Let <i>numberOfPositionals</i>(<i>f</i>) denote the number of positional parameters of a
2215 * function <i>f</i>, and let <i>numberOfRequiredParams</i>(<i>f</i>) denote t he number of
2216 * required parameters of a function <i>f</i>. Furthermore, let <i>s</i> denot e the set of all
2217 * named parameters of the <i>m<sub>1</sub>, &hellip;, m<sub>k</sub></i>. Then let
2218 * * <i>h = max(numberOfPositionals(m<sub>i</sub>)),</i>
2219 * * <i>r = min(numberOfRequiredParams(m<sub>i</sub>)), for all <i>i</i>, 1 <= i <= k.</i>
2220 * If <i>r <= h</i> then <i>I</i> has a method named <i>n</i>, with <i>r</i> r equired parameters
2221 * of type <b>dynamic</b>, <i>h</i> positional parameters of type <b>dynamic</ b>, named parameters
2222 * <i>s</i> of type <b>dynamic</b> and return type <b>dynamic</b>.
2223 * * Otherwise none of the members <i>m<sub>1</sub>, &hellip;, m<sub>k</sub></ i> is inherited.
2224 */
2225 static const StaticTypeWarningCode INCONSISTENT_METHOD_INHERITANCE = const Sta ticTypeWarningCode.con1('INCONSISTENT_METHOD_INHERITANCE', 3, "'%s' is inherited by at least two interfaces inconsistently, from %s");
2226
2227 /**
2228 * 12.15.1 Ordinary Invocation: It is a static type warning if <i>T</i> does n ot have an
2229 * accessible (3.2) instance member named <i>m</i>.
2230 *
2231 * @param memberName the name of the static member
2232 * @see UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER
2233 */
2234 static const StaticTypeWarningCode INSTANCE_ACCESS_TO_STATIC_MEMBER = const St aticTypeWarningCode.con1('INSTANCE_ACCESS_TO_STATIC_MEMBER', 4, "Static member ' %s' cannot be accessed using instance access");
2235
2236 /**
2237 * 12.18 Assignment: It is a static type warning if the static type of <i>e</i > may not be
2238 * assigned to the static type of <i>v</i>. The static type of the expression <i>v = e</i> is the
2239 * static type of <i>e</i>.
2240 *
2241 * 12.18 Assignment: It is a static type warning if the static type of <i>e</i > may not be
2242 * assigned to the static type of <i>C.v</i>. The static type of the expressio n <i>C.v = e</i> is
2243 * the static type of <i>e</i>.
2244 *
2245 * 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>. It is a static type
2246 * warning if the static type of <i>e<sub>2</sub></i> may not be assigned to < i>T</i>.
2247 * 2145 *
2248 * @param rhsTypeName the name of the right hand side type 2146 * @param rhsTypeName the name of the right hand side type
2249 * @param lhsTypeName the name of the left hand side type 2147 * @param lhsTypeName the name of the left hand side type
2250 */ 2148 * @see StaticTypeWarningCode#INVALID_ASSIGNMENT
2251 static const StaticTypeWarningCode INVALID_ASSIGNMENT = const StaticTypeWarnin gCode.con1('INVALID_ASSIGNMENT', 5, "A value of type '%s' cannot be assigned to a variable of type '%s'"); 2149 */
2252 2150 static const HintCode INVALID_ASSIGNMENT = const HintCode.con1('INVALID_ASSIGN MENT', 11, "A value of type '%s' cannot be assigned to a variable of type '%s'") ;
2253 /** 2151
2254 * 12.15.1 Ordinary Invocation: An ordinary method invocation <i>i</i> has the form 2152 /**
2255 * <i>o.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub>: a<sub>n+1</ sub>, &hellip; 2153 * Generate a hint for methods or functions that have a return type, but do no t have a non-void
2256 * x<sub>n+k</sub>: a<sub>n+k</sub>)</i>. 2154 * return statement on all branches. At the end of methods or functions with n o return, Dart
2257 * 2155 * implicitly returns `null`, avoiding these implicit returns is considered a best practice.
2258 * Let <i>T</i> be the static type of <i>o</i>. It is a static type warning if <i>T</i> does not 2156 *
2259 * have an accessible instance member named <i>m</i>. If <i>T.m</i> exists, it is a static warning 2157 * @param returnType the name of the declared return type
2260 * if the type <i>F</i> of <i>T.m</i> may not be assigned to a function type. If <i>T.m</i> does 2158 */
2261 * not exist, or if <i>F</i> is not a function type, the static type of <i>i</ i> is dynamic. 2159 static const HintCode MISSING_RETURN = const HintCode.con2('MISSING_RETURN', 1 2, "This function declares a return type of '%s', but does not end with a return statement", "Either add a return statement or change the return type to 'void'" );
2262 * 2160
2263 * 12.15.3 Static Invocation: It is a static type warning if the type <i>F</i> of <i>C.m</i> may 2161 /**
2264 * not be assigned to a function type. 2162 * A getter with the override annotation does not override an existing getter.
2265 * 2163 */
2266 * 12.15.4 Super Invocation: A super method invocation <i>i</i> has the form 2164 static const HintCode OVERRIDE_ON_NON_OVERRIDING_GETTER = const HintCode.con1( 'OVERRIDE_ON_NON_OVERRIDING_GETTER', 13, "Getter does not override an inherited getter");
2267 * <i>super.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub>: a<sub>n +1</sub>, &hellip; 2165
2268 * x<sub>n+k</sub>: a<sub>n+k</sub>)</i>. If <i>S.m</i> exists, it is a static warning if the type 2166 /**
2269 * <i>F</i> of <i>S.m</i> may not be assigned to a function type. 2167 * A method with the override annotation does not override an existing method.
2270 * 2168 */
2271 * @param nonFunctionIdentifier the name of the identifier that is not a funct ion type 2169 static const HintCode OVERRIDE_ON_NON_OVERRIDING_METHOD = const HintCode.con1( 'OVERRIDE_ON_NON_OVERRIDING_METHOD', 14, "Method does not override an inherited method");
2272 */ 2170
2273 static const StaticTypeWarningCode INVOCATION_OF_NON_FUNCTION = const StaticTy peWarningCode.con1('INVOCATION_OF_NON_FUNCTION', 6, "'%s' is not a method"); 2171 /**
2274 2172 * A setter with the override annotation does not override an existing setter.
2275 /** 2173 */
2276 * 12.14.4 Function Expression Invocation: A function expression invocation <i >i</i> has the form 2174 static const HintCode OVERRIDE_ON_NON_OVERRIDING_SETTER = const HintCode.con1( 'OVERRIDE_ON_NON_OVERRIDING_SETTER', 15, "Setter does not override an inherited setter");
2277 * <i>e<sub>f</sub>(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub>: a <sub>n+1</sub>, 2175
2278 * &hellip;, x<sub>n+k</sub>: a<sub>n+k</sub>)</i>, where <i>e<sub>f</sub></i> is an expression. 2176 /**
2279 * 2177 * Hint for classes that override equals, but not hashCode.
2280 * It is a static type warning if the static type <i>F</i> of <i>e<sub>f</sub> </i> may not be 2178 *
2281 * assigned to a function type. 2179 * @param className the name of the current class
2282 */ 2180 */
2283 static const StaticTypeWarningCode INVOCATION_OF_NON_FUNCTION_EXPRESSION = con st StaticTypeWarningCode.con1('INVOCATION_OF_NON_FUNCTION_EXPRESSION', 7, "Canno t invoke a non-function"); 2181 static const HintCode OVERRIDE_EQUALS_BUT_NOT_HASH_CODE = const HintCode.con1( 'OVERRIDE_EQUALS_BUT_NOT_HASH_CODE', 16, "The class '%s' overrides 'operator==', but not 'get hashCode'");
2284 2182
2285 /** 2183 /**
2286 * 12.20 Conditional: It is a static type warning if the type of <i>e<sub>1</s ub></i> may not be 2184 * Type checks of the type `x is! Null` should be done with `x != null`.
2287 * assigned to bool. 2185 */
2288 * 2186 static const HintCode TYPE_CHECK_IS_NOT_NULL = const HintCode.con1('TYPE_CHECK _IS_NOT_NULL', 17, "Tests for non-null should be done with '!= null'");
2289 * 13.5 If: It is a static type warning if the type of the expression <i>b</i> may not be assigned 2187
2290 * to bool. 2188 /**
2291 * 2189 * Type checks of the type `x is Null` should be done with `x == null`.
2292 * 13.7 While: It is a static type warning if the type of <i>e</i> may not be assigned to bool. 2190 */
2293 * 2191 static const HintCode TYPE_CHECK_IS_NULL = const HintCode.con1('TYPE_CHECK_IS_ NULL', 18, "Tests for null should be done with '== null'");
2294 * 13.8 Do: It is a static type warning if the type of <i>e</i> cannot be assi gned to bool. 2192
2295 */ 2193 /**
2296 static const StaticTypeWarningCode NON_BOOL_CONDITION = const StaticTypeWarnin gCode.con1('NON_BOOL_CONDITION', 8, "Conditions must have a static type of 'bool '"); 2194 * This hint is generated anywhere where the [StaticTypeWarningCode#UNDEFINED_ GETTER] or
2297 2195 * [StaticWarningCode#UNDEFINED_GETTER] would have been generated, if we used propagated
2298 /** 2196 * information for the warnings.
2299 * 13.15 Assert: It is a static type warning if the type of <i>e</i> may not b e assigned to either
2300 * bool or () &rarr; bool
2301 */
2302 static const StaticTypeWarningCode NON_BOOL_EXPRESSION = const StaticTypeWarni ngCode.con1('NON_BOOL_EXPRESSION', 9, "Assertions must be on either a 'bool' or '() -> bool'");
2303
2304 /**
2305 * 12.28 Unary Expressions: The expression !<i>e</i> is equivalent to the expr ession
2306 * <i>e</i>?<b>false<b> : <b>true</b>.
2307 *
2308 * 12.20 Conditional: It is a static type warning if the type of <i>e<sub>1</s ub></i> may not be
2309 * assigned to bool.
2310 */
2311 static const StaticTypeWarningCode NON_BOOL_NEGATION_EXPRESSION = const Static TypeWarningCode.con1('NON_BOOL_NEGATION_EXPRESSION', 10, "Negation argument must have a static type of 'bool'");
2312
2313 /**
2314 * 15.8 Parameterized Types: It is a static type warning if <i>A<sub>i</sub>, 1 &lt;= i &lt;=
2315 * n</i> does not denote a type in the enclosing lexical scope.
2316 */
2317 static const StaticTypeWarningCode NON_TYPE_AS_TYPE_ARGUMENT = const StaticTyp eWarningCode.con1('NON_TYPE_AS_TYPE_ARGUMENT', 11, "The name '%s' is not a type and cannot be used as a parameterized type");
2318
2319 /**
2320 * 13.11 Return: It is a static type warning if the type of <i>e</i> may not b e assigned to the
2321 * declared return type of the immediately enclosing function.
2322 *
2323 * @param actualReturnType the return type as declared in the return statement
2324 * @param expectedReturnType the expected return type as defined by the method
2325 * @param methodName the name of the method
2326 */
2327 static const StaticTypeWarningCode RETURN_OF_INVALID_TYPE = const StaticTypeWa rningCode.con1('RETURN_OF_INVALID_TYPE', 12, "The return type '%s' is not a '%s' , as defined by the method '%s'");
2328
2329 /**
2330 * 12.11 Instance Creation: It is a static type warning if any of the type arg uments to a
2331 * constructor of a generic type <i>G</i> invoked by a new expression or a con stant object
2332 * expression are not subtypes of the bounds of the corresponding formal type parameters of
2333 * <i>G</i>.
2334 *
2335 * 15.8 Parameterized Types: If <i>S</i> is the static type of a member <i>m</ i> of <i>G</i>, then
2336 * the static type of the member <i>m</i> of <i>G&lt;A<sub>1</sub>, &hellip;,
2337 * A<sub>n</sub>&gt;</i> is <i>[A<sub>1</sub>, &hellip;, A<sub>n</sub>/T<sub>1 </sub>, &hellip;,
2338 * T<sub>n</sub>]S</i> where <i>T<sub>1</sub>, &hellip;, T<sub>n</sub></i> are the formal type
2339 * parameters of <i>G</i>. Let <i>B<sub>i</sub></i> be the bounds of <i>T<sub> i</sub>, 1 &lt;= i
2340 * &lt;= n</i>. It is a static type warning if <i>A<sub>i</sub></i> is not a s ubtype of
2341 * <i>[A<sub>1</sub>, &hellip;, A<sub>n</sub>/T<sub>1</sub>, &hellip;,
2342 * T<sub>n</sub>]B<sub>i</sub>, 1 &lt;= i &lt;= n</i>.
2343 *
2344 * 7.6.2 Factories: It is a static type warning if any of the type arguments t o <i>k'</i> are not
2345 * subtypes of the bounds of the corresponding formal type parameters of type.
2346 *
2347 * @param boundedTypeName the name of the type used in the instance creation t hat should be
2348 * limited by the bound as specified in the class declaration
2349 * @param boundingTypeName the name of the bounding type
2350 * @see #TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND
2351 */
2352 static const StaticTypeWarningCode TYPE_ARGUMENT_NOT_MATCHING_BOUNDS = const S taticTypeWarningCode.con1('TYPE_ARGUMENT_NOT_MATCHING_BOUNDS', 13, "'%s' does no t extend '%s'");
2353
2354 /**
2355 * 10 Generics: It is a static type warning if a type parameter is a supertype of its upper bound.
2356 *
2357 * @param typeParameterName the name of the type parameter
2358 * @see #TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
2359 */
2360 static const StaticTypeWarningCode TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND = con st StaticTypeWarningCode.con1('TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND', 14, "'%s' cannot be a supertype of its upper bound");
2361
2362 /**
2363 * 12.15.3 Unqualified Invocation: If there exists a lexically visible declara tion named
2364 * <i>id</i>, let <i>f<sub>id</sub></i> be the innermost such declaration. The n: [skip].
2365 * Otherwise, <i>f<sub>id</sub></i> is considered equivalent to the ordinary m ethod invocation
2366 * <b>this</b>.<i>id</i>(<i>a<sub>1</sub></i>, ..., <i>a<sub>n</sub></i>, <i>x <sub>n+1</sub></i> :
2367 * <i>a<sub>n+1</sub></i>, ..., <i>x<sub>n+k</sub></i> : <i>a<sub>n+k</sub></i >).
2368 *
2369 * @param methodName the name of the method that is undefined
2370 */
2371 static const StaticTypeWarningCode UNDEFINED_FUNCTION = const StaticTypeWarnin gCode.con1('UNDEFINED_FUNCTION', 15, "The function '%s' is not defined");
2372
2373 /**
2374 * 12.17 Getter Invocation: Let <i>T</i> be the static type of <i>e</i>. It is a static type
2375 * warning if <i>T</i> does not have a getter named <i>m</i>.
2376 * 2197 *
2377 * @param getterName the name of the getter 2198 * @param getterName the name of the getter
2378 * @param enclosingType the name of the enclosing type where the getter is bei ng looked for 2199 * @param enclosingType the name of the enclosing type where the getter is bei ng looked for
2379 */ 2200 * @see StaticTypeWarningCode#UNDEFINED_GETTER
2380 static const StaticTypeWarningCode UNDEFINED_GETTER = const StaticTypeWarningC ode.con1('UNDEFINED_GETTER', 16, "There is no such getter '%s' in '%s'"); 2201 * @see StaticWarningCode#UNDEFINED_GETTER
2381 2202 */
2382 /** 2203 static const HintCode UNDEFINED_GETTER = const HintCode.con1('UNDEFINED_GETTER ', 19, "There is no such getter '%s' in '%s'");
2383 * 12.15.1 Ordinary Invocation: Let <i>T</i> be the static type of <i>o</i>. I t is a static type 2204
2384 * warning if <i>T</i> does not have an accessible instance member named <i>m< /i>. 2205 /**
2206 * This hint is generated anywhere where the [StaticTypeWarningCode#UNDEFINED_ METHOD] would
2207 * have been generated, if we used propagated information for the warnings.
2385 * 2208 *
2386 * @param methodName the name of the method that is undefined 2209 * @param methodName the name of the method that is undefined
2387 * @param typeName the resolved type name that the method lookup is happening on 2210 * @param typeName the resolved type name that the method lookup is happening on
2388 */ 2211 * @see StaticTypeWarningCode#UNDEFINED_METHOD
2389 static const StaticTypeWarningCode UNDEFINED_METHOD = const StaticTypeWarningC ode.con1('UNDEFINED_METHOD', 17, "The method '%s' is not defined for the class ' %s'"); 2212 */
2390 2213 static const HintCode UNDEFINED_METHOD = const HintCode.con1('UNDEFINED_METHOD ', 20, "The method '%s' is not defined for the class '%s'");
2391 /** 2214
2392 * 12.18 Assignment: Evaluation of an assignment of the form 2215 /**
2393 * <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] = <i>e<sub>3</sub></i> is equiva lent to the 2216 * This hint is generated anywhere where the [StaticTypeWarningCode#UNDEFINED_ OPERATOR]
2394 * evaluation of the expression (a, i, e){a.[]=(i, e); return e;} (<i>e<sub>1< /sub></i>, 2217 * would have been generated, if we used propagated information for the warnin gs.
2395 * <i>e<sub>2</sub></i>, <i>e<sub>2</sub></i>).
2396 *
2397 * 12.29 Assignable Expressions: An assignable expression of the form
2398 * <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] is evaluated as a method invocat ion of the operator
2399 * method [] on <i>e<sub>1</sub></i> with argument <i>e<sub>2</sub></i>.
2400 *
2401 * 12.15.1 Ordinary Invocation: Let <i>T</i> be the static type of <i>o</i>. I t is a static type
2402 * warning if <i>T</i> does not have an accessible instance member named <i>m< /i>.
2403 * 2218 *
2404 * @param operator the name of the operator 2219 * @param operator the name of the operator
2405 * @param enclosingType the name of the enclosing type where the operator is b eing looked for 2220 * @param enclosingType the name of the enclosing type where the operator is b eing looked for
2406 */ 2221 * @see StaticTypeWarningCode#UNDEFINED_OPERATOR
2407 static const StaticTypeWarningCode UNDEFINED_OPERATOR = const StaticTypeWarnin gCode.con1('UNDEFINED_OPERATOR', 18, "There is no such operator '%s' in '%s'"); 2222 */
2408 2223 static const HintCode UNDEFINED_OPERATOR = const HintCode.con1('UNDEFINED_OPER ATOR', 21, "There is no such operator '%s' in '%s'");
2409 /** 2224
2410 * 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>. It is a static type 2225 /**
2411 * warning if <i>T</i> does not have an accessible instance setter named <i>v= </i>. 2226 * This hint is generated anywhere where the [StaticTypeWarningCode#UNDEFINED_ SETTER] or
2227 * [StaticWarningCode#UNDEFINED_SETTER] would have been generated, if we used propagated
2228 * information for the warnings.
2412 * 2229 *
2413 * @param setterName the name of the setter 2230 * @param setterName the name of the setter
2414 * @param enclosingType the name of the enclosing type where the setter is bei ng looked for 2231 * @param enclosingType the name of the enclosing type where the setter is bei ng looked for
2415 * @see #INACCESSIBLE_SETTER 2232 * @see StaticTypeWarningCode#UNDEFINED_SETTER
2416 */ 2233 * @see StaticWarningCode#UNDEFINED_SETTER
2417 static const StaticTypeWarningCode UNDEFINED_SETTER = const StaticTypeWarningC ode.con1('UNDEFINED_SETTER', 19, "There is no such setter '%s' in '%s'"); 2234 */
2418 2235 static const HintCode UNDEFINED_SETTER = const HintCode.con1('UNDEFINED_SETTER ', 22, "There is no such setter '%s' in '%s'");
2419 /** 2236
2420 * 12.15.4 Super Invocation: A super method invocation <i>i</i> has the form 2237 /**
2421 * <i>super.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub>: a<sub>n +1</sub>, &hellip; 2238 * Unnecessary cast.
2422 * x<sub>n+k</sub>: a<sub>n+k</sub>)</i>. It is a static type warning if <i>S< /i> does not have an 2239 */
2423 * accessible instance member named <i>m</i>. 2240 static const HintCode UNNECESSARY_CAST = const HintCode.con1('UNNECESSARY_CAST ', 23, "Unnecessary cast");
2424 * 2241
2425 * @param methodName the name of the method that is undefined 2242 /**
2426 * @param typeName the resolved type name that the method lookup is happening on 2243 * Unnecessary type checks, the result is always true.
2427 */ 2244 */
2428 static const StaticTypeWarningCode UNDEFINED_SUPER_METHOD = const StaticTypeWa rningCode.con1('UNDEFINED_SUPER_METHOD', 20, "There is no such method '%s' in '% s'"); 2245 static const HintCode UNNECESSARY_TYPE_CHECK_FALSE = const HintCode.con1('UNNE CESSARY_TYPE_CHECK_FALSE', 24, "Unnecessary type check, the result is always fal se");
2429 2246
2430 /** 2247 /**
2431 * 12.15.1 Ordinary Invocation: It is a static type warning if <i>T</i> does n ot have an 2248 * Unnecessary type checks, the result is always false.
2432 * accessible (3.2) instance member named <i>m</i>. 2249 */
2433 * 2250 static const HintCode UNNECESSARY_TYPE_CHECK_TRUE = const HintCode.con1('UNNEC ESSARY_TYPE_CHECK_TRUE', 25, "Unnecessary type check, the result is always true" );
2434 * This is a specialization of [INSTANCE_ACCESS_TO_STATIC_MEMBER] that is used when we are 2251
2435 * able to find the name defined in a supertype. It exists to provide a more i nformative error 2252 /**
2436 * message. 2253 * Unused imports are imports which are never not used.
2437 */ 2254 */
2438 static const StaticTypeWarningCode UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_M EMBER = const StaticTypeWarningCode.con1('UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STA TIC_MEMBER', 21, "Static members from supertypes must be qualified by the name o f the defining type"); 2255 static const HintCode UNUSED_IMPORT = const HintCode.con1('UNUSED_IMPORT', 26, "Unused import");
2439 2256
2440 /** 2257 /**
2441 * 15.8 Parameterized Types: It is a static type warning if <i>G</i> is not a generic type with 2258 * Hint for cases where the source expects a method or function to return a no n-void result, but
2442 * exactly <i>n</i> type parameters. 2259 * the method or function signature returns void.
2443 * 2260 *
2444 * @param typeName the name of the type being referenced (<i>G</i>) 2261 * @param name the name of the method or function that returns void
2445 * @param parameterCount the number of type parameters that were declared 2262 */
2446 * @param argumentCount the number of type arguments provided 2263 static const HintCode USE_OF_VOID_RESULT = const HintCode.con1('USE_OF_VOID_RE SULT', 27, "The result of '%s' is being used, even though it is declared to be ' void'");
2447 * @see CompileTimeErrorCode#CONST_WITH_INVALID_TYPE_PARAMETERS 2264
2448 * @see CompileTimeErrorCode#NEW_WITH_INVALID_TYPE_PARAMETERS 2265 static const List<HintCode> values = const [
2449 */ 2266 ARGUMENT_TYPE_NOT_ASSIGNABLE,
2450 static const StaticTypeWarningCode WRONG_NUMBER_OF_TYPE_ARGUMENTS = const Stat icTypeWarningCode.con1('WRONG_NUMBER_OF_TYPE_ARGUMENTS', 22, "The type '%s' is d eclared with %d type parameters, but %d type arguments were given"); 2267 DEAD_CODE,
2451 2268 DEAD_CODE_CATCH_FOLLOWING_CATCH,
2452 static const List<StaticTypeWarningCode> values = const [ 2269 DEAD_CODE_ON_CATCH_SUBTYPE,
2453 EXPECTED_ONE_LIST_TYPE_ARGUMENTS, 2270 DEPRECATED_MEMBER_USE,
2454 EXPECTED_TWO_MAP_TYPE_ARGUMENTS, 2271 DUPLICATE_IMPORT,
2455 INACCESSIBLE_SETTER, 2272 DIVISION_OPTIMIZATION,
2456 INCONSISTENT_METHOD_INHERITANCE, 2273 IS_DOUBLE,
2457 INSTANCE_ACCESS_TO_STATIC_MEMBER, 2274 IS_INT,
2275 IS_NOT_DOUBLE,
2276 IS_NOT_INT,
2458 INVALID_ASSIGNMENT, 2277 INVALID_ASSIGNMENT,
2459 INVOCATION_OF_NON_FUNCTION, 2278 MISSING_RETURN,
2460 INVOCATION_OF_NON_FUNCTION_EXPRESSION, 2279 OVERRIDE_ON_NON_OVERRIDING_GETTER,
2461 NON_BOOL_CONDITION, 2280 OVERRIDE_ON_NON_OVERRIDING_METHOD,
2462 NON_BOOL_EXPRESSION, 2281 OVERRIDE_ON_NON_OVERRIDING_SETTER,
2463 NON_BOOL_NEGATION_EXPRESSION, 2282 OVERRIDE_EQUALS_BUT_NOT_HASH_CODE,
2464 NON_TYPE_AS_TYPE_ARGUMENT, 2283 TYPE_CHECK_IS_NOT_NULL,
2465 RETURN_OF_INVALID_TYPE, 2284 TYPE_CHECK_IS_NULL,
2466 TYPE_ARGUMENT_NOT_MATCHING_BOUNDS,
2467 TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND,
2468 UNDEFINED_FUNCTION,
2469 UNDEFINED_GETTER, 2285 UNDEFINED_GETTER,
2470 UNDEFINED_METHOD, 2286 UNDEFINED_METHOD,
2471 UNDEFINED_OPERATOR, 2287 UNDEFINED_OPERATOR,
2472 UNDEFINED_SETTER, 2288 UNDEFINED_SETTER,
2473 UNDEFINED_SUPER_METHOD, 2289 UNNECESSARY_CAST,
2474 UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER, 2290 UNNECESSARY_TYPE_CHECK_FALSE,
2475 WRONG_NUMBER_OF_TYPE_ARGUMENTS]; 2291 UNNECESSARY_TYPE_CHECK_TRUE,
2292 UNUSED_IMPORT,
2293 USE_OF_VOID_RESULT];
2476 2294
2477 /** 2295 /**
2478 * The template used to create the message to be displayed for this error. 2296 * The template used to create the message to be displayed for this error.
2479 */ 2297 */
2480 final String message; 2298 final String message;
2481 2299
2482 /** 2300 /**
2483 * The template used to create the correction to be displayed for this error, or `null` if 2301 * The template used to create the correction to be displayed for this error, or `null` if
2484 * there is no correction information for this error. 2302 * there is no correction information for this error.
2485 */ 2303 */
2486 final String correction; 2304 final String correction;
2487 2305
2488 /** 2306 /**
2489 * Initialize a newly created error code to have the given message. 2307 * Initialize a newly created error code to have the given message.
2490 * 2308 *
2491 * @param message the message template used to create the message to be displa yed for the error 2309 * @param message the message template used to create the message to be displa yed for the error
2492 */ 2310 */
2493 const StaticTypeWarningCode.con1(String name, int ordinal, String message) : t his.con2(name, ordinal, message, null); 2311 const HintCode.con1(String name, int ordinal, String message) : this.con2(name , ordinal, message, null);
2494 2312
2495 /** 2313 /**
2496 * Initialize a newly created error code to have the given message and correct ion. 2314 * Initialize a newly created error code to have the given message and correct ion.
2497 * 2315 *
2498 * @param message the template used to create the message to be displayed for the error 2316 * @param message the template used to create the message to be displayed for the error
2499 * @param correction the template used to create the correction to be displaye d for the error 2317 * @param correction the template used to create the correction to be displaye d for the error
2500 */ 2318 */
2501 const StaticTypeWarningCode.con2(String name, int ordinal, this.message, this. correction) : super(name, ordinal); 2319 const HintCode.con2(String name, int ordinal, this.message, this.correction) : super(name, ordinal);
2502 2320
2503 @override 2321 @override
2504 ErrorSeverity get errorSeverity => ErrorType.STATIC_TYPE_WARNING.severity; 2322 ErrorSeverity get errorSeverity => ErrorType.HINT.severity;
2505 2323
2506 @override 2324 @override
2507 ErrorType get type => ErrorType.STATIC_TYPE_WARNING; 2325 ErrorType get type => ErrorType.HINT;
2508 } 2326 }
2509 2327
2510 /** 2328 /**
2511 * The enumeration `AngularCode` defines Angular specific problems. 2329 * The enumeration `HtmlWarningCode` defines the error codes used for warnings i n HTML files.
2330 * The convention for this class is for the name of the error code to indicate t he problem that
2331 * caused the error to be generated and for the error message to explain what is wrong and, when
2332 * appropriate, how the problem can be corrected.
2512 */ 2333 */
2513 class AngularCode extends Enum<AngularCode> implements ErrorCode { 2334 class HtmlWarningCode extends Enum<HtmlWarningCode> implements ErrorCode {
2514 static const AngularCode CANNOT_PARSE_SELECTOR = const AngularCode('CANNOT_PAR SE_SELECTOR', 0, "The selector '%s' cannot be parsed"); 2335 /**
2336 * An error code indicating that the value of the 'src' attribute of a Dart sc ript tag is not a
2337 * valid URI.
2338 *
2339 * @param uri the URI that is invalid
2340 */
2341 static const HtmlWarningCode INVALID_URI = const HtmlWarningCode.con1('INVALID _URI', 0, "Invalid URI syntax: '%s'");
2515 2342
2516 static const AngularCode INVALID_FORMATTER_NAME = const AngularCode('INVALID_F ORMATTER_NAME', 1, "Formatter name must be a simple identifier"); 2343 /**
2344 * An error code indicating that the value of the 'src' attribute of a Dart sc ript tag references
2345 * a file that does not exist.
2346 *
2347 * @param uri the URI pointing to a non-existent file
2348 */
2349 static const HtmlWarningCode URI_DOES_NOT_EXIST = const HtmlWarningCode.con1(' URI_DOES_NOT_EXIST', 1, "Target of URI does not exist: '%s'");
2517 2350
2518 static const AngularCode INVALID_PROPERTY_KIND = const AngularCode('INVALID_PR OPERTY_KIND', 2, "Unknown property binding kind '%s', use one of the '@', '=>', '=>!' or '<=>'"); 2351 static const List<HtmlWarningCode> values = const [INVALID_URI, URI_DOES_NOT_E XIST];
2519
2520 static const AngularCode INVALID_PROPERTY_FIELD = const AngularCode('INVALID_P ROPERTY_FIELD', 3, "Unknown property field '%s'");
2521
2522 static const AngularCode INVALID_PROPERTY_MAP = const AngularCode('INVALID_PRO PERTY_MAP', 4, "Argument 'map' must be a constant map literal");
2523
2524 static const AngularCode INVALID_PROPERTY_NAME = const AngularCode('INVALID_PR OPERTY_NAME', 5, "Property name must be a string literal");
2525
2526 static const AngularCode INVALID_PROPERTY_SPEC = const AngularCode('INVALID_PR OPERTY_SPEC', 6, "Property binding specification must be a string literal");
2527
2528 static const AngularCode INVALID_REPEAT_SYNTAX = const AngularCode('INVALID_RE PEAT_SYNTAX', 7, "Expected statement in form '_item_ in _collection_ [tracked by _id_]'");
2529
2530 static const AngularCode INVALID_REPEAT_ITEM_SYNTAX = const AngularCode('INVAL ID_REPEAT_ITEM_SYNTAX', 8, "Item must by identifier or in '(_key_, _value_)' pai r.");
2531
2532 static const AngularCode INVALID_URI = const AngularCode('INVALID_URI', 9, "In valid URI syntax: '%s'");
2533
2534 static const AngularCode MISSING_FORMATTER_COLON = const AngularCode('MISSING_ FORMATTER_COLON', 10, "Missing ':' before formatter argument");
2535
2536 static const AngularCode MISSING_NAME = const AngularCode('MISSING_NAME', 11, "Argument 'name' must be provided");
2537
2538 static const AngularCode MISSING_PUBLISH_AS = const AngularCode('MISSING_PUBLI SH_AS', 12, "Argument 'publishAs' must be provided");
2539
2540 static const AngularCode MISSING_SELECTOR = const AngularCode('MISSING_SELECTO R', 13, "Argument 'selector' must be provided");
2541
2542 static const AngularCode URI_DOES_NOT_EXIST = const AngularCode('URI_DOES_NOT_ EXIST', 14, "Target of URI does not exist: '%s'");
2543
2544 static const List<AngularCode> values = const [
2545 CANNOT_PARSE_SELECTOR,
2546 INVALID_FORMATTER_NAME,
2547 INVALID_PROPERTY_KIND,
2548 INVALID_PROPERTY_FIELD,
2549 INVALID_PROPERTY_MAP,
2550 INVALID_PROPERTY_NAME,
2551 INVALID_PROPERTY_SPEC,
2552 INVALID_REPEAT_SYNTAX,
2553 INVALID_REPEAT_ITEM_SYNTAX,
2554 INVALID_URI,
2555 MISSING_FORMATTER_COLON,
2556 MISSING_NAME,
2557 MISSING_PUBLISH_AS,
2558 MISSING_SELECTOR,
2559 URI_DOES_NOT_EXIST];
2560 2352
2561 /** 2353 /**
2562 * The template used to create the message to be displayed for this error. 2354 * The template used to create the message to be displayed for this error.
2355 */
2356 final String message;
2357
2358 /**
2359 * The template used to create the correction to be displayed for this error, or `null` if
2360 * there is no correction information for this error.
2361 */
2362 final String correction;
2363
2364 /**
2365 * Initialize a newly created error code to have the given message.
2366 *
2367 * @param message the message template used to create the message to be displa yed for the error
2368 */
2369 const HtmlWarningCode.con1(String name, int ordinal, String message) : this.co n2(name, ordinal, message, null);
2370
2371 /**
2372 * Initialize a newly created error code to have the given message and correct ion.
2373 *
2374 * @param message the template used to create the message to be displayed for the error
2375 * @param correction the template used to create the correction to be displaye d for the error
2376 */
2377 const HtmlWarningCode.con2(String name, int ordinal, this.message, this.correc tion) : super(name, ordinal);
2378
2379 @override
2380 ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
2381
2382 @override
2383 ErrorType get type => ErrorType.STATIC_WARNING;
2384 }
2385
2386 /**
2387 * The enumeration `PolymerCode` defines Polymer specific problems.
2388 */
2389 class PolymerCode extends Enum<PolymerCode> implements ErrorCode {
2390 static const PolymerCode ATTRIBUTE_FIELD_NOT_PUBLISHED = const PolymerCode('AT TRIBUTE_FIELD_NOT_PUBLISHED', 0, "Field '%s' in '%s' must be @published");
2391
2392 static const PolymerCode DUPLICATE_ATTRIBUTE_DEFINITION = const PolymerCode('D UPLICATE_ATTRIBUTE_DEFINITION', 1, "The attribute '%s' is already defined");
2393
2394 static const PolymerCode EMPTY_ATTRIBUTES = const PolymerCode('EMPTY_ATTRIBUTE S', 2, "Empty 'attributes' attribute is useless");
2395
2396 static const PolymerCode INVALID_ATTRIBUTE_NAME = const PolymerCode('INVALID_A TTRIBUTE_NAME', 3, "'%s' is not a valid name for a custom element attribute");
2397
2398 static const PolymerCode INVALID_TAG_NAME = const PolymerCode('INVALID_TAG_NAM E', 4, "'%s' is not a valid name for a custom element");
2399
2400 static const PolymerCode MISSING_TAG_NAME = const PolymerCode('MISSING_TAG_NAM E', 5, "Missing tag name of the custom element. Please include an attribute like name='your-tag-name'");
2401
2402 static const PolymerCode UNDEFINED_ATTRIBUTE_FIELD = const PolymerCode('UNDEFI NED_ATTRIBUTE_FIELD', 6, "There is no such field '%s' in '%s'");
2403
2404 static const List<PolymerCode> values = const [
2405 ATTRIBUTE_FIELD_NOT_PUBLISHED,
2406 DUPLICATE_ATTRIBUTE_DEFINITION,
2407 EMPTY_ATTRIBUTES,
2408 INVALID_ATTRIBUTE_NAME,
2409 INVALID_TAG_NAME,
2410 MISSING_TAG_NAME,
2411 UNDEFINED_ATTRIBUTE_FIELD];
2412
2413 /**
2414 * The template used to create the message to be displayed for this error.
2563 */ 2415 */
2564 final String message; 2416 final String message;
2565 2417
2566 /** 2418 /**
2567 * Initialize a newly created error code to have the given message. 2419 * Initialize a newly created error code to have the given message.
2568 * 2420 *
2569 * @param message the message template used to create the message to be displa yed for the error 2421 * @param message the message template used to create the message to be displa yed for the error
2570 */ 2422 */
2571 const AngularCode(String name, int ordinal, this.message) : super(name, ordina l); 2423 const PolymerCode(String name, int ordinal, this.message) : super(name, ordina l);
2572 2424
2573 @override 2425 @override
2574 String get correction => null; 2426 String get correction => null;
2575 2427
2576 @override 2428 @override
2577 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; 2429 ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
2578 2430
2579 @override 2431 @override
2580 ErrorType get type => ErrorType.ANGULAR; 2432 ErrorType get type => ErrorType.POLYMER;
2581 } 2433 }
2582 2434
2583 /** 2435 /**
2584 * The enumeration `HintCode` defines the hints and coding recommendations for b est practices 2436 * The enumeration `PubSuggestionCode` defines the suggestions used for reportin g deviations
2585 * which are not mentioned in the Dart Language Specification. 2437 * from pub best practices. The convention for this class is for the name of the bad practice to
2438 * indicate the problem that caused the suggestion to be generated and for the m essage to explain
2439 * what is wrong and, when appropriate, how the situation can be corrected.
2586 */ 2440 */
2587 class HintCode extends Enum<HintCode> implements ErrorCode { 2441 class PubSuggestionCode extends Enum<PubSuggestionCode> implements ErrorCode {
2588 /** 2442 /**
2589 * This hint is generated anywhere where the 2443 * It is a bad practice for a source file in a package "lib" directory hierarc hy to traverse
2590 * [StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE] would have been generated, if we used 2444 * outside that directory hierarchy. For example, a source file in the "lib" d irectory should not
2591 * propagated information for the warnings. 2445 * contain a directive such as `import '../web/some.dart'` which references a file outside
2592 * 2446 * the lib directory.
2593 * @param actualType the name of the actual argument type 2447 */
2594 * @param expectedType the name of the expected type 2448 static const PubSuggestionCode FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE = const PubSuggestionCode.con1('FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE', 0, "A file in the 'lib' directory hierarchy should not reference a file outside that hierarchy");
2595 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE 2449
2596 */ 2450 /**
2597 static const HintCode ARGUMENT_TYPE_NOT_ASSIGNABLE = const HintCode.con1('ARGU MENT_TYPE_NOT_ASSIGNABLE', 0, "The argument type '%s' cannot be assigned to the parameter type '%s'"); 2451 * It is a bad practice for a source file ouside a package "lib" directory hie rarchy to traverse
2598 2452 * into that directory hierarchy. For example, a source file in the "web" dire ctory should not
2599 /** 2453 * contain a directive such as `import '../lib/some.dart'` which references a file inside
2600 * Dead code is code that is never reached, this can happen for instance if a statement follows a 2454 * the lib directory.
2601 * return statement. 2455 */
2602 */ 2456 static const PubSuggestionCode FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE = const PubSuggestionCode.con1('FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE', 1, "A file outside the 'lib' directory hierarchy should not reference a file in side that hierarchy. Use a package: reference instead.");
2603 static const HintCode DEAD_CODE = const HintCode.con1('DEAD_CODE', 1, "Dead co de"); 2457
2604 2458 /**
2605 /** 2459 * It is a bad practice for a package import to reference anything outside the given package, or
2606 * Dead code is code that is never reached. This case covers cases where the u ser has catch 2460 * more generally, it is bad practice for a package import to contain a "..". For example, a
2607 * clauses after `catch (e)` or `on Object catch (e)`. 2461 * source file should not contain a directive such as `import 'package:foo/../ some.dart'`.
2608 */ 2462 */
2609 static const HintCode DEAD_CODE_CATCH_FOLLOWING_CATCH = const HintCode.con1('D EAD_CODE_CATCH_FOLLOWING_CATCH', 2, "Dead code, catch clauses after a 'catch (e) ' or an 'on Object catch (e)' are never reached"); 2463 static const PubSuggestionCode PACKAGE_IMPORT_CONTAINS_DOT_DOT = const PubSugg estionCode.con1('PACKAGE_IMPORT_CONTAINS_DOT_DOT', 2, "A package import should n ot contain '..'");
2610 2464
2611 /** 2465 static const List<PubSuggestionCode> values = const [
2612 * Dead code is code that is never reached. This case covers cases where the u ser has an on-catch 2466 FILE_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE,
2613 * clause such as `on A catch (e)`, where a supertype of `A` was already caugh t. 2467 FILE_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE,
2614 * 2468 PACKAGE_IMPORT_CONTAINS_DOT_DOT];
2615 * @param subtypeName name of the subtype 2469
2616 * @param supertypeName name of the supertype 2470 /**
2617 */ 2471 * The template used to create the message to be displayed for this error.
2618 static const HintCode DEAD_CODE_ON_CATCH_SUBTYPE = const HintCode.con1('DEAD_C ODE_ON_CATCH_SUBTYPE', 3, "Dead code, this on-catch block will never be executed since '%s' is a subtype of '%s'"); 2472 */
2619 2473 final String message;
2620 /** 2474
2621 * Deprecated members should not be invoked or used. 2475 /**
2622 * 2476 * The template used to create the correction to be displayed for this error, or `null` if
2623 * @param memberName the name of the member 2477 * there is no correction information for this error.
2624 */ 2478 */
2625 static const HintCode DEPRECATED_MEMBER_USE = const HintCode.con1('DEPRECATED_ MEMBER_USE', 4, "'%s' is deprecated"); 2479 final String correction;
2626 2480
2627 /** 2481 /**
2628 * Duplicate imports. 2482 * Initialize a newly created error code to have the given message.
2629 */ 2483 *
2630 static const HintCode DUPLICATE_IMPORT = const HintCode.con1('DUPLICATE_IMPORT ', 5, "Duplicate import"); 2484 * @param message the message template used to create the message to be displa yed for the error
2631 2485 */
2632 /** 2486 const PubSuggestionCode.con1(String name, int ordinal, String message) : this. con2(name, ordinal, message, null);
2633 * Hint to use the ~/ operator. 2487
2634 */ 2488 /**
2635 static const HintCode DIVISION_OPTIMIZATION = const HintCode.con1('DIVISION_OP TIMIZATION', 6, "The operator x ~/ y is more efficient than (x / y).toInt()"); 2489 * Initialize a newly created error code to have the given message and correct ion.
2636 2490 *
2637 /** 2491 * @param message the template used to create the message to be displayed for the error
2638 * Hint for the `x is double` type checks. 2492 * @param correction the template used to create the correction to be displaye d for the error
2639 */ 2493 */
2640 static const HintCode IS_DOUBLE = const HintCode.con1('IS_DOUBLE', 7, "When co mpiled to JS, this test might return true when the left hand side is an int"); 2494 const PubSuggestionCode.con2(String name, int ordinal, this.message, this.corr ection) : super(name, ordinal);
2641 2495
2642 /** 2496 @override
2643 * Hint for the `x is int` type checks. 2497 ErrorSeverity get errorSeverity => ErrorType.PUB_SUGGESTION.severity;
2644 */ 2498
2645 static const HintCode IS_INT = const HintCode.con1('IS_INT', 8, "When compiled to JS, this test might return true when the left hand side is a double"); 2499 @override
2646 2500 ErrorType get type => ErrorType.PUB_SUGGESTION;
2647 /** 2501 }
2648 * Hint for the `x is! double` type checks. 2502
2649 */ 2503 /**
2650 static const HintCode IS_NOT_DOUBLE = const HintCode.con1('IS_NOT_DOUBLE', 9, "When compiled to JS, this test might return false when the left hand side is an int"); 2504 * The enumeration `StaticTypeWarningCode` defines the error codes used for stat ic type
2651 2505 * warnings. The convention for this class is for the name of the error code to indicate the problem
2652 /** 2506 * that caused the error to be generated and for the error message to explain wh at is wrong and,
2653 * Hint for the `x is! int` type checks. 2507 * when appropriate, how the problem can be corrected.
2654 */ 2508 */
2655 static const HintCode IS_NOT_INT = const HintCode.con1('IS_NOT_INT', 10, "When compiled to JS, this test might return false when the left hand side is a doubl e"); 2509 class StaticTypeWarningCode extends Enum<StaticTypeWarningCode> implements Error Code {
2656 2510 /**
2657 /** 2511 * 12.7 Lists: A fresh instance (7.6.1) <i>a</i>, of size <i>n</i>, whose clas s implements the
2658 * This hint is generated anywhere where the [StaticTypeWarningCode#INVALID_AS SIGNMENT] 2512 * built-in class <i>List&lt;E></i> is allocated.
2659 * would have been generated, if we used propagated information for the warnin gs. 2513 *
2514 * @param numTypeArgument the number of provided type arguments
2515 */
2516 static const StaticTypeWarningCode EXPECTED_ONE_LIST_TYPE_ARGUMENTS = const St aticTypeWarningCode.con1('EXPECTED_ONE_LIST_TYPE_ARGUMENTS', 0, "List literal re quires exactly one type arguments or none, but %d found");
2517
2518 /**
2519 * 12.8 Maps: A fresh instance (7.6.1) <i>m</i>, of size <i>n</i>, whose class implements the
2520 * built-in class <i>Map&lt;K, V></i> is allocated.
2521 *
2522 * @param numTypeArgument the number of provided type arguments
2523 */
2524 static const StaticTypeWarningCode EXPECTED_TWO_MAP_TYPE_ARGUMENTS = const Sta ticTypeWarningCode.con1('EXPECTED_TWO_MAP_TYPE_ARGUMENTS', 1, "Map literal requi res exactly two type arguments or none, but %d found");
2525
2526 /**
2527 * 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>. It is a static type
2528 * warning if <i>T</i> does not have an accessible instance setter named <i>v= </i>.
2529 *
2530 * @see #UNDEFINED_SETTER
2531 */
2532 static const StaticTypeWarningCode INACCESSIBLE_SETTER = const StaticTypeWarni ngCode.con1('INACCESSIBLE_SETTER', 2, "");
2533
2534 /**
2535 * 8.1.1 Inheritance and Overriding: However, if the above rules would cause m ultiple members
2536 * <i>m<sub>1</sub>, &hellip;, m<sub>k</sub></i> with the same name <i>n</i> t hat would be
2537 * inherited (because identically named members existed in several superinterf aces) then at most
2538 * one member is inherited.
2539 *
2540 * If the static types <i>T<sub>1</sub>, &hellip;, T<sub>k</sub></i> of the me mbers
2541 * <i>m<sub>1</sub>, &hellip;, m<sub>k</sub></i> are not identical, then there must be a member
2542 * <i>m<sub>x</sub></i> such that <i>T<sub>x</sub> &lt;: T<sub>i</sub>, 1 &lt; = x &lt;= k</i> for
2543 * all <i>i, 1 &lt;= i &lt;= k</i>, or a static type warning occurs. The membe r that is inherited
2544 * is <i>m<sub>x</sub></i>, if it exists; otherwise:
2545 * * Let <i>numberOfPositionals</i>(<i>f</i>) denote the number of positional parameters of a
2546 * function <i>f</i>, and let <i>numberOfRequiredParams</i>(<i>f</i>) denote t he number of
2547 * required parameters of a function <i>f</i>. Furthermore, let <i>s</i> denot e the set of all
2548 * named parameters of the <i>m<sub>1</sub>, &hellip;, m<sub>k</sub></i>. Then let
2549 * * <i>h = max(numberOfPositionals(m<sub>i</sub>)),</i>
2550 * * <i>r = min(numberOfRequiredParams(m<sub>i</sub>)), for all <i>i</i>, 1 <= i <= k.</i>
2551 * If <i>r <= h</i> then <i>I</i> has a method named <i>n</i>, with <i>r</i> r equired parameters
2552 * of type <b>dynamic</b>, <i>h</i> positional parameters of type <b>dynamic</ b>, named parameters
2553 * <i>s</i> of type <b>dynamic</b> and return type <b>dynamic</b>.
2554 * * Otherwise none of the members <i>m<sub>1</sub>, &hellip;, m<sub>k</sub></ i> is inherited.
2555 */
2556 static const StaticTypeWarningCode INCONSISTENT_METHOD_INHERITANCE = const Sta ticTypeWarningCode.con1('INCONSISTENT_METHOD_INHERITANCE', 3, "'%s' is inherited by at least two interfaces inconsistently, from %s");
2557
2558 /**
2559 * 12.15.1 Ordinary Invocation: It is a static type warning if <i>T</i> does n ot have an
2560 * accessible (3.2) instance member named <i>m</i>.
2561 *
2562 * @param memberName the name of the static member
2563 * @see UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER
2564 */
2565 static const StaticTypeWarningCode INSTANCE_ACCESS_TO_STATIC_MEMBER = const St aticTypeWarningCode.con1('INSTANCE_ACCESS_TO_STATIC_MEMBER', 4, "Static member ' %s' cannot be accessed using instance access");
2566
2567 /**
2568 * 12.18 Assignment: It is a static type warning if the static type of <i>e</i > may not be
2569 * assigned to the static type of <i>v</i>. The static type of the expression <i>v = e</i> is the
2570 * static type of <i>e</i>.
2571 *
2572 * 12.18 Assignment: It is a static type warning if the static type of <i>e</i > may not be
2573 * assigned to the static type of <i>C.v</i>. The static type of the expressio n <i>C.v = e</i> is
2574 * the static type of <i>e</i>.
2575 *
2576 * 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>. It is a static type
2577 * warning if the static type of <i>e<sub>2</sub></i> may not be assigned to < i>T</i>.
2660 * 2578 *
2661 * @param rhsTypeName the name of the right hand side type 2579 * @param rhsTypeName the name of the right hand side type
2662 * @param lhsTypeName the name of the left hand side type 2580 * @param lhsTypeName the name of the left hand side type
2663 * @see StaticTypeWarningCode#INVALID_ASSIGNMENT 2581 */
2664 */ 2582 static const StaticTypeWarningCode INVALID_ASSIGNMENT = const StaticTypeWarnin gCode.con1('INVALID_ASSIGNMENT', 5, "A value of type '%s' cannot be assigned to a variable of type '%s'");
2665 static const HintCode INVALID_ASSIGNMENT = const HintCode.con1('INVALID_ASSIGN MENT', 11, "A value of type '%s' cannot be assigned to a variable of type '%s'") ; 2583
2666 2584 /**
2667 /** 2585 * 12.15.1 Ordinary Invocation: An ordinary method invocation <i>i</i> has the form
2668 * Generate a hint for methods or functions that have a return type, but do no t have a non-void 2586 * <i>o.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub>: a<sub>n+1</ sub>, &hellip;
2669 * return statement on all branches. At the end of methods or functions with n o return, Dart 2587 * x<sub>n+k</sub>: a<sub>n+k</sub>)</i>.
2670 * implicitly returns `null`, avoiding these implicit returns is considered a best practice. 2588 *
2671 * 2589 * Let <i>T</i> be the static type of <i>o</i>. It is a static type warning if <i>T</i> does not
2672 * @param returnType the name of the declared return type 2590 * have an accessible instance member named <i>m</i>. If <i>T.m</i> exists, it is a static warning
2673 */ 2591 * if the type <i>F</i> of <i>T.m</i> may not be assigned to a function type. If <i>T.m</i> does
2674 static const HintCode MISSING_RETURN = const HintCode.con2('MISSING_RETURN', 1 2, "This function declares a return type of '%s', but does not end with a return statement", "Either add a return statement or change the return type to 'void'" ); 2592 * not exist, or if <i>F</i> is not a function type, the static type of <i>i</ i> is dynamic.
2675 2593 *
2676 /** 2594 * 12.15.3 Static Invocation: It is a static type warning if the type <i>F</i> of <i>C.m</i> may
2677 * A getter with the override annotation does not override an existing getter. 2595 * not be assigned to a function type.
2678 */ 2596 *
2679 static const HintCode OVERRIDE_ON_NON_OVERRIDING_GETTER = const HintCode.con1( 'OVERRIDE_ON_NON_OVERRIDING_GETTER', 13, "Getter does not override an inherited getter"); 2597 * 12.15.4 Super Invocation: A super method invocation <i>i</i> has the form
2680 2598 * <i>super.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub>: a<sub>n +1</sub>, &hellip;
2681 /** 2599 * x<sub>n+k</sub>: a<sub>n+k</sub>)</i>. If <i>S.m</i> exists, it is a static warning if the type
2682 * A method with the override annotation does not override an existing method. 2600 * <i>F</i> of <i>S.m</i> may not be assigned to a function type.
2683 */ 2601 *
2684 static const HintCode OVERRIDE_ON_NON_OVERRIDING_METHOD = const HintCode.con1( 'OVERRIDE_ON_NON_OVERRIDING_METHOD', 14, "Method does not override an inherited method"); 2602 * @param nonFunctionIdentifier the name of the identifier that is not a funct ion type
2685 2603 */
2686 /** 2604 static const StaticTypeWarningCode INVOCATION_OF_NON_FUNCTION = const StaticTy peWarningCode.con1('INVOCATION_OF_NON_FUNCTION', 6, "'%s' is not a method");
2687 * A setter with the override annotation does not override an existing setter. 2605
2688 */ 2606 /**
2689 static const HintCode OVERRIDE_ON_NON_OVERRIDING_SETTER = const HintCode.con1( 'OVERRIDE_ON_NON_OVERRIDING_SETTER', 15, "Setter does not override an inherited setter"); 2607 * 12.14.4 Function Expression Invocation: A function expression invocation <i >i</i> has the form
2690 2608 * <i>e<sub>f</sub>(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub>: a <sub>n+1</sub>,
2691 /** 2609 * &hellip;, x<sub>n+k</sub>: a<sub>n+k</sub>)</i>, where <i>e<sub>f</sub></i> is an expression.
2692 * Hint for classes that override equals, but not hashCode. 2610 *
2693 * 2611 * It is a static type warning if the static type <i>F</i> of <i>e<sub>f</sub> </i> may not be
2694 * @param className the name of the current class 2612 * assigned to a function type.
2695 */ 2613 */
2696 static const HintCode OVERRIDE_EQUALS_BUT_NOT_HASH_CODE = const HintCode.con1( 'OVERRIDE_EQUALS_BUT_NOT_HASH_CODE', 16, "The class '%s' overrides 'operator==', but not 'get hashCode'"); 2614 static const StaticTypeWarningCode INVOCATION_OF_NON_FUNCTION_EXPRESSION = con st StaticTypeWarningCode.con1('INVOCATION_OF_NON_FUNCTION_EXPRESSION', 7, "Canno t invoke a non-function");
2697 2615
2698 /** 2616 /**
2699 * Type checks of the type `x is! Null` should be done with `x != null`. 2617 * 12.20 Conditional: It is a static type warning if the type of <i>e<sub>1</s ub></i> may not be
2700 */ 2618 * assigned to bool.
2701 static const HintCode TYPE_CHECK_IS_NOT_NULL = const HintCode.con1('TYPE_CHECK _IS_NOT_NULL', 17, "Tests for non-null should be done with '!= null'"); 2619 *
2702 2620 * 13.5 If: It is a static type warning if the type of the expression <i>b</i> may not be assigned
2703 /** 2621 * to bool.
2704 * Type checks of the type `x is Null` should be done with `x == null`. 2622 *
2705 */ 2623 * 13.7 While: It is a static type warning if the type of <i>e</i> may not be assigned to bool.
2706 static const HintCode TYPE_CHECK_IS_NULL = const HintCode.con1('TYPE_CHECK_IS_ NULL', 18, "Tests for null should be done with '== null'"); 2624 *
2707 2625 * 13.8 Do: It is a static type warning if the type of <i>e</i> cannot be assi gned to bool.
2708 /** 2626 */
2709 * This hint is generated anywhere where the [StaticTypeWarningCode#UNDEFINED_ GETTER] or 2627 static const StaticTypeWarningCode NON_BOOL_CONDITION = const StaticTypeWarnin gCode.con1('NON_BOOL_CONDITION', 8, "Conditions must have a static type of 'bool '");
2710 * [StaticWarningCode#UNDEFINED_GETTER] would have been generated, if we used propagated 2628
2711 * information for the warnings. 2629 /**
2630 * 13.15 Assert: It is a static type warning if the type of <i>e</i> may not b e assigned to either
2631 * bool or () &rarr; bool
2632 */
2633 static const StaticTypeWarningCode NON_BOOL_EXPRESSION = const StaticTypeWarni ngCode.con1('NON_BOOL_EXPRESSION', 9, "Assertions must be on either a 'bool' or '() -> bool'");
2634
2635 /**
2636 * 12.28 Unary Expressions: The expression !<i>e</i> is equivalent to the expr ession
2637 * <i>e</i>?<b>false<b> : <b>true</b>.
2638 *
2639 * 12.20 Conditional: It is a static type warning if the type of <i>e<sub>1</s ub></i> may not be
2640 * assigned to bool.
2641 */
2642 static const StaticTypeWarningCode NON_BOOL_NEGATION_EXPRESSION = const Static TypeWarningCode.con1('NON_BOOL_NEGATION_EXPRESSION', 10, "Negation argument must have a static type of 'bool'");
2643
2644 /**
2645 * 15.8 Parameterized Types: It is a static type warning if <i>A<sub>i</sub>, 1 &lt;= i &lt;=
2646 * n</i> does not denote a type in the enclosing lexical scope.
2647 */
2648 static const StaticTypeWarningCode NON_TYPE_AS_TYPE_ARGUMENT = const StaticTyp eWarningCode.con1('NON_TYPE_AS_TYPE_ARGUMENT', 11, "The name '%s' is not a type and cannot be used as a parameterized type");
2649
2650 /**
2651 * 13.11 Return: It is a static type warning if the type of <i>e</i> may not b e assigned to the
2652 * declared return type of the immediately enclosing function.
2653 *
2654 * @param actualReturnType the return type as declared in the return statement
2655 * @param expectedReturnType the expected return type as defined by the method
2656 * @param methodName the name of the method
2657 */
2658 static const StaticTypeWarningCode RETURN_OF_INVALID_TYPE = const StaticTypeWa rningCode.con1('RETURN_OF_INVALID_TYPE', 12, "The return type '%s' is not a '%s' , as defined by the method '%s'");
2659
2660 /**
2661 * 12.11 Instance Creation: It is a static type warning if any of the type arg uments to a
2662 * constructor of a generic type <i>G</i> invoked by a new expression or a con stant object
2663 * expression are not subtypes of the bounds of the corresponding formal type parameters of
2664 * <i>G</i>.
2665 *
2666 * 15.8 Parameterized Types: If <i>S</i> is the static type of a member <i>m</ i> of <i>G</i>, then
2667 * the static type of the member <i>m</i> of <i>G&lt;A<sub>1</sub>, &hellip;,
2668 * A<sub>n</sub>&gt;</i> is <i>[A<sub>1</sub>, &hellip;, A<sub>n</sub>/T<sub>1 </sub>, &hellip;,
2669 * T<sub>n</sub>]S</i> where <i>T<sub>1</sub>, &hellip;, T<sub>n</sub></i> are the formal type
2670 * parameters of <i>G</i>. Let <i>B<sub>i</sub></i> be the bounds of <i>T<sub> i</sub>, 1 &lt;= i
2671 * &lt;= n</i>. It is a static type warning if <i>A<sub>i</sub></i> is not a s ubtype of
2672 * <i>[A<sub>1</sub>, &hellip;, A<sub>n</sub>/T<sub>1</sub>, &hellip;,
2673 * T<sub>n</sub>]B<sub>i</sub>, 1 &lt;= i &lt;= n</i>.
2674 *
2675 * 7.6.2 Factories: It is a static type warning if any of the type arguments t o <i>k'</i> are not
2676 * subtypes of the bounds of the corresponding formal type parameters of type.
2677 *
2678 * @param boundedTypeName the name of the type used in the instance creation t hat should be
2679 * limited by the bound as specified in the class declaration
2680 * @param boundingTypeName the name of the bounding type
2681 * @see #TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND
2682 */
2683 static const StaticTypeWarningCode TYPE_ARGUMENT_NOT_MATCHING_BOUNDS = const S taticTypeWarningCode.con1('TYPE_ARGUMENT_NOT_MATCHING_BOUNDS', 13, "'%s' does no t extend '%s'");
2684
2685 /**
2686 * 10 Generics: It is a static type warning if a type parameter is a supertype of its upper bound.
2687 *
2688 * @param typeParameterName the name of the type parameter
2689 * @see #TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
2690 */
2691 static const StaticTypeWarningCode TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND = con st StaticTypeWarningCode.con1('TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND', 14, "'%s' cannot be a supertype of its upper bound");
2692
2693 /**
2694 * 12.15.3 Unqualified Invocation: If there exists a lexically visible declara tion named
2695 * <i>id</i>, let <i>f<sub>id</sub></i> be the innermost such declaration. The n: [skip].
2696 * Otherwise, <i>f<sub>id</sub></i> is considered equivalent to the ordinary m ethod invocation
2697 * <b>this</b>.<i>id</i>(<i>a<sub>1</sub></i>, ..., <i>a<sub>n</sub></i>, <i>x <sub>n+1</sub></i> :
2698 * <i>a<sub>n+1</sub></i>, ..., <i>x<sub>n+k</sub></i> : <i>a<sub>n+k</sub></i >).
2699 *
2700 * @param methodName the name of the method that is undefined
2701 */
2702 static const StaticTypeWarningCode UNDEFINED_FUNCTION = const StaticTypeWarnin gCode.con1('UNDEFINED_FUNCTION', 15, "The function '%s' is not defined");
2703
2704 /**
2705 * 12.17 Getter Invocation: Let <i>T</i> be the static type of <i>e</i>. It is a static type
2706 * warning if <i>T</i> does not have a getter named <i>m</i>.
2712 * 2707 *
2713 * @param getterName the name of the getter 2708 * @param getterName the name of the getter
2714 * @param enclosingType the name of the enclosing type where the getter is bei ng looked for 2709 * @param enclosingType the name of the enclosing type where the getter is bei ng looked for
2715 * @see StaticTypeWarningCode#UNDEFINED_GETTER 2710 */
2716 * @see StaticWarningCode#UNDEFINED_GETTER 2711 static const StaticTypeWarningCode UNDEFINED_GETTER = const StaticTypeWarningC ode.con1('UNDEFINED_GETTER', 16, "There is no such getter '%s' in '%s'");
2717 */ 2712
2718 static const HintCode UNDEFINED_GETTER = const HintCode.con1('UNDEFINED_GETTER ', 19, "There is no such getter '%s' in '%s'"); 2713 /**
2719 2714 * 12.15.1 Ordinary Invocation: Let <i>T</i> be the static type of <i>o</i>. I t is a static type
2720 /** 2715 * warning if <i>T</i> does not have an accessible instance member named <i>m< /i>.
2721 * This hint is generated anywhere where the [StaticTypeWarningCode#UNDEFINED_ METHOD] would
2722 * have been generated, if we used propagated information for the warnings.
2723 * 2716 *
2724 * @param methodName the name of the method that is undefined 2717 * @param methodName the name of the method that is undefined
2725 * @param typeName the resolved type name that the method lookup is happening on 2718 * @param typeName the resolved type name that the method lookup is happening on
2726 * @see StaticTypeWarningCode#UNDEFINED_METHOD 2719 */
2727 */ 2720 static const StaticTypeWarningCode UNDEFINED_METHOD = const StaticTypeWarningC ode.con1('UNDEFINED_METHOD', 17, "The method '%s' is not defined for the class ' %s'");
2728 static const HintCode UNDEFINED_METHOD = const HintCode.con1('UNDEFINED_METHOD ', 20, "The method '%s' is not defined for the class '%s'"); 2721
2729 2722 /**
2730 /** 2723 * 12.18 Assignment: Evaluation of an assignment of the form
2731 * This hint is generated anywhere where the [StaticTypeWarningCode#UNDEFINED_ OPERATOR] 2724 * <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] = <i>e<sub>3</sub></i> is equiva lent to the
2732 * would have been generated, if we used propagated information for the warnin gs. 2725 * evaluation of the expression (a, i, e){a.[]=(i, e); return e;} (<i>e<sub>1< /sub></i>,
2726 * <i>e<sub>2</sub></i>, <i>e<sub>2</sub></i>).
2727 *
2728 * 12.29 Assignable Expressions: An assignable expression of the form
2729 * <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] is evaluated as a method invocat ion of the operator
2730 * method [] on <i>e<sub>1</sub></i> with argument <i>e<sub>2</sub></i>.
2731 *
2732 * 12.15.1 Ordinary Invocation: Let <i>T</i> be the static type of <i>o</i>. I t is a static type
2733 * warning if <i>T</i> does not have an accessible instance member named <i>m< /i>.
2733 * 2734 *
2734 * @param operator the name of the operator 2735 * @param operator the name of the operator
2735 * @param enclosingType the name of the enclosing type where the operator is b eing looked for 2736 * @param enclosingType the name of the enclosing type where the operator is b eing looked for
2736 * @see StaticTypeWarningCode#UNDEFINED_OPERATOR 2737 */
2737 */ 2738 static const StaticTypeWarningCode UNDEFINED_OPERATOR = const StaticTypeWarnin gCode.con1('UNDEFINED_OPERATOR', 18, "There is no such operator '%s' in '%s'");
2738 static const HintCode UNDEFINED_OPERATOR = const HintCode.con1('UNDEFINED_OPER ATOR', 21, "There is no such operator '%s' in '%s'"); 2739
2739 2740 /**
2740 /** 2741 * 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>. It is a static type
2741 * This hint is generated anywhere where the [StaticTypeWarningCode#UNDEFINED_ SETTER] or 2742 * warning if <i>T</i> does not have an accessible instance setter named <i>v= </i>.
2742 * [StaticWarningCode#UNDEFINED_SETTER] would have been generated, if we used propagated
2743 * information for the warnings.
2744 * 2743 *
2745 * @param setterName the name of the setter 2744 * @param setterName the name of the setter
2746 * @param enclosingType the name of the enclosing type where the setter is bei ng looked for 2745 * @param enclosingType the name of the enclosing type where the setter is bei ng looked for
2747 * @see StaticTypeWarningCode#UNDEFINED_SETTER 2746 * @see #INACCESSIBLE_SETTER
2748 * @see StaticWarningCode#UNDEFINED_SETTER 2747 */
2749 */ 2748 static const StaticTypeWarningCode UNDEFINED_SETTER = const StaticTypeWarningC ode.con1('UNDEFINED_SETTER', 19, "There is no such setter '%s' in '%s'");
2750 static const HintCode UNDEFINED_SETTER = const HintCode.con1('UNDEFINED_SETTER ', 22, "There is no such setter '%s' in '%s'"); 2749
2751 2750 /**
2752 /** 2751 * 12.15.4 Super Invocation: A super method invocation <i>i</i> has the form
2753 * Unnecessary cast. 2752 * <i>super.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub>: a<sub>n +1</sub>, &hellip;
2754 */ 2753 * x<sub>n+k</sub>: a<sub>n+k</sub>)</i>. It is a static type warning if <i>S< /i> does not have an
2755 static const HintCode UNNECESSARY_CAST = const HintCode.con1('UNNECESSARY_CAST ', 23, "Unnecessary cast"); 2754 * accessible instance member named <i>m</i>.
2756 2755 *
2757 /** 2756 * @param methodName the name of the method that is undefined
2758 * Unnecessary type checks, the result is always true. 2757 * @param typeName the resolved type name that the method lookup is happening on
2759 */ 2758 */
2760 static const HintCode UNNECESSARY_TYPE_CHECK_FALSE = const HintCode.con1('UNNE CESSARY_TYPE_CHECK_FALSE', 24, "Unnecessary type check, the result is always fal se"); 2759 static const StaticTypeWarningCode UNDEFINED_SUPER_METHOD = const StaticTypeWa rningCode.con1('UNDEFINED_SUPER_METHOD', 20, "There is no such method '%s' in '% s'");
2761 2760
2762 /** 2761 /**
2763 * Unnecessary type checks, the result is always false. 2762 * 12.15.1 Ordinary Invocation: It is a static type warning if <i>T</i> does n ot have an
2764 */ 2763 * accessible (3.2) instance member named <i>m</i>.
2765 static const HintCode UNNECESSARY_TYPE_CHECK_TRUE = const HintCode.con1('UNNEC ESSARY_TYPE_CHECK_TRUE', 25, "Unnecessary type check, the result is always true" ); 2764 *
2766 2765 * This is a specialization of [INSTANCE_ACCESS_TO_STATIC_MEMBER] that is used when we are
2767 /** 2766 * able to find the name defined in a supertype. It exists to provide a more i nformative error
2768 * Unused imports are imports which are never not used. 2767 * message.
2769 */ 2768 */
2770 static const HintCode UNUSED_IMPORT = const HintCode.con1('UNUSED_IMPORT', 26, "Unused import"); 2769 static const StaticTypeWarningCode UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_M EMBER = const StaticTypeWarningCode.con1('UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STA TIC_MEMBER', 21, "Static members from supertypes must be qualified by the name o f the defining type");
2771 2770
2772 /** 2771 /**
2773 * Hint for cases where the source expects a method or function to return a no n-void result, but 2772 * 15.8 Parameterized Types: It is a static type warning if <i>G</i> is not a generic type with
2774 * the method or function signature returns void. 2773 * exactly <i>n</i> type parameters.
2775 * 2774 *
2776 * @param name the name of the method or function that returns void 2775 * @param typeName the name of the type being referenced (<i>G</i>)
2777 */ 2776 * @param parameterCount the number of type parameters that were declared
2778 static const HintCode USE_OF_VOID_RESULT = const HintCode.con1('USE_OF_VOID_RE SULT', 27, "The result of '%s' is being used, even though it is declared to be ' void'"); 2777 * @param argumentCount the number of type arguments provided
2779 2778 * @see CompileTimeErrorCode#CONST_WITH_INVALID_TYPE_PARAMETERS
2780 static const List<HintCode> values = const [ 2779 * @see CompileTimeErrorCode#NEW_WITH_INVALID_TYPE_PARAMETERS
2781 ARGUMENT_TYPE_NOT_ASSIGNABLE, 2780 */
2782 DEAD_CODE, 2781 static const StaticTypeWarningCode WRONG_NUMBER_OF_TYPE_ARGUMENTS = const Stat icTypeWarningCode.con1('WRONG_NUMBER_OF_TYPE_ARGUMENTS', 22, "The type '%s' is d eclared with %d type parameters, but %d type arguments were given");
2783 DEAD_CODE_CATCH_FOLLOWING_CATCH, 2782
2784 DEAD_CODE_ON_CATCH_SUBTYPE, 2783 static const List<StaticTypeWarningCode> values = const [
2785 DEPRECATED_MEMBER_USE, 2784 EXPECTED_ONE_LIST_TYPE_ARGUMENTS,
2786 DUPLICATE_IMPORT, 2785 EXPECTED_TWO_MAP_TYPE_ARGUMENTS,
2787 DIVISION_OPTIMIZATION, 2786 INACCESSIBLE_SETTER,
2788 IS_DOUBLE, 2787 INCONSISTENT_METHOD_INHERITANCE,
2789 IS_INT, 2788 INSTANCE_ACCESS_TO_STATIC_MEMBER,
2790 IS_NOT_DOUBLE,
2791 IS_NOT_INT,
2792 INVALID_ASSIGNMENT, 2789 INVALID_ASSIGNMENT,
2793 MISSING_RETURN, 2790 INVOCATION_OF_NON_FUNCTION,
2794 OVERRIDE_ON_NON_OVERRIDING_GETTER, 2791 INVOCATION_OF_NON_FUNCTION_EXPRESSION,
2795 OVERRIDE_ON_NON_OVERRIDING_METHOD, 2792 NON_BOOL_CONDITION,
2796 OVERRIDE_ON_NON_OVERRIDING_SETTER, 2793 NON_BOOL_EXPRESSION,
2797 OVERRIDE_EQUALS_BUT_NOT_HASH_CODE, 2794 NON_BOOL_NEGATION_EXPRESSION,
2798 TYPE_CHECK_IS_NOT_NULL, 2795 NON_TYPE_AS_TYPE_ARGUMENT,
2799 TYPE_CHECK_IS_NULL, 2796 RETURN_OF_INVALID_TYPE,
2797 TYPE_ARGUMENT_NOT_MATCHING_BOUNDS,
2798 TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND,
2799 UNDEFINED_FUNCTION,
2800 UNDEFINED_GETTER, 2800 UNDEFINED_GETTER,
2801 UNDEFINED_METHOD, 2801 UNDEFINED_METHOD,
2802 UNDEFINED_OPERATOR, 2802 UNDEFINED_OPERATOR,
2803 UNDEFINED_SETTER, 2803 UNDEFINED_SETTER,
2804 UNNECESSARY_CAST, 2804 UNDEFINED_SUPER_METHOD,
2805 UNNECESSARY_TYPE_CHECK_FALSE, 2805 UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER,
2806 UNNECESSARY_TYPE_CHECK_TRUE, 2806 WRONG_NUMBER_OF_TYPE_ARGUMENTS];
2807 UNUSED_IMPORT,
2808 USE_OF_VOID_RESULT];
2809 2807
2810 /** 2808 /**
2811 * The template used to create the message to be displayed for this error. 2809 * The template used to create the message to be displayed for this error.
2812 */ 2810 */
2813 final String message; 2811 final String message;
2814 2812
2815 /** 2813 /**
2816 * The template used to create the correction to be displayed for this error, or `null` if 2814 * The template used to create the correction to be displayed for this error, or `null` if
2817 * there is no correction information for this error. 2815 * there is no correction information for this error.
2818 */ 2816 */
2819 final String correction; 2817 final String correction;
2820 2818
2821 /** 2819 /**
2822 * Initialize a newly created error code to have the given message. 2820 * Initialize a newly created error code to have the given message.
2823 * 2821 *
2824 * @param message the message template used to create the message to be displa yed for the error 2822 * @param message the message template used to create the message to be displa yed for the error
2825 */ 2823 */
2826 const HintCode.con1(String name, int ordinal, String message) : this.con2(name , ordinal, message, null); 2824 const StaticTypeWarningCode.con1(String name, int ordinal, String message) : t his.con2(name, ordinal, message, null);
2827 2825
2828 /** 2826 /**
2829 * Initialize a newly created error code to have the given message and correct ion. 2827 * Initialize a newly created error code to have the given message and correct ion.
2830 * 2828 *
2831 * @param message the template used to create the message to be displayed for the error 2829 * @param message the template used to create the message to be displayed for the error
2832 * @param correction the template used to create the correction to be displaye d for the error 2830 * @param correction the template used to create the correction to be displaye d for the error
2833 */ 2831 */
2834 const HintCode.con2(String name, int ordinal, this.message, this.correction) : super(name, ordinal); 2832 const StaticTypeWarningCode.con2(String name, int ordinal, this.message, this. correction) : super(name, ordinal);
2835 2833
2836 @override 2834 @override
2837 ErrorSeverity get errorSeverity => ErrorType.HINT.severity; 2835 ErrorSeverity get errorSeverity => ErrorType.STATIC_TYPE_WARNING.severity;
2838 2836
2839 @override 2837 @override
2840 ErrorType get type => ErrorType.HINT; 2838 ErrorType get type => ErrorType.STATIC_TYPE_WARNING;
2841 } 2839 }
2842 2840
2843 /** 2841 /**
2844 * Instances of the class `BooleanErrorListener` implement a listener that keeps track of
2845 * whether an error has been reported to it.
2846 */
2847 class BooleanErrorListener implements AnalysisErrorListener {
2848 /**
2849 * A flag indicating whether an error has been reported to this listener.
2850 */
2851 bool _errorReported = false;
2852
2853 /**
2854 * Return `true` if an error has been reported to this listener.
2855 *
2856 * @return `true` if an error has been reported to this listener
2857 */
2858 bool get errorReported => _errorReported;
2859
2860 @override
2861 void onError(AnalysisError error) {
2862 _errorReported = true;
2863 }
2864 }
2865
2866 /**
2867 * The enumeration `StaticWarningCode` defines the error codes used for static w arnings. The 2842 * The enumeration `StaticWarningCode` defines the error codes used for static w arnings. The
2868 * convention for this class is for the name of the error code to indicate the p roblem that caused 2843 * convention for this class is for the name of the error code to indicate the p roblem that caused
2869 * the error to be generated and for the error message to explain what is wrong and, when 2844 * the error to be generated and for the error message to explain what is wrong and, when
2870 * appropriate, how the problem can be corrected. 2845 * appropriate, how the problem can be corrected.
2871 */ 2846 */
2872 class StaticWarningCode extends Enum<StaticWarningCode> implements ErrorCode { 2847 class StaticWarningCode extends Enum<StaticWarningCode> implements ErrorCode {
2873 /** 2848 /**
2874 * 14.1 Imports: If a name <i>N</i> is referenced by a library <i>L</i> and <i >N</i> is introduced 2849 * 14.1 Imports: If a name <i>N</i> is referenced by a library <i>L</i> and <i >N</i> is introduced
2875 * into the top level scope <i>L</i> by more than one import then: 2850 * into the top level scope <i>L</i> by more than one import then:
2876 * <ol> 2851 * <ol>
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
3767 const StaticWarningCode.con2(String name, int ordinal, this.message, this.corr ection) : super(name, ordinal); 3742 const StaticWarningCode.con2(String name, int ordinal, this.message, this.corr ection) : super(name, ordinal);
3768 3743
3769 @override 3744 @override
3770 ErrorSeverity get errorSeverity => ErrorType.STATIC_WARNING.severity; 3745 ErrorSeverity get errorSeverity => ErrorType.STATIC_WARNING.severity;
3771 3746
3772 @override 3747 @override
3773 ErrorType get type => ErrorType.STATIC_WARNING; 3748 ErrorType get type => ErrorType.STATIC_WARNING;
3774 } 3749 }
3775 3750
3776 /** 3751 /**
3777 * The enumeration `ErrorProperty` defines the properties that can be associated with an 3752 * The enumeration `TodoCode` defines the single TODO `ErrorCode`.
3778 * [AnalysisError].
3779 */ 3753 */
3780 class ErrorProperty extends Enum<ErrorProperty> { 3754 class TodoCode extends Enum<TodoCode> implements ErrorCode {
3781 /** 3755 /**
3782 * A property whose value is an array of [ExecutableElement] that should 3756 * The single enum of TodoCode.
3783 * be but are not implemented by a concrete class.
3784 */ 3757 */
3785 static const ErrorProperty UNIMPLEMENTED_METHODS = const ErrorProperty('UNIMPL EMENTED_METHODS', 0); 3758 static const TodoCode TODO = const TodoCode('TODO', 0);
3786 3759
3787 static const List<ErrorProperty> values = const [UNIMPLEMENTED_METHODS]; 3760 static const List<TodoCode> values = const [TODO];
3788 3761
3789 const ErrorProperty(String name, int ordinal) : super(name, ordinal); 3762 /**
3763 * This matches the two common Dart task styles
3764 *
3765 * * TODO:
3766 * * TODO(username):
3767 *
3768 * As well as
3769 * * TODO
3770 *
3771 * But not
3772 * * todo
3773 * * TODOS
3774 */
3775 static RegExp TODO_REGEX = new RegExp("([\\s/\\*])((TODO[^\\w\\d][^\\r\\n]*)|( TODO:?\$))");
3776
3777 const TodoCode(String name, int ordinal) : super(name, ordinal);
3778
3779 @override
3780 String get correction => null;
3781
3782 @override
3783 ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
3784
3785 @override
3786 String get message => "%s";
3787
3788 @override
3789 ErrorType get type => ErrorType.TODO;
3790 } 3790 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/lib/src/generated/html.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698