| Index: packages/analyzer/lib/src/error/codes.dart
|
| diff --git a/packages/analyzer/lib/src/generated/error.dart b/packages/analyzer/lib/src/error/codes.dart
|
| similarity index 85%
|
| copy from packages/analyzer/lib/src/generated/error.dart
|
| copy to packages/analyzer/lib/src/error/codes.dart
|
| index 4e56e1045172109bd3a0e593a9da8823246af6d1..06d6ae3d7af7a926896acd173100560f907773d6 100644
|
| --- a/packages/analyzer/lib/src/generated/error.dart
|
| +++ b/packages/analyzer/lib/src/error/codes.dart
|
| @@ -2,316 +2,110 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| -library engine.error;
|
| +library analyzer.src.error.codes;
|
|
|
| -import 'dart:collection';
|
| -
|
| -import 'ast.dart' show AstNode;
|
| -import 'element.dart';
|
| -import 'java_core.dart';
|
| -import 'scanner.dart' show Token;
|
| -import 'source.dart';
|
| +import 'package:analyzer/error/error.dart';
|
| +import 'package:analyzer/src/dart/element/element.dart';
|
|
|
| /**
|
| - * An error discovered during the analysis of some Dart code.
|
| - *
|
| - * See [AnalysisErrorListener].
|
| + * The error codes used for errors in analysis options files. The convention for
|
| + * this class is for the name of the error code to indicate the problem that
|
| + * caused the error to be generated and for the error message to explain what is
|
| + * wrong and, when appropriate, how the problem can be corrected.
|
| */
|
| -class AnalysisError {
|
| - /**
|
| - * An empty array of errors used when no errors are expected.
|
| - */
|
| - static const List<AnalysisError> NO_ERRORS = const <AnalysisError>[];
|
| -
|
| - /**
|
| - * A [Comparator] that sorts by the name of the file that the [AnalysisError]
|
| - * was found.
|
| - */
|
| - static Comparator<AnalysisError> FILE_COMPARATOR = (AnalysisError o1,
|
| - AnalysisError o2) =>
|
| - o1.source.shortName.compareTo(o2.source.shortName);
|
| -
|
| - /**
|
| - * A [Comparator] that sorts error codes first by their severity (errors
|
| - * first, warnings second), and then by the the error code type.
|
| - */
|
| - static Comparator<AnalysisError> ERROR_CODE_COMPARATOR =
|
| - (AnalysisError o1, AnalysisError o2) {
|
| - ErrorCode errorCode1 = o1.errorCode;
|
| - ErrorCode errorCode2 = o2.errorCode;
|
| - ErrorSeverity errorSeverity1 = errorCode1.errorSeverity;
|
| - ErrorSeverity errorSeverity2 = errorCode2.errorSeverity;
|
| - if (errorSeverity1 == errorSeverity2) {
|
| - ErrorType errorType1 = errorCode1.type;
|
| - ErrorType errorType2 = errorCode2.type;
|
| - return errorType1.compareTo(errorType2);
|
| - } else {
|
| - return errorSeverity2.compareTo(errorSeverity1);
|
| - }
|
| - };
|
| -
|
| - /**
|
| - * The error code associated with the error.
|
| - */
|
| - final ErrorCode errorCode;
|
| -
|
| - /**
|
| - * The localized error message.
|
| - */
|
| - String _message;
|
| -
|
| - /**
|
| - * The correction to be displayed for this error, or `null` if there is no
|
| - * correction information for this error.
|
| - */
|
| - String _correction;
|
| -
|
| - /**
|
| - * The source in which the error occurred, or `null` if unknown.
|
| - */
|
| - Source source;
|
| -
|
| - /**
|
| - * The character offset from the beginning of the source (zero based) where
|
| - * the error occurred.
|
| - */
|
| - int offset = 0;
|
| -
|
| - /**
|
| - * The number of characters from the offset to the end of the source which
|
| - * encompasses the compilation error.
|
| - */
|
| - int length = 0;
|
| -
|
| - /**
|
| - * A flag indicating whether this error can be shown to be a non-issue because
|
| - * of the result of type propagation.
|
| - */
|
| - bool isStaticOnly = false;
|
| -
|
| - /**
|
| - * Initialize a newly created analysis error. The error is associated with the
|
| - * given [source] and is located at the given [offset] with the given
|
| - * [length]. The error will have the given [errorCode] and the list of
|
| - * [arguments] will be used to complete the message.
|
| - */
|
| - AnalysisError(this.source, this.offset, this.length, this.errorCode,
|
| - [List<Object> arguments]) {
|
| - this._message = formatList(errorCode.message, arguments);
|
| - String correctionTemplate = errorCode.correction;
|
| - if (correctionTemplate != null) {
|
| - this._correction = formatList(correctionTemplate, arguments);
|
| - }
|
| - }
|
| -
|
| +class AnalysisOptionsErrorCode extends ErrorCode {
|
| /**
|
| - * Initialize a newly created analysis error for the specified [source]. The
|
| - * error will have the given [errorCode] and the list of [arguments] will be
|
| - * used to complete the message. The error has no location information.
|
| - */
|
| - @deprecated // Use new AnalysisError(source, 0, 0, errorCode, arguments)
|
| - AnalysisError.con1(Source source, ErrorCode errorCode,
|
| - [List<Object> arguments])
|
| - : this(source, 0, 0, errorCode, arguments);
|
| -
|
| - /**
|
| - * Initialize a newly created analysis error for the specified [source] at the
|
| - * given [offset] with the given [length]. The error will have the given
|
| - * [errorCode] and the list of [arguments] will be used to complete the
|
| - * message.
|
| - */
|
| - @deprecated // Use new AnalysisError(source, offset, length, errorCode, arguments)
|
| - AnalysisError.con2(Source source, int offset, int length, ErrorCode errorCode,
|
| - [List<Object> arguments])
|
| - : this(source, offset, length, errorCode, arguments);
|
| -
|
| - /**
|
| - * Return the template used to create the correction to be displayed for this
|
| - * error, or `null` if there is no correction information for this error. The
|
| - * correction should indicate how the user can fix the error.
|
| + * An error code indicating that there is a syntactic error in the file.
|
| + *
|
| + * Parameters:
|
| + * 0: the error message from the parse error
|
| */
|
| - String get correction => _correction;
|
| -
|
| - @override
|
| - int get hashCode {
|
| - int hashCode = offset;
|
| - hashCode ^= (_message != null) ? _message.hashCode : 0;
|
| - hashCode ^= (source != null) ? source.hashCode : 0;
|
| - return hashCode;
|
| - }
|
| + static const AnalysisOptionsErrorCode PARSE_ERROR =
|
| + const AnalysisOptionsErrorCode('PARSE_ERROR', '{0}');
|
|
|
| /**
|
| - * Return the message to be displayed for this error. The message should
|
| - * indicate what is wrong and why it is wrong.
|
| + * Initialize a newly created error code to have the given [name].
|
| */
|
| - String get message => _message;
|
| + const AnalysisOptionsErrorCode(String name, String message,
|
| + [String correction])
|
| + : super(name, message, correction);
|
|
|
| @override
|
| - bool operator ==(Object obj) {
|
| - if (identical(obj, this)) {
|
| - return true;
|
| - }
|
| - // prepare other AnalysisError
|
| - if (obj is! AnalysisError) {
|
| - return false;
|
| - }
|
| - AnalysisError other = obj as AnalysisError;
|
| - // Quick checks.
|
| - if (!identical(errorCode, other.errorCode)) {
|
| - return false;
|
| - }
|
| - if (offset != other.offset || length != other.length) {
|
| - return false;
|
| - }
|
| - if (isStaticOnly != other.isStaticOnly) {
|
| - return false;
|
| - }
|
| - // Deep checks.
|
| - if (_message != other._message) {
|
| - return false;
|
| - }
|
| - if (source != other.source) {
|
| - return false;
|
| - }
|
| - // OK
|
| - return true;
|
| - }
|
| -
|
| - /**
|
| - * Return the value of the given [property], or `null` if the given property
|
| - * is not defined for this error.
|
| - */
|
| - Object getProperty(ErrorProperty property) => null;
|
| + ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
|
|
|
| @override
|
| - String toString() {
|
| - StringBuffer buffer = new StringBuffer();
|
| - buffer.write((source != null) ? source.fullName : "<unknown source>");
|
| - buffer.write("(");
|
| - buffer.write(offset);
|
| - buffer.write("..");
|
| - buffer.write(offset + length - 1);
|
| - buffer.write("): ");
|
| - //buffer.write("(" + lineNumber + ":" + columnNumber + "): ");
|
| - buffer.write(_message);
|
| - return buffer.toString();
|
| - }
|
| -
|
| - /**
|
| - * Merge all of the errors in the lists in the given list of [errorLists] into
|
| - * a single list of errors.
|
| - */
|
| - static List<AnalysisError> mergeLists(List<List<AnalysisError>> errorLists) {
|
| - Set<AnalysisError> errors = new HashSet<AnalysisError>();
|
| - for (List<AnalysisError> errorList in errorLists) {
|
| - errors.addAll(errorList);
|
| - }
|
| - return errors.toList();
|
| - }
|
| + ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
|
| }
|
|
|
| /**
|
| - * An object that listen for [AnalysisError]s being produced by the analysis
|
| - * engine.
|
| + * The error codes used for warnings in analysis options files. The convention
|
| + * for this class is for the name of the error code to indicate the problem that
|
| + * caused the error to be generated and for the error message to explain what is
|
| + * wrong and, when appropriate, how the problem can be corrected.
|
| */
|
| -abstract class AnalysisErrorListener {
|
| +class AnalysisOptionsWarningCode extends ErrorCode {
|
| /**
|
| - * An error listener that ignores errors that are reported to it.
|
| - */
|
| - static final AnalysisErrorListener NULL_LISTENER =
|
| - new AnalysisErrorListener_NULL_LISTENER();
|
| -
|
| - /**
|
| - * This method is invoked when an [error] has been found by the analysis
|
| - * engine.
|
| + * An error code indicating that a plugin is being configured with an
|
| + * unsupported option and legal options are provided.
|
| + *
|
| + * Parameters:
|
| + * 0: the plugin name
|
| + * 1: the unsupported option key
|
| + * 2: legal values
|
| */
|
| - void onError(AnalysisError error);
|
| -}
|
| -
|
| -/**
|
| - * An [AnalysisErrorListener] that ignores error.
|
| - */
|
| -class AnalysisErrorListener_NULL_LISTENER implements AnalysisErrorListener {
|
| - @override
|
| - void onError(AnalysisError event) {
|
| - // Ignore errors
|
| - }
|
| -}
|
| + static const AnalysisOptionsWarningCode UNSUPPORTED_OPTION_WITH_LEGAL_VALUES =
|
| + const AnalysisOptionsWarningCode('UNSUPPORTED_OPTION_WITH_LEGAL_VALUES',
|
| + "The option '{1}' is not supported by {0}, supported values are {2}");
|
|
|
| -/**
|
| - * An [AnalysisError] that can have arbitrary properties associated with it.
|
| - */
|
| -class AnalysisErrorWithProperties extends AnalysisError {
|
| /**
|
| - * The properties associated with this error.
|
| + * An error code indicating that a plugin is being configured with an
|
| + * unsupported option where there is just one legal value.
|
| + *
|
| + * Parameters:
|
| + * 0: the plugin name
|
| + * 1: the unsupported option key
|
| + * 2: the legal value
|
| */
|
| - HashMap<ErrorProperty, Object> _propertyMap =
|
| - new HashMap<ErrorProperty, Object>();
|
| + static const AnalysisOptionsWarningCode UNSUPPORTED_OPTION_WITH_LEGAL_VALUE =
|
| + const AnalysisOptionsWarningCode('UNSUPPORTED_OPTION_WITH_LEGAL_VALUE',
|
| + "The option '{1}' is not supported by {0}, did you mean {2}?");
|
|
|
| /**
|
| - * Initialize a newly created analysis error. The error is associated with the
|
| - * given [source] and is located at the given [offset] with the given
|
| - * [length]. The error will have the given [errorCode] and the list of
|
| - * [arguments] will be used to complete the message.
|
| + * An error code indicating that an option entry is being configured with an
|
| + * unsupported value.
|
| + *
|
| + * Parameters:
|
| + * 0: the option name
|
| + * 1: the unsupported value
|
| + * 2: legal values
|
| */
|
| - AnalysisErrorWithProperties(
|
| - Source source, int offset, int length, ErrorCode errorCode,
|
| - [List<Object> arguments])
|
| - : super(source, offset, length, errorCode, arguments);
|
| + static const AnalysisOptionsWarningCode UNSUPPORTED_VALUE =
|
| + const AnalysisOptionsWarningCode('UNSUPPORTED_VALUE',
|
| + "The value '{1}' is not supported by {0}, legal values are {2}");
|
|
|
| /**
|
| - * Initialize a newly created analysis error for the specified [source]. The
|
| - * error will have the given [errorCode] and the list of [arguments] will be
|
| - * used to complete the message. The error has no location information.
|
| + * An error code indicating that an unrecognized error code is being used to
|
| + * specify an error filter.
|
| + *
|
| + * Parameters:
|
| + * 0: the unrecognized error code
|
| */
|
| - @deprecated // Use new AnalysisErrorWithProperties(source, 0, 0, errorCode, arguments)
|
| - AnalysisErrorWithProperties.con1(Source source, ErrorCode errorCode,
|
| - [List<Object> arguments])
|
| - : this(source, 0, 0, errorCode, arguments);
|
| + static const AnalysisOptionsWarningCode UNRECOGNIZED_ERROR_CODE =
|
| + const AnalysisOptionsWarningCode(
|
| + 'UNRECOGNIZED_ERROR_CODE', "'{0}' is not a recognized error code");
|
|
|
| /**
|
| - * Initialize a newly created analysis error for the specified [source] at the
|
| - * given [offset] with the given [length]. The error will have the given
|
| - * [errorCode] and the list of [arguments] will be used to complete the
|
| - * message.
|
| + * Initialize a newly created warning code to have the given [name].
|
| */
|
| - @deprecated // Use new AnalysisErrorWithProperties(source, offset, length, errorCode, arguments)
|
| - AnalysisErrorWithProperties.con2(
|
| - Source source, int offset, int length, ErrorCode errorCode,
|
| - [List<Object> arguments])
|
| - : this(source, offset, length, errorCode, arguments);
|
| + const AnalysisOptionsWarningCode(String name, String message,
|
| + [String correction])
|
| + : super(name, message, correction);
|
|
|
| @override
|
| - Object getProperty(ErrorProperty property) => _propertyMap[property];
|
| -
|
| - /**
|
| - * Set the value of the given [property] to the given [value]. Using a value
|
| - * of `null` will effectively remove the property from this error.
|
| - */
|
| - void setProperty(ErrorProperty property, Object value) {
|
| - _propertyMap[property] = value;
|
| - }
|
| -}
|
| -
|
| -/**
|
| - * An [AnalysisErrorListener] that keeps track of whether any error has been
|
| - * reported to it.
|
| - */
|
| -class BooleanErrorListener implements AnalysisErrorListener {
|
| - /**
|
| - * A flag indicating whether an error has been reported to this listener.
|
| - */
|
| - bool _errorReported = false;
|
| -
|
| - /**
|
| - * Return `true` if an error has been reported to this listener.
|
| - */
|
| - bool get errorReported => _errorReported;
|
| + ErrorSeverity get errorSeverity => ErrorSeverity.WARNING;
|
|
|
| @override
|
| - void onError(AnalysisError error) {
|
| - _errorReported = true;
|
| - }
|
| + ErrorType get type => ErrorType.STATIC_WARNING;
|
| }
|
|
|
| /**
|
| @@ -334,7 +128,8 @@ class CheckedModeCompileTimeErrorCode extends ErrorCode {
|
| * 12.11.2 Const: It is a compile-time error if evaluation of a constant
|
| * object results in an uncaught exception being thrown.
|
| */
|
| - static const CheckedModeCompileTimeErrorCode CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH =
|
| + static const CheckedModeCompileTimeErrorCode
|
| + CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH =
|
| const CheckedModeCompileTimeErrorCode(
|
| 'CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH',
|
| "The object type '{0}' cannot be assigned to the field '{1}', which has type '{2}'");
|
| @@ -343,7 +138,8 @@ class CheckedModeCompileTimeErrorCode extends ErrorCode {
|
| * 12.11.2 Const: It is a compile-time error if evaluation of a constant
|
| * object results in an uncaught exception being thrown.
|
| */
|
| - static const CheckedModeCompileTimeErrorCode CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH =
|
| + static const CheckedModeCompileTimeErrorCode
|
| + CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH =
|
| const CheckedModeCompileTimeErrorCode(
|
| 'CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH',
|
| "The object type '{0}' cannot be assigned to a parameter of type '{1}'");
|
| @@ -360,7 +156,8 @@ class CheckedModeCompileTimeErrorCode extends ErrorCode {
|
| * 0: the name of the type of the initializer expression
|
| * 1: the name of the type of the field
|
| */
|
| - static const CheckedModeCompileTimeErrorCode CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE =
|
| + static const CheckedModeCompileTimeErrorCode
|
| + CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE =
|
| const CheckedModeCompileTimeErrorCode(
|
| 'CONST_FIELD_INITIALIZER_NOT_ASSIGNABLE',
|
| "The initializer type '{0}' cannot be assigned to the field type '{1}'");
|
| @@ -378,8 +175,9 @@ class CheckedModeCompileTimeErrorCode extends ErrorCode {
|
| * warning if <i>T<sub>j</sub></i> may not be assigned to <i>S<sub>j</sub>,
|
| * 1 <= j <= m</i>.
|
| */
|
| - static const CheckedModeCompileTimeErrorCode LIST_ELEMENT_TYPE_NOT_ASSIGNABLE =
|
| - const CheckedModeCompileTimeErrorCode('LIST_ELEMENT_TYPE_NOT_ASSIGNABLE',
|
| + static const CheckedModeCompileTimeErrorCode
|
| + LIST_ELEMENT_TYPE_NOT_ASSIGNABLE = const CheckedModeCompileTimeErrorCode(
|
| + 'LIST_ELEMENT_TYPE_NOT_ASSIGNABLE',
|
| "The element type '{0}' cannot be assigned to the list type '{1}'");
|
|
|
| /**
|
| @@ -476,6 +274,26 @@ class CompileTimeErrorCode extends ErrorCode {
|
| const CompileTimeErrorCode('AMBIGUOUS_EXPORT',
|
| "The name '{0}' is defined in the libraries '{1}' and '{2}'");
|
|
|
| + /**
|
| + * 15 Metadata: The constant expression given in an annotation is type checked
|
| + * and evaluated in the scope surrounding the declaration being annotated.
|
| + *
|
| + * 12.11.2 Const: It is a compile-time error if <i>T</i> is not a class
|
| + * accessible in the current scope, optionally followed by type arguments.
|
| + *
|
| + * 12.11.2 Const: If <i>e</i> is of the form <i>const T.id(a<sub>1</sub>,
|
| + * …, a<sub>n</sub>, x<sub>n+1</sub>: a<sub>n+1</sub>, …
|
| + * x<sub>n+k</sub>: a<sub>n+k</sub>)</i> it is a compile-time error if
|
| + * <i>T</i> is not a class accessible in the current scope, optionally
|
| + * followed by type arguments.
|
| + *
|
| + * Parameters:
|
| + * 0: the name of the non-type element
|
| + */
|
| + static const CompileTimeErrorCode ANNOTATION_WITH_NON_CLASS =
|
| + const CompileTimeErrorCode(
|
| + 'ANNOTATION_WITH_NON_CLASS', "The name '{0}' is not a class");
|
| +
|
| /**
|
| * 12.33 Argument Definition Test: It is a compile time error if <i>v</i> does
|
| * not denote a formal parameter.
|
| @@ -626,7 +444,8 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * constructor is declared by a class C if any instance variable declared in C
|
| * is initialized with an expression that is not a constant expression.
|
| */
|
| - static const CompileTimeErrorCode CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST =
|
| + static const CompileTimeErrorCode
|
| + CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST =
|
| const CompileTimeErrorCode(
|
| 'CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST',
|
| "Can't define the 'const' constructor because the field '{0}' is initialized with a non-constant value");
|
| @@ -694,7 +513,8 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * 12.1 Constants: A qualified reference to a static constant variable that is
|
| * not qualified by a deferred prefix.
|
| */
|
| - static const CompileTimeErrorCode CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY =
|
| + static const CompileTimeErrorCode
|
| + CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY =
|
| const CompileTimeErrorCode(
|
| 'CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY',
|
| "Constant values from a deferred library cannot be used to initialized a 'const' variable");
|
| @@ -712,7 +532,8 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * map literal is an instance of a class that implements the operator
|
| * <i>==</i> unless the key is a string or integer.
|
| */
|
| - static const CompileTimeErrorCode CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS =
|
| + static const CompileTimeErrorCode
|
| + CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS =
|
| const CompileTimeErrorCode(
|
| 'CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS',
|
| "The constant map entry key expression type '{0}' cannot override the == operator");
|
| @@ -791,7 +612,7 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * 1: the number of type parameters that were declared
|
| * 2: the number of type arguments provided
|
| *
|
| - * See [CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS], and
|
| + * See [StaticWarningCode.NEW_WITH_INVALID_TYPE_PARAMETERS], and
|
| * [StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS].
|
| */
|
| static const CompileTimeErrorCode CONST_WITH_INVALID_TYPE_PARAMETERS =
|
| @@ -888,7 +709,8 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * 7.6.2 Factories: It is a compile-time error if <i>k</i> explicitly
|
| * specifies a default value for an optional parameter.
|
| */
|
| - static const CompileTimeErrorCode DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR =
|
| + static const CompileTimeErrorCode
|
| + DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR =
|
| const CompileTimeErrorCode(
|
| 'DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR',
|
| "Default values aren't allowed in factory constructors that redirect to another constructor");
|
| @@ -1037,6 +859,15 @@ class CompileTimeErrorCode extends ErrorCode {
|
| const CompileTimeErrorCode('EXTENDS_DEFERRED_CLASS',
|
| "This class cannot extend the deferred class '{0}'");
|
|
|
| + /**
|
| + * DEP 37 extends the syntax for assert() to allow a second "message"
|
| + * argument. We issue this error if the user tries to supply a "message"
|
| + * argument but the DEP is not enabled.
|
| + */
|
| + static const CompileTimeErrorCode EXTRA_ARGUMENT_TO_ASSERT =
|
| + const CompileTimeErrorCode('EXTRA_ARGUMENT_TO_ASSERT',
|
| + "Assertions only accept a single argument");
|
| +
|
| /**
|
| * 12.14.2 Binding Actuals to Formals: It is a static warning if <i>m <
|
| * h</i> or if <i>m > n</i>.
|
| @@ -1067,7 +898,8 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * initializer for a variable that is initialized by means of an initializing
|
| * formal of <i>k</i>.
|
| */
|
| - static const CompileTimeErrorCode FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER =
|
| + static const CompileTimeErrorCode
|
| + FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER =
|
| const CompileTimeErrorCode(
|
| 'FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER',
|
| "Fields cannot be initialized in both the parameter list and the initializers");
|
| @@ -1547,25 +1379,6 @@ class CompileTimeErrorCode extends ErrorCode {
|
| const CompileTimeErrorCode('MISSING_CONST_IN_MAP_LITERAL',
|
| "Map literals must be prefixed with 'const' when used as a constant expression");
|
|
|
| - /**
|
| - * Enum proposal: It is a static warning if all of the following conditions
|
| - * hold:
|
| - * * The switch statement does not have a 'default' clause.
|
| - * * The static type of <i>e</i> is an enumerated typed with elements
|
| - * <i>id<sub>1</sub></i>, …, <i>id<sub>n</sub></i>.
|
| - * * The sets {<i>e<sub>1</sub></i>, …, <i>e<sub>k</sub></i>} and
|
| - * {<i>id<sub>1</sub></i>, …, <i>id<sub>n</sub></i>} are not the
|
| - * same.
|
| - *
|
| - * Parameters:
|
| - * 0: the name of the constant that is missing
|
| - */
|
| - static const CompileTimeErrorCode MISSING_ENUM_CONSTANT_IN_SWITCH =
|
| - const CompileTimeErrorCode(
|
| - 'MISSING_ENUM_CONSTANT_IN_SWITCH',
|
| - "Missing case clause for '{0}'",
|
| - "Add a case clause for the missing constant or add a default clause.");
|
| -
|
| /**
|
| * 9 Mixins: It is a compile-time error if a declared or derived mixin
|
| * explicitly declares a constructor.
|
| @@ -1677,8 +1490,9 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * 7.6.1 Generative Constructors: A generative constructor may be redirecting,
|
| * in which case its only action is to invoke another generative constructor.
|
| */
|
| - static const CompileTimeErrorCode MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS =
|
| - const CompileTimeErrorCode('MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS',
|
| + static const CompileTimeErrorCode
|
| + MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS = const CompileTimeErrorCode(
|
| + 'MULTIPLE_REDIRECTING_CONSTRUCTOR_INVOCATIONS',
|
| "Constructor may have at most one 'this' redirection");
|
|
|
| /**
|
| @@ -1765,7 +1579,8 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * 12.1 Constants: A qualified reference to a static constant variable that is
|
| * not qualified by a deferred prefix.
|
| */
|
| - static const CompileTimeErrorCode NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY =
|
| + static const CompileTimeErrorCode
|
| + NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY =
|
| const CompileTimeErrorCode(
|
| 'NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY',
|
| "Constant values from a deferred library cannot be used as a case expression");
|
| @@ -1785,7 +1600,8 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * 12.1 Constants: A qualified reference to a static constant variable that is
|
| * not qualified by a deferred prefix.
|
| */
|
| - static const CompileTimeErrorCode NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY =
|
| + static const CompileTimeErrorCode
|
| + NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY =
|
| const CompileTimeErrorCode(
|
| 'NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY',
|
| "Constant values from a deferred library cannot be used as a default parameter value");
|
| @@ -1805,7 +1621,8 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * 12.1 Constants: A qualified reference to a static constant variable that is
|
| * not qualified by a deferred prefix.
|
| */
|
| - static const CompileTimeErrorCode NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY =
|
| + static const CompileTimeErrorCode
|
| + NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY =
|
| const CompileTimeErrorCode(
|
| 'NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY',
|
| "Constant values from a deferred library cannot be used as values in a 'const' list");
|
| @@ -1844,8 +1661,9 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * 12.1 Constants: A qualified reference to a static constant variable that is
|
| * not qualified by a deferred prefix.
|
| */
|
| - static const CompileTimeErrorCode NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY =
|
| - const CompileTimeErrorCode('NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY',
|
| + static const CompileTimeErrorCode
|
| + NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY = const CompileTimeErrorCode(
|
| + 'NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY',
|
| "Constant values from a deferred library cannot be used as values in a 'const' map");
|
|
|
| /**
|
| @@ -1878,7 +1696,8 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * 12.1 Constants: A qualified reference to a static constant variable that is
|
| * not qualified by a deferred prefix.
|
| */
|
| - static const CompileTimeErrorCode NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY =
|
| + static const CompileTimeErrorCode
|
| + NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY =
|
| const CompileTimeErrorCode(
|
| 'NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY',
|
| "Constant values from a deferred library cannot be used as constant initializers");
|
| @@ -2021,7 +1840,8 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * Parameters:
|
| * 0: the name of the class that implements itself recursively
|
| */
|
| - static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS =
|
| + static const CompileTimeErrorCode
|
| + RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS =
|
| const CompileTimeErrorCode(
|
| 'RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS',
|
| "'{0}' cannot extend itself");
|
| @@ -2039,7 +1859,8 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * Parameters:
|
| * 0: the name of the class that implements itself recursively
|
| */
|
| - static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS =
|
| + static const CompileTimeErrorCode
|
| + RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS =
|
| const CompileTimeErrorCode(
|
| 'RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS',
|
| "'{0}' cannot implement itself");
|
| @@ -2057,7 +1878,8 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * Parameters:
|
| * 0: the name of the class that implements itself recursively
|
| */
|
| - static const CompileTimeErrorCode RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_WITH =
|
| + static const CompileTimeErrorCode
|
| + RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_WITH =
|
| const CompileTimeErrorCode(
|
| 'RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_WITH',
|
| "'{0}' cannot use itself as a mixin");
|
| @@ -2100,7 +1922,8 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * <i>redirecting</i>, in which case its only action is to invoke another
|
| * generative constructor.
|
| */
|
| - static const CompileTimeErrorCode REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR =
|
| + static const CompileTimeErrorCode
|
| + REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR =
|
| const CompileTimeErrorCode(
|
| 'REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR',
|
| "Generative constructor cannot redirect to a factory constructor");
|
| @@ -2112,7 +1935,7 @@ class CompileTimeErrorCode extends ErrorCode {
|
| */
|
| static const CompileTimeErrorCode REFERENCED_BEFORE_DECLARATION =
|
| const CompileTimeErrorCode('REFERENCED_BEFORE_DECLARATION',
|
| - "Local variables cannot be referenced before they are declared");
|
| + "Local variable '{0}' cannot be referenced before it is declared");
|
|
|
| /**
|
| * 12.8.1 Rethrow: It is a compile-time error if an expression of the form
|
| @@ -2120,23 +1943,28 @@ class CompileTimeErrorCode extends ErrorCode {
|
| */
|
| static const CompileTimeErrorCode RETHROW_OUTSIDE_CATCH =
|
| const CompileTimeErrorCode(
|
| - 'RETHROW_OUTSIDE_CATCH', "rethrow must be inside of a catch clause");
|
| + 'RETHROW_OUTSIDE_CATCH',
|
| + "Rethrow must be inside of catch clause.",
|
| + "Try moving the expression into a catch clause, or using a 'throw' expression.");
|
|
|
| /**
|
| * 13.12 Return: It is a compile-time error if a return statement of the form
|
| * <i>return e;</i> appears in a generative constructor.
|
| */
|
| static const CompileTimeErrorCode RETURN_IN_GENERATIVE_CONSTRUCTOR =
|
| - const CompileTimeErrorCode('RETURN_IN_GENERATIVE_CONSTRUCTOR',
|
| - "Constructors cannot return a value");
|
| + const CompileTimeErrorCode(
|
| + 'RETURN_IN_GENERATIVE_CONSTRUCTOR',
|
| + "Constructors can't return values.",
|
| + "Try removing the return statement or using a factory constructor.");
|
|
|
| /**
|
| * 13.12 Return: It is a compile-time error if a return statement of the form
|
| * <i>return e;</i> appears in a generator function.
|
| */
|
| - static const CompileTimeErrorCode RETURN_IN_GENERATOR =
|
| - const CompileTimeErrorCode('RETURN_IN_GENERATOR',
|
| - "Cannot return a value from a generator function (one marked with either 'async*' or 'sync*')");
|
| + static const CompileTimeErrorCode RETURN_IN_GENERATOR = const CompileTimeErrorCode(
|
| + 'RETURN_IN_GENERATOR',
|
| + "Can't return a value from a generator function (using the '{0}' modifier).",
|
| + "Try removing the value, replacing 'return' with 'yield' or changing the method body modifier.");
|
|
|
| /**
|
| * 14.1 Imports: It is a compile-time error if a prefix used in a deferred
|
| @@ -2231,8 +2059,9 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * class <i>S</i> does not declare a generative constructor named <i>S</i>
|
| * (respectively <i>S.id</i>)
|
| */
|
| - static const CompileTimeErrorCode UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT =
|
| - const CompileTimeErrorCode('UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT',
|
| + static const CompileTimeErrorCode
|
| + UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT = const CompileTimeErrorCode(
|
| + 'UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT',
|
| "The class '{0}' does not have a default generative constructor");
|
|
|
| /**
|
| @@ -2264,12 +2093,25 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * Parameters:
|
| * 0: the URI pointing to a non-existent file
|
| *
|
| - * See [INVALID_URI].
|
| + * See [INVALID_URI], [URI_HAS_NOT_BEEN_GENERATED].
|
| */
|
| static const CompileTimeErrorCode URI_DOES_NOT_EXIST =
|
| const CompileTimeErrorCode(
|
| 'URI_DOES_NOT_EXIST', "Target of URI does not exist: '{0}'");
|
|
|
| + /**
|
| + * Just like [URI_DOES_NOT_EXIST], but used when the URI refers to a file that
|
| + * is expected to be generated.
|
| + *
|
| + * Parameters:
|
| + * 0: the URI pointing to a non-existent file
|
| + *
|
| + * See [INVALID_URI], [URI_DOES_NOT_EXIST].
|
| + */
|
| + static const CompileTimeErrorCode URI_HAS_NOT_BEEN_GENERATED =
|
| + const CompileTimeErrorCode('URI_HAS_NOT_BEEN_GENERATED',
|
| + "Target of URI has not been generated: '{0}'");
|
| +
|
| /**
|
| * 14.1 Imports: It is a compile-time error if <i>x</i> is not a compile-time
|
| * constant, or if <i>x</i> involves string interpolation.
|
| @@ -2310,7 +2152,8 @@ class CompileTimeErrorCode extends ErrorCode {
|
| * Parameters:
|
| * 0: the number of parameters found in the operator declaration
|
| */
|
| - static const CompileTimeErrorCode WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINUS =
|
| + static const CompileTimeErrorCode
|
| + WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINUS =
|
| const CompileTimeErrorCode(
|
| 'WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR_MINUS',
|
| "Operator '-' should declare 0 or 1 parameter, but {0} found");
|
| @@ -2356,478 +2199,23 @@ class CompileTimeErrorCode extends ErrorCode {
|
| }
|
|
|
| /**
|
| - * An error listener that can be enabled or disabled while executing a function.
|
| - */
|
| -class DisablableErrorListener implements AnalysisErrorListener {
|
| - /**
|
| - * The listener to which errors will be reported if this listener is enabled.
|
| - */
|
| - final AnalysisErrorListener baseListener;
|
| -
|
| - /**
|
| - * A flag indicating whether this listener is currently enabled.
|
| - */
|
| - bool enabled = true;
|
| -
|
| - /**
|
| - * Initialize a newly created listener to report errors to the given
|
| - * [baseListener].
|
| - */
|
| - DisablableErrorListener(this.baseListener);
|
| -
|
| - /**
|
| - * Disable the processing of errors while evaluating the given [function].
|
| - * Return the value returned by the function.
|
| - */
|
| - dynamic disableWhile(dynamic function()) {
|
| - bool wasEnabled = enabled;
|
| - try {
|
| - enabled = false;
|
| - return function();
|
| - } finally {
|
| - enabled = wasEnabled;
|
| - }
|
| - }
|
| -
|
| - /**
|
| - * Disable the processing of errors while evaluating the given [function].
|
| - * Return the value returned by the function.
|
| - */
|
| - dynamic enableWhile(dynamic function()) {
|
| - bool wasEnabled = enabled;
|
| - try {
|
| - enabled = true;
|
| - return function();
|
| - } finally {
|
| - enabled = wasEnabled;
|
| - }
|
| - }
|
| -
|
| - @override
|
| - void onError(AnalysisError error) {
|
| - if (enabled) {
|
| - baseListener.onError(error);
|
| - }
|
| - }
|
| -}
|
| -
|
| -/**
|
| - * An error code associated with an [AnalysisError].
|
| - *
|
| - * Generally, we want to provide messages that consist of three sentences. From
|
| - * the user's perspective these sentences should explain:
|
| - * 1. what is wrong,
|
| - * 2. why is it wrong, and
|
| - * 3. how do I fix it.
|
| - * However, we combine the first two in the [message] and the last in the
|
| - * [correction].
|
| - */
|
| -abstract class ErrorCode {
|
| - /**
|
| - * An empty list of error codes.
|
| - */
|
| - static const List<ErrorCode> EMPTY_LIST = const <ErrorCode>[];
|
| -
|
| - /**
|
| - * The name of the error code.
|
| - */
|
| - final String name;
|
| -
|
| - /**
|
| - * The template used to create the message to be displayed for this error. The
|
| - * message should indicate what is wrong and why it is wrong.
|
| - */
|
| - final String message;
|
| -
|
| - /**
|
| - * The template used to create the correction to be displayed for this error,
|
| - * or `null` if there is no correction information for this error. The
|
| - * correction should indicate how the user can fix the error.
|
| - */
|
| - final String correction;
|
| -
|
| - /**
|
| - * Initialize a newly created error code to have the given [name]. The message
|
| - * associated with the error will be created from the given [message]
|
| - * template. The correction associated with the error will be created from the
|
| - * given [correction] template.
|
| - */
|
| - const ErrorCode(this.name, this.message, [this.correction]);
|
| -
|
| - /**
|
| - * The severity of the error.
|
| - */
|
| - ErrorSeverity get errorSeverity;
|
| -
|
| - /**
|
| - * The type of the error.
|
| - */
|
| - ErrorType get type;
|
| -
|
| - /**
|
| - * The unique name of this error code.
|
| - */
|
| - String get uniqueName => "$runtimeType.$name";
|
| -}
|
| -
|
| -/**
|
| - * The properties that can be associated with an [AnalysisError].
|
| - */
|
| -class ErrorProperty extends Enum<ErrorProperty> {
|
| - /**
|
| - * A property whose value is a list of [FieldElement]s that are final, but
|
| - * not initialized by a constructor.
|
| - */
|
| - static const ErrorProperty NOT_INITIALIZED_FIELDS =
|
| - const ErrorProperty('NOT_INITIALIZED_FIELDS', 0);
|
| -
|
| - /**
|
| - * A property whose value is the name of the library that is used by all
|
| - * of the "part of" directives, so should be used in the "library" directive.
|
| - * Is `null` if there is no a single name used by all of the parts.
|
| - */
|
| - static const ErrorProperty PARTS_LIBRARY_NAME =
|
| - const ErrorProperty('PARTS_LIBRARY_NAME', 1);
|
| -
|
| - /**
|
| - * A property whose value is a list of [ExecutableElement] that should
|
| - * be but are not implemented by a concrete class.
|
| - */
|
| - static const ErrorProperty UNIMPLEMENTED_METHODS =
|
| - const ErrorProperty('UNIMPLEMENTED_METHODS', 2);
|
| -
|
| - static const List<ErrorProperty> values = const [
|
| - NOT_INITIALIZED_FIELDS,
|
| - PARTS_LIBRARY_NAME,
|
| - UNIMPLEMENTED_METHODS
|
| - ];
|
| -
|
| - const ErrorProperty(String name, int ordinal) : super(name, ordinal);
|
| -}
|
| -
|
| -/**
|
| - * An object used to create analysis errors and report then to an error
|
| - * listener.
|
| - */
|
| -class ErrorReporter {
|
| - /**
|
| - * The error listener to which errors will be reported.
|
| - */
|
| - final AnalysisErrorListener _errorListener;
|
| -
|
| - /**
|
| - * The default source to be used when reporting errors.
|
| - */
|
| - final Source _defaultSource;
|
| -
|
| - /**
|
| - * The source to be used when reporting errors.
|
| - */
|
| - Source _source;
|
| -
|
| - /**
|
| - * Initialize a newly created error reporter that will report errors to the
|
| - * given [_errorListener]. Errors will be reported against the
|
| - * [_defaultSource] unless another source is provided later.
|
| - */
|
| - ErrorReporter(this._errorListener, this._defaultSource) {
|
| - if (_errorListener == null) {
|
| - throw new IllegalArgumentException("An error listener must be provided");
|
| - } else if (_defaultSource == null) {
|
| - throw new IllegalArgumentException("A default source must be provided");
|
| - }
|
| - this._source = _defaultSource;
|
| - }
|
| -
|
| - Source get source => _source;
|
| -
|
| - /**
|
| - * Set the source to be used when reporting errors to the given [source].
|
| - * Setting the source to `null` will cause the default source to be used.
|
| - */
|
| - void set source(Source source) {
|
| - this._source = source == null ? _defaultSource : source;
|
| - }
|
| -
|
| - /**
|
| - * Creates an error with properties with the given [errorCode] and
|
| - * [arguments]. The [node] is used to compute the location of the error.
|
| - */
|
| - AnalysisErrorWithProperties newErrorWithProperties(
|
| - ErrorCode errorCode, AstNode node, List<Object> arguments) =>
|
| - new AnalysisErrorWithProperties(
|
| - _source, node.offset, node.length, errorCode, arguments);
|
| -
|
| - /**
|
| - * Report the given [error].
|
| - */
|
| - void reportError(AnalysisError error) {
|
| - _errorListener.onError(error);
|
| - }
|
| -
|
| - /**
|
| - * Report an error with the given [errorCode] and [arguments]. The [element]
|
| - * is used to compute the location of the error.
|
| - */
|
| - void reportErrorForElement(ErrorCode errorCode, Element element,
|
| - [List<Object> arguments]) {
|
| - int length = 0;
|
| - if (element is ImportElement) {
|
| - length = 6; // 'import'.length
|
| - } else if (element is ExportElement) {
|
| - length = 6; // 'export'.length
|
| - } else {
|
| - length = element.nameLength;
|
| - }
|
| - reportErrorForOffset(errorCode, element.nameOffset, length, arguments);
|
| - }
|
| -
|
| - /**
|
| - * Report an error with the given [errorCode] and [arguments].
|
| - * The [node] is used to compute the location of the error.
|
| - *
|
| - * If the arguments contain the names of two or more types, the method
|
| - * [reportTypeErrorForNode] should be used and the types
|
| - * themselves (rather than their names) should be passed as arguments.
|
| - */
|
| - void reportErrorForNode(ErrorCode errorCode, AstNode node,
|
| - [List<Object> arguments]) {
|
| - reportErrorForOffset(errorCode, node.offset, node.length, arguments);
|
| - }
|
| -
|
| - /**
|
| - * Report an error with the given [errorCode] and [arguments]. The location of
|
| - * the error is specified by the given [offset] and [length].
|
| - */
|
| - void reportErrorForOffset(ErrorCode errorCode, int offset, int length,
|
| - [List<Object> arguments]) {
|
| - _errorListener.onError(
|
| - new AnalysisError(_source, offset, length, errorCode, arguments));
|
| - }
|
| -
|
| - /**
|
| - * Report an error with the given [errorCode] and [arguments]. The [token] is
|
| - * used to compute the location of the error.
|
| - */
|
| - void reportErrorForToken(ErrorCode errorCode, Token token,
|
| - [List<Object> arguments]) {
|
| - reportErrorForOffset(errorCode, token.offset, token.length, arguments);
|
| - }
|
| -
|
| - /**
|
| - * Report an error with the given [errorCode] and [arguments]. The [node] is
|
| - * used to compute the location of the error. The arguments are expected to
|
| - * contain two or more types. Convert the types into strings by using the
|
| - * display names of the types, unless there are two or more types with the
|
| - * same names, in which case the extended display names of the types will be
|
| - * used in order to clarify the message.
|
| - *
|
| - * If there are not two or more types in the argument list, the method
|
| - * [reportErrorForNode] should be used instead.
|
| - */
|
| - void reportTypeErrorForNode(
|
| - ErrorCode errorCode, AstNode node, List<Object> arguments) {
|
| - _convertTypeNames(arguments);
|
| - reportErrorForOffset(errorCode, node.offset, node.length, arguments);
|
| - }
|
| -
|
| - /**
|
| - * Given an array of [arguments] that is expected to contain two or more
|
| - * types, convert the types into strings by using the display names of the
|
| - * types, unless there are two or more types with the same names, in which
|
| - * case the extended display names of the types will be used in order to
|
| - * clarify the message.
|
| - */
|
| - void _convertTypeNames(List<Object> arguments) {
|
| - if (_hasEqualTypeNames(arguments)) {
|
| - int count = arguments.length;
|
| - for (int i = 0; i < count; i++) {
|
| - Object argument = arguments[i];
|
| - if (argument is DartType) {
|
| - DartType type = argument;
|
| - Element element = type.element;
|
| - if (element == null) {
|
| - arguments[i] = type.displayName;
|
| - } else {
|
| - arguments[i] = element.getExtendedDisplayName(type.displayName);
|
| - }
|
| - }
|
| - }
|
| - } else {
|
| - int count = arguments.length;
|
| - for (int i = 0; i < count; i++) {
|
| - Object argument = arguments[i];
|
| - if (argument is DartType) {
|
| - arguments[i] = argument.displayName;
|
| - }
|
| - }
|
| - }
|
| - }
|
| -
|
| - /**
|
| - * Return `true` if the given array of [arguments] contains two or more types
|
| - * with the same display name.
|
| - */
|
| - bool _hasEqualTypeNames(List<Object> arguments) {
|
| - int count = arguments.length;
|
| - HashSet<String> typeNames = new HashSet<String>();
|
| - for (int i = 0; i < count; i++) {
|
| - if (arguments[i] is DartType &&
|
| - !typeNames.add((arguments[i] as DartType).displayName)) {
|
| - return true;
|
| - }
|
| - }
|
| - return false;
|
| - }
|
| -}
|
| -
|
| -/**
|
| - * The severity of an [ErrorCode].
|
| + * The hints and coding recommendations for best practices which are not
|
| + * mentioned in the Dart Language Specification.
|
| */
|
| -class ErrorSeverity extends Enum<ErrorSeverity> {
|
| - /**
|
| - * The severity representing a non-error. This is never used for any error
|
| - * code, but is useful for clients.
|
| - */
|
| - static const ErrorSeverity NONE = const ErrorSeverity('NONE', 0, " ", "none");
|
| -
|
| - /**
|
| - * The severity representing an informational level analysis issue.
|
| - */
|
| - static const ErrorSeverity INFO = const ErrorSeverity('INFO', 1, "I", "info");
|
| -
|
| - /**
|
| - * The severity representing a warning. Warnings can become errors if the `-Werror` command
|
| - * line flag is specified.
|
| - */
|
| - static const ErrorSeverity WARNING =
|
| - const ErrorSeverity('WARNING', 2, "W", "warning");
|
| -
|
| - /**
|
| - * The severity representing an error.
|
| - */
|
| - static const ErrorSeverity ERROR =
|
| - const ErrorSeverity('ERROR', 3, "E", "error");
|
| -
|
| - static const List<ErrorSeverity> values = const [NONE, INFO, WARNING, ERROR];
|
| -
|
| - /**
|
| - * The name of the severity used when producing machine output.
|
| - */
|
| - final String machineCode;
|
| -
|
| - /**
|
| - * The name of the severity used when producing readable output.
|
| - */
|
| - final String displayName;
|
| -
|
| +class HintCode extends ErrorCode {
|
| /**
|
| - * Initialize a newly created severity with the given names.
|
| + * When an abstract supertype member is references with `super` as its target,
|
| + * it cannot be overridden, so it is always a runtime error.
|
| *
|
| * Parameters:
|
| - * 0: the name of the severity used when producing machine output
|
| - * 1: the name of the severity used when producing readable output
|
| - */
|
| - const ErrorSeverity(
|
| - String name, int ordinal, this.machineCode, this.displayName)
|
| - : super(name, ordinal);
|
| -
|
| - /**
|
| - * Return the severity constant that represents the greatest severity.
|
| - */
|
| - ErrorSeverity max(ErrorSeverity severity) =>
|
| - this.ordinal >= severity.ordinal ? this : severity;
|
| -}
|
| -
|
| -/**
|
| - * The type of an [ErrorCode].
|
| - */
|
| -class ErrorType extends Enum<ErrorType> {
|
| - /**
|
| - * Task (todo) comments in user code.
|
| - */
|
| - static const ErrorType TODO = const ErrorType('TODO', 0, ErrorSeverity.INFO);
|
| -
|
| - /**
|
| - * Extra analysis run over the code to follow best practices, which are not in
|
| - * the Dart Language Specification.
|
| - */
|
| - static const ErrorType HINT = const ErrorType('HINT', 1, ErrorSeverity.INFO);
|
| -
|
| - /**
|
| - * Compile-time errors are errors that preclude execution. A compile time
|
| - * error must be reported by a Dart compiler before the erroneous code is
|
| - * executed.
|
| + * 0: the display name for the kind of the referenced element
|
| + * 1: the name of the referenced element
|
| */
|
| - static const ErrorType COMPILE_TIME_ERROR =
|
| - const ErrorType('COMPILE_TIME_ERROR', 2, ErrorSeverity.ERROR);
|
| + static const HintCode ABSTRACT_SUPER_MEMBER_REFERENCE = const HintCode(
|
| + 'ABSTRACT_SUPER_MEMBER_REFERENCE',
|
| + "The {0} '{1}' is always abstract in the supertype.",
|
| + null);
|
|
|
| - /**
|
| - * Checked mode compile-time errors are errors that preclude execution in
|
| - * checked mode.
|
| - */
|
| - static const ErrorType CHECKED_MODE_COMPILE_TIME_ERROR = const ErrorType(
|
| - 'CHECKED_MODE_COMPILE_TIME_ERROR', 3, ErrorSeverity.ERROR);
|
| -
|
| - /**
|
| - * Static warnings are those warnings reported by the static checker. They
|
| - * have no effect on execution. Static warnings must be provided by Dart
|
| - * compilers used during development.
|
| - */
|
| - static const ErrorType STATIC_WARNING =
|
| - const ErrorType('STATIC_WARNING', 4, ErrorSeverity.WARNING);
|
| -
|
| - /**
|
| - * Many, but not all, static warnings relate to types, in which case they are
|
| - * known as static type warnings.
|
| - */
|
| - static const ErrorType STATIC_TYPE_WARNING =
|
| - const ErrorType('STATIC_TYPE_WARNING', 5, ErrorSeverity.WARNING);
|
| -
|
| - /**
|
| - * Syntactic errors are errors produced as a result of input that does not
|
| - * conform to the grammar.
|
| - */
|
| - static const ErrorType SYNTACTIC_ERROR =
|
| - const ErrorType('SYNTACTIC_ERROR', 6, ErrorSeverity.ERROR);
|
| -
|
| - /**
|
| - * Lint warnings describe style and best practice recommendations that can be
|
| - * used to formalize a project's style guidelines.
|
| - */
|
| - static const ErrorType LINT = const ErrorType('LINT', 7, ErrorSeverity.INFO);
|
| -
|
| - static const List<ErrorType> values = const [
|
| - TODO,
|
| - HINT,
|
| - COMPILE_TIME_ERROR,
|
| - CHECKED_MODE_COMPILE_TIME_ERROR,
|
| - STATIC_WARNING,
|
| - STATIC_TYPE_WARNING,
|
| - SYNTACTIC_ERROR,
|
| - LINT
|
| - ];
|
| -
|
| - /**
|
| - * The severity of this type of error.
|
| - */
|
| - final ErrorSeverity severity;
|
| -
|
| - /**
|
| - * Initialize a newly created error type to have the given [name] and
|
| - * [severity].
|
| - */
|
| - const ErrorType(String name, int ordinal, this.severity)
|
| - : super(name, ordinal);
|
| -
|
| - String get displayName => name.toLowerCase().replaceAll('_', ' ');
|
| -}
|
| -
|
| -/**
|
| - * The hints and coding recommendations for best practices which are not
|
| - * mentioned in the Dart Language Specification.
|
| - */
|
| -class HintCode extends ErrorCode {
|
| /**
|
| * This hint is generated anywhere where the
|
| * [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE] would have been generated,
|
| @@ -2839,7 +2227,17 @@ class HintCode extends ErrorCode {
|
| */
|
| static const HintCode ARGUMENT_TYPE_NOT_ASSIGNABLE = const HintCode(
|
| 'ARGUMENT_TYPE_NOT_ASSIGNABLE',
|
| - "The argument type '{0}' cannot be assigned to the parameter type '{1}'");
|
| + "The argument type '{0}' cannot be assigned to the parameter type '{1}'.",
|
| + null);
|
| +
|
| + /**
|
| + * When the target expression uses '?.' operator, it can be `null`, so all the
|
| + * subsequent invocations should also use '?.' operator.
|
| + */
|
| + static const HintCode CAN_BE_NULL_AFTER_NULL_AWARE = const HintCode(
|
| + 'CAN_BE_NULL_AFTER_NULL_AWARE',
|
| + "The expression uses '?.', so can be 'null'",
|
| + "Replace the '.' with a '?.' in the invocation");
|
|
|
| /**
|
| * Dead code is code that is never reached, this can happen for instance if a
|
| @@ -2934,6 +2332,76 @@ class HintCode extends ErrorCode {
|
| 'INVALID_ASSIGNMENT',
|
| "A value of type '{0}' cannot be assigned to a variable of type '{1}'");
|
|
|
| + /**
|
| + * This hint is generated anywhere a @factory annotation is associated with
|
| + * anything other than a method.
|
| + */
|
| + static const HintCode INVALID_FACTORY_ANNOTATION = const HintCode(
|
| + 'INVALID_FACTORY_ANNOTATION',
|
| + "Only methods can be annotated as factories.");
|
| +
|
| + /**
|
| + * This hint is generated anywhere a @factory annotation is associated with
|
| + * a method that does not declare a return type.
|
| + */
|
| + static const HintCode INVALID_FACTORY_METHOD_DECL = const HintCode(
|
| + 'INVALID_FACTORY_METHOD_DECL',
|
| + "Factory method '{0}' must have a return type.");
|
| +
|
| + /**
|
| + * This hint is generated anywhere a @factory annotation is associated with
|
| + * a non-abstract method that can return anything other than a newly allocated
|
| + * object.
|
| + *
|
| + * Parameters:
|
| + * 0: the name of the method
|
| + */
|
| + static const HintCode INVALID_FACTORY_METHOD_IMPL = const HintCode(
|
| + 'INVALID_FACTORY_METHOD_IMPL',
|
| + "Factory method '{0}' does not return a newly allocated object.");
|
| +
|
| + /**
|
| + * This hint is generated anywhere where a member annotated with `@protected`
|
| + * is used outside an instance member of a subclass.
|
| + *
|
| + * Parameters:
|
| + * 0: the name of the member
|
| + * 1: the name of the defining class
|
| + */
|
| + static const HintCode INVALID_USE_OF_PROTECTED_MEMBER = const HintCode(
|
| + 'INVALID_USE_OF_PROTECTED_MEMBER',
|
| + "The member '{0}' can only be used within instance members of subclasses of '{1}'");
|
| +
|
| + /**
|
| + * Generate a hint for a constructor, function or method invocation where a
|
| + * required parameter is missing.
|
| + *
|
| + * Parameters:
|
| + * 0: the name of the parameter
|
| + */
|
| + static const HintCode MISSING_REQUIRED_PARAM = const HintCode(
|
| + 'MISSING_REQUIRED_PARAM', "The parameter '{0}' is required.");
|
| +
|
| + /**
|
| + * Generate a hint for a constructor, function or method invocation where a
|
| + * required parameter is missing.
|
| + *
|
| + * Parameters:
|
| + * 0: the name of the parameter
|
| + * 1: message details
|
| + */
|
| + static const HintCode MISSING_REQUIRED_PARAM_WITH_DETAILS = const HintCode(
|
| + 'MISSING_REQUIRED_PARAM_WITH_DETAILS',
|
| + "The parameter '{0}' is required. {1}");
|
| +
|
| + /**
|
| + * Generate a hint for an element that is annotated with `@JS(...)` whose
|
| + * library declaration is not similarly annotated.
|
| + */
|
| + static const HintCode MISSING_JS_LIB_ANNOTATION = const HintCode(
|
| + 'MISSING_JS_LIB_ANNOTATION',
|
| + "The @JS() annotation can only be used if it is also declared on the library directive.");
|
| +
|
| /**
|
| * Generate a hint for methods or functions that have a return type, but do
|
| * not have a non-void return statement on all branches. At the end of methods
|
| @@ -2948,6 +2416,27 @@ class HintCode extends ErrorCode {
|
| "This function declares a return type of '{0}', but does not end with a return statement",
|
| "Either add a return statement or change the return type to 'void'");
|
|
|
| + /**
|
| + * Generate a hint for methods that override methods annotated `@mustCallSuper`
|
| + * that do not invoke the overridden super method.
|
| + *
|
| + * Parameters:
|
| + * 0: the name of the class declaring the overriden method
|
| + */
|
| + static const HintCode MUST_CALL_SUPER = const HintCode(
|
| + 'MUST_CALL_SUPER',
|
| + "This method overrides a method annotated as @mustCall super in '{0}', "
|
| + "but does invoke the overriden method");
|
| +
|
| + /**
|
| + * A condition in a control flow statement could evaluate to `null` because it
|
| + * uses the null-aware '?.' operator.
|
| + */
|
| + static const HintCode NULL_AWARE_IN_CONDITION = const HintCode(
|
| + 'NULL_AWARE_IN_CONDITION',
|
| + "The value of the '?.' operator can be 'null', which is not appropriate in a condition",
|
| + "Replace the '?.' with a '.', testing the left-hand side for null if necessary");
|
| +
|
| /**
|
| * A getter with the override annotation does not override an existing getter.
|
| */
|
| @@ -2955,6 +2444,13 @@ class HintCode extends ErrorCode {
|
| 'OVERRIDE_ON_NON_OVERRIDING_GETTER',
|
| "Getter does not override an inherited getter");
|
|
|
| + /**
|
| + * A field with the override annotation does not override a getter or setter.
|
| + */
|
| + static const HintCode OVERRIDE_ON_NON_OVERRIDING_FIELD = const HintCode(
|
| + 'OVERRIDE_ON_NON_OVERRIDING_FIELD',
|
| + "Field does not override an inherited getter or setter");
|
| +
|
| /**
|
| * A method with the override annotation does not override an existing method.
|
| */
|
| @@ -3003,7 +2499,14 @@ class HintCode extends ErrorCode {
|
| * 1: the name of the enclosing type where the getter is being looked for
|
| */
|
| static const HintCode UNDEFINED_GETTER = const HintCode('UNDEFINED_GETTER',
|
| - "The getter '{0}' is not defined for the class '{1}'");
|
| + "The getter '{0}' is not defined for the class '{1}'.", null);
|
| +
|
| + /**
|
| + * An undefined name hidden in an import or export directive.
|
| + */
|
| + static const HintCode UNDEFINED_HIDDEN_NAME = const HintCode(
|
| + 'UNDEFINED_HIDDEN_NAME',
|
| + "The library '{0}' doesn't export a member with the hidden name '{1}'");
|
|
|
| /**
|
| * This hint is generated anywhere where the
|
| @@ -3015,7 +2518,7 @@ class HintCode extends ErrorCode {
|
| * 1: the resolved type name that the method lookup is happening on
|
| */
|
| static const HintCode UNDEFINED_METHOD = const HintCode('UNDEFINED_METHOD',
|
| - "The method '{0}' is not defined for the class '{1}'");
|
| + "The method '{0}' is not defined for the class '{1}'.", null);
|
|
|
| /**
|
| * This hint is generated anywhere where the
|
| @@ -3028,7 +2531,8 @@ class HintCode extends ErrorCode {
|
| */
|
| static const HintCode UNDEFINED_OPERATOR = const HintCode(
|
| 'UNDEFINED_OPERATOR',
|
| - "The operator '{0}' is not defined for the class '{1}'");
|
| + "The operator '{0}' is not defined for the class '{1}'.",
|
| + null);
|
|
|
| /**
|
| * This hint is generated anywhere where the
|
| @@ -3041,7 +2545,14 @@ class HintCode extends ErrorCode {
|
| * 1: the name of the enclosing type where the setter is being looked for
|
| */
|
| static const HintCode UNDEFINED_SETTER = const HintCode('UNDEFINED_SETTER',
|
| - "The setter '{0}' is not defined for the class '{1}'");
|
| + "The setter '{0}' is not defined for the class '{1}'.", null);
|
| +
|
| + /**
|
| + * An undefined name shown in an import or export directive.
|
| + */
|
| + static const HintCode UNDEFINED_SHOWN_NAME = const HintCode(
|
| + 'UNDEFINED_SHOWN_NAME',
|
| + "The library '{0}' doesn't export a member with the shown name '{1}'");
|
|
|
| /**
|
| * Unnecessary cast.
|
| @@ -3049,6 +2560,12 @@ class HintCode extends ErrorCode {
|
| static const HintCode UNNECESSARY_CAST =
|
| const HintCode('UNNECESSARY_CAST', "Unnecessary cast");
|
|
|
| + /**
|
| + * Unnecessary `noSuchMethod` declaration.
|
| + */
|
| + static const HintCode UNNECESSARY_NO_SUCH_METHOD = const HintCode(
|
| + 'UNNECESSARY_NO_SUCH_METHOD', "Unnecessary 'noSuchMethod' declaration");
|
| +
|
| /**
|
| * Unnecessary type checks, the result is always true.
|
| */
|
| @@ -3102,6 +2619,12 @@ class HintCode extends ErrorCode {
|
| 'UNUSED_LOCAL_VARIABLE',
|
| "The value of the local variable '{0}' is not used");
|
|
|
| + /**
|
| + * Unused shown names are names shown on imports which are never used.
|
| + */
|
| + static const HintCode UNUSED_SHOWN_NAME = const HintCode(
|
| + 'UNUSED_SHOWN_NAME', "The name {0} is shown, but not used.");
|
| +
|
| /**
|
| * Hint for cases where the source expects a method or function to return a
|
| * non-void result, but the method or function signature returns void.
|
| @@ -3472,6 +2995,10 @@ class StaticTypeWarningCode extends ErrorCode {
|
| const StaticTypeWarningCode('NON_BOOL_OPERAND',
|
| "The operands of the '{0}' operator must be assignable to 'bool'");
|
|
|
| + static const StaticTypeWarningCode NON_NULLABLE_FIELD_NOT_INITIALIZED =
|
| + const StaticTypeWarningCode('NON_NULLABLE_FIELD_NOT_INITIALIZED',
|
| + "Variable '{0}' of non-nullable type '{1}' must be initialized");
|
| +
|
| /**
|
| * 15.8 Parameterized Types: It is a static type warning if <i>A<sub>i</sub>,
|
| * 1 <= i <= n</i> does not denote a type in the enclosing lexical scope.
|
| @@ -3491,8 +3018,10 @@ class StaticTypeWarningCode extends ErrorCode {
|
| * 2: the name of the method
|
| */
|
| static const StaticTypeWarningCode RETURN_OF_INVALID_TYPE =
|
| - const StaticTypeWarningCode('RETURN_OF_INVALID_TYPE',
|
| - "The return type '{0}' is not a '{1}', as defined by the method '{2}'");
|
| + const StaticTypeWarningCode(
|
| + 'RETURN_OF_INVALID_TYPE',
|
| + "The return type '{0}' is not a '{1}', as defined by the method '{2}'.",
|
| + null);
|
|
|
| /**
|
| * 12.11 Instance Creation: It is a static type warning if any of the type
|
| @@ -3550,7 +3079,7 @@ class StaticTypeWarningCode extends ErrorCode {
|
| */
|
| static const StaticTypeWarningCode UNDEFINED_ENUM_CONSTANT =
|
| const StaticTypeWarningCode('UNDEFINED_ENUM_CONSTANT',
|
| - "There is no constant named '{0}' in '{1}'");
|
| + "There is no constant named '{0}' in '{1}'.", null);
|
|
|
| /**
|
| * 12.15.3 Unqualified Invocation: If there exists a lexically visible
|
| @@ -3566,7 +3095,7 @@ class StaticTypeWarningCode extends ErrorCode {
|
| */
|
| static const StaticTypeWarningCode UNDEFINED_FUNCTION =
|
| const StaticTypeWarningCode(
|
| - 'UNDEFINED_FUNCTION', "The function '{0}' is not defined");
|
| + 'UNDEFINED_FUNCTION', "The function '{0}' is not defined.", null);
|
|
|
| /**
|
| * 12.17 Getter Invocation: Let <i>T</i> be the static type of <i>e</i>. It is
|
| @@ -3578,7 +3107,7 @@ class StaticTypeWarningCode extends ErrorCode {
|
| */
|
| static const StaticTypeWarningCode UNDEFINED_GETTER =
|
| const StaticTypeWarningCode('UNDEFINED_GETTER',
|
| - "The getter '{0}' is not defined for the class '{1}'");
|
| + "The getter '{0}' is not defined for the class '{1}'.", null);
|
|
|
| /**
|
| * 12.15.1 Ordinary Invocation: Let <i>T</i> be the static type of <i>o</i>.
|
| @@ -3591,7 +3120,22 @@ class StaticTypeWarningCode extends ErrorCode {
|
| */
|
| static const StaticTypeWarningCode UNDEFINED_METHOD =
|
| const StaticTypeWarningCode('UNDEFINED_METHOD',
|
| - "The method '{0}' is not defined for the class '{1}'");
|
| + "The method '{0}' is not defined for the class '{1}'.", null);
|
| +
|
| + /**
|
| + * 12.15.1 Ordinary Invocation: Let <i>T</i> be the static type of <i>o</i>.
|
| + * It is a static type warning if <i>T</i> does not have an accessible
|
| + * instance member named <i>m</i>.
|
| + *
|
| + * Parameters:
|
| + * 0: the name of the method that is undefined
|
| + * 1: the resolved type name that the method lookup is happening on
|
| + */
|
| + static const StaticTypeWarningCode UNDEFINED_METHOD_WITH_CONSTRUCTOR =
|
| + const StaticTypeWarningCode(
|
| + 'UNDEFINED_METHOD_WITH_CONSTRUCTOR',
|
| + "The method '{0}' is not defined for the class '{1}', but a constructor with that name is defined.",
|
| + "Try adding 'new' or 'const' to invoke the constuctor, or change the method name.");
|
|
|
| /**
|
| * 12.18 Assignment: Evaluation of an assignment of the form
|
| @@ -3615,7 +3159,7 @@ class StaticTypeWarningCode extends ErrorCode {
|
| */
|
| static const StaticTypeWarningCode UNDEFINED_OPERATOR =
|
| const StaticTypeWarningCode('UNDEFINED_OPERATOR',
|
| - "The operator '{0}' is not defined for the class '{1}'");
|
| + "The operator '{0}' is not defined for the class '{1}'.", null);
|
|
|
| /**
|
| * 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>.
|
| @@ -3630,7 +3174,7 @@ class StaticTypeWarningCode extends ErrorCode {
|
| */
|
| static const StaticTypeWarningCode UNDEFINED_SETTER =
|
| const StaticTypeWarningCode('UNDEFINED_SETTER',
|
| - "The setter '{0}' is not defined for the class '{1}'");
|
| + "The setter '{0}' is not defined for the class '{1}'.", null);
|
|
|
| /**
|
| * 12.17 Getter Invocation: Let <i>T</i> be the static type of <i>e</i>. It is
|
| @@ -3642,7 +3186,7 @@ class StaticTypeWarningCode extends ErrorCode {
|
| */
|
| static const StaticTypeWarningCode UNDEFINED_SUPER_GETTER =
|
| const StaticTypeWarningCode('UNDEFINED_SUPER_GETTER',
|
| - "The getter '{0}' is not defined in a superclass of '{1}'");
|
| + "The getter '{0}' is not defined in a superclass of '{1}'.", null);
|
|
|
| /**
|
| * 12.15.4 Super Invocation: A super method invocation <i>i</i> has the form
|
| @@ -3657,7 +3201,7 @@ class StaticTypeWarningCode extends ErrorCode {
|
| */
|
| static const StaticTypeWarningCode UNDEFINED_SUPER_METHOD =
|
| const StaticTypeWarningCode('UNDEFINED_SUPER_METHOD',
|
| - "The method '{0}' is not defined in a superclass of '{1}'");
|
| + "The method '{0}' is not defined in a superclass of '{1}'.", null);
|
|
|
| /**
|
| * 12.18 Assignment: Evaluation of an assignment of the form
|
| @@ -3681,7 +3225,7 @@ class StaticTypeWarningCode extends ErrorCode {
|
| */
|
| static const StaticTypeWarningCode UNDEFINED_SUPER_OPERATOR =
|
| const StaticTypeWarningCode('UNDEFINED_SUPER_OPERATOR',
|
| - "The operator '{0}' is not defined in a superclass of '{1}'");
|
| + "The operator '{0}' is not defined in a superclass of '{1}'.", null);
|
|
|
| /**
|
| * 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>.
|
| @@ -3696,7 +3240,7 @@ class StaticTypeWarningCode extends ErrorCode {
|
| */
|
| static const StaticTypeWarningCode UNDEFINED_SUPER_SETTER =
|
| const StaticTypeWarningCode('UNDEFINED_SUPER_SETTER',
|
| - "The setter '{0}' is not defined in a superclass of '{1}'");
|
| + "The setter '{0}' is not defined in a superclass of '{1}'.", null);
|
|
|
| /**
|
| * 12.15.1 Ordinary Invocation: It is a static type warning if <i>T</i> does
|
| @@ -3706,7 +3250,8 @@ class StaticTypeWarningCode extends ErrorCode {
|
| * when we are able to find the name defined in a supertype. It exists to
|
| * provide a more informative error message.
|
| */
|
| - static const StaticTypeWarningCode UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER =
|
| + static const StaticTypeWarningCode
|
| + UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER =
|
| const StaticTypeWarningCode(
|
| 'UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER',
|
| "Static members from supertypes must be qualified by the name of the defining type");
|
| @@ -3749,6 +3294,32 @@ class StaticTypeWarningCode extends ErrorCode {
|
| const StaticTypeWarningCode('YIELD_OF_INVALID_TYPE',
|
| "The type '{0}' implied by the 'yield' expression must be assignable to '{1}'");
|
|
|
| + /**
|
| + * 17.6.2 For-in. If the iterable expression does not implement Iterable,
|
| + * this warning is reported.
|
| + *
|
| + * Parameters:
|
| + * 0: The type of the iterable expression.
|
| + * 1: The sequence type -- Iterable for `for` or Stream for `await for`.
|
| + */
|
| + static const StaticTypeWarningCode FOR_IN_OF_INVALID_TYPE =
|
| + const StaticTypeWarningCode('FOR_IN_OF_INVALID_TYPE',
|
| + "The type '{0}' used in the 'for' loop must implement {1}");
|
| +
|
| + /**
|
| + * 17.6.2 For-in. It the iterable expression does not implement Iterable with
|
| + * a type argument that can be assigned to the for-in variable's type, this
|
| + * warning is reported.
|
| + *
|
| + * Parameters:
|
| + * 0: The type of the iterable expression.
|
| + * 1: The sequence type -- Iterable for `for` or Stream for `await for`.
|
| + * 2: The loop variable type.
|
| + */
|
| + static const StaticTypeWarningCode FOR_IN_OF_INVALID_ELEMENT_TYPE =
|
| + const StaticTypeWarningCode('FOR_IN_OF_INVALID_ELEMENT_TYPE',
|
| + "The type '{0}' used in the 'for' loop must implement {1} with a type argument that can be assigned to '{2}'");
|
| +
|
| /**
|
| * Initialize a newly created error code to have the given [name]. The message
|
| * associated with the error will be created from the given [message]
|
| @@ -3822,8 +3393,10 @@ class StaticWarningCode extends ErrorCode {
|
| * 1: the name of the expected type
|
| */
|
| static const StaticWarningCode ARGUMENT_TYPE_NOT_ASSIGNABLE =
|
| - const StaticWarningCode('ARGUMENT_TYPE_NOT_ASSIGNABLE',
|
| - "The argument type '{0}' cannot be assigned to the parameter type '{1}'");
|
| + const StaticWarningCode(
|
| + 'ARGUMENT_TYPE_NOT_ASSIGNABLE',
|
| + "The argument type '{0}' cannot be assigned to the parameter type '{1}'.",
|
| + null);
|
|
|
| /**
|
| * 5 Variables: Attempting to assign to a final variable elsewhere will cause
|
| @@ -3917,7 +3490,7 @@ class StaticWarningCode extends ErrorCode {
|
| * Parameters:
|
| * 0: the ambiguous name
|
| * 1: the name of the dart: library in which the element is found
|
| - * 1: the name of the non-dart: library in which the element is found
|
| + * 2: the name of the non-dart: library in which the element is found
|
| */
|
| static const StaticWarningCode CONFLICTING_DART_IMPORT =
|
| const StaticWarningCode('CONFLICTING_DART_IMPORT',
|
| @@ -3931,7 +3504,8 @@ class StaticWarningCode extends ErrorCode {
|
| * Parameters:
|
| * 0: the name of the super class declaring a static member
|
| */
|
| - static const StaticWarningCode CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER =
|
| + static const StaticWarningCode
|
| + CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER =
|
| const StaticWarningCode(
|
| 'CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER',
|
| "Superclass '{0}' declares static member with the same name");
|
| @@ -3960,7 +3534,8 @@ class StaticWarningCode extends ErrorCode {
|
| * Parameters:
|
| * 0: the name of the super class declaring a static member
|
| */
|
| - static const StaticWarningCode CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER =
|
| + static const StaticWarningCode
|
| + CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER =
|
| const StaticWarningCode(
|
| 'CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER',
|
| "Superclass '{0}' declares static member with the same name");
|
| @@ -4030,7 +3605,8 @@ class StaticWarningCode extends ErrorCode {
|
| * been initialized at its point of declaration is also initialized in a
|
| * constructor.
|
| */
|
| - static const StaticWarningCode FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION =
|
| + static const StaticWarningCode
|
| + FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION =
|
| const StaticWarningCode(
|
| 'FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION',
|
| "Values cannot be set in the constructor if they are final, and have already been set");
|
| @@ -4043,7 +3619,8 @@ class StaticWarningCode extends ErrorCode {
|
| * Parameters:
|
| * 0: the name of the field in question
|
| */
|
| - static const StaticWarningCode FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR =
|
| + static const StaticWarningCode
|
| + FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR =
|
| const StaticWarningCode(
|
| 'FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR',
|
| "'{0}' is final and was given a value when it was declared, so it cannot be set to a new value");
|
| @@ -4092,7 +3669,7 @@ class StaticWarningCode extends ErrorCode {
|
| */
|
| static const StaticWarningCode FINAL_NOT_INITIALIZED =
|
| const StaticWarningCode('FINAL_NOT_INITIALIZED',
|
| - "The final variable '{0}' must be initialized");
|
| + "The final variable '{0}' must be initialized", null, false);
|
|
|
| /**
|
| * 7.6.1 Generative Constructors: Each final instance variable <i>f</i>
|
| @@ -4108,7 +3685,7 @@ class StaticWarningCode extends ErrorCode {
|
| */
|
| static const StaticWarningCode FINAL_NOT_INITIALIZED_CONSTRUCTOR_1 =
|
| const StaticWarningCode('FINAL_NOT_INITIALIZED_CONSTRUCTOR_1',
|
| - "The final variable '{0}' must be initialized");
|
| + "The final variable '{0}' must be initialized", null, false);
|
|
|
| /**
|
| * 7.6.1 Generative Constructors: Each final instance variable <i>f</i>
|
| @@ -4124,8 +3701,11 @@ class StaticWarningCode extends ErrorCode {
|
| * 1: the name of the uninitialized final variable
|
| */
|
| static const StaticWarningCode FINAL_NOT_INITIALIZED_CONSTRUCTOR_2 =
|
| - const StaticWarningCode('FINAL_NOT_INITIALIZED_CONSTRUCTOR_2',
|
| - "The final variables '{0}' and '{1}' must be initialized");
|
| + const StaticWarningCode(
|
| + 'FINAL_NOT_INITIALIZED_CONSTRUCTOR_2',
|
| + "The final variables '{0}' and '{1}' must be initialized",
|
| + null,
|
| + false);
|
|
|
| /**
|
| * 7.6.1 Generative Constructors: Each final instance variable <i>f</i>
|
| @@ -4142,8 +3722,11 @@ class StaticWarningCode extends ErrorCode {
|
| * 2: the number of additional not initialized variables that aren't listed
|
| */
|
| static const StaticWarningCode FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS =
|
| - const StaticWarningCode('FINAL_NOT_INITIALIZED_CONSTRUCTOR_3',
|
| - "The final variables '{0}', '{1}' and '{2}' more must be initialized");
|
| + const StaticWarningCode(
|
| + 'FINAL_NOT_INITIALIZED_CONSTRUCTOR_3',
|
| + "The final variables '{0}', '{1}' and '{2}' more must be initialized",
|
| + null,
|
| + false);
|
|
|
| /**
|
| * 15.5 Function Types: It is a static warning if a concrete class implements
|
| @@ -4190,7 +3773,8 @@ class StaticWarningCode extends ErrorCode {
|
| * getters none of the <i>m<sub>i</sub></i> are inherited, and a static
|
| * warning is issued.
|
| */
|
| - static const StaticWarningCode INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD =
|
| + static const StaticWarningCode
|
| + INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD =
|
| const StaticWarningCode(
|
| 'INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD',
|
| "'{0}' is inherited as a getter and also a method");
|
| @@ -4204,7 +3788,8 @@ class StaticWarningCode extends ErrorCode {
|
| * 0: the name of the member with the name conflict
|
| * 1: the name of the enclosing class that has the static member
|
| */
|
| - static const StaticWarningCode INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC =
|
| + static const StaticWarningCode
|
| + INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC =
|
| const StaticWarningCode(
|
| 'INSTANCE_METHOD_NAME_COLLIDES_WITH_SUPERCLASS_STATIC',
|
| "'{0}' collides with a static member in the superclass '{1}'");
|
| @@ -4241,6 +3826,34 @@ class StaticWarningCode extends ErrorCode {
|
| const StaticWarningCode('INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE',
|
| "The parameter type '{0}' is not assignable to '{1}' as required by the method it is overriding from '{2}'");
|
|
|
| + /**
|
| + * Generic Method DEP: number of type parameters must match.
|
| + * <https://github.com/leafpetersen/dep-generic-methods/blob/master/proposal.md#function-subtyping>
|
| + *
|
| + * Parameters:
|
| + * 0: the number of type parameters in the method
|
| + * 1: the number of type parameters in the overridden method
|
| + * 2: the name of the class where the overridden method is declared
|
| + */
|
| + static const StaticWarningCode INVALID_METHOD_OVERRIDE_TYPE_PARAMETERS =
|
| + const StaticWarningCode('INVALID_METHOD_OVERRIDE_TYPE_PARAMETERS',
|
| + "The method has {0} type parameters, but it is overriding a method with {1} type parameters from '{2}'");
|
| +
|
| + /**
|
| + * Generic Method DEP: bounds of type parameters must be compatible.
|
| + * <https://github.com/leafpetersen/dep-generic-methods/blob/master/proposal.md#function-subtyping>
|
| + *
|
| + * Parameters:
|
| + * 0: the type parameter name
|
| + * 1: the type parameter bound
|
| + * 2: the overridden type parameter name
|
| + * 3: the overridden type parameter bound
|
| + * 4: the name of the class where the overridden method is declared
|
| + */
|
| + static const StaticWarningCode INVALID_METHOD_OVERRIDE_TYPE_PARAMETER_BOUND =
|
| + const StaticWarningCode('INVALID_METHOD_OVERRIDE_TYPE_PARAMETER_BOUND',
|
| + "The type parameter '{0}' extends '{1}', but that is stricter than '{2}' extends '{3}' in the overridden method from '{4}'");
|
| +
|
| /**
|
| * 7.1 Instance Methods: It is a static warning if an instance method
|
| * <i>m1</i> overrides an instance method <i>m2</i> and the type of <i>m1</i>
|
| @@ -4296,8 +3909,9 @@ class StaticWarningCode extends ErrorCode {
|
| * <i>p</i> and the signature of <i>m1</i> specifies a different default value
|
| * for <i>p</i>.
|
| */
|
| - static const StaticWarningCode INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED =
|
| - const StaticWarningCode('INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED',
|
| + static const StaticWarningCode
|
| + INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED = const StaticWarningCode(
|
| + 'INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_NAMED',
|
| "Parameters cannot override default values, this method overrides '{0}.{1}' where '{2}' has a different value");
|
|
|
| /**
|
| @@ -4307,7 +3921,8 @@ class StaticWarningCode extends ErrorCode {
|
| * <i>p</i> and the signature of <i>m1</i> specifies a different default value
|
| * for <i>p</i>.
|
| */
|
| - static const StaticWarningCode INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL =
|
| + static const StaticWarningCode
|
| + INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL =
|
| const StaticWarningCode(
|
| 'INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES_POSITIONAL',
|
| "Parameters cannot override default values, this method overrides '{0}.{1}' where this positional parameter has a different value");
|
| @@ -4319,11 +3934,12 @@ class StaticWarningCode extends ErrorCode {
|
| *
|
| * Parameters:
|
| * 0: the number of named parameters in the overridden member
|
| - * 1: the name of the class from the overridden method
|
| + * 1: the signature of the overridden member
|
| + * 2: the name of the class from the overridden method
|
| */
|
| static const StaticWarningCode INVALID_OVERRIDE_NAMED = const StaticWarningCode(
|
| 'INVALID_OVERRIDE_NAMED',
|
| - "Missing the named parameter '{0}' to match the overridden method from '{1}'");
|
| + "Missing the named parameter '{0}' to match the overridden method from '{1}' from '{2}'");
|
|
|
| /**
|
| * 7.1 Instance Methods: It is a static warning if an instance method
|
| @@ -4332,11 +3948,12 @@ class StaticWarningCode extends ErrorCode {
|
| *
|
| * Parameters:
|
| * 0: the number of positional parameters in the overridden member
|
| - * 1: the name of the class from the overridden method
|
| + * 1: the signature of the overridden member
|
| + * 2: the name of the class from the overridden method
|
| */
|
| static const StaticWarningCode INVALID_OVERRIDE_POSITIONAL =
|
| const StaticWarningCode('INVALID_OVERRIDE_POSITIONAL',
|
| - "Must have at least {0} parameters to match the overridden method from '{1}'");
|
| + "Must have at least {0} parameters to match the overridden method '{1}' from '{2}'");
|
|
|
| /**
|
| * 7.1 Instance Methods: It is a static warning if an instance method
|
| @@ -4345,11 +3962,12 @@ class StaticWarningCode extends ErrorCode {
|
| *
|
| * Parameters:
|
| * 0: the number of required parameters in the overridden member
|
| - * 1: the name of the class from the overridden method
|
| + * 1: the signature of the overridden member
|
| + * 2: the name of the class from the overridden method
|
| */
|
| static const StaticWarningCode INVALID_OVERRIDE_REQUIRED =
|
| const StaticWarningCode('INVALID_OVERRIDE_REQUIRED',
|
| - "Must have {0} required parameters or less to match the overridden method from '{1}'");
|
| + "Must have {0} required parameters or less to match the overridden method '{1}' from '{2}'");
|
|
|
| /**
|
| * 7.3 Setters: It is a static warning if a setter <i>m1</i> overrides a
|
| @@ -4429,18 +4047,44 @@ class StaticWarningCode extends ErrorCode {
|
| * <i>S</i>, and <i>T</i> may not be assigned to <i>S</i>.
|
| */
|
| static const StaticWarningCode MISMATCHED_GETTER_AND_SETTER_TYPES =
|
| - const StaticWarningCode('MISMATCHED_GETTER_AND_SETTER_TYPES',
|
| - "The parameter type for setter '{0}' is '{1}' which is not assignable to its getter (of type '{2}')");
|
| + const StaticWarningCode(
|
| + 'MISMATCHED_GETTER_AND_SETTER_TYPES',
|
| + "The parameter type for setter '{0}' is '{1}' which is not assignable to its getter (of type '{2}')",
|
| + null,
|
| + false);
|
|
|
| /**
|
| * 7.3 Setters: It is a static warning if a class has a setter named <i>v=</i>
|
| * with argument type <i>T</i> and a getter named <i>v</i> with return type
|
| * <i>S</i>, and <i>T</i> may not be assigned to <i>S</i>.
|
| */
|
| - static const StaticWarningCode MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE =
|
| + static const StaticWarningCode
|
| + MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE =
|
| const StaticWarningCode(
|
| 'MISMATCHED_GETTER_AND_SETTER_TYPES_FROM_SUPERTYPE',
|
| - "The parameter type for setter '{0}' is '{1}' which is not assignable to its getter (of type '{2}'), from superclass '{3}'");
|
| + "The parameter type for setter '{0}' is '{1}' which is not assignable to its getter (of type '{2}'), from superclass '{3}'",
|
| + null,
|
| + false);
|
| +
|
| + /**
|
| + * 17.9 Switch: It is a static warning if all of the following conditions
|
| + * hold:
|
| + * * The switch statement does not have a 'default' clause.
|
| + * * The static type of <i>e</i> is an enumerated typed with elements
|
| + * <i>id<sub>1</sub></i>, …, <i>id<sub>n</sub></i>.
|
| + * * The sets {<i>e<sub>1</sub></i>, …, <i>e<sub>k</sub></i>} and
|
| + * {<i>id<sub>1</sub></i>, …, <i>id<sub>n</sub></i>} are not the
|
| + * same.
|
| + *
|
| + * Parameters:
|
| + * 0: the name of the constant that is missing
|
| + */
|
| + static const StaticWarningCode MISSING_ENUM_CONSTANT_IN_SWITCH =
|
| + const StaticWarningCode(
|
| + 'MISSING_ENUM_CONSTANT_IN_SWITCH',
|
| + "Missing case clause for '{0}'",
|
| + "Add a case clause for the missing constant or add a default clause.",
|
| + false);
|
|
|
| /**
|
| * 13.12 Return: It is a static warning if a function contains both one or
|
| @@ -4449,7 +4093,9 @@ class StaticWarningCode extends ErrorCode {
|
| */
|
| static const StaticWarningCode MIXED_RETURN_TYPES = const StaticWarningCode(
|
| 'MIXED_RETURN_TYPES',
|
| - "Methods and functions cannot use return both with and without values");
|
| + "Methods and functions cannot use return both with and without values",
|
| + null,
|
| + false);
|
|
|
| /**
|
| * 12.11.1 New: It is a static warning if <i>q</i> is a constructor of an
|
| @@ -4539,7 +4185,8 @@ class StaticWarningCode extends ErrorCode {
|
| * 3: the name of the fourth member
|
| * 4: the number of additional missing members that aren't listed
|
| */
|
| - static const StaticWarningCode NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS =
|
| + static const StaticWarningCode
|
| + NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS =
|
| const StaticWarningCode(
|
| 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLUS',
|
| "Missing concrete implementation of {0}, {1}, {2}, {3} and {4} more");
|
| @@ -4564,7 +4211,8 @@ class StaticWarningCode extends ErrorCode {
|
| * 2: the name of the third member
|
| * 3: the name of the fourth member
|
| */
|
| - static const StaticWarningCode NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR =
|
| + static const StaticWarningCode
|
| + NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR =
|
| const StaticWarningCode(
|
| 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR',
|
| "Missing concrete implementation of {0}, {1}, {2} and {3}");
|
| @@ -4586,8 +4234,9 @@ class StaticWarningCode extends ErrorCode {
|
| * Parameters:
|
| * 0: the name of the member
|
| */
|
| - static const StaticWarningCode NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE =
|
| - const StaticWarningCode('NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE',
|
| + static const StaticWarningCode
|
| + NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE = const StaticWarningCode(
|
| + 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE',
|
| "Missing concrete implementation of {0}");
|
|
|
| /**
|
| @@ -4609,7 +4258,8 @@ class StaticWarningCode extends ErrorCode {
|
| * 1: the name of the second member
|
| * 2: the name of the third member
|
| */
|
| - static const StaticWarningCode NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE =
|
| + static const StaticWarningCode
|
| + NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE =
|
| const StaticWarningCode(
|
| 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE',
|
| "Missing concrete implementation of {0}, {1} and {2}");
|
| @@ -4632,8 +4282,9 @@ class StaticWarningCode extends ErrorCode {
|
| * 0: the name of the first member
|
| * 1: the name of the second member
|
| */
|
| - static const StaticWarningCode NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO =
|
| - const StaticWarningCode('NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO',
|
| + static const StaticWarningCode
|
| + NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO = const StaticWarningCode(
|
| + 'NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO',
|
| "Missing concrete implementation of {0} and {1}");
|
|
|
| /**
|
| @@ -4656,7 +4307,7 @@ class StaticWarningCode extends ErrorCode {
|
| */
|
| static const StaticWarningCode NON_VOID_RETURN_FOR_OPERATOR =
|
| const StaticWarningCode('NON_VOID_RETURN_FOR_OPERATOR',
|
| - "The return type of the operator []= must be 'void'");
|
| + "The return type of the operator []= must be 'void'", null, false);
|
|
|
| /**
|
| * 7.3 Setters: It is a static warning if a setter declares a return type
|
| @@ -4664,7 +4315,7 @@ class StaticWarningCode extends ErrorCode {
|
| */
|
| static const StaticWarningCode NON_VOID_RETURN_FOR_SETTER =
|
| const StaticWarningCode('NON_VOID_RETURN_FOR_SETTER',
|
| - "The return type of the setter must be 'void'");
|
| + "The return type of the setter must be 'void'", null, false);
|
|
|
| /**
|
| * 15.1 Static Types: A type <i>T</i> is malformed iff:
|
| @@ -4763,7 +4414,10 @@ class StaticWarningCode extends ErrorCode {
|
| * * The return type of <i>f</i> may not be assigned to void.
|
| */
|
| static const StaticWarningCode RETURN_WITHOUT_VALUE = const StaticWarningCode(
|
| - 'RETURN_WITHOUT_VALUE', "Missing return value after 'return'");
|
| + 'RETURN_WITHOUT_VALUE',
|
| + "Missing return value after 'return'",
|
| + null,
|
| + false);
|
|
|
| /**
|
| * 12.16.3 Static Invocation: It is a static warning if <i>C</i> does not
|
| @@ -4822,7 +4476,7 @@ class StaticWarningCode extends ErrorCode {
|
| */
|
| static const StaticWarningCode TYPE_PARAMETER_REFERENCED_BY_STATIC =
|
| const StaticWarningCode('TYPE_PARAMETER_REFERENCED_BY_STATIC',
|
| - "Static members cannot reference type parameters");
|
| + "Static members cannot reference type parameters of the class");
|
|
|
| /**
|
| * 12.16.3 Static Invocation: A static method invocation <i>i</i> has the form
|
| @@ -4854,7 +4508,8 @@ class StaticWarningCode extends ErrorCode {
|
| */
|
| static const StaticWarningCode UNDEFINED_GETTER = const StaticWarningCode(
|
| 'UNDEFINED_GETTER',
|
| - "The getter '{0}' is not defined for the class '{1}'");
|
| + "The getter '{0}' is not defined for the class '{1}'.",
|
| + null);
|
|
|
| /**
|
| * 12.30 Identifier Reference: It is as static warning if an identifier
|
| @@ -4869,6 +4524,13 @@ class StaticWarningCode extends ErrorCode {
|
| static const StaticWarningCode UNDEFINED_IDENTIFIER =
|
| const StaticWarningCode('UNDEFINED_IDENTIFIER', "Undefined name '{0}'");
|
|
|
| + /**
|
| + * If the identifier is 'await', be helpful about it.
|
| + */
|
| + static const StaticWarningCode UNDEFINED_IDENTIFIER_AWAIT =
|
| + const StaticWarningCode('UNDEFINED_IDENTIFIER_AWAIT',
|
| + "Undefined name 'await'; did you mean to add the 'async' marker to '{0}'?");
|
| +
|
| /**
|
| * 12.14.2 Binding Actuals to Formals: Furthermore, each <i>q<sub>i</sub></i>,
|
| * <i>1<=i<=l</i>, must have a corresponding named parameter in the set
|
| @@ -4899,7 +4561,8 @@ class StaticWarningCode extends ErrorCode {
|
| */
|
| static const StaticWarningCode UNDEFINED_SETTER = const StaticWarningCode(
|
| 'UNDEFINED_SETTER',
|
| - "The setter '{0}' is not defined for the class '{1}'");
|
| + "The setter '{0}' is not defined for the class '{1}'.",
|
| + null);
|
|
|
| /**
|
| * 12.16.3 Static Invocation: It is a static warning if <i>C</i> does not
|
| @@ -4924,7 +4587,7 @@ class StaticWarningCode extends ErrorCode {
|
| */
|
| static const StaticWarningCode UNDEFINED_SUPER_GETTER =
|
| const StaticWarningCode('UNDEFINED_SUPER_GETTER',
|
| - "The getter '{0}' is not defined in a superclass of '{1}'");
|
| + "The getter '{0}' is not defined in a superclass of '{1}'.", null);
|
|
|
| /**
|
| * 12.18 Assignment: It is as static warning if an assignment of the form
|
| @@ -4943,14 +4606,20 @@ class StaticWarningCode extends ErrorCode {
|
| */
|
| static const StaticWarningCode UNDEFINED_SUPER_SETTER =
|
| const StaticWarningCode('UNDEFINED_SUPER_SETTER',
|
| - "The setter '{0}' is not defined in a superclass of '{1}'");
|
| + "The setter '{0}' is not defined in a superclass of '{1}'.", null);
|
|
|
| /**
|
| * 7.2 Getters: It is a static warning if the return type of a getter is void.
|
| */
|
| static const StaticWarningCode VOID_RETURN_FOR_GETTER =
|
| const StaticWarningCode('VOID_RETURN_FOR_GETTER',
|
| - "The return type of the getter must not be 'void'");
|
| + "The return type of the getter must not be 'void'", null, false);
|
| +
|
| + /**
|
| + * A flag indicating whether this warning is an error when running with strong
|
| + * mode enabled.
|
| + */
|
| + final bool isStrongModeError;
|
|
|
| /**
|
| * Initialize a newly created error code to have the given [name]. The message
|
| @@ -4958,7 +4627,8 @@ class StaticWarningCode extends ErrorCode {
|
| * template. The correction associated with the error will be created from the
|
| * given [correction] template.
|
| */
|
| - const StaticWarningCode(String name, String message, [String correction])
|
| + const StaticWarningCode(String name, String message,
|
| + [String correction, this.isStrongModeError = true])
|
| : super(name, message, correction);
|
|
|
| @override
|
| @@ -4968,6 +4638,203 @@ class StaticWarningCode extends ErrorCode {
|
| ErrorType get type => ErrorType.STATIC_WARNING;
|
| }
|
|
|
| +/**
|
| + * This class has Strong Mode specific error codes.
|
| + *
|
| + * These error codes tend to use the same message across different severity
|
| + * levels, so they are grouped for clarity.
|
| + *
|
| + * All of these error codes also use the "STRONG_MODE_" prefix in their name.
|
| + */
|
| +class StrongModeCode extends ErrorCode {
|
| + static const String _implicitCastMessage =
|
| + 'Unsound implicit cast from {0} to {1}';
|
| +
|
| + static const String _unsafeBlockClosureInferenceMessage =
|
| + 'Unsafe use of block closure in a type-inferred variable outside a '
|
| + 'function body. Workaround: add a type annotation for `{0}`. See '
|
| + 'dartbug.com/26947';
|
| +
|
| + static const String _typeCheckMessage =
|
| + 'Type check failed: {0} is not of type {1}';
|
| +
|
| + static const String _invalidOverrideMessage =
|
| + 'The type of {0}.{1} ({2}) is not a '
|
| + 'subtype of {3}.{1} ({4}).';
|
| +
|
| + /**
|
| + * This is appended to the end of an error message about implicit dynamic.
|
| + *
|
| + * The idea is to make sure the user is aware that this error message is the
|
| + * result of turning on a particular option, and they are free to turn it
|
| + * back off.
|
| + */
|
| + static const String _implicitDynamicTip =
|
| + ". Either add an explicit type like 'dynamic'"
|
| + ", or enable implicit-dynamic in your Analyzer options.";
|
| +
|
| + static const String _inferredTypeMessage = '{0} has inferred type {1}';
|
| +
|
| + static const StrongModeCode DOWN_CAST_COMPOSITE = const StrongModeCode(
|
| + ErrorType.STATIC_WARNING, 'DOWN_CAST_COMPOSITE', _implicitCastMessage);
|
| +
|
| + static const StrongModeCode DOWN_CAST_IMPLICIT = const StrongModeCode(
|
| + ErrorType.HINT, 'DOWN_CAST_IMPLICIT', _implicitCastMessage);
|
| +
|
| + static const StrongModeCode DOWN_CAST_IMPLICIT_ASSIGN = const StrongModeCode(
|
| + ErrorType.HINT, 'DOWN_CAST_IMPLICIT_ASSIGN', _implicitCastMessage);
|
| +
|
| + static const StrongModeCode DYNAMIC_CAST = const StrongModeCode(
|
| + ErrorType.HINT, 'DYNAMIC_CAST', _implicitCastMessage);
|
| +
|
| + static const StrongModeCode ASSIGNMENT_CAST = const StrongModeCode(
|
| + ErrorType.HINT, 'ASSIGNMENT_CAST', _implicitCastMessage);
|
| +
|
| + static const StrongModeCode INVALID_PARAMETER_DECLARATION =
|
| + const StrongModeCode(ErrorType.COMPILE_TIME_ERROR,
|
| + 'INVALID_PARAMETER_DECLARATION', _typeCheckMessage);
|
| +
|
| + static const StrongModeCode COULD_NOT_INFER = const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'COULD_NOT_INFER',
|
| + "Could not infer type parameter {0}, {1} must be of type {2}.");
|
| +
|
| + static const StrongModeCode INFERRED_TYPE = const StrongModeCode(
|
| + ErrorType.HINT, 'INFERRED_TYPE', _inferredTypeMessage);
|
| +
|
| + static const StrongModeCode INFERRED_TYPE_LITERAL = const StrongModeCode(
|
| + ErrorType.HINT, 'INFERRED_TYPE_LITERAL', _inferredTypeMessage);
|
| +
|
| + static const StrongModeCode INFERRED_TYPE_ALLOCATION = const StrongModeCode(
|
| + ErrorType.HINT, 'INFERRED_TYPE_ALLOCATION', _inferredTypeMessage);
|
| +
|
| + static const StrongModeCode INFERRED_TYPE_CLOSURE = const StrongModeCode(
|
| + ErrorType.HINT, 'INFERRED_TYPE_CLOSURE', _inferredTypeMessage);
|
| +
|
| + static const StrongModeCode STATIC_TYPE_ERROR = const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'STATIC_TYPE_ERROR',
|
| + 'Type check failed: {0} ({1}) is not of type {2}');
|
| +
|
| + static const StrongModeCode INVALID_SUPER_INVOCATION = const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'INVALID_SUPER_INVOCATION',
|
| + "super call must be last in an initializer "
|
| + "list (see https://goo.gl/EY6hDP): {0}");
|
| +
|
| + static const StrongModeCode NON_GROUND_TYPE_CHECK_INFO = const StrongModeCode(
|
| + ErrorType.HINT,
|
| + 'NON_GROUND_TYPE_CHECK_INFO',
|
| + "Runtime check on non-ground type {0} may throw StrongModeError");
|
| +
|
| + static const StrongModeCode DYNAMIC_INVOKE = const StrongModeCode(
|
| + ErrorType.HINT, 'DYNAMIC_INVOKE', '{0} requires a dynamic invoke');
|
| +
|
| + static const StrongModeCode INVALID_METHOD_OVERRIDE = const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'INVALID_METHOD_OVERRIDE',
|
| + 'Invalid override. $_invalidOverrideMessage');
|
| +
|
| + static const StrongModeCode INVALID_METHOD_OVERRIDE_FROM_BASE =
|
| + const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'INVALID_METHOD_OVERRIDE_FROM_BASE',
|
| + 'Base class introduces an invalid override. '
|
| + '$_invalidOverrideMessage');
|
| +
|
| + static const StrongModeCode INVALID_METHOD_OVERRIDE_FROM_MIXIN =
|
| + const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'INVALID_METHOD_OVERRIDE_FROM_MIXIN',
|
| + 'Mixin introduces an invalid override. $_invalidOverrideMessage');
|
| +
|
| + static const StrongModeCode INVALID_FIELD_OVERRIDE = const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'INVALID_FIELD_OVERRIDE',
|
| + 'Field declaration {3}.{1} cannot be '
|
| + 'overridden in {0}.');
|
| +
|
| + static const StrongModeCode IMPLICIT_DYNAMIC_PARAMETER = const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'IMPLICIT_DYNAMIC_PARAMETER',
|
| + "Missing parameter type for '{0}'$_implicitDynamicTip");
|
| +
|
| + static const StrongModeCode IMPLICIT_DYNAMIC_RETURN = const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'IMPLICIT_DYNAMIC_RETURN',
|
| + "Missing return type for '{0}'$_implicitDynamicTip");
|
| +
|
| + static const StrongModeCode IMPLICIT_DYNAMIC_VARIABLE = const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'IMPLICIT_DYNAMIC_VARIABLE',
|
| + "Missing variable type for '{0}'$_implicitDynamicTip");
|
| +
|
| + static const StrongModeCode IMPLICIT_DYNAMIC_FIELD = const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'IMPLICIT_DYNAMIC_FIELD',
|
| + "Missing field type for '{0}'$_implicitDynamicTip");
|
| +
|
| + static const StrongModeCode IMPLICIT_DYNAMIC_TYPE = const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'IMPLICIT_DYNAMIC_TYPE',
|
| + "Missing type arguments for generic type '{0}'"
|
| + "$_implicitDynamicTip");
|
| +
|
| + static const StrongModeCode IMPLICIT_DYNAMIC_LIST_LITERAL =
|
| + const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'IMPLICIT_DYNAMIC_LIST_LITERAL',
|
| + "Missing type argument for list literal$_implicitDynamicTip");
|
| +
|
| + static const StrongModeCode IMPLICIT_DYNAMIC_MAP_LITERAL =
|
| + const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'IMPLICIT_DYNAMIC_MAP_LITERAL',
|
| + 'Missing type arguments for map literal$_implicitDynamicTip');
|
| +
|
| + static const StrongModeCode IMPLICIT_DYNAMIC_FUNCTION = const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'IMPLICIT_DYNAMIC_FUNCTION',
|
| + "Missing type arguments for generic function '{0}<{1}>'"
|
| + "$_implicitDynamicTip");
|
| +
|
| + static const StrongModeCode IMPLICIT_DYNAMIC_METHOD = const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'IMPLICIT_DYNAMIC_METHOD',
|
| + "Missing type arguments for generic method '{0}<{1}>'"
|
| + "$_implicitDynamicTip");
|
| +
|
| + static const StrongModeCode IMPLICIT_DYNAMIC_INVOKE = const StrongModeCode(
|
| + ErrorType.COMPILE_TIME_ERROR,
|
| + 'IMPLICIT_DYNAMIC_INVOKE',
|
| + "Missing type arguments for calling generic function type '{0}'"
|
| + "$_implicitDynamicTip");
|
| +
|
| + static const StrongModeCode UNSAFE_BLOCK_CLOSURE_INFERENCE =
|
| + const StrongModeCode(
|
| + ErrorType.STATIC_WARNING,
|
| + 'UNSAFE_BLOCK_CLOSURE_INFERENCE',
|
| + _unsafeBlockClosureInferenceMessage);
|
| +
|
| + @override
|
| + final ErrorType type;
|
| +
|
| + /**
|
| + * Initialize a newly created error code to have the given [type] and [name].
|
| + *
|
| + * The message associated with the error will be created from the given
|
| + * [message] template. The correction associated with the error will be
|
| + * created from the optional [correction] template.
|
| + */
|
| + const StrongModeCode(ErrorType type, String name, String message,
|
| + [String correction])
|
| + : type = type,
|
| + super('STRONG_MODE_$name', message, correction);
|
| +
|
| + @override
|
| + ErrorSeverity get errorSeverity => type.severity;
|
| +}
|
| +
|
| /**
|
| * The error code indicating a marker in code for work that needs to be finished
|
| * or revisited.
|
|
|