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

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

Issue 2370813003: Move error codes and clean-up (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/scanner/scanner.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * The errors produced during sytactic analysis (scanning and parsing).
7 */
8 library analyzer.src.dart.error.syntactic_errors;
9
10 import 'package:analyzer/error/error.dart';
11
12 /**
13 * The error codes used for errors detected by the parser. The convention for
14 * this class is for the name of the error code to indicate the problem that
15 * caused the error to be generated and for the error message to explain what
16 * is wrong and, when appropriate, how the problem can be corrected.
17 */
18 class ParserErrorCode extends ErrorCode {
19 static const ParserErrorCode ABSTRACT_CLASS_MEMBER = const ParserErrorCode(
20 'ABSTRACT_CLASS_MEMBER',
21 "Members of classes cannot be declared to be 'abstract'");
22
23 static const ParserErrorCode ABSTRACT_ENUM = const ParserErrorCode(
24 'ABSTRACT_ENUM', "Enums cannot be declared to be 'abstract'");
25
26 static const ParserErrorCode ABSTRACT_STATIC_METHOD = const ParserErrorCode(
27 'ABSTRACT_STATIC_METHOD',
28 "Static methods cannot be declared to be 'abstract'");
29
30 static const ParserErrorCode ABSTRACT_TOP_LEVEL_FUNCTION =
31 const ParserErrorCode('ABSTRACT_TOP_LEVEL_FUNCTION',
32 "Top-level functions cannot be declared to be 'abstract'");
33
34 static const ParserErrorCode ABSTRACT_TOP_LEVEL_VARIABLE =
35 const ParserErrorCode('ABSTRACT_TOP_LEVEL_VARIABLE',
36 "Top-level variables cannot be declared to be 'abstract'");
37
38 static const ParserErrorCode ABSTRACT_TYPEDEF = const ParserErrorCode(
39 'ABSTRACT_TYPEDEF', "Type aliases cannot be declared to be 'abstract'");
40
41 static const ParserErrorCode ANNOTATION_ON_ENUM_CONSTANT =
42 const ParserErrorCode('ANNOTATION_ON_ENUM_CONSTANT',
43 "Enum constants cannot have annotations");
44
45 /**
46 * 16.32 Identifier Reference: It is a compile-time error if any of the
47 * identifiers async, await, or yield is used as an identifier in a function
48 * body marked with either async, async*, or sync*.
49 */
50 static const ParserErrorCode ASYNC_KEYWORD_USED_AS_IDENTIFIER =
51 const ParserErrorCode('ASYNC_KEYWORD_USED_AS_IDENTIFIER',
52 "The keywords 'async', 'await', and 'yield' may not be used as identif iers in an asynchronous or generator function.");
53
54 /**
55 * Some environments, such as Fletch, do not support async.
56 */
57 static const ParserErrorCode ASYNC_NOT_SUPPORTED = const ParserErrorCode(
58 'ASYNC_NOT_SUPPORTED',
59 "Async and sync are not supported in this environment.");
60
61 static const ParserErrorCode BREAK_OUTSIDE_OF_LOOP = const ParserErrorCode(
62 'BREAK_OUTSIDE_OF_LOOP',
63 "A break statement cannot be used outside of a loop or switch statement");
64
65 static const ParserErrorCode CLASS_IN_CLASS = const ParserErrorCode(
66 'CLASS_IN_CLASS',
67 "Classes can't be declared inside other classes.",
68 "Try moving the class to the top-level.");
69
70 static const ParserErrorCode COLON_IN_PLACE_OF_IN = const ParserErrorCode(
71 'COLON_IN_PLACE_OF_IN', "For-in loops use 'in' rather than a colon");
72
73 static const ParserErrorCode CONST_AND_FINAL = const ParserErrorCode(
74 'CONST_AND_FINAL',
75 "Members can't be declared to be both 'const' and 'final'.",
76 "Try removing either the 'const' or 'final' keyword.");
77
78 static const ParserErrorCode CONST_AND_VAR = const ParserErrorCode(
79 'CONST_AND_VAR',
80 "Members can't be declared to be both 'const' and 'var'.",
81 "Try removing either the 'const' or 'var' keyword.");
82
83 static const ParserErrorCode CONST_CLASS = const ParserErrorCode(
84 'CONST_CLASS',
85 "Classes can't be declared to be 'const'.",
86 "Try removing the 'const' keyword or moving to the class' constructor(s)." );
87
88 static const ParserErrorCode CONST_CONSTRUCTOR_WITH_BODY =
89 const ParserErrorCode(
90 'CONST_CONSTRUCTOR_WITH_BODY',
91 "Const constructor can't have a body.",
92 "Try removing the 'const' keyword or the body.");
93
94 static const ParserErrorCode CONST_ENUM = const ParserErrorCode(
95 'CONST_ENUM',
96 "Enums can't be declared to be 'const'.",
97 "Try removing the 'const' keyword.");
98
99 static const ParserErrorCode CONST_FACTORY = const ParserErrorCode(
100 'CONST_FACTORY',
101 "Only redirecting factory constructors can be declared to be 'const'.",
102 "Try removing the 'const' keyword or replacing the body with '=' followed by a valid target.");
103
104 static const ParserErrorCode CONST_METHOD = const ParserErrorCode(
105 'CONST_METHOD',
106 "Getters, setters and methods can't be declared to be 'const'.",
107 "Try removing the 'const' keyword.");
108
109 static const ParserErrorCode CONST_TYPEDEF = const ParserErrorCode(
110 'CONST_TYPEDEF',
111 "Type aliases can't be declared to be 'const'.",
112 "Try removing the 'const' keyword.");
113
114 static const ParserErrorCode CONSTRUCTOR_WITH_RETURN_TYPE =
115 const ParserErrorCode(
116 'CONSTRUCTOR_WITH_RETURN_TYPE',
117 "Constructors can't have a return type.",
118 "Try removing the return type.");
119
120 static const ParserErrorCode CONTINUE_OUTSIDE_OF_LOOP = const ParserErrorCode(
121 'CONTINUE_OUTSIDE_OF_LOOP',
122 "A continue statement cannot be used outside of a loop or switch statement ");
123
124 static const ParserErrorCode CONTINUE_WITHOUT_LABEL_IN_CASE =
125 const ParserErrorCode('CONTINUE_WITHOUT_LABEL_IN_CASE',
126 "A continue statement in a switch statement must have a label as a tar get");
127
128 static const ParserErrorCode DEPRECATED_CLASS_TYPE_ALIAS =
129 const ParserErrorCode('DEPRECATED_CLASS_TYPE_ALIAS',
130 "The 'typedef' mixin application was replaced with 'class'");
131
132 static const ParserErrorCode DIRECTIVE_AFTER_DECLARATION =
133 const ParserErrorCode('DIRECTIVE_AFTER_DECLARATION',
134 "Directives must appear before any declarations");
135
136 static const ParserErrorCode DUPLICATE_LABEL_IN_SWITCH_STATEMENT =
137 const ParserErrorCode('DUPLICATE_LABEL_IN_SWITCH_STATEMENT',
138 "The label {0} was already used in this switch statement");
139
140 static const ParserErrorCode DUPLICATED_MODIFIER = const ParserErrorCode(
141 'DUPLICATED_MODIFIER', "The modifier '{0}' was already specified.");
142
143 static const ParserErrorCode EMPTY_ENUM_BODY = const ParserErrorCode(
144 'EMPTY_ENUM_BODY', "An enum must declare at least one constant name");
145
146 static const ParserErrorCode ENUM_IN_CLASS = const ParserErrorCode(
147 'ENUM_IN_CLASS', "Enums cannot be declared inside classes");
148
149 static const ParserErrorCode EQUALITY_CANNOT_BE_EQUALITY_OPERAND =
150 const ParserErrorCode('EQUALITY_CANNOT_BE_EQUALITY_OPERAND',
151 "Equality expression cannot be operand of another equality expression. ");
152
153 static const ParserErrorCode EXPECTED_CASE_OR_DEFAULT = const ParserErrorCode(
154 'EXPECTED_CASE_OR_DEFAULT', "Expected 'case' or 'default'");
155
156 static const ParserErrorCode EXPECTED_CLASS_MEMBER =
157 const ParserErrorCode('EXPECTED_CLASS_MEMBER', "Expected a class member");
158
159 static const ParserErrorCode EXPECTED_EXECUTABLE = const ParserErrorCode(
160 'EXPECTED_EXECUTABLE',
161 "Expected a method, getter, setter or operator declaration");
162
163 static const ParserErrorCode EXPECTED_LIST_OR_MAP_LITERAL =
164 const ParserErrorCode(
165 'EXPECTED_LIST_OR_MAP_LITERAL', "Expected a list or map literal");
166
167 static const ParserErrorCode EXPECTED_STRING_LITERAL = const ParserErrorCode(
168 'EXPECTED_STRING_LITERAL', "Expected a string literal");
169
170 static const ParserErrorCode EXPECTED_TOKEN =
171 const ParserErrorCode('EXPECTED_TOKEN', "Expected to find '{0}'");
172
173 static const ParserErrorCode EXPECTED_TYPE_NAME =
174 const ParserErrorCode('EXPECTED_TYPE_NAME', "Expected a type name");
175
176 static const ParserErrorCode EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE =
177 const ParserErrorCode('EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE',
178 "Export directives must preceed part directives");
179
180 static const ParserErrorCode EXTERNAL_AFTER_CONST = const ParserErrorCode(
181 'EXTERNAL_AFTER_CONST',
182 "The modifier 'external' should be before the modifier 'const'");
183
184 static const ParserErrorCode EXTERNAL_AFTER_FACTORY = const ParserErrorCode(
185 'EXTERNAL_AFTER_FACTORY',
186 "The modifier 'external' should be before the modifier 'factory'");
187
188 static const ParserErrorCode EXTERNAL_AFTER_STATIC = const ParserErrorCode(
189 'EXTERNAL_AFTER_STATIC',
190 "The modifier 'external' should be before the modifier 'static'");
191
192 static const ParserErrorCode EXTERNAL_CLASS = const ParserErrorCode(
193 'EXTERNAL_CLASS', "Classes cannot be declared to be 'external'");
194
195 static const ParserErrorCode EXTERNAL_CONSTRUCTOR_WITH_BODY =
196 const ParserErrorCode('EXTERNAL_CONSTRUCTOR_WITH_BODY',
197 "External constructors cannot have a body");
198
199 static const ParserErrorCode EXTERNAL_ENUM = const ParserErrorCode(
200 'EXTERNAL_ENUM', "Enums cannot be declared to be 'external'");
201
202 static const ParserErrorCode EXTERNAL_FIELD = const ParserErrorCode(
203 'EXTERNAL_FIELD', "Fields cannot be declared to be 'external'");
204
205 static const ParserErrorCode EXTERNAL_GETTER_WITH_BODY =
206 const ParserErrorCode(
207 'EXTERNAL_GETTER_WITH_BODY', "External getters cannot have a body");
208
209 static const ParserErrorCode EXTERNAL_METHOD_WITH_BODY =
210 const ParserErrorCode(
211 'EXTERNAL_METHOD_WITH_BODY', "External methods cannot have a body");
212
213 static const ParserErrorCode EXTERNAL_OPERATOR_WITH_BODY =
214 const ParserErrorCode('EXTERNAL_OPERATOR_WITH_BODY',
215 "External operators cannot have a body");
216
217 static const ParserErrorCode EXTERNAL_SETTER_WITH_BODY =
218 const ParserErrorCode(
219 'EXTERNAL_SETTER_WITH_BODY', "External setters cannot have a body");
220
221 static const ParserErrorCode EXTERNAL_TYPEDEF = const ParserErrorCode(
222 'EXTERNAL_TYPEDEF', "Type aliases cannot be declared to be 'external'");
223
224 static const ParserErrorCode FACTORY_TOP_LEVEL_DECLARATION =
225 const ParserErrorCode('FACTORY_TOP_LEVEL_DECLARATION',
226 "Top-level declarations cannot be declared to be 'factory'");
227
228 static const ParserErrorCode FACTORY_WITH_INITIALIZERS =
229 const ParserErrorCode(
230 'FACTORY_WITH_INITIALIZERS',
231 "A 'factory' constructor cannot have initializers",
232 "Either remove the 'factory' keyword to make this a generative "
233 "constructor or remove the initializers.");
234
235 static const ParserErrorCode FACTORY_WITHOUT_BODY = const ParserErrorCode(
236 'FACTORY_WITHOUT_BODY',
237 "A non-redirecting 'factory' constructor must have a body");
238
239 static const ParserErrorCode FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR =
240 const ParserErrorCode('FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR',
241 "Field initializers can only be used in a constructor");
242
243 static const ParserErrorCode FINAL_AND_VAR = const ParserErrorCode(
244 'FINAL_AND_VAR',
245 "Members cannot be declared to be both 'final' and 'var'");
246
247 static const ParserErrorCode FINAL_CLASS = const ParserErrorCode(
248 'FINAL_CLASS', "Classes cannot be declared to be 'final'");
249
250 static const ParserErrorCode FINAL_CONSTRUCTOR = const ParserErrorCode(
251 'FINAL_CONSTRUCTOR', "A constructor cannot be declared to be 'final'");
252
253 static const ParserErrorCode FINAL_ENUM = const ParserErrorCode(
254 'FINAL_ENUM', "Enums cannot be declared to be 'final'");
255
256 static const ParserErrorCode FINAL_METHOD = const ParserErrorCode(
257 'FINAL_METHOD',
258 "Getters, setters and methods cannot be declared to be 'final'");
259
260 static const ParserErrorCode FINAL_TYPEDEF = const ParserErrorCode(
261 'FINAL_TYPEDEF', "Type aliases cannot be declared to be 'final'");
262
263 static const ParserErrorCode FUNCTION_TYPED_PARAMETER_VAR = const ParserErrorC ode(
264 'FUNCTION_TYPED_PARAMETER_VAR',
265 "Function typed parameters cannot specify 'const', 'final' or 'var' instea d of return type");
266
267 static const ParserErrorCode GETTER_IN_FUNCTION = const ParserErrorCode(
268 'GETTER_IN_FUNCTION',
269 "Getters cannot be defined within methods or functions");
270
271 static const ParserErrorCode GETTER_WITH_PARAMETERS = const ParserErrorCode(
272 'GETTER_WITH_PARAMETERS',
273 "Getter should be declared without a parameter list");
274
275 static const ParserErrorCode ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE =
276 const ParserErrorCode('ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE',
277 "Illegal assignment to non-assignable expression");
278
279 static const ParserErrorCode IMPLEMENTS_BEFORE_EXTENDS =
280 const ParserErrorCode('IMPLEMENTS_BEFORE_EXTENDS',
281 "The extends clause must be before the implements clause");
282
283 static const ParserErrorCode IMPLEMENTS_BEFORE_WITH = const ParserErrorCode(
284 'IMPLEMENTS_BEFORE_WITH',
285 "The with clause must be before the implements clause");
286
287 static const ParserErrorCode IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE =
288 const ParserErrorCode('IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE',
289 "Import directives must preceed part directives");
290
291 static const ParserErrorCode INITIALIZED_VARIABLE_IN_FOR_EACH =
292 const ParserErrorCode('INITIALIZED_VARIABLE_IN_FOR_EACH',
293 "The loop variable in a for-each loop cannot be initialized");
294
295 static const ParserErrorCode INVALID_AWAIT_IN_FOR = const ParserErrorCode(
296 'INVALID_AWAIT_IN_FOR',
297 "The modifier 'await' is not allowed for a normal 'for' statement",
298 "Remove the keyword or use a for-each statement.");
299
300 static const ParserErrorCode INVALID_CODE_POINT = const ParserErrorCode(
301 'INVALID_CODE_POINT',
302 "The escape sequence '{0}' is not a valid code point");
303
304 static const ParserErrorCode INVALID_COMMENT_REFERENCE = const ParserErrorCode (
305 'INVALID_COMMENT_REFERENCE',
306 "Comment references should contain a possibly prefixed identifier and can start with 'new', but should not contain anything else");
307
308 static const ParserErrorCode INVALID_HEX_ESCAPE = const ParserErrorCode(
309 'INVALID_HEX_ESCAPE',
310 "An escape sequence starting with '\\x' must be followed by 2 hexidecimal digits");
311
312 static const ParserErrorCode INVALID_LITERAL_IN_CONFIGURATION =
313 const ParserErrorCode('INVALID_LITERAL_IN_CONFIGURATION',
314 "The literal in a configuration cannot contain interpolation");
315
316 static const ParserErrorCode INVALID_OPERATOR = const ParserErrorCode(
317 'INVALID_OPERATOR', "The string '{0}' is not a valid operator");
318
319 static const ParserErrorCode INVALID_OPERATOR_FOR_SUPER =
320 const ParserErrorCode('INVALID_OPERATOR_FOR_SUPER',
321 "The operator '{0}' cannot be used with 'super'");
322
323 static const ParserErrorCode INVALID_STAR_AFTER_ASYNC = const ParserErrorCode(
324 'INVALID_STAR_AFTER_ASYNC',
325 "The modifier 'async*' is not allowed for an expression function body",
326 "Convert the body to a block.");
327
328 static const ParserErrorCode INVALID_SYNC = const ParserErrorCode(
329 'INVALID_SYNC',
330 "The modifier 'sync' is not allowed for an exrpression function body",
331 "Convert the body to a block.");
332
333 static const ParserErrorCode INVALID_UNICODE_ESCAPE = const ParserErrorCode(
334 'INVALID_UNICODE_ESCAPE',
335 "An escape sequence starting with '\\u' must be followed by 4 hexidecimal digits or from 1 to 6 digits between '{' and '}'");
336
337 static const ParserErrorCode LIBRARY_DIRECTIVE_NOT_FIRST =
338 const ParserErrorCode('LIBRARY_DIRECTIVE_NOT_FIRST',
339 "The library directive must appear before all other directives");
340
341 static const ParserErrorCode LOCAL_FUNCTION_DECLARATION_MODIFIER =
342 const ParserErrorCode('LOCAL_FUNCTION_DECLARATION_MODIFIER',
343 "Local function declarations cannot specify any modifier");
344
345 static const ParserErrorCode MISSING_ASSIGNABLE_SELECTOR =
346 const ParserErrorCode('MISSING_ASSIGNABLE_SELECTOR',
347 "Missing selector such as \".<identifier>\" or \"[0]\"");
348
349 static const ParserErrorCode MISSING_ASSIGNMENT_IN_INITIALIZER =
350 const ParserErrorCode('MISSING_ASSIGNMENT_IN_INITIALIZER',
351 "Expected an assignment after the field name");
352
353 static const ParserErrorCode MISSING_CATCH_OR_FINALLY = const ParserErrorCode(
354 'MISSING_CATCH_OR_FINALLY',
355 "A try statement must have either a catch or finally clause");
356
357 static const ParserErrorCode MISSING_CLASS_BODY = const ParserErrorCode(
358 'MISSING_CLASS_BODY',
359 "A class definition must have a body, even if it is empty");
360
361 static const ParserErrorCode MISSING_CLOSING_PARENTHESIS =
362 const ParserErrorCode(
363 'MISSING_CLOSING_PARENTHESIS', "The closing parenthesis is missing");
364
365 static const ParserErrorCode MISSING_CONST_FINAL_VAR_OR_TYPE =
366 const ParserErrorCode('MISSING_CONST_FINAL_VAR_OR_TYPE',
367 "Variables must be declared using the keywords 'const', 'final', 'var' or a type name");
368
369 static const ParserErrorCode MISSING_ENUM_BODY = const ParserErrorCode(
370 'MISSING_ENUM_BODY',
371 "An enum definition must have a body with at least one constant name");
372
373 static const ParserErrorCode MISSING_EXPRESSION_IN_INITIALIZER =
374 const ParserErrorCode('MISSING_EXPRESSION_IN_INITIALIZER',
375 "Expected an expression after the assignment operator");
376
377 static const ParserErrorCode MISSING_EXPRESSION_IN_THROW =
378 const ParserErrorCode('MISSING_EXPRESSION_IN_THROW',
379 "Missing expression after 'throw'.", "Did you mean 'rethrow'?");
380
381 static const ParserErrorCode MISSING_FUNCTION_BODY = const ParserErrorCode(
382 'MISSING_FUNCTION_BODY', "A function body must be provided");
383
384 static const ParserErrorCode MISSING_FUNCTION_PARAMETERS =
385 const ParserErrorCode('MISSING_FUNCTION_PARAMETERS',
386 "Functions must have an explicit list of parameters");
387
388 static const ParserErrorCode MISSING_METHOD_PARAMETERS =
389 const ParserErrorCode('MISSING_METHOD_PARAMETERS',
390 "Methods must have an explicit list of parameters");
391
392 static const ParserErrorCode MISSING_GET = const ParserErrorCode(
393 'MISSING_GET',
394 "Getters must have the keyword 'get' before the getter name");
395
396 static const ParserErrorCode MISSING_IDENTIFIER =
397 const ParserErrorCode('MISSING_IDENTIFIER', "Expected an identifier");
398
399 static const ParserErrorCode MISSING_INITIALIZER =
400 const ParserErrorCode('MISSING_INITIALIZER', "Expected an initializer");
401
402 static const ParserErrorCode MISSING_KEYWORD_OPERATOR = const ParserErrorCode(
403 'MISSING_KEYWORD_OPERATOR',
404 "Operator declarations must be preceeded by the keyword 'operator'");
405
406 static const ParserErrorCode MISSING_NAME_IN_LIBRARY_DIRECTIVE =
407 const ParserErrorCode('MISSING_NAME_IN_LIBRARY_DIRECTIVE',
408 "Library directives must include a library name");
409
410 static const ParserErrorCode MISSING_NAME_IN_PART_OF_DIRECTIVE =
411 const ParserErrorCode('MISSING_NAME_IN_PART_OF_DIRECTIVE',
412 "Library directives must include a library name");
413
414 static const ParserErrorCode MISSING_PREFIX_IN_DEFERRED_IMPORT =
415 const ParserErrorCode('MISSING_PREFIX_IN_DEFERRED_IMPORT',
416 "Deferred imports must have a prefix");
417
418 static const ParserErrorCode MISSING_STAR_AFTER_SYNC = const ParserErrorCode(
419 'MISSING_STAR_AFTER_SYNC',
420 "The modifier 'sync' must be followed by a star ('*')",
421 "Remove the modifier or add a star.");
422
423 static const ParserErrorCode MISSING_STATEMENT =
424 const ParserErrorCode('MISSING_STATEMENT', "Expected a statement");
425
426 static const ParserErrorCode MISSING_TERMINATOR_FOR_PARAMETER_GROUP =
427 const ParserErrorCode('MISSING_TERMINATOR_FOR_PARAMETER_GROUP',
428 "There is no '{0}' to close the parameter group");
429
430 static const ParserErrorCode MISSING_TYPEDEF_PARAMETERS =
431 const ParserErrorCode('MISSING_TYPEDEF_PARAMETERS',
432 "Type aliases for functions must have an explicit list of parameters") ;
433
434 static const ParserErrorCode MISSING_VARIABLE_IN_FOR_EACH = const ParserErrorC ode(
435 'MISSING_VARIABLE_IN_FOR_EACH',
436 "A loop variable must be declared in a for-each loop before the 'in', but none were found");
437
438 static const ParserErrorCode MIXED_PARAMETER_GROUPS = const ParserErrorCode(
439 'MIXED_PARAMETER_GROUPS',
440 "Cannot have both positional and named parameters in a single parameter li st");
441
442 static const ParserErrorCode MULTIPLE_EXTENDS_CLAUSES = const ParserErrorCode(
443 'MULTIPLE_EXTENDS_CLAUSES',
444 "Each class definition can have at most one extends clause");
445
446 static const ParserErrorCode MULTIPLE_IMPLEMENTS_CLAUSES =
447 const ParserErrorCode('MULTIPLE_IMPLEMENTS_CLAUSES',
448 "Each class definition can have at most one implements clause");
449
450 static const ParserErrorCode MULTIPLE_LIBRARY_DIRECTIVES =
451 const ParserErrorCode('MULTIPLE_LIBRARY_DIRECTIVES',
452 "Only one library directive may be declared in a file");
453
454 static const ParserErrorCode MULTIPLE_NAMED_PARAMETER_GROUPS =
455 const ParserErrorCode('MULTIPLE_NAMED_PARAMETER_GROUPS',
456 "Cannot have multiple groups of named parameters in a single parameter list");
457
458 static const ParserErrorCode MULTIPLE_PART_OF_DIRECTIVES =
459 const ParserErrorCode('MULTIPLE_PART_OF_DIRECTIVES',
460 "Only one part-of directive may be declared in a file");
461
462 static const ParserErrorCode MULTIPLE_POSITIONAL_PARAMETER_GROUPS =
463 const ParserErrorCode('MULTIPLE_POSITIONAL_PARAMETER_GROUPS',
464 "Cannot have multiple groups of positional parameters in a single para meter list");
465
466 static const ParserErrorCode MULTIPLE_VARIABLES_IN_FOR_EACH =
467 const ParserErrorCode('MULTIPLE_VARIABLES_IN_FOR_EACH',
468 "A single loop variable must be declared in a for-each loop before the 'in', but {0} were found");
469
470 static const ParserErrorCode MULTIPLE_WITH_CLAUSES = const ParserErrorCode(
471 'MULTIPLE_WITH_CLAUSES',
472 "Each class definition can have at most one with clause");
473
474 static const ParserErrorCode NAMED_FUNCTION_EXPRESSION =
475 const ParserErrorCode(
476 'NAMED_FUNCTION_EXPRESSION', "Function expressions cannot be named");
477
478 static const ParserErrorCode NAMED_PARAMETER_OUTSIDE_GROUP =
479 const ParserErrorCode('NAMED_PARAMETER_OUTSIDE_GROUP',
480 "Named parameters must be enclosed in curly braces ('{' and '}')");
481
482 static const ParserErrorCode NATIVE_CLAUSE_IN_NON_SDK_CODE =
483 const ParserErrorCode('NATIVE_CLAUSE_IN_NON_SDK_CODE',
484 "Native clause can only be used in the SDK and code that is loaded thr ough native extensions");
485
486 static const ParserErrorCode NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE =
487 const ParserErrorCode('NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE',
488 "Native functions can only be declared in the SDK and code that is loa ded through native extensions");
489
490 static const ParserErrorCode NON_CONSTRUCTOR_FACTORY = const ParserErrorCode(
491 'NON_CONSTRUCTOR_FACTORY',
492 "Only constructors can be declared to be a 'factory'");
493
494 static const ParserErrorCode NON_IDENTIFIER_LIBRARY_NAME =
495 const ParserErrorCode('NON_IDENTIFIER_LIBRARY_NAME',
496 "The name of a library must be an identifier");
497
498 static const ParserErrorCode NON_PART_OF_DIRECTIVE_IN_PART =
499 const ParserErrorCode('NON_PART_OF_DIRECTIVE_IN_PART',
500 "The part-of directive must be the only directive in a part");
501
502 static const ParserErrorCode NON_STRING_LITERAL_AS_URI =
503 const ParserErrorCode(
504 'NON_STRING_LITERAL_AS_URI',
505 "The URI must be a string literal",
506 "Enclose the URI in either single or double quotes.");
507
508 static const ParserErrorCode NON_USER_DEFINABLE_OPERATOR =
509 const ParserErrorCode('NON_USER_DEFINABLE_OPERATOR',
510 "The operator '{0}' is not user definable");
511
512 static const ParserErrorCode NORMAL_BEFORE_OPTIONAL_PARAMETERS =
513 const ParserErrorCode('NORMAL_BEFORE_OPTIONAL_PARAMETERS',
514 "Normal parameters must occur before optional parameters");
515
516 static const ParserErrorCode NULLABLE_TYPE_IN_EXTENDS = const ParserErrorCode(
517 'NULLABLE_TYPE_IN_EXTENDS',
518 "A nullable type cannot be used in an extends clause",
519 "Remove the '?' from the type name");
520
521 static const ParserErrorCode NULLABLE_TYPE_IN_IMPLEMENTS =
522 const ParserErrorCode(
523 'NULLABLE_TYPE_IN_IMPLEMENTS',
524 "A nullable type cannot be used in an implements clause",
525 "Remove the '?' from the type name");
526
527 static const ParserErrorCode NULLABLE_TYPE_IN_WITH = const ParserErrorCode(
528 'NULLABLE_TYPE_IN_WITH',
529 "A nullable type cannot be used in a with clause",
530 "Remove the '?' from the type name");
531
532 static const ParserErrorCode NULLABLE_TYPE_PARAMETER = const ParserErrorCode(
533 'NULLABLE_TYPE_PARAMETER',
534 "Type parameters cannot be nullable",
535 "Remove the '?' from the type name");
536
537 static const ParserErrorCode POSITIONAL_AFTER_NAMED_ARGUMENT =
538 const ParserErrorCode('POSITIONAL_AFTER_NAMED_ARGUMENT',
539 "Positional arguments must occur before named arguments");
540
541 static const ParserErrorCode POSITIONAL_PARAMETER_OUTSIDE_GROUP =
542 const ParserErrorCode('POSITIONAL_PARAMETER_OUTSIDE_GROUP',
543 "Positional parameters must be enclosed in square brackets ('[' and '] ')");
544
545 static const ParserErrorCode REDIRECTING_CONSTRUCTOR_WITH_BODY =
546 const ParserErrorCode('REDIRECTING_CONSTRUCTOR_WITH_BODY',
547 "Redirecting constructors cannot have a body");
548
549 static const ParserErrorCode REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR =
550 const ParserErrorCode('REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR',
551 "Only factory constructor can specify '=' redirection.");
552
553 static const ParserErrorCode SETTER_IN_FUNCTION = const ParserErrorCode(
554 'SETTER_IN_FUNCTION',
555 "Setters cannot be defined within methods or functions");
556
557 static const ParserErrorCode STATIC_AFTER_CONST = const ParserErrorCode(
558 'STATIC_AFTER_CONST',
559 "The modifier 'static' should be before the modifier 'const'");
560
561 static const ParserErrorCode STATIC_AFTER_FINAL = const ParserErrorCode(
562 'STATIC_AFTER_FINAL',
563 "The modifier 'static' should be before the modifier 'final'");
564
565 static const ParserErrorCode STATIC_AFTER_VAR = const ParserErrorCode(
566 'STATIC_AFTER_VAR',
567 "The modifier 'static' should be before the modifier 'var'");
568
569 static const ParserErrorCode STATIC_CONSTRUCTOR = const ParserErrorCode(
570 'STATIC_CONSTRUCTOR', "Constructors cannot be static");
571
572 static const ParserErrorCode STATIC_GETTER_WITHOUT_BODY =
573 const ParserErrorCode(
574 'STATIC_GETTER_WITHOUT_BODY', "A 'static' getter must have a body");
575
576 static const ParserErrorCode STATIC_OPERATOR =
577 const ParserErrorCode('STATIC_OPERATOR', "Operators cannot be static");
578
579 static const ParserErrorCode STATIC_SETTER_WITHOUT_BODY =
580 const ParserErrorCode(
581 'STATIC_SETTER_WITHOUT_BODY', "A 'static' setter must have a body");
582
583 static const ParserErrorCode STATIC_TOP_LEVEL_DECLARATION =
584 const ParserErrorCode('STATIC_TOP_LEVEL_DECLARATION',
585 "Top-level declarations cannot be declared to be 'static'");
586
587 static const ParserErrorCode SWITCH_HAS_CASE_AFTER_DEFAULT_CASE =
588 const ParserErrorCode('SWITCH_HAS_CASE_AFTER_DEFAULT_CASE',
589 "The 'default' case should be the last case in a switch statement");
590
591 static const ParserErrorCode SWITCH_HAS_MULTIPLE_DEFAULT_CASES =
592 const ParserErrorCode('SWITCH_HAS_MULTIPLE_DEFAULT_CASES',
593 "The 'default' case can only be declared once");
594
595 static const ParserErrorCode TOP_LEVEL_OPERATOR = const ParserErrorCode(
596 'TOP_LEVEL_OPERATOR', "Operators must be declared within a class");
597
598 static const ParserErrorCode TYPEDEF_IN_CLASS = const ParserErrorCode(
599 'TYPEDEF_IN_CLASS',
600 "Function type aliases cannot be declared inside classes");
601
602 static const ParserErrorCode UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP =
603 const ParserErrorCode('UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP',
604 "There is no '{0}' to open a parameter group");
605
606 static const ParserErrorCode UNEXPECTED_TOKEN =
607 const ParserErrorCode('UNEXPECTED_TOKEN', "Unexpected token '{0}'");
608
609 static const ParserErrorCode WITH_BEFORE_EXTENDS = const ParserErrorCode(
610 'WITH_BEFORE_EXTENDS',
611 "The extends clause must be before the with clause");
612
613 static const ParserErrorCode WITH_WITHOUT_EXTENDS = const ParserErrorCode(
614 'WITH_WITHOUT_EXTENDS',
615 "The with clause cannot be used without an extends clause");
616
617 static const ParserErrorCode WRONG_SEPARATOR_FOR_NAMED_PARAMETER =
618 const ParserErrorCode('WRONG_SEPARATOR_FOR_NAMED_PARAMETER',
619 "The default value of a named parameter should be preceeded by ':'");
620
621 static const ParserErrorCode WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER =
622 const ParserErrorCode('WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER',
623 "The default value of a positional parameter should be preceeded by '= '");
624
625 static const ParserErrorCode WRONG_TERMINATOR_FOR_PARAMETER_GROUP =
626 const ParserErrorCode('WRONG_TERMINATOR_FOR_PARAMETER_GROUP',
627 "Expected '{0}' to close parameter group");
628
629 static const ParserErrorCode VAR_AND_TYPE = const ParserErrorCode(
630 'VAR_AND_TYPE',
631 "Variables cannot be declared using both 'var' and a type name; remove the 'var'");
632
633 static const ParserErrorCode VAR_AS_TYPE_NAME = const ParserErrorCode(
634 'VAR_AS_TYPE_NAME', "The keyword 'var' cannot be used as a type name");
635
636 static const ParserErrorCode VAR_CLASS = const ParserErrorCode(
637 'VAR_CLASS', "Classes cannot be declared to be 'var'");
638
639 static const ParserErrorCode VAR_ENUM =
640 const ParserErrorCode('VAR_ENUM', "Enums cannot be declared to be 'var'");
641
642 static const ParserErrorCode VAR_RETURN_TYPE = const ParserErrorCode(
643 'VAR_RETURN_TYPE', "The return type cannot be 'var'");
644
645 static const ParserErrorCode VAR_TYPEDEF = const ParserErrorCode(
646 'VAR_TYPEDEF', "Type aliases cannot be declared to be 'var'");
647
648 static const ParserErrorCode VOID_PARAMETER = const ParserErrorCode(
649 'VOID_PARAMETER', "Parameters cannot have a type of 'void'");
650
651 static const ParserErrorCode VOID_VARIABLE = const ParserErrorCode(
652 'VOID_VARIABLE', "Variables cannot have a type of 'void'");
653
654 /**
655 * Initialize a newly created error code to have the given [name]. The message
656 * associated with the error will be created from the given [message]
657 * template. The correction associated with the error will be created from the
658 * given [correction] template.
659 */
660 const ParserErrorCode(String name, String message, [String correction])
661 : super(name, message, correction);
662
663 @override
664 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
665
666 @override
667 ErrorType get type => ErrorType.SYNTACTIC_ERROR;
668 }
669
670 /**
671 * The error codes used for errors detected by the scanner.
672 */
673 class ScannerErrorCode extends ErrorCode {
674 static const ScannerErrorCode ILLEGAL_CHARACTER =
675 const ScannerErrorCode('ILLEGAL_CHARACTER', "Illegal character {0}");
676
677 static const ScannerErrorCode MISSING_DIGIT =
678 const ScannerErrorCode('MISSING_DIGIT', "Decimal digit expected");
679
680 static const ScannerErrorCode MISSING_HEX_DIGIT =
681 const ScannerErrorCode('MISSING_HEX_DIGIT', "Hexidecimal digit expected");
682
683 static const ScannerErrorCode MISSING_QUOTE =
684 const ScannerErrorCode('MISSING_QUOTE', "Expected quote (' or \")");
685
686 static const ScannerErrorCode UNABLE_GET_CONTENT = const ScannerErrorCode(
687 'UNABLE_GET_CONTENT', "Unable to get content: {0}");
688
689 static const ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT =
690 const ScannerErrorCode(
691 'UNTERMINATED_MULTI_LINE_COMMENT', "Unterminated multi-line comment");
692
693 static const ScannerErrorCode UNTERMINATED_STRING_LITERAL =
694 const ScannerErrorCode(
695 'UNTERMINATED_STRING_LITERAL', "Unterminated string literal");
696
697 /**
698 * Initialize a newly created error code to have the given [name]. The message
699 * associated with the error will be created from the given [message]
700 * template. The correction associated with the error will be created from the
701 * given [correction] template.
702 */
703 const ScannerErrorCode(String name, String message, [String correction])
704 : super(name, message, correction);
705
706 @override
707 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
708
709 @override
710 ErrorType get type => ErrorType.SYNTACTIC_ERROR;
711 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/scanner/scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698