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

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

Issue 1309543011: Add support for assert statements with messages to the analyzer. Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
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 library engine.error; 5 library engine.error;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'ast.dart' show AstNode; 9 import 'ast.dart' show AstNode;
10 import 'element.dart'; 10 import 'element.dart';
(...skipping 10 matching lines...) Expand all
21 /** 21 /**
22 * An empty array of errors used when no errors are expected. 22 * An empty array of errors used when no errors are expected.
23 */ 23 */
24 static const List<AnalysisError> NO_ERRORS = const <AnalysisError>[]; 24 static const List<AnalysisError> NO_ERRORS = const <AnalysisError>[];
25 25
26 /** 26 /**
27 * A [Comparator] that sorts by the name of the file that the [AnalysisError] 27 * A [Comparator] that sorts by the name of the file that the [AnalysisError]
28 * was found. 28 * was found.
29 */ 29 */
30 static Comparator<AnalysisError> FILE_COMPARATOR = (AnalysisError o1, 30 static Comparator<AnalysisError> FILE_COMPARATOR = (AnalysisError o1,
31 AnalysisError o2) => o1.source.shortName.compareTo(o2.source.shortName); 31 AnalysisError o2) =>
32 o1.source.shortName.compareTo(o2.source.shortName);
32 33
33 /** 34 /**
34 * A [Comparator] that sorts error codes first by their severity (errors 35 * A [Comparator] that sorts error codes first by their severity (errors
35 * first, warnings second), and then by the the error code type. 36 * first, warnings second), and then by the the error code type.
36 */ 37 */
37 static Comparator<AnalysisError> ERROR_CODE_COMPARATOR = (AnalysisError o1, 38 static Comparator<AnalysisError> ERROR_CODE_COMPARATOR =
38 AnalysisError o2) { 39 (AnalysisError o1, AnalysisError o2) {
39 ErrorCode errorCode1 = o1.errorCode; 40 ErrorCode errorCode1 = o1.errorCode;
40 ErrorCode errorCode2 = o2.errorCode; 41 ErrorCode errorCode2 = o2.errorCode;
41 ErrorSeverity errorSeverity1 = errorCode1.errorSeverity; 42 ErrorSeverity errorSeverity1 = errorCode1.errorSeverity;
42 ErrorSeverity errorSeverity2 = errorCode2.errorSeverity; 43 ErrorSeverity errorSeverity2 = errorCode2.errorSeverity;
43 if (errorSeverity1 == errorSeverity2) { 44 if (errorSeverity1 == errorSeverity2) {
44 ErrorType errorType1 = errorCode1.type; 45 ErrorType errorType1 = errorCode1.type;
45 ErrorType errorType2 = errorCode2.type; 46 ErrorType errorType2 = errorCode2.type;
46 return errorType1.compareTo(errorType2); 47 return errorType1.compareTo(errorType2);
47 } else { 48 } else {
48 return errorSeverity2.compareTo(errorSeverity1); 49 return errorSeverity2.compareTo(errorSeverity1);
(...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 * * The static type of <i>e</i> is an enumerated typed with elements 1554 * * The static type of <i>e</i> is an enumerated typed with elements
1554 * <i>id<sub>1</sub></i>, &hellip;, <i>id<sub>n</sub></i>. 1555 * <i>id<sub>1</sub></i>, &hellip;, <i>id<sub>n</sub></i>.
1555 * * The sets {<i>e<sub>1</sub></i>, &hellip;, <i>e<sub>k</sub></i>} and 1556 * * The sets {<i>e<sub>1</sub></i>, &hellip;, <i>e<sub>k</sub></i>} and
1556 * {<i>id<sub>1</sub></i>, &hellip;, <i>id<sub>n</sub></i>} are not the 1557 * {<i>id<sub>1</sub></i>, &hellip;, <i>id<sub>n</sub></i>} are not the
1557 * same. 1558 * same.
1558 * 1559 *
1559 * Parameters: 1560 * Parameters:
1560 * 0: the name of the constant that is missing 1561 * 0: the name of the constant that is missing
1561 */ 1562 */
1562 static const CompileTimeErrorCode MISSING_ENUM_CONSTANT_IN_SWITCH = 1563 static const CompileTimeErrorCode MISSING_ENUM_CONSTANT_IN_SWITCH =
1563 const CompileTimeErrorCode('MISSING_ENUM_CONSTANT_IN_SWITCH', 1564 const CompileTimeErrorCode(
1565 'MISSING_ENUM_CONSTANT_IN_SWITCH',
1564 "Missing case clause for '{0}'", 1566 "Missing case clause for '{0}'",
1565 "Add a case clause for the missing constant or add a default clause.") ; 1567 "Add a case clause for the missing constant or add a default clause.") ;
1566 1568
1567 /** 1569 /**
1568 * 9 Mixins: It is a compile-time error if a declared or derived mixin 1570 * 9 Mixins: It is a compile-time error if a declared or derived mixin
1569 * explicitly declares a constructor. 1571 * explicitly declares a constructor.
1570 * 1572 *
1571 * Parameters: 1573 * Parameters:
1572 * 0: the name of the mixin that is invalid 1574 * 0: the name of the mixin that is invalid
1573 */ 1575 */
(...skipping 15 matching lines...) Expand all
1589 "This class cannot mixin the deferred class '{0}'"); 1591 "This class cannot mixin the deferred class '{0}'");
1590 1592
1591 /** 1593 /**
1592 * Not yet in the spec, but consistent with VM behavior. It is a 1594 * Not yet in the spec, but consistent with VM behavior. It is a
1593 * compile-time error if all of the constructors of a mixin's base class have 1595 * compile-time error if all of the constructors of a mixin's base class have
1594 * at least one optional parameter (since only constructors that lack 1596 * at least one optional parameter (since only constructors that lack
1595 * optional parameters can be forwarded to the mixin). See 1597 * optional parameters can be forwarded to the mixin). See
1596 * https://code.google.com/p/dart/issues/detail?id=15101#c4 1598 * https://code.google.com/p/dart/issues/detail?id=15101#c4
1597 */ 1599 */
1598 static const CompileTimeErrorCode MIXIN_HAS_NO_CONSTRUCTORS = 1600 static const CompileTimeErrorCode MIXIN_HAS_NO_CONSTRUCTORS =
1599 const CompileTimeErrorCode('MIXIN_HAS_NO_CONSTRUCTORS', 1601 const CompileTimeErrorCode(
1602 'MIXIN_HAS_NO_CONSTRUCTORS',
1600 "This mixin application is invalid because all of the constructors " 1603 "This mixin application is invalid because all of the constructors "
1601 "in the base class '{0}' have optional parameters."); 1604 "in the base class '{0}' have optional parameters.");
1602 1605
1603 /** 1606 /**
1604 * 9 Mixins: It is a compile-time error if a mixin is derived from a class 1607 * 9 Mixins: It is a compile-time error if a mixin is derived from a class
1605 * whose superclass is not Object. 1608 * whose superclass is not Object.
1606 * 1609 *
1607 * Parameters: 1610 * Parameters:
1608 * 0: the name of the mixin that is invalid 1611 * 0: the name of the mixin that is invalid
1609 */ 1612 */
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 2881
2879 /** 2882 /**
2880 * Generate a hint for methods or functions that have a return type, but do 2883 * Generate a hint for methods or functions that have a return type, but do
2881 * not have a non-void return statement on all branches. At the end of methods 2884 * not have a non-void return statement on all branches. At the end of methods
2882 * or functions with no return, Dart implicitly returns `null`, avoiding these 2885 * or functions with no return, Dart implicitly returns `null`, avoiding these
2883 * implicit returns is considered a best practice. 2886 * implicit returns is considered a best practice.
2884 * 2887 *
2885 * Parameters: 2888 * Parameters:
2886 * 0: the name of the declared return type 2889 * 0: the name of the declared return type
2887 */ 2890 */
2888 static const HintCode MISSING_RETURN = const HintCode('MISSING_RETURN', 2891 static const HintCode MISSING_RETURN = const HintCode(
2892 'MISSING_RETURN',
2889 "This function declares a return type of '{0}', but does not end with a re turn statement", 2893 "This function declares a return type of '{0}', but does not end with a re turn statement",
2890 "Either add a return statement or change the return type to 'void'"); 2894 "Either add a return statement or change the return type to 'void'");
2891 2895
2892 /** 2896 /**
2893 * A getter with the override annotation does not override an existing getter. 2897 * A getter with the override annotation does not override an existing getter.
2894 */ 2898 */
2895 static const HintCode OVERRIDE_ON_NON_OVERRIDING_GETTER = const HintCode( 2899 static const HintCode OVERRIDE_ON_NON_OVERRIDING_GETTER = const HintCode(
2896 'OVERRIDE_ON_NON_OVERRIDING_GETTER', 2900 'OVERRIDE_ON_NON_OVERRIDING_GETTER',
2897 "Getter does not override an inherited getter"); 2901 "Getter does not override an inherited getter");
2898 2902
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
3196 } 3200 }
3197 3201
3198 /** 3202 /**
3199 * The error codes used for static type warnings. The convention for this class 3203 * The error codes used for static type warnings. The convention for this class
3200 * is for the name of the error code to indicate the problem that caused the 3204 * is for the name of the error code to indicate the problem that caused the
3201 * error to be generated and for the error message to explain what is wrong and, 3205 * error to be generated and for the error message to explain what is wrong and,
3202 * when appropriate, how the problem can be corrected. 3206 * when appropriate, how the problem can be corrected.
3203 */ 3207 */
3204 class StaticTypeWarningCode extends ErrorCode { 3208 class StaticTypeWarningCode extends ErrorCode {
3205 /** 3209 /**
3210 * 17.17 Assert: It is a static type warning if the type of s may not be
3211 * assigned to String.
3212 */
3213 static const StaticTypeWarningCode ASSERT_MESSAGE_NON_STRING =
3214 const StaticTypeWarningCode('ASSERT_MESSAGE_NON_STRING',
3215 "Assertion messages must be assignable to String");
3216
3217 /**
3206 * 12.7 Lists: A fresh instance (7.6.1) <i>a</i>, of size <i>n</i>, whose 3218 * 12.7 Lists: A fresh instance (7.6.1) <i>a</i>, of size <i>n</i>, whose
3207 * class implements the built-in class <i>List&lt;E></i> is allocated. 3219 * class implements the built-in class <i>List&lt;E></i> is allocated.
3208 * 3220 *
3209 * Parameters: 3221 * Parameters:
3210 * 0: the number of provided type arguments 3222 * 0: the number of provided type arguments
3211 */ 3223 */
3212 static const StaticTypeWarningCode EXPECTED_ONE_LIST_TYPE_ARGUMENTS = 3224 static const StaticTypeWarningCode EXPECTED_ONE_LIST_TYPE_ARGUMENTS =
3213 const StaticTypeWarningCode('EXPECTED_ONE_LIST_TYPE_ARGUMENTS', 3225 const StaticTypeWarningCode('EXPECTED_ONE_LIST_TYPE_ARGUMENTS',
3214 "List literal requires exactly one type arguments or none, but {0} fou nd"); 3226 "List literal requires exactly one type arguments or none, but {0} fou nd");
3215 3227
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
3721 * 2. If <i>N</i> is referenced as a function, getter or setter, a 3733 * 2. If <i>N</i> is referenced as a function, getter or setter, a
3722 * <i>NoSuchMethodError</i> is raised. 3734 * <i>NoSuchMethodError</i> is raised.
3723 * 3. If <i>N</i> is referenced as a type, it is treated as a malformed type. 3735 * 3. If <i>N</i> is referenced as a type, it is treated as a malformed type.
3724 * 3736 *
3725 * Parameters: 3737 * Parameters:
3726 * 0: the name of the ambiguous type 3738 * 0: the name of the ambiguous type
3727 * 1: the name of the first library that the type is found 3739 * 1: the name of the first library that the type is found
3728 * 2: the name of the second library that the type is found 3740 * 2: the name of the second library that the type is found
3729 */ 3741 */
3730 static const StaticWarningCode AMBIGUOUS_IMPORT = const StaticWarningCode( 3742 static const StaticWarningCode AMBIGUOUS_IMPORT = const StaticWarningCode(
3731 'AMBIGUOUS_IMPORT', "The name '{0}' is defined in the libraries {1}", 3743 'AMBIGUOUS_IMPORT',
3744 "The name '{0}' is defined in the libraries {1}",
3732 "Consider using 'as prefix' for one of the import directives " 3745 "Consider using 'as prefix' for one of the import directives "
3733 "or hiding the name from all but one of the imports."); 3746 "or hiding the name from all but one of the imports.");
3734 3747
3735 /** 3748 /**
3736 * 12.11.1 New: It is a static warning if the static type of <i>a<sub>i</sub>, 3749 * 12.11.1 New: It is a static warning if the static type of <i>a<sub>i</sub>,
3737 * 1 &lt;= i &lt;= n+ k</i> may not be assigned to the type of the 3750 * 1 &lt;= i &lt;= n+ k</i> may not be assigned to the type of the
3738 * corresponding formal parameter of the constructor <i>T.id</i> (respectively 3751 * corresponding formal parameter of the constructor <i>T.id</i> (respectively
3739 * <i>T</i>). 3752 * <i>T</i>).
3740 * 3753 *
3741 * 12.11.2 Const: It is a static warning if the static type of 3754 * 12.11.2 Const: It is a static warning if the static type of
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
4938 * Initialize a newly created error code to have the given [name]. 4951 * Initialize a newly created error code to have the given [name].
4939 */ 4952 */
4940 const TodoCode(String name) : super(name, "{0}"); 4953 const TodoCode(String name) : super(name, "{0}");
4941 4954
4942 @override 4955 @override
4943 ErrorSeverity get errorSeverity => ErrorSeverity.INFO; 4956 ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
4944 4957
4945 @override 4958 @override
4946 ErrorType get type => ErrorType.TODO; 4959 ErrorType get type => ErrorType.TODO;
4947 } 4960 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698