[analyzer] Rename error constants to camelCase.

This change was generated by the following process:

- The script `pkg/analyzer/tool/messages/rename_error_constants.dart`
  was run. This generated the vast majority of the diffs.

- Then all modified files were reformatted using
  `tools/sdk/dart-sdk/bin/dart/format`.

- Finally, the script `pkg/analyzer/tool/messages/generate.dart` was
  run, to rebuild generated code.

Change-Id: I6a6a69644ed8740ad6269d98cb169076151824ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444921
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
Paul Berry
2025-08-13 22:02:42 -07:00
committed by Commit Queue
parent 919d50344a
commit f2123a8f7c
1080 changed files with 16365 additions and 20406 deletions
@@ -38,7 +38,7 @@ void translateErrorToken(ErrorToken token, ReportError reportError) {
// TODO(paulberry,ahe): Fasta reports the error location as the entire
// string; analyzer expects the end of the string.
reportError(
ScannerErrorCode.UNTERMINATED_STRING_LITERAL,
ScannerErrorCode.unterminatedStringLiteral,
endOffset - 1,
null,
);
@@ -48,7 +48,7 @@ void translateErrorToken(ErrorToken token, ReportError reportError) {
// TODO(paulberry,ahe): Fasta reports the error location as the entire
// comment; analyzer expects the end of the comment.
reportError(
ScannerErrorCode.UNTERMINATED_MULTI_LINE_COMMENT,
ScannerErrorCode.unterminatedMultiLineComment,
endOffset - 1,
null,
);
@@ -58,24 +58,24 @@ void translateErrorToken(ErrorToken token, ReportError reportError) {
// TODO(paulberry,ahe): Fasta reports the error location as the entire
// number; analyzer expects the end of the number.
charOffset = endOffset - 1;
return _makeError(ScannerErrorCode.MISSING_DIGIT, null);
return _makeError(ScannerErrorCode.missingDigit, null);
case "MISSING_HEX_DIGIT":
// TODO(paulberry,ahe): Fasta reports the error location as the entire
// number; analyzer expects the end of the number.
charOffset = endOffset - 1;
return _makeError(ScannerErrorCode.MISSING_HEX_DIGIT, null);
return _makeError(ScannerErrorCode.missingHexDigit, null);
case "ILLEGAL_CHARACTER":
// We can safely assume `token.character` is non-`null` because this error
// is only reported when there is a character associated with the token.
return _makeError(ScannerErrorCode.ILLEGAL_CHARACTER, [token.character!]);
return _makeError(ScannerErrorCode.illegalCharacter, [token.character!]);
case "UNEXPECTED_SEPARATOR_IN_NUMBER":
return _makeError(ScannerErrorCode.UNEXPECTED_SEPARATOR_IN_NUMBER, null);
return _makeError(ScannerErrorCode.unexpectedSeparatorInNumber, null);
case "UNSUPPORTED_OPERATOR":
return _makeError(ScannerErrorCode.UNSUPPORTED_OPERATOR, [
return _makeError(ScannerErrorCode.unsupportedOperator, [
(token as UnsupportedOperator).token.lexeme,
]);
@@ -85,19 +85,19 @@ void translateErrorToken(ErrorToken token, ReportError reportError) {
TokenType type = token.begin!.type;
if (type == TokenType.OPEN_CURLY_BRACKET ||
type == TokenType.STRING_INTERPOLATION_EXPRESSION) {
return _makeError(ScannerErrorCode.EXPECTED_TOKEN, ['}']);
return _makeError(ScannerErrorCode.expectedToken, ['}']);
}
if (type == TokenType.OPEN_SQUARE_BRACKET) {
return _makeError(ScannerErrorCode.EXPECTED_TOKEN, [']']);
return _makeError(ScannerErrorCode.expectedToken, [']']);
}
if (type == TokenType.OPEN_PAREN) {
return _makeError(ScannerErrorCode.EXPECTED_TOKEN, [')']);
return _makeError(ScannerErrorCode.expectedToken, [')']);
}
if (type == TokenType.LT) {
return _makeError(ScannerErrorCode.EXPECTED_TOKEN, ['>']);
return _makeError(ScannerErrorCode.expectedToken, ['>']);
}
} else if (errorCode == codeUnexpectedDollarInString) {
return _makeError(ScannerErrorCode.MISSING_IDENTIFIER, null);
return _makeError(ScannerErrorCode.missingIdentifier, null);
}
throw new UnimplementedError(
'$errorCode "${errorCode.analyzerCodes?.first}"',
@@ -29,52 +29,52 @@ import "package:_fe_analyzer_shared/src/base/errors.dart";
class ScannerErrorCode extends DiagnosticCode {
/// Parameters:
/// String p0: the token that was expected but not found
static const ScannerErrorCode EXPECTED_TOKEN = const ScannerErrorCode(
static const ScannerErrorCode expectedToken = const ScannerErrorCode(
'EXPECTED_TOKEN',
"Expected to find '{0}'.",
);
/// Parameters:
/// Object p0: the illegal character
static const ScannerErrorCode ILLEGAL_CHARACTER = const ScannerErrorCode(
static const ScannerErrorCode illegalCharacter = const ScannerErrorCode(
'ILLEGAL_CHARACTER',
"Illegal character '{0}'.",
);
/// No parameters.
static const ScannerErrorCode MISSING_DIGIT = const ScannerErrorCode(
static const ScannerErrorCode missingDigit = const ScannerErrorCode(
'MISSING_DIGIT',
"Decimal digit expected.",
);
/// No parameters.
static const ScannerErrorCode MISSING_HEX_DIGIT = const ScannerErrorCode(
static const ScannerErrorCode missingHexDigit = const ScannerErrorCode(
'MISSING_HEX_DIGIT',
"Hexadecimal digit expected.",
);
/// No parameters.
static const ScannerErrorCode MISSING_IDENTIFIER = const ScannerErrorCode(
static const ScannerErrorCode missingIdentifier = const ScannerErrorCode(
'MISSING_IDENTIFIER',
"Expected an identifier.",
);
/// No parameters.
static const ScannerErrorCode MISSING_QUOTE = const ScannerErrorCode(
static const ScannerErrorCode missingQuote = const ScannerErrorCode(
'MISSING_QUOTE',
"Expected quote (' or \").",
);
/// Parameters:
/// Object p0: the path of the file that cannot be read
static const ScannerErrorCode UNABLE_GET_CONTENT = const ScannerErrorCode(
static const ScannerErrorCode unableGetContent = const ScannerErrorCode(
'UNABLE_GET_CONTENT',
"Unable to get content of '{0}'.",
);
/// No parameters.
static const ScannerErrorCode
UNEXPECTED_DOLLAR_IN_STRING = const ScannerErrorCode(
unexpectedDollarInString = const ScannerErrorCode(
'UNEXPECTED_DOLLAR_IN_STRING',
"A '\$' has special meaning inside a string, and must be followed by an "
"identifier or an expression in curly braces ({}).",
@@ -83,7 +83,7 @@ class ScannerErrorCode extends DiagnosticCode {
/// No parameters.
static const ScannerErrorCode
UNEXPECTED_SEPARATOR_IN_NUMBER = const ScannerErrorCode(
unexpectedSeparatorInNumber = const ScannerErrorCode(
'UNEXPECTED_SEPARATOR_IN_NUMBER',
"Digit separators ('_') in a number literal can only be placed between two "
"digits.",
@@ -92,13 +92,13 @@ class ScannerErrorCode extends DiagnosticCode {
/// Parameters:
/// String p0: the unsupported operator
static const ScannerErrorCode UNSUPPORTED_OPERATOR = const ScannerErrorCode(
static const ScannerErrorCode unsupportedOperator = const ScannerErrorCode(
'UNSUPPORTED_OPERATOR',
"The '{0}' operator is not supported.",
);
/// No parameters.
static const ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT =
static const ScannerErrorCode unterminatedMultiLineComment =
const ScannerErrorCode(
'UNTERMINATED_MULTI_LINE_COMMENT',
"Unterminated multi-line comment.",
@@ -108,7 +108,7 @@ class ScannerErrorCode extends DiagnosticCode {
);
/// No parameters.
static const ScannerErrorCode UNTERMINATED_STRING_LITERAL =
static const ScannerErrorCode unterminatedStringLiteral =
const ScannerErrorCode(
'UNTERMINATED_STRING_LITERAL',
"Unterminated string literal.",
+5 -7
View File
@@ -52,21 +52,19 @@ final completionFilterTextSplitPattern = RegExp(r'=>|[\(]');
final completionSetterTypePattern = RegExp(r'^\((\S+)\s+\S+\)$');
final diagnosticTagsForErrorCode = <String, List<lsp.DiagnosticTag>>{
_diagnosticCode(WarningCode.DEAD_CODE): [lsp.DiagnosticTag.Unnecessary],
_diagnosticCode(HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE): [
_diagnosticCode(WarningCode.deadCode): [lsp.DiagnosticTag.Unnecessary],
_diagnosticCode(HintCode.deprecatedMemberUseFromSamePackage): [
lsp.DiagnosticTag.Deprecated,
],
_diagnosticCode(
HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE_WITH_MESSAGE,
): [lsp.DiagnosticTag.Deprecated],
_diagnosticCode(HintCode.DEPRECATED_MEMBER_USE): [
_diagnosticCode(HintCode.deprecatedMemberUseFromSamePackageWithMessage): [
lsp.DiagnosticTag.Deprecated,
],
_diagnosticCode(HintCode.deprecatedMemberUse): [lsp.DiagnosticTag.Deprecated],
'deprecated_member_use_from_same_package': [lsp.DiagnosticTag.Deprecated],
'deprecated_member_use_from_same_package_with_message': [
lsp.DiagnosticTag.Deprecated,
],
_diagnosticCode(HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE): [
_diagnosticCode(HintCode.deprecatedMemberUseWithMessage): [
lsp.DiagnosticTag.Deprecated,
],
};
@@ -313,7 +313,7 @@ class StatementCompletionProcessor {
: null;
}
var expr = diagnosticMatching(ScannerErrorCode.UNTERMINATED_STRING_LITERAL);
var expr = diagnosticMatching(ScannerErrorCode.unterminatedStringLiteral);
if (expr != null) {
var source = utils.getNodeText(expr);
var content = source;
@@ -339,18 +339,15 @@ class StatementCompletionProcessor {
delimiter = content.substring(0, 1);
loc = expr.offset + source.length;
}
_removeError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL);
_removeError(ScannerErrorCode.unterminatedStringLiteral);
_addInsertEdit(loc, delimiter);
}
expr =
diagnosticMatching(
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.expectedToken,
partialMatch: "']'",
) ??
diagnosticMatching(
ScannerErrorCode.EXPECTED_TOKEN,
partialMatch: "']'",
);
diagnosticMatching(ScannerErrorCode.expectedToken, partialMatch: "']'");
if (expr != null) {
expr = expr.thisOrAncestorOfType<ListLiteral>();
if (expr is ListLiteral) {
@@ -363,8 +360,8 @@ class StatementCompletionProcessor {
} else {
_addInsertEdit(loc, ']');
}
_removeError(ParserErrorCode.EXPECTED_TOKEN, partialMatch: "']'");
_removeError(ScannerErrorCode.EXPECTED_TOKEN, partialMatch: "']'");
_removeError(ParserErrorCode.expectedToken, partialMatch: "']'");
_removeError(ScannerErrorCode.expectedToken, partialMatch: "']'");
}
}
}
@@ -436,7 +433,7 @@ class StatementCompletionProcessor {
var delta = 0;
if (diagnostics.isNotEmpty) {
var error = _findDiagnostic(
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.expectedToken,
partialMatch: "';'",
);
if (error != null) {
@@ -752,9 +749,7 @@ class StatementCompletionProcessor {
var needsParen = false;
int computeExitPos(FormalParameterList parameters) {
if (needsParen = parameters.rightParenthesis.isSynthetic) {
var error = _findDiagnostic(
ParserErrorCode.MISSING_CLOSING_PARENTHESIS,
);
var error = _findDiagnostic(ParserErrorCode.missingClosingParenthesis);
if (error != null) {
return error.offset - 1;
}
@@ -794,7 +789,7 @@ class StatementCompletionProcessor {
return false;
}
var error = _findDiagnostic(
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.expectedToken,
partialMatch: "';'",
);
if (error != null) {
@@ -928,8 +923,8 @@ class StatementCompletionProcessor {
bool _complete_methodCall(AstNode node) {
var parenError =
_findDiagnostic(ParserErrorCode.EXPECTED_TOKEN, partialMatch: "')'") ??
_findDiagnostic(ScannerErrorCode.EXPECTED_TOKEN, partialMatch: "')'");
_findDiagnostic(ParserErrorCode.expectedToken, partialMatch: "')'") ??
_findDiagnostic(ScannerErrorCode.expectedToken, partialMatch: "')'");
if (parenError == null) {
return false;
}
@@ -947,7 +942,7 @@ class StatementCompletionProcessor {
var loc = min(selectionOffset, argList.end);
_addInsertEdit(loc, ')');
var semicolonError = _findDiagnostic(
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.expectedToken,
partialMatch: "';'",
);
if (semicolonError != null) {
@@ -982,7 +977,7 @@ class StatementCompletionProcessor {
return false;
}
var error = _findDiagnostic(
ParserErrorCode.EXPECTED_TOKEN,
ParserErrorCode.expectedToken,
partialMatch: "';'",
);
if (error != null) {
@@ -1075,7 +1070,7 @@ class StatementCompletionProcessor {
if (onKeyword != null && exceptionType != null) {
if (exceptionType.length == 0 ||
_findDiagnostic(
CompileTimeErrorCode.NON_TYPE_IN_CATCH_CLAUSE,
CompileTimeErrorCode.nonTypeInCatchClause,
partialMatch: "name 'catch",
) !=
null) {
@@ -90,9 +90,9 @@ class BulkFixProcessor {
/// will almost certainly be invalid code.
static const Map<DiagnosticCode, List<MultiProducerGenerator>>
nonLintMultiProducerMap = {
CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE: [DataDriven.new],
CompileTimeErrorCode.CAST_TO_NON_TYPE: [DataDriven.new],
CompileTimeErrorCode.EXTENDS_NON_CLASS: [DataDriven.new],
CompileTimeErrorCode.argumentTypeNotAssignable: [DataDriven.new],
CompileTimeErrorCode.castToNonType: [DataDriven.new],
CompileTimeErrorCode.extendsNonClass: [DataDriven.new],
// TODO(brianwilkerson): The following fix fails if an invocation of the
// function is the argument that needs to be removed.
// CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS: [
@@ -103,53 +103,41 @@ class BulkFixProcessor {
// CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED: [
// DataDriven.newInstance,
// ],
CompileTimeErrorCode.IMPLEMENTS_NON_CLASS: [DataDriven.new],
CompileTimeErrorCode.INVALID_OVERRIDE: [DataDriven.new],
CompileTimeErrorCode.INVALID_OVERRIDE_SETTER: [DataDriven.new],
CompileTimeErrorCode.MISSING_REQUIRED_ARGUMENT: [DataDriven.new],
CompileTimeErrorCode.MIXIN_OF_NON_CLASS: [DataDriven.new],
CompileTimeErrorCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT: [
CompileTimeErrorCode.implementsNonClass: [DataDriven.new],
CompileTimeErrorCode.invalidOverride: [DataDriven.new],
CompileTimeErrorCode.invalidOverrideSetter: [DataDriven.new],
CompileTimeErrorCode.missingRequiredArgument: [DataDriven.new],
CompileTimeErrorCode.mixinOfNonClass: [DataDriven.new],
CompileTimeErrorCode.newWithUndefinedConstructorDefault: [DataDriven.new],
CompileTimeErrorCode.nonTypeAsTypeArgument: [DataDriven.new],
CompileTimeErrorCode.notEnoughPositionalArgumentsNamePlural: [
DataDriven.new,
],
CompileTimeErrorCode.NON_TYPE_AS_TYPE_ARGUMENT: [DataDriven.new],
CompileTimeErrorCode.NOT_ENOUGH_POSITIONAL_ARGUMENTS_NAME_PLURAL: [
CompileTimeErrorCode.notEnoughPositionalArgumentsNameSingular: [
DataDriven.new,
],
CompileTimeErrorCode.NOT_ENOUGH_POSITIONAL_ARGUMENTS_NAME_SINGULAR: [
CompileTimeErrorCode.notEnoughPositionalArgumentsPlural: [DataDriven.new],
CompileTimeErrorCode.notEnoughPositionalArgumentsSingular: [DataDriven.new],
CompileTimeErrorCode.undefinedClass: [DataDriven.new],
CompileTimeErrorCode.undefinedExtensionGetter: [DataDriven.new],
CompileTimeErrorCode.undefinedFunction: [DataDriven.new],
CompileTimeErrorCode.undefinedGetter: [DataDriven.new],
CompileTimeErrorCode.undefinedIdentifier: [DataDriven.new],
CompileTimeErrorCode.undefinedMethod: [DataDriven.new],
CompileTimeErrorCode.undefinedNamedParameter: [DataDriven.new],
CompileTimeErrorCode.undefinedSetter: [DataDriven.new],
CompileTimeErrorCode.wrongNumberOfTypeArguments: [DataDriven.new],
CompileTimeErrorCode.wrongNumberOfTypeArgumentsConstructor: [
DataDriven.new,
],
CompileTimeErrorCode.NOT_ENOUGH_POSITIONAL_ARGUMENTS_PLURAL: [
DataDriven.new,
],
CompileTimeErrorCode.NOT_ENOUGH_POSITIONAL_ARGUMENTS_SINGULAR: [
DataDriven.new,
],
CompileTimeErrorCode.UNDEFINED_CLASS: [DataDriven.new],
CompileTimeErrorCode.UNDEFINED_EXTENSION_GETTER: [DataDriven.new],
CompileTimeErrorCode.UNDEFINED_FUNCTION: [DataDriven.new],
CompileTimeErrorCode.UNDEFINED_GETTER: [DataDriven.new],
CompileTimeErrorCode.UNDEFINED_IDENTIFIER: [DataDriven.new],
CompileTimeErrorCode.UNDEFINED_METHOD: [DataDriven.new],
CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER: [DataDriven.new],
CompileTimeErrorCode.UNDEFINED_SETTER: [DataDriven.new],
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS: [DataDriven.new],
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR: [
DataDriven.new,
],
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_EXTENSION: [
DataDriven.new,
],
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_METHOD: [
DataDriven.new,
],
HintCode.DEPRECATED_MEMBER_USE: [DataDriven.new],
HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE: [DataDriven.new],
HintCode.DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE_WITH_MESSAGE: [
DataDriven.new,
],
HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE: [DataDriven.new],
WarningCode.DEPRECATED_EXPORT_USE: [DataDriven.new],
WarningCode.OVERRIDE_ON_NON_OVERRIDING_METHOD: [DataDriven.new],
CompileTimeErrorCode.wrongNumberOfTypeArgumentsExtension: [DataDriven.new],
CompileTimeErrorCode.wrongNumberOfTypeArgumentsMethod: [DataDriven.new],
HintCode.deprecatedMemberUse: [DataDriven.new],
HintCode.deprecatedMemberUseFromSamePackage: [DataDriven.new],
HintCode.deprecatedMemberUseFromSamePackageWithMessage: [DataDriven.new],
HintCode.deprecatedMemberUseWithMessage: [DataDriven.new],
WarningCode.deprecatedExportUse: [DataDriven.new],
WarningCode.overrideOnNonOverridingMethod: [DataDriven.new],
};
/// Cached results of [_canBulkFix].
@@ -449,7 +437,7 @@ class BulkFixProcessor {
details.add(
BulkFix(pubspecFile.path, [
BulkFixDetail(
PubspecWarningCode.MISSING_DEPENDENCY.name.toLowerCase(),
PubspecWarningCode.missingDependency.name.toLowerCase(),
1,
),
]),
@@ -662,9 +650,9 @@ class BulkFixProcessor {
directivesOrderingError = diagnostic;
break;
}
} else if (diagnosticCode == WarningCode.DUPLICATE_IMPORT ||
diagnosticCode == HintCode.UNNECESSARY_IMPORT ||
diagnosticCode == WarningCode.UNUSED_IMPORT) {
} else if (diagnosticCode == WarningCode.duplicateImport ||
diagnosticCode == HintCode.unnecessaryImport ||
diagnosticCode == WarningCode.unusedImport) {
unusedImportDiagnostics.add(diagnostic);
}
}
@@ -1147,9 +1135,9 @@ extension on Diagnostic {
bool get isFixable {
// Special cases that can be bulk fixed by this class but not by
// FixProcessor.
if (diagnosticCode == WarningCode.DUPLICATE_IMPORT ||
diagnosticCode == HintCode.UNNECESSARY_IMPORT ||
diagnosticCode == WarningCode.UNUSED_IMPORT ||
if (diagnosticCode == WarningCode.duplicateImport ||
diagnosticCode == HintCode.unnecessaryImport ||
diagnosticCode == WarningCode.unusedImport ||
(DirectivesOrdering.allCodes.contains(diagnosticCode))) {
return true;
}
@@ -38,21 +38,20 @@ class RemoveComparison extends ResolvedCorrectionProducer {
/// Whether the condition will always return `false`.
bool get _conditionIsFalse {
var diagnosticCode = (diagnostic as Diagnostic).diagnosticCode;
return diagnosticCode == WarningCode.UNNECESSARY_NAN_COMPARISON_FALSE ||
return diagnosticCode == WarningCode.unnecessaryNanComparisonFalse ||
diagnosticCode ==
WarningCode.UNNECESSARY_NULL_COMPARISON_ALWAYS_NULL_FALSE ||
diagnosticCode ==
WarningCode.UNNECESSARY_NULL_COMPARISON_NEVER_NULL_FALSE ||
diagnosticCode == WarningCode.UNNECESSARY_TYPE_CHECK_FALSE;
WarningCode.unnecessaryNullComparisonAlwaysNullFalse ||
diagnosticCode == WarningCode.unnecessaryNullComparisonNeverNullFalse ||
diagnosticCode == WarningCode.unnecessaryTypeCheckFalse;
}
/// Whether the condition will always return `true`.
bool get _conditionIsTrue {
var errorCode = (diagnostic as Diagnostic).diagnosticCode;
return errorCode == WarningCode.UNNECESSARY_NAN_COMPARISON_TRUE ||
errorCode == WarningCode.UNNECESSARY_NULL_COMPARISON_ALWAYS_NULL_TRUE ||
errorCode == WarningCode.UNNECESSARY_NULL_COMPARISON_NEVER_NULL_TRUE ||
errorCode == WarningCode.UNNECESSARY_TYPE_CHECK_TRUE ||
return errorCode == WarningCode.unnecessaryNanComparisonTrue ||
errorCode == WarningCode.unnecessaryNullComparisonAlwaysNullTrue ||
errorCode == WarningCode.unnecessaryNullComparisonNeverNullTrue ||
errorCode == WarningCode.unnecessaryTypeCheckTrue ||
errorCode == LinterLintCode.avoid_null_checks_in_equality_operators;
}
@@ -31,12 +31,12 @@ import 'package:yaml_edit/yaml_edit.dart';
/// The generator used to generate fixes in analysis options files.
class AnalysisOptionsFixGenerator {
static const List<DiagnosticCode> codesWithFixes = [
AnalysisOptionsWarningCode.DEPRECATED_LINT,
AnalysisOptionsWarningCode.ANALYSIS_OPTION_DEPRECATED_WITH_REPLACEMENT,
AnalysisOptionsWarningCode.DUPLICATE_RULE,
AnalysisOptionsWarningCode.REMOVED_LINT,
AnalysisOptionsWarningCode.UNDEFINED_LINT,
AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITHOUT_VALUES,
AnalysisOptionsWarningCode.deprecatedLint,
AnalysisOptionsWarningCode.analysisOptionDeprecatedWithReplacement,
AnalysisOptionsWarningCode.duplicateRule,
AnalysisOptionsWarningCode.removedLint,
AnalysisOptionsWarningCode.undefinedLint,
AnalysisOptionsWarningCode.unsupportedOptionWithoutValues,
];
/// The resource provider used to access the file system.
@@ -91,8 +91,7 @@ class AnalysisOptionsFixGenerator {
}
if (diagnosticCode ==
AnalysisOptionsWarningCode
.ANALYSIS_OPTION_DEPRECATED_WITH_REPLACEMENT) {
AnalysisOptionsWarningCode.analysisOptionDeprecatedWithReplacement) {
var analyzerMap = options['analyzer'];
if (analyzerMap is! YamlMap) {
return fixes;
@@ -116,13 +115,13 @@ class AnalysisOptionsFixGenerator {
strongModeMap,
);
}
} else if (diagnosticCode == AnalysisOptionsWarningCode.DEPRECATED_LINT ||
diagnosticCode == AnalysisOptionsWarningCode.DUPLICATE_RULE ||
diagnosticCode == AnalysisOptionsWarningCode.REMOVED_LINT ||
diagnosticCode == AnalysisOptionsWarningCode.UNDEFINED_LINT) {
} else if (diagnosticCode == AnalysisOptionsWarningCode.deprecatedLint ||
diagnosticCode == AnalysisOptionsWarningCode.duplicateRule ||
diagnosticCode == AnalysisOptionsWarningCode.removedLint ||
diagnosticCode == AnalysisOptionsWarningCode.undefinedLint) {
await _addFix_removeLint(coveringNodePath);
} else if (diagnosticCode ==
AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITHOUT_VALUES) {
AnalysisOptionsWarningCode.unsupportedOptionWithoutValues) {
await _addFix_removeSetting(coveringNodePath);
}
return fixes;
@@ -25,8 +25,8 @@ import 'package:yaml/yaml.dart';
/// The generator used to generate fixes in pubspec.yaml files.
class PubspecFixGenerator {
static const List<DiagnosticCode> codesWithFixes = [
PubspecWarningCode.MISSING_DEPENDENCY,
PubspecWarningCode.MISSING_NAME,
PubspecWarningCode.missingDependency,
PubspecWarningCode.missingName,
];
/// The resource provider used to access the file system.
@@ -93,40 +93,37 @@ class PubspecFixGenerator {
return fixes;
}
if (diagnosticCode == PubspecWarningCode.ASSET_DOES_NOT_EXIST) {
if (diagnosticCode == PubspecWarningCode.assetDoesNotExist) {
// Consider replacing the path with a valid path.
} else if (diagnosticCode ==
PubspecWarningCode.ASSET_DIRECTORY_DOES_NOT_EXIST) {
PubspecWarningCode.assetDirectoryDoesNotExist) {
// Consider replacing the path with a valid path.
// Consider creating the directory.
} else if (diagnosticCode == PubspecWarningCode.ASSET_FIELD_NOT_LIST) {
} else if (diagnosticCode == PubspecWarningCode.assetFieldNotList) {
// Not sure how to fix a structural issue.
} else if (diagnosticCode == PubspecWarningCode.ASSET_NOT_STRING) {
} else if (diagnosticCode == PubspecWarningCode.assetNotString) {
// Not sure how to fix a structural issue.
} else if (diagnosticCode ==
PubspecWarningCode.DEPENDENCIES_FIELD_NOT_MAP) {
} else if (diagnosticCode == PubspecWarningCode.dependenciesFieldNotMap) {
// Not sure how to fix a structural issue.
} else if (diagnosticCode == PubspecWarningCode.DEPRECATED_FIELD) {
} else if (diagnosticCode == PubspecWarningCode.deprecatedField) {
// Consider removing the field.
} else if (diagnosticCode == PubspecWarningCode.FLUTTER_FIELD_NOT_MAP) {
} else if (diagnosticCode == PubspecWarningCode.flutterFieldNotMap) {
// Not sure how to fix a structural issue.
} else if (diagnosticCode == PubspecWarningCode.INVALID_DEPENDENCY) {
} else if (diagnosticCode == PubspecWarningCode.invalidDependency) {
// Consider adding `publish_to: none`.
} else if (diagnosticCode == PubspecWarningCode.MISSING_NAME) {
} else if (diagnosticCode == PubspecWarningCode.missingName) {
await _addNameEntry();
} else if (diagnosticCode == PubspecWarningCode.NAME_NOT_STRING) {
} else if (diagnosticCode == PubspecWarningCode.nameNotString) {
// Not sure how to fix a structural issue.
} else if (diagnosticCode == PubspecWarningCode.PATH_DOES_NOT_EXIST) {
} else if (diagnosticCode == PubspecWarningCode.pathDoesNotExist) {
// Consider replacing the path with a valid path.
} else if (diagnosticCode == PubspecWarningCode.PATH_NOT_POSIX) {
} else if (diagnosticCode == PubspecWarningCode.pathNotPosix) {
// Consider converting to a POSIX-style path.
} else if (diagnosticCode ==
PubspecWarningCode.PATH_PUBSPEC_DOES_NOT_EXIST) {
} else if (diagnosticCode == PubspecWarningCode.pathPubspecDoesNotExist) {
// Consider replacing the path with a valid path.
} else if (diagnosticCode ==
PubspecWarningCode.UNNECESSARY_DEV_DEPENDENCY) {
} else if (diagnosticCode == PubspecWarningCode.unnecessaryDevDependency) {
// Consider removing the dependency.
} else if (diagnosticCode == PubspecWarningCode.MISSING_DEPENDENCY) {
} else if (diagnosticCode == PubspecWarningCode.missingDependency) {
await _addMissingDependency(diagnosticCode);
}
return fixes;
File diff suppressed because it is too large Load Diff
@@ -65,9 +65,9 @@ class ImportOrganizer {
bool _isUnusedImport(UriBasedDirective directive) {
for (var diagnostic in diagnostics) {
if ((diagnostic.diagnosticCode == WarningCode.DUPLICATE_IMPORT ||
diagnostic.diagnosticCode == WarningCode.UNUSED_IMPORT ||
diagnostic.diagnosticCode == HintCode.UNNECESSARY_IMPORT) &&
if ((diagnostic.diagnosticCode == WarningCode.duplicateImport ||
diagnostic.diagnosticCode == WarningCode.unusedImport ||
diagnostic.diagnosticCode == HintCode.unnecessaryImport) &&
directive.uri.offset == diagnostic.offset) {
return true;
}
@@ -77,7 +77,7 @@ class ImportOrganizer {
bool _isUnusedShowName(SimpleIdentifier name) {
for (var diagnostic in diagnostics) {
if ((diagnostic.diagnosticCode == WarningCode.UNUSED_SHOWN_NAME) &&
if ((diagnostic.diagnosticCode == WarningCode.unusedShownName) &&
name.offset == diagnostic.offset) {
return true;
}
@@ -84,13 +84,13 @@ class AbstractSingleUnitTest extends AbstractContextTest {
if (verifyNoTestUnitErrors) {
expect(
unitResult.diagnostics.where((d) {
return d.diagnosticCode != WarningCode.DEAD_CODE &&
d.diagnosticCode != WarningCode.UNUSED_CATCH_CLAUSE &&
d.diagnosticCode != WarningCode.UNUSED_CATCH_STACK &&
d.diagnosticCode != WarningCode.UNUSED_ELEMENT &&
d.diagnosticCode != WarningCode.UNUSED_FIELD &&
d.diagnosticCode != WarningCode.UNUSED_IMPORT &&
d.diagnosticCode != WarningCode.UNUSED_LOCAL_VARIABLE;
return d.diagnosticCode != WarningCode.deadCode &&
d.diagnosticCode != WarningCode.unusedCatchClause &&
d.diagnosticCode != WarningCode.unusedCatchStack &&
d.diagnosticCode != WarningCode.unusedElement &&
d.diagnosticCode != WarningCode.unusedField &&
d.diagnosticCode != WarningCode.unusedImport &&
d.diagnosticCode != WarningCode.unusedLocalVariable;
}),
isEmpty,
);
@@ -43,7 +43,7 @@ class AnalysisErrorTest {
// prepare AnalysisError
engineDiagnostic = MockDiagnostic(
source: source,
diagnosticCode: engine.CompileTimeErrorCode.AMBIGUOUS_EXPORT,
diagnosticCode: engine.CompileTimeErrorCode.ambiguousExport,
offset: 10,
length: 20,
message: 'my message',
@@ -111,7 +111,7 @@ class AnalysisErrorTest {
void test_fromEngine_hasCorrection() {
engineDiagnostic = MockDiagnostic(
source: source,
diagnosticCode: engine.CompileTimeErrorCode.AMBIGUOUS_EXPORT,
diagnosticCode: engine.CompileTimeErrorCode.ambiguousExport,
offset: 10,
length: 20,
message: 'my message',
@@ -202,7 +202,7 @@ class AnalysisErrorTest {
void test_fromEngine_noCorrection() {
engineDiagnostic = MockDiagnostic(
source: source,
diagnosticCode: engine.CompileTimeErrorCode.AMBIGUOUS_EXPORT,
diagnosticCode: engine.CompileTimeErrorCode.ambiguousExport,
offset: 10,
length: 20,
message: 'my message',
@@ -66,7 +66,7 @@ linter:
rules:
- undefined
''',
[AnalysisOptionsWarningCode.UNDEFINED_LINT],
[AnalysisOptionsWarningCode.undefinedLint],
);
}
@@ -72,7 +72,7 @@ Future<int> f() async {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.UNDEFINED_IDENTIFIER_AWAIT;
CompileTimeErrorCode.undefinedIdentifierAwait;
},
);
}
@@ -91,7 +91,7 @@ void doStuff() => takeFutureCallback(() async => await 1);
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.UNDEFINED_IDENTIFIER_AWAIT;
CompileTimeErrorCode.undefinedIdentifierAwait;
},
);
}
@@ -467,8 +467,7 @@ Future<int> f() async {
}
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.AWAIT_IN_WRONG_CONTEXT;
return error.diagnosticCode == CompileTimeErrorCode.awaitInWrongContext;
},
);
}
@@ -163,7 +163,7 @@ void f() async {
}
''',
errorFilter:
(error) => error.diagnosticCode != ParserErrorCode.EXPECTED_TOKEN,
(error) => error.diagnosticCode != ParserErrorCode.expectedToken,
);
}
@@ -327,7 +327,7 @@ Future<void> baz() async {
''',
errorFilter:
(error) =>
error.diagnosticCode == CompileTimeErrorCode.INVALID_ASSIGNMENT,
error.diagnosticCode == CompileTimeErrorCode.invalidAssignment,
);
}
@@ -342,7 +342,7 @@ void baz() {
await assertNoFix(
errorFilter:
(error) =>
error.diagnosticCode == CompileTimeErrorCode.INVALID_ASSIGNMENT,
error.diagnosticCode == CompileTimeErrorCode.invalidAssignment,
);
}
@@ -364,7 +364,7 @@ Future<void> baz() async {
''',
errorFilter:
(error) =>
error.diagnosticCode == CompileTimeErrorCode.INVALID_ASSIGNMENT,
error.diagnosticCode == CompileTimeErrorCode.invalidAssignment,
);
}
}
@@ -660,7 +660,7 @@ class C extends Widget with Diagnosticable {
''',
errorFilter:
(error) =>
error.diagnosticCode != CompileTimeErrorCode.UNDEFINED_CLASS,
error.diagnosticCode != CompileTimeErrorCode.undefinedClass,
);
}
@@ -695,7 +695,7 @@ class C extends Widget with Diagnosticable {
''',
errorFilter:
(error) =>
error.diagnosticCode != CompileTimeErrorCode.UNDEFINED_CLASS,
error.diagnosticCode != CompileTimeErrorCode.undefinedClass,
);
}
@@ -31,7 +31,7 @@ class A {
main() {}
''');
await assertHasFixAllFix(
CompileTimeErrorCode.NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS,
CompileTimeErrorCode.noAnnotationConstructorArguments,
'''
class A {
const A();
@@ -300,7 +300,7 @@ void f() {
}
''',
errorFilter: (e) {
return e.diagnosticCode == CompileTimeErrorCode.UNDEFINED_ENUM_CONSTANT;
return e.diagnosticCode == CompileTimeErrorCode.undefinedEnumConstant;
},
);
}
@@ -323,7 +323,7 @@ E e() {
''',
errorFilter: (e) {
return e.diagnosticCode ==
CompileTimeErrorCode.DOT_SHORTHAND_UNDEFINED_GETTER;
CompileTimeErrorCode.dotShorthandUndefinedGetter;
},
);
}
@@ -31,7 +31,7 @@ f(A a) {
class A {}
class B {}
''');
await assertHasFixAllFix(CompileTimeErrorCode.INVALID_ASSIGNMENT, '''
await assertHasFixAllFix(CompileTimeErrorCode.invalidAssignment, '''
f(A a) {
B b, b2;
b = a as B;
@@ -52,7 +52,7 @@ f(List<A> a) {
class A {}
class B {}
''');
await assertHasFixAllFix(CompileTimeErrorCode.INVALID_ASSIGNMENT, '''
await assertHasFixAllFix(CompileTimeErrorCode.invalidAssignment, '''
f(List<A> a) {
List<B> b, b2;
b = a.where((e) => e is B).cast<B>().toList();
@@ -73,7 +73,7 @@ f(Map<A, B> a) {
class A {}
class B {}
''');
await assertHasFixAllFix(CompileTimeErrorCode.INVALID_ASSIGNMENT, '''
await assertHasFixAllFix(CompileTimeErrorCode.invalidAssignment, '''
f(Map<A, B> a) {
Map<B, A> b, b2;
b = a.cast<B, A>();
@@ -96,7 +96,7 @@ class A {
}
class B {}
''');
await assertHasFixAllFix(CompileTimeErrorCode.INVALID_ASSIGNMENT, '''
await assertHasFixAllFix(CompileTimeErrorCode.invalidAssignment, '''
f(A a) {
B b, b2;
b = (a..m()) as B;
@@ -119,7 +119,7 @@ f(Set<A> a) {
class A {}
class B {}
''');
await assertHasFixAllFix(CompileTimeErrorCode.INVALID_ASSIGNMENT, '''
await assertHasFixAllFix(CompileTimeErrorCode.invalidAssignment, '''
f(Set<A> a) {
Set<B> b, b2;
b = a.cast<B>();
@@ -139,7 +139,7 @@ f(A a) {
class A {}
class B {}
''');
await assertHasFixAllFix(CompileTimeErrorCode.INVALID_ASSIGNMENT, '''
await assertHasFixAllFix(CompileTimeErrorCode.invalidAssignment, '''
f(A a) {
B b = a as B;
B b2 = a as B;
@@ -158,7 +158,7 @@ f(List<A> a) {
class A {}
class B {}
''');
await assertHasFixAllFix(CompileTimeErrorCode.INVALID_ASSIGNMENT, '''
await assertHasFixAllFix(CompileTimeErrorCode.invalidAssignment, '''
f(List<A> a) {
List<B> b = a.where((e) => e is B).cast<B>().toList();
List<B> b2 = a.where((e) => e is B).cast<B>().toList();
@@ -177,7 +177,7 @@ f(Map<A, B> a) {
class A {}
class B {}
''');
await assertHasFixAllFix(CompileTimeErrorCode.INVALID_ASSIGNMENT, '''
await assertHasFixAllFix(CompileTimeErrorCode.invalidAssignment, '''
f(Map<A, B> a) {
Map<B, A> b = a.cast<B, A>();
Map<B, A> b2 = a.cast<B, A>();
@@ -198,7 +198,7 @@ class A {
}
class B {}
''');
await assertHasFixAllFix(CompileTimeErrorCode.INVALID_ASSIGNMENT, '''
await assertHasFixAllFix(CompileTimeErrorCode.invalidAssignment, '''
f(A a) {
B b = (a..m()) as B;
B b2 = (a..m()) as B;
@@ -219,7 +219,7 @@ f(Set<A> a) {
class A {}
class B {}
''');
await assertHasFixAllFix(CompileTimeErrorCode.INVALID_ASSIGNMENT, '''
await assertHasFixAllFix(CompileTimeErrorCode.invalidAssignment, '''
f(Set<A> a) {
Set<B> b = a.cast<B>();
Set<B> b2 = a.cast<B>();
@@ -645,7 +645,7 @@ void foo(int a) {
''');
await assertNoFix(
errorFilter: (e) {
return e.diagnosticCode == CompileTimeErrorCode.INVALID_ASSIGNMENT;
return e.diagnosticCode == CompileTimeErrorCode.invalidAssignment;
},
);
}
@@ -52,7 +52,7 @@ void f(String str) {
errorFilter:
(error) =>
error.diagnosticCode ==
CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO,
CompileTimeErrorCode.ambiguousExtensionMemberAccessTwo,
);
await assertHasFixesWithoutApplying(
@@ -64,7 +64,7 @@ void f(String str) {
errorFilter:
(error) =>
error.diagnosticCode ==
CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO,
CompileTimeErrorCode.ambiguousExtensionMemberAccessTwo,
);
}
@@ -128,7 +128,7 @@ f() {
expectedNumberOfFixesForKind: 1,
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO;
CompileTimeErrorCode.ambiguousExtensionMemberAccessTwo;
},
);
}
@@ -206,7 +206,7 @@ extension E2 on A {
errorFilter:
(error) =>
error.diagnosticCode ==
CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO,
CompileTimeErrorCode.ambiguousExtensionMemberAccessTwo,
);
}
@@ -242,7 +242,7 @@ extension E2 on A {
errorFilter:
(error) =>
error.diagnosticCode ==
CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO,
CompileTimeErrorCode.ambiguousExtensionMemberAccessTwo,
);
}
@@ -282,7 +282,7 @@ extension E2 on A {
errorFilter:
(error) =>
error.diagnosticCode ==
CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO,
CompileTimeErrorCode.ambiguousExtensionMemberAccessTwo,
);
}
@@ -391,7 +391,7 @@ void f(String str) {
errorFilter:
(error) =>
error.diagnosticCode ==
CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO,
CompileTimeErrorCode.ambiguousExtensionMemberAccessTwo,
);
await assertHasFixesWithoutApplying(
@@ -403,7 +403,7 @@ void f(String str) {
errorFilter:
(error) =>
error.diagnosticCode ==
CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO,
CompileTimeErrorCode.ambiguousExtensionMemberAccessTwo,
);
}
}
@@ -138,7 +138,7 @@ class C {
''',
errorFilter:
(error) =>
error.diagnosticCode == CompileTimeErrorCode.ASSIGNMENT_TO_FINAL,
error.diagnosticCode == CompileTimeErrorCode.assignmentToFinal,
);
}
@@ -177,7 +177,7 @@ void f(C c) {
''',
errorFilter:
(error) =>
error.diagnosticCode == CompileTimeErrorCode.ASSIGNMENT_TO_FINAL,
error.diagnosticCode == CompileTimeErrorCode.assignmentToFinal,
);
}
@@ -201,7 +201,7 @@ class C {
''',
errorFilter:
(error) =>
error.diagnosticCode == CompileTimeErrorCode.ASSIGNMENT_TO_FINAL,
error.diagnosticCode == CompileTimeErrorCode.assignmentToFinal,
);
}
@@ -32,7 +32,7 @@ class AddMissingEnumCaseClausesTest extends FixProcessorTest {
return (error) {
if (!hasError &&
error.diagnosticCode ==
StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH) {
StaticWarningCode.missingEnumConstantInSwitch) {
hasError = true;
return true;
}
@@ -252,7 +252,7 @@ int f(E x) {
errorFilter:
(e) =>
e.diagnosticCode ==
CompileTimeErrorCode.NON_EXHAUSTIVE_SWITCH_EXPRESSION,
CompileTimeErrorCode.nonExhaustiveSwitchExpression,
);
}
@@ -369,7 +369,7 @@ class AddMissingSwitchCasesTest_SwitchStatement extends FixProcessorTest {
return (diagnostic) {
if (!hasError &&
diagnostic.diagnosticCode ==
CompileTimeErrorCode.NON_EXHAUSTIVE_SWITCH_STATEMENT) {
CompileTimeErrorCode.nonExhaustiveSwitchStatement) {
hasError = true;
return true;
}
@@ -522,7 +522,7 @@ void f(E e) {
errorFilter:
(e) =>
e.diagnosticCode ==
CompileTimeErrorCode.NON_EXHAUSTIVE_SWITCH_STATEMENT,
CompileTimeErrorCode.nonExhaustiveSwitchStatement,
);
}
@@ -32,7 +32,7 @@ f(String p, String q) {
}
}
''');
await assertNoFixAllFix(CompileTimeErrorCode.NON_BOOL_CONDITION);
await assertNoFixAllFix(CompileTimeErrorCode.nonBoolCondition);
}
Future<void> test_nonBoolCondition_all_nullable() async {
@@ -46,7 +46,7 @@ f(String? p, String? q) {
}
}
''');
await assertHasFixAllFix(CompileTimeErrorCode.NON_BOOL_CONDITION, '''
await assertHasFixAllFix(CompileTimeErrorCode.nonBoolCondition, '''
f(String? p, String? q) {
if (p != null) {
print(p);
@@ -392,7 +392,7 @@ void g() {
errorFilter:
(diagnostic) =>
diagnostic.diagnosticCode ==
CompileTimeErrorCode.INVALID_ASSIGNMENT,
CompileTimeErrorCode.invalidAssignment,
);
}
@@ -406,7 +406,7 @@ void g(int i) {
await assertNoFix(
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE;
CompileTimeErrorCode.argumentTypeNotAssignable;
},
);
}
@@ -449,7 +449,7 @@ void g(int i, int? x) {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE;
CompileTimeErrorCode.argumentTypeNotAssignable;
},
);
}
@@ -464,7 +464,7 @@ void g(int i, int x) {
await assertNoFix(
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE;
CompileTimeErrorCode.argumentTypeNotAssignable;
},
);
}
@@ -479,7 +479,7 @@ void g(int i, int? x) {
await assertNoFix(
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE;
CompileTimeErrorCode.argumentTypeNotAssignable;
},
);
}
@@ -571,7 +571,7 @@ void f (List<int>? args) {
errorFilter:
(diagnostic) =>
diagnostic.diagnosticCode !=
CompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE,
CompileTimeErrorCode.listElementTypeNotAssignable,
);
}
@@ -622,7 +622,7 @@ f(List<String>? args) {
errorFilter:
(diagnostic) =>
diagnostic.diagnosticCode !=
CompileTimeErrorCode.YIELD_EACH_OF_INVALID_TYPE,
CompileTimeErrorCode.yieldEachOfInvalidType,
);
}
@@ -645,8 +645,7 @@ g() {
errorFilter:
(diagnostic) =>
diagnostic.diagnosticCode ==
CompileTimeErrorCode
.UNCHECKED_USE_OF_NULLABLE_VALUE_IN_YIELD_EACH,
CompileTimeErrorCode.uncheckedUseOfNullableValueInYieldEach,
);
}
@@ -669,7 +668,7 @@ class C {
errorFilter:
(diagnostic) =>
diagnostic.diagnosticCode !=
CompileTimeErrorCode.YIELD_EACH_OF_INVALID_TYPE,
CompileTimeErrorCode.yieldEachOfInvalidType,
);
}
@@ -688,7 +687,7 @@ Iterable<String> f(List<String>? args) sync* {
errorFilter:
(diagnostic) =>
diagnostic.diagnosticCode !=
CompileTimeErrorCode.YIELD_EACH_OF_INVALID_TYPE,
CompileTimeErrorCode.yieldEachOfInvalidType,
);
}
}
@@ -38,7 +38,7 @@ void f(Object? x) {
}
''');
await assertHasFixAllFix(
CompileTimeErrorCode.SWITCH_CASE_COMPLETES_NORMALLY,
CompileTimeErrorCode.switchCaseCompletesNormally,
'''
void f(Object? x) {
switch (x) {
@@ -145,7 +145,7 @@ class C with M {}
''',
matchFixMessage: "Hide others to use 'M' from 'lib4.dart'",
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.AMBIGUOUS_IMPORT;
return error.diagnosticCode == CompileTimeErrorCode.ambiguousImport;
},
);
}
@@ -195,7 +195,7 @@ class C with M {}
''',
matchFixMessage: "Hide others to use 'M' from 'lib3.dart'",
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.AMBIGUOUS_IMPORT;
return error.diagnosticCode == CompileTimeErrorCode.ambiguousImport;
},
);
}
@@ -228,7 +228,7 @@ void foo(int i) {
''',
matchFixMessage: "Hide others to use 'E' from 'lib1.dart'",
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.AMBIGUOUS_IMPORT;
return error.diagnosticCode == CompileTimeErrorCode.ambiguousImport;
},
);
}
@@ -276,7 +276,7 @@ class C with M {}
''',
matchFixMessage: "Hide others to use 'M' from 'lib1.dart'",
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.AMBIGUOUS_IMPORT;
return error.diagnosticCode == CompileTimeErrorCode.ambiguousImport;
},
);
}
@@ -566,7 +566,7 @@ void f() {
matchFixMessage: "Hide others to use 'N' from 'lib2.dart'",
errorFilter:
(error) =>
error.diagnosticCode == CompileTimeErrorCode.AMBIGUOUS_IMPORT,
error.diagnosticCode == CompileTimeErrorCode.ambiguousImport,
);
}
@@ -595,7 +595,7 @@ void f() {
matchFixMessage: "Hide others to use 'N' from 'lib2.dart' as l",
errorFilter:
(error) =>
error.diagnosticCode == CompileTimeErrorCode.AMBIGUOUS_IMPORT,
error.diagnosticCode == CompileTimeErrorCode.ambiguousImport,
);
}
@@ -623,7 +623,7 @@ class C with M {}
''',
matchFixMessage: "Hide others to use 'M' from 'lib1.dart'",
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.AMBIGUOUS_IMPORT;
return error.diagnosticCode == CompileTimeErrorCode.ambiguousImport;
},
);
await assertHasFix(
@@ -636,7 +636,7 @@ class C with M {}
''',
matchFixMessage: "Hide others to use 'M' from 'lib2.dart'",
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.AMBIGUOUS_IMPORT;
return error.diagnosticCode == CompileTimeErrorCode.ambiguousImport;
},
);
await assertHasFix(
@@ -649,7 +649,7 @@ class C with M {}
''',
matchFixMessage: "Hide others to use 'M' from 'lib3.dart'",
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.AMBIGUOUS_IMPORT;
return error.diagnosticCode == CompileTimeErrorCode.ambiguousImport;
},
);
}
@@ -865,7 +865,7 @@ void f(N? n, O? o) {
''',
errorFilter:
(error) =>
error.diagnosticCode == CompileTimeErrorCode.AMBIGUOUS_IMPORT,
error.diagnosticCode == CompileTimeErrorCode.ambiguousImport,
matchFixMessage: "Remove show to use 'N' from 'lib2.dart'",
);
}
@@ -494,7 +494,7 @@ void f(A a) {
}
''',
errorFilter:
(e) => e.diagnosticCode == CompileTimeErrorCode.UNDEFINED_GETTER,
(e) => e.diagnosticCode == CompileTimeErrorCode.undefinedGetter,
);
}
@@ -521,7 +521,7 @@ void f() {
}
''',
errorFilter:
(e) => e.diagnosticCode == CompileTimeErrorCode.UNDEFINED_GETTER,
(e) => e.diagnosticCode == CompileTimeErrorCode.undefinedGetter,
);
}
@@ -242,7 +242,7 @@ void f() {
});
}
''');
await assertHasFixAllFix(WarningCode.UNNECESSARY_SET_LITERAL, '''
await assertHasFixAllFix(WarningCode.unnecessarySetLiteral, '''
void g(void Function() fun) {}
void f() {
@@ -38,7 +38,7 @@ extension E on int {
errorFilter:
(error) =>
error.diagnosticCode ==
CompileTimeErrorCode.EXTENSION_DECLARES_INSTANCE_FIELD,
CompileTimeErrorCode.extensionDeclaresInstanceField,
);
}
@@ -242,7 +242,7 @@ class A {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER;
CompileTimeErrorCode.implicitThisReferenceInInitializer;
},
);
}
@@ -266,7 +266,7 @@ class A {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER;
CompileTimeErrorCode.implicitThisReferenceInInitializer;
},
);
}
@@ -290,7 +290,7 @@ class A {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER;
CompileTimeErrorCode.implicitThisReferenceInInitializer;
},
);
}
@@ -50,7 +50,7 @@ void f() {
g(() => {g(() => {1})});
}
''');
await assertHasFixAllFix(WarningCode.UNNECESSARY_SET_LITERAL, '''
await assertHasFixAllFix(WarningCode.unnecessarySetLiteral, '''
void g(void Function() fun) {}
void f() {
@@ -60,7 +60,7 @@ void f() { }
/// Docs.
// TODO(user): msg.
void f() { }
''', errorFilter: (e) => e.diagnosticCode != TodoCode.TODO);
''', errorFilter: (e) => e.diagnosticCode != TodoCode.todo);
}
Future<void> test_docCommentSolo() async {
@@ -71,7 +71,7 @@ void f() { }
await assertHasFix('''
// TODO(user): msg.
void f() { }
''', errorFilter: (e) => e.diagnosticCode != TodoCode.TODO);
''', errorFilter: (e) => e.diagnosticCode != TodoCode.todo);
}
Future<void> test_extraLeadingSpace() async {
@@ -82,7 +82,7 @@ void f() { }
await assertHasFix('''
// TODO(user): msg.
void f() { }
''', errorFilter: (e) => e.diagnosticCode != TodoCode.TODO);
''', errorFilter: (e) => e.diagnosticCode != TodoCode.todo);
}
Future<void> test_lowerCase() async {
@@ -101,7 +101,7 @@ void f() { }
// TODO(user msg.
void f() { }
''');
await assertNoFix(errorFilter: (e) => e.diagnosticCode != TodoCode.TODO);
await assertNoFix(errorFilter: (e) => e.diagnosticCode != TodoCode.todo);
}
Future<void> test_missingColon() async {
@@ -112,7 +112,7 @@ void f() { }
await assertHasFix('''
// TODO(user): msg.
void f() { }
''', errorFilter: (e) => e.diagnosticCode != TodoCode.TODO);
''', errorFilter: (e) => e.diagnosticCode != TodoCode.todo);
}
Future<void> test_missingColon_surroundingComments() async {
@@ -127,7 +127,7 @@ void f() { }
// TODO(user): msg.
// Trailing comment.
void f() { }
''', errorFilter: (e) => e.diagnosticCode != TodoCode.TODO);
''', errorFilter: (e) => e.diagnosticCode != TodoCode.todo);
}
Future<void> test_missingColonAndMessage() async {
@@ -135,7 +135,7 @@ void f() { }
// TODO(user)
void f() {}
''');
await assertNoFix(errorFilter: (e) => e.diagnosticCode != TodoCode.TODO);
await assertNoFix(errorFilter: (e) => e.diagnosticCode != TodoCode.todo);
}
Future<void> test_missingLeadingSpace() async {
@@ -146,7 +146,7 @@ void f() {}
await assertHasFix('''
// TODO(user): msg.
void f() {}
''', errorFilter: (e) => e.diagnosticCode != TodoCode.TODO);
''', errorFilter: (e) => e.diagnosticCode != TodoCode.todo);
}
Future<void> test_unwantedSpaceBeforeUser() async {
@@ -157,6 +157,6 @@ void f() {}
await assertHasFix('''
// TODO(user): msg.
void f() {}
''', errorFilter: (e) => e.diagnosticCode != TodoCode.TODO);
''', errorFilter: (e) => e.diagnosticCode != TodoCode.todo);
}
}
@@ -94,7 +94,7 @@ import 'foo';
''',
errorFilter:
(error) =>
error.diagnosticCode != CompileTimeErrorCode.URI_DOES_NOT_EXIST,
error.diagnosticCode != CompileTimeErrorCode.uriDoesNotExist,
);
}
@@ -450,7 +450,7 @@ class Test {
}
''',
errorFilter: (e) {
return e.diagnosticCode == CompileTimeErrorCode.UNDEFINED_FUNCTION;
return e.diagnosticCode == CompileTimeErrorCode.undefinedFunction;
},
);
}
@@ -541,8 +541,7 @@ class Test {
}
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.UNDEFINED_IDENTIFIER;
return error.diagnosticCode == CompileTimeErrorCode.undefinedIdentifier;
},
);
assertLinkedGroup(change.linkedEditGroups[0], ['Test])', 'Test {']);
@@ -314,7 +314,7 @@ class Test {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.FINAL_NOT_INITIALIZED &&
CompileTimeErrorCode.finalNotInitialized &&
error.message.contains("'_a'");
},
);
@@ -891,8 +891,7 @@ extension E on int {
''',
errorFilter:
(diagnostic) =>
diagnostic.diagnosticCode ==
CompileTimeErrorCode.UNDEFINED_METHOD,
diagnostic.diagnosticCode == CompileTimeErrorCode.undefinedMethod,
);
}
@@ -911,14 +910,13 @@ extension E on A {
await assertNoFix(
errorFilter:
(diagnostic) =>
diagnostic.diagnosticCode ==
CompileTimeErrorCode.UNDEFINED_METHOD,
diagnostic.diagnosticCode == CompileTimeErrorCode.undefinedMethod,
);
await assertNoFix(
errorFilter:
(diagnostic) =>
diagnostic.diagnosticCode ==
CompileTimeErrorCode.INVALID_ASSIGNMENT,
CompileTimeErrorCode.invalidAssignment,
);
}
@@ -979,8 +977,7 @@ extension E on int {
''',
errorFilter:
(diagnostic) =>
diagnostic.diagnosticCode ==
CompileTimeErrorCode.UNDEFINED_METHOD,
diagnostic.diagnosticCode == CompileTimeErrorCode.undefinedMethod,
);
}
@@ -995,8 +992,7 @@ extension E on int {
await assertNoFix(
errorFilter:
(diagnostic) =>
diagnostic.diagnosticCode ==
CompileTimeErrorCode.UNDEFINED_METHOD,
diagnostic.diagnosticCode == CompileTimeErrorCode.undefinedMethod,
);
}
@@ -1020,8 +1016,7 @@ extension E on int {
''',
errorFilter:
(diagnostic) =>
diagnostic.diagnosticCode ==
CompileTimeErrorCode.UNDEFINED_METHOD,
diagnostic.diagnosticCode == CompileTimeErrorCode.undefinedMethod,
);
}
@@ -1042,8 +1037,7 @@ extension E on B {
await assertNoFix(
errorFilter:
(diagnostic) =>
diagnostic.diagnosticCode ==
CompileTimeErrorCode.UNDEFINED_METHOD,
diagnostic.diagnosticCode == CompileTimeErrorCode.undefinedMethod,
);
}
@@ -278,7 +278,7 @@ A f() {
''',
errorFilter: (e) {
return e.diagnosticCode ==
CompileTimeErrorCode.DOT_SHORTHAND_UNDEFINED_GETTER;
CompileTimeErrorCode.dotShorthandUndefinedGetter;
},
);
}
@@ -301,7 +301,7 @@ A f() {
''',
errorFilter: (e) {
return e.diagnosticCode ==
CompileTimeErrorCode.DOT_SHORTHAND_UNDEFINED_GETTER;
CompileTimeErrorCode.dotShorthandUndefinedGetter;
},
);
}
@@ -46,8 +46,7 @@ class B implements A {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode
.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE;
CompileTimeErrorCode.nonAbstractClassInheritsAbstractMemberOne;
},
);
}
@@ -76,8 +75,7 @@ class B implements A {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode
.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE;
CompileTimeErrorCode.nonAbstractClassInheritsAbstractMemberOne;
},
);
}
@@ -105,8 +103,7 @@ class B implements A {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode
.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE;
CompileTimeErrorCode.nonAbstractClassInheritsAbstractMemberOne;
},
);
}
@@ -298,8 +298,7 @@ mixin Test {
}
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.UNDEFINED_IDENTIFIER;
return error.diagnosticCode == CompileTimeErrorCode.undefinedIdentifier;
},
);
assertLinkedGroup(change.linkedEditGroups[0], ['Test])', 'Test {']);
@@ -60,7 +60,7 @@ mixin DataDrivenFixProcessorTestMixin on AbstractSingleUnitTest {
/// A method that can be used as an error filter to ignore any unused_import
/// diagnostics.
bool ignoreUnusedImport(Diagnostic diagnostic) =>
diagnostic.diagnosticCode != WarningCode.UNUSED_IMPORT;
diagnostic.diagnosticCode != WarningCode.unusedImport;
/// Sets the content of the library that defines the element referenced by the
/// data on which this test is based.
@@ -42,7 +42,7 @@ void f(A a, B b, C c) {
}
''',
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.UNDEFINED_CLASS &&
return error.diagnosticCode == CompileTimeErrorCode.undefinedClass &&
testCode.indexOf('B b') == error.offset;
},
);
@@ -54,7 +54,7 @@ void f(A a, B b, C c) {
}
''',
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.UNDEFINED_CLASS &&
return error.diagnosticCode == CompileTimeErrorCode.undefinedClass &&
testCode.indexOf('C c') == error.offset;
},
);
@@ -89,7 +89,7 @@ void f(String s, lib.C c) {
}
''',
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.UNDEFINED_METHOD;
return error.diagnosticCode == CompileTimeErrorCode.undefinedMethod;
},
);
}
@@ -123,7 +123,7 @@ void f(String s, C c) {
}
''',
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.UNDEFINED_METHOD;
return error.diagnosticCode == CompileTimeErrorCode.undefinedMethod;
},
);
}
@@ -162,7 +162,7 @@ void f(String s, C c) {
}
''',
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.UNDEFINED_OPERATOR;
return error.diagnosticCode == CompileTimeErrorCode.undefinedOperator;
},
);
}
@@ -197,7 +197,7 @@ void f() {
}
''',
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.UNDEFINED_CLASS &&
return error.diagnosticCode == CompileTimeErrorCode.undefinedClass &&
testCode.indexOf('B?') == error.offset;
},
);
@@ -253,7 +253,7 @@ void f(A a1) {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.UNDEFINED_IDENTIFIER &&
CompileTimeErrorCode.undefinedIdentifier &&
testCode.indexOf('E.') == error.offset;
},
);
@@ -266,7 +266,7 @@ void f(A a1) {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.UNDEFINED_IDENTIFIER &&
CompileTimeErrorCode.undefinedIdentifier &&
testCode.indexOf("a')") == error.offset;
},
);
@@ -71,7 +71,7 @@ void f() {
}
''',
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.UNDEFINED_CLASS;
return error.diagnosticCode == CompileTimeErrorCode.undefinedClass;
},
);
}
@@ -99,7 +99,7 @@ void f() {
}
''',
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.UNDEFINED_CLASS;
return error.diagnosticCode == CompileTimeErrorCode.undefinedClass;
},
);
}
@@ -714,7 +714,7 @@ void f() {
}
''',
errorFilter:
(e) => e.diagnosticCode == CompileTimeErrorCode.UNDEFINED_FUNCTION,
(e) => e.diagnosticCode == CompileTimeErrorCode.undefinedFunction,
);
}
@@ -269,8 +269,7 @@ class MyAnnotation {
void f() {}
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.UNDEFINED_IDENTIFIER;
return error.diagnosticCode == CompileTimeErrorCode.undefinedIdentifier;
},
);
}
@@ -42,7 +42,7 @@ void f(A a, B b, C c) {
}
''',
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.UNDEFINED_CLASS &&
return error.diagnosticCode == CompileTimeErrorCode.undefinedClass &&
testCode.indexOf('B') == error.offset;
},
);
@@ -54,7 +54,7 @@ void f(A a, B b, C c) {
}
''',
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.UNDEFINED_CLASS &&
return error.diagnosticCode == CompileTimeErrorCode.undefinedClass &&
testCode.indexOf('C') == error.offset;
},
);
@@ -88,7 +88,7 @@ void f(String s, lib.C c) {
}
''',
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.UNDEFINED_METHOD;
return error.diagnosticCode == CompileTimeErrorCode.undefinedMethod;
},
);
}
@@ -121,7 +121,7 @@ void f(String s, C c) {
}
''',
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.UNDEFINED_METHOD;
return error.diagnosticCode == CompileTimeErrorCode.undefinedMethod;
},
);
}
@@ -159,7 +159,7 @@ void f(String s, C c) {
}
''',
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.UNDEFINED_OPERATOR;
return error.diagnosticCode == CompileTimeErrorCode.undefinedOperator;
},
);
}
@@ -193,7 +193,7 @@ void f() {
}
''',
errorFilter: (error) {
return error.diagnosticCode == CompileTimeErrorCode.UNDEFINED_CLASS &&
return error.diagnosticCode == CompileTimeErrorCode.undefinedClass &&
testCode.indexOf('B') == error.offset;
},
);
@@ -248,7 +248,7 @@ void f(A a1) {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.UNDEFINED_IDENTIFIER &&
CompileTimeErrorCode.undefinedIdentifier &&
testCode.indexOf('E') == error.offset;
},
);
@@ -261,7 +261,7 @@ void f(A a1) {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.UNDEFINED_IDENTIFIER &&
CompileTimeErrorCode.undefinedIdentifier &&
testCode.indexOf("a')") == error.offset;
},
);
@@ -128,8 +128,7 @@ enum E
{}''',
errorFilter:
(error) =>
error.diagnosticCode !=
CompileTimeErrorCode.ENUM_WITHOUT_CONSTANTS,
error.diagnosticCode != CompileTimeErrorCode.enumWithoutConstants,
);
}
}
@@ -25,7 +25,7 @@ extension String {}
extension String {}
''');
var fixes = await getFixesForFirst(
(e) => e.diagnosticCode == ParserErrorCode.EXPECTED_TOKEN,
(e) => e.diagnosticCode == ParserErrorCode.expectedToken,
);
expect(fixes, hasLength(1));
assertProduces(fixes.first, r'''
@@ -49,7 +49,7 @@ extension int {}
extension on int {}
''',
errorFilter: (error) {
return error.diagnosticCode == ParserErrorCode.EXPECTED_TOKEN;
return error.diagnosticCode == ParserErrorCode.expectedToken;
},
);
}
@@ -90,7 +90,7 @@ extension List<int> {}
extension on List<int> {}
''',
errorFilter: (error) {
return error.diagnosticCode == ParserErrorCode.EXPECTED_TOKEN;
return error.diagnosticCode == ParserErrorCode.expectedToken;
},
);
}
@@ -182,7 +182,7 @@ f() {
f() {
var l = [ for (final i in [1, 2]) i + 3 ];
}
''', errorFilter: (e) => e.diagnosticCode != WarningCode.UNUSED_LOCAL_VARIABLE);
''', errorFilter: (e) => e.diagnosticCode != WarningCode.unusedLocalVariable);
}
Future<void> test_listPattern() async {
@@ -195,7 +195,7 @@ f() {
f() {
for (final [i, j] in [[1, 2]]) { }
}
''', errorFilter: (e) => e.diagnosticCode != WarningCode.UNUSED_LOCAL_VARIABLE);
''', errorFilter: (e) => e.diagnosticCode != WarningCode.unusedLocalVariable);
}
Future<void> test_mapPattern() async {
@@ -208,7 +208,7 @@ f() {
f() {
for (final {'i' : j} in [{'i' : 1}]) { }
}
''', errorFilter: (e) => e.diagnosticCode != WarningCode.UNUSED_LOCAL_VARIABLE);
''', errorFilter: (e) => e.diagnosticCode != WarningCode.unusedLocalVariable);
}
Future<void> test_noType() async {
@@ -248,7 +248,7 @@ class A {
f() {
for (final A(:a) in [A(1)]) { }
}
''', errorFilter: (e) => e.diagnosticCode != WarningCode.UNUSED_LOCAL_VARIABLE);
''', errorFilter: (e) => e.diagnosticCode != WarningCode.unusedLocalVariable);
}
Future<void> test_recordPattern() async {
@@ -261,7 +261,7 @@ f() {
f() {
for (final (i, j) in [(1, 2)]) { }
}
''', errorFilter: (e) => e.diagnosticCode != WarningCode.UNUSED_LOCAL_VARIABLE);
''', errorFilter: (e) => e.diagnosticCode != WarningCode.unusedLocalVariable);
}
Future<void> test_type() async {
@@ -34,7 +34,7 @@ import 'other.dart' show Stream, Future hide Stream;
DartFixKind.MERGE_COMBINATORS_HIDE_SHOW,
],
errorFilter: (error) {
return error.diagnosticCode == WarningCode.MULTIPLE_COMBINATORS;
return error.diagnosticCode == WarningCode.multipleCombinators;
},
);
}
@@ -49,7 +49,7 @@ import 'other.dart' hide Stream hide Future;
DartFixKind.MERGE_COMBINATORS_SHOW_HIDE,
],
errorFilter: (error) {
return error.diagnosticCode == WarningCode.MULTIPLE_COMBINATORS;
return error.diagnosticCode == WarningCode.multipleCombinators;
},
);
}
@@ -58,7 +58,7 @@ import 'other.dart' hide Stream hide Future;
@reflectiveTest
class MergeHideUsingHideTest extends _MergeCombinatorTest {
@override
DiagnosticCode get diagnosticCode => WarningCode.MULTIPLE_COMBINATORS;
DiagnosticCode get diagnosticCode => WarningCode.multipleCombinators;
@override
FixKind get kind => DartFixKind.MERGE_COMBINATORS_HIDE_HIDE;
@@ -170,7 +170,7 @@ import 'other.dart' show Stream, FutureOr, Future show Stream, FutureOr;
@reflectiveTest
class MergeHideUsingShowTest extends _MergeCombinatorTest {
@override
DiagnosticCode get diagnosticCode => WarningCode.MULTIPLE_COMBINATORS;
DiagnosticCode get diagnosticCode => WarningCode.multipleCombinators;
@override
FixKind get kind => DartFixKind.MERGE_COMBINATORS_SHOW_HIDE;
@@ -282,7 +282,7 @@ import 'other.dart' show Stream, FutureOr, Future show Stream, FutureOr;
@reflectiveTest
class MergeShowUsingHideTest extends _MergeCombinatorTest {
@override
DiagnosticCode get diagnosticCode => WarningCode.MULTIPLE_COMBINATORS;
DiagnosticCode get diagnosticCode => WarningCode.multipleCombinators;
@override
FixKind get kind => DartFixKind.MERGE_COMBINATORS_HIDE_SHOW;
@@ -422,7 +422,7 @@ import 'other.dart' hide Completer, Future, Timer;
@reflectiveTest
class MergeShowUsingShowTest extends _MergeCombinatorTest {
@override
DiagnosticCode get diagnosticCode => WarningCode.MULTIPLE_COMBINATORS;
DiagnosticCode get diagnosticCode => WarningCode.multipleCombinators;
@override
FixKind get kind => DartFixKind.MERGE_COMBINATORS_SHOW_SHOW;
@@ -97,7 +97,7 @@ class OrganizeImportsDirectivesOrderingTest extends FixProcessorLintTest {
var firstError = true;
return (Diagnostic diagnostic) {
if (firstError &&
diagnostic.diagnosticCode == WarningCode.UNUSED_SHOWN_NAME) {
diagnostic.diagnosticCode == WarningCode.unusedShownName) {
firstError = false;
return true;
}
@@ -28,7 +28,7 @@ class MyClass {
abstract void m2() {}
}
''');
await assertHasFixAllFix(ParserErrorCode.ABSTRACT_CLASS_MEMBER, '''
await assertHasFixAllFix(ParserErrorCode.abstractClassMember, '''
class MyClass {
void m1() {}
void m2() {}
@@ -22,7 +22,7 @@ void main() {
}
bool _ignoreDeadCode(Diagnostic diagnostic) =>
diagnostic.diagnosticCode != WarningCode.DEAD_CODE;
diagnostic.diagnosticCode != WarningCode.deadCode;
@reflectiveTest
class RemoveComparisonTest extends FixProcessorTest {
@@ -68,7 +68,7 @@ void f(int i) {
errorFilter:
(error) =>
error.diagnosticCode ==
CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
CompileTimeErrorCode.constConstructorParamTypeMismatch,
);
}
@@ -175,7 +175,7 @@ var v = [const A(), B()];
errorFilter:
(error) =>
error.diagnosticCode ==
CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT,
CompileTimeErrorCode.nonConstantListElement,
);
}
@@ -203,7 +203,7 @@ Object f() {
(error) =>
error.offset == parsedTestCode.positions[0].offset &&
error.diagnosticCode ==
CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT,
CompileTimeErrorCode.nonConstantListElement,
);
await assertHasFix(
r'''
@@ -219,7 +219,7 @@ Object f() {
(error) =>
error.offset == parsedTestCode.positions[1].offset &&
error.diagnosticCode ==
CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT,
CompileTimeErrorCode.nonConstantListElement,
);
}
@@ -247,7 +247,7 @@ Object f() {
(error) =>
error.offset == parsedTestCode.position.offset &&
error.diagnosticCode ==
CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT,
CompileTimeErrorCode.nonConstantListElement,
);
}
@@ -273,7 +273,7 @@ final x = [const A(), A.nonConst()];
errorFilter:
(error) =>
error.diagnosticCode ==
CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT,
CompileTimeErrorCode.nonConstantListElement,
);
}
}
@@ -428,8 +428,7 @@ var v = {1: const A(), 2: B()};
// TODO(FMorschel): CONST_WITH_NON_CONST should not be probably triggered
errorFilter:
(error) =>
error.diagnosticCode ==
CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE,
error.diagnosticCode == CompileTimeErrorCode.nonConstantMapValue,
);
}
@@ -452,8 +451,7 @@ final v = {1: const A(), 2: A.nonConst()};
// TODO(FMorschel): CONST_WITH_NON_CONST should not be probably triggered
errorFilter:
(error) =>
error.diagnosticCode ==
CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE,
error.diagnosticCode == CompileTimeErrorCode.nonConstantMapValue,
);
}
}
@@ -518,7 +516,7 @@ var v = {const A(), B()};
errorFilter:
(error) =>
error.diagnosticCode ==
CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT,
CompileTimeErrorCode.nonConstantSetElement,
);
}
@@ -542,7 +540,7 @@ final v = {const A(), A.nonConst()};
errorFilter:
(error) =>
error.diagnosticCode ==
CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT,
CompileTimeErrorCode.nonConstantSetElement,
);
}
}
@@ -713,7 +711,7 @@ class B {
var x = B(a1: A(), b: const [0], a2: A());
''',
errorFilter: (e) {
return e.diagnosticCode == CompileTimeErrorCode.CONST_WITH_NON_CONST &&
return e.diagnosticCode == CompileTimeErrorCode.constWithNonConst &&
e.offset == testCode.indexOf('A()');
},
);
@@ -753,7 +751,7 @@ class A {}
var x = [A(), if (true) const [0] else const [1]];
''',
errorFilter: (e) {
return e.diagnosticCode == CompileTimeErrorCode.CONST_WITH_NON_CONST;
return e.diagnosticCode == CompileTimeErrorCode.constWithNonConst;
},
);
}
@@ -779,7 +777,7 @@ class B {
var x = [A(), const B(), const B(), A()];
''',
errorFilter: (e) {
return e.diagnosticCode == CompileTimeErrorCode.CONST_WITH_NON_CONST &&
return e.diagnosticCode == CompileTimeErrorCode.constWithNonConst &&
e.offset == testCode.indexOf('A()');
},
);
@@ -798,7 +796,7 @@ class A {}
var x = [A(), const [0], const [1]];
''',
errorFilter: (e) {
return e.diagnosticCode == CompileTimeErrorCode.CONST_WITH_NON_CONST;
return e.diagnosticCode == CompileTimeErrorCode.constWithNonConst;
},
);
}
@@ -817,7 +815,7 @@ class A {}
var x = [A(), ...const [0], ...const [1]];
''',
errorFilter: (e) {
return e.diagnosticCode == CompileTimeErrorCode.CONST_WITH_NON_CONST;
return e.diagnosticCode == CompileTimeErrorCode.constWithNonConst;
},
);
}
@@ -835,7 +833,7 @@ class A {}
var x = {0: A(), ...const {1: 2}, ...const {3: 4}};
''',
errorFilter: (e) {
return e.diagnosticCode == CompileTimeErrorCode.CONST_WITH_NON_CONST;
return e.diagnosticCode == CompileTimeErrorCode.constWithNonConst;
},
);
}
@@ -853,7 +851,7 @@ class A {}
var x = {A(), ...const {0}, ...const {1}};
''',
errorFilter: (e) {
return e.diagnosticCode == CompileTimeErrorCode.CONST_WITH_NON_CONST;
return e.diagnosticCode == CompileTimeErrorCode.constWithNonConst;
},
);
}
@@ -871,7 +869,7 @@ class A {}
final x = A(), y = const [0], z = A();
''',
errorFilter: (e) {
return e.diagnosticCode == CompileTimeErrorCode.CONST_WITH_NON_CONST &&
return e.diagnosticCode == CompileTimeErrorCode.constWithNonConst &&
e.offset == testCode.lastIndexOf('A()');
},
);
@@ -890,7 +888,7 @@ class A {}
final Object x = A(), y = const [0];
''',
errorFilter: (e) {
return e.diagnosticCode == CompileTimeErrorCode.CONST_WITH_NON_CONST;
return e.diagnosticCode == CompileTimeErrorCode.constWithNonConst;
},
);
}
@@ -28,7 +28,7 @@ mixin class B extends A {}
mixin class C extends A {}
''');
await assertHasFixAllFix(
CompileTimeErrorCode.MIXIN_CLASS_DECLARATION_EXTENDS_NOT_OBJECT,
CompileTimeErrorCode.mixinClassDeclarationExtendsNotObject,
'''
class A {}
mixin class B {}
@@ -21,7 +21,7 @@ void main() {
}
bool _ignoreDeadCode(Diagnostic diagnostic) =>
diagnostic.diagnosticCode != WarningCode.DEAD_CODE;
diagnostic.diagnosticCode != WarningCode.deadCode;
@reflectiveTest
class DeadNullAwareAssignmentExpressionTest extends FixProcessorTest {
@@ -36,16 +36,13 @@ augment abstract class A {}
augment final class A {}
''');
await assertHasFixAllFix(
CompileTimeErrorCode.AUGMENTATION_MODIFIER_EXTRA,
'''
await assertHasFixAllFix(CompileTimeErrorCode.augmentationModifierExtra, '''
part of 'a.dart';
augment class A {}
augment class A {}
''',
);
''');
}
}
@@ -331,8 +331,7 @@ final class S extends Struct {}
final class C {}
''',
errorFilter:
(error) =>
error.diagnosticCode == FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_WITH,
(error) => error.diagnosticCode == FfiCode.subtypeOfStructClassInWith,
);
}
}
@@ -36,7 +36,7 @@ augment extension E on int { }
augment extension E on num { }
''');
await assertHasFixAllFix(
ParserErrorCode.EXTENSION_AUGMENTATION_HAS_ON_CLAUSE,
ParserErrorCode.extensionAugmentationHasOnClause,
'''
part of 'a.dart';
@@ -57,7 +57,7 @@ void f(Object p, Object q) {
}
}
''');
await assertHasFixAllFix(WarningCode.UNNECESSARY_CAST, '''
await assertHasFixAllFix(WarningCode.unnecessaryCast, '''
void f(Object p, Object q) {
if (p is String) {
var v = p;
@@ -54,7 +54,7 @@ class A {
int v2;
}
''');
await assertHasFixAllFix(WarningCode.UNNECESSARY_FINAL, '''
await assertHasFixAllFix(WarningCode.unnecessaryFinal, '''
class A {
A(this.v1, this.v2);
int v1;
@@ -31,7 +31,7 @@ void f() {
}
}
''');
await assertHasFixAllFix(WarningCode.UNUSED_CATCH_CLAUSE, '''
await assertHasFixAllFix(WarningCode.unusedCatchClause, '''
void f() {
try {
throw 42;
@@ -31,7 +31,7 @@ void f() {
}
}
''');
await assertHasFixAllFix(WarningCode.UNUSED_CATCH_STACK, '''
await assertHasFixAllFix(WarningCode.unusedCatchStack, '''
void f() {
try {
throw 42;
@@ -181,7 +181,7 @@ enum _MyEnum {A, B, C}
''',
errorFilter:
(diagnostic) =>
diagnostic.diagnosticCode == WarningCode.UNUSED_ELEMENT,
diagnostic.diagnosticCode == WarningCode.unusedElement,
);
}
@@ -94,7 +94,7 @@ import 'dart:math';
import 'dart:async';
void f() {}
''');
await assertHasFixAllFix(WarningCode.UNUSED_IMPORT, '''
await assertHasFixAllFix(WarningCode.unusedImport, '''
void f() {}
''');
}
@@ -109,7 +109,7 @@ var tau = math.pi * 2;
void f() {}
''');
await assertHasFixAllFix(WarningCode.UNUSED_IMPORT, '''
await assertHasFixAllFix(WarningCode.unusedImport, '''
import 'dart:math' as math;
var tau = math.pi * 2;
@@ -126,7 +126,7 @@ void f() {}
import 'dart:math'; import 'dart:math'; import 'dart:math';
void f() {}
''');
await assertHasFixAllFix(WarningCode.UNUSED_IMPORT, '''
await assertHasFixAllFix(WarningCode.unusedImport, '''
void f() {}
''');
@@ -137,7 +137,7 @@ void f() {}
import 'dart:math'; import 'dart:math'; import 'dart:math';
void f() {}
''');
await assertHasFixAllFix(WarningCode.UNUSED_IMPORT, '''
await assertHasFixAllFix(WarningCode.unusedImport, '''
import 'dart:math';
void f() {}
''');
@@ -150,7 +150,7 @@ import 'dart:math';
import 'dart:math';
void f() {}
''');
await assertHasFixAllFix(WarningCode.UNUSED_IMPORT, '''
await assertHasFixAllFix(WarningCode.unusedImport, '''
void f() {}
''');
}
@@ -213,7 +213,7 @@ import 'dart:_internal';
''');
await assertHasFix('''
''', errorFilter: (e) => e.diagnosticCode == WarningCode.UNUSED_IMPORT);
''', errorFilter: (e) => e.diagnosticCode == WarningCode.unusedImport);
}
Future<void> test_severalLines() async {
@@ -272,7 +272,7 @@ void f() {
errorFilter:
(e) =>
e.diagnosticCode !=
CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION,
CompileTimeErrorCode.referencedBeforeDeclaration,
);
}
}
@@ -75,7 +75,7 @@ typedef F = var Function();
typedef F = Function();
''',
errorFilter: (error) {
return error.diagnosticCode == ParserErrorCode.VAR_RETURN_TYPE;
return error.diagnosticCode == ParserErrorCode.varReturnType;
},
);
}
@@ -28,7 +28,7 @@ void f() {
boolean w;
}
''');
await assertHasFixAllFix(CompileTimeErrorCode.UNDEFINED_CLASS_BOOLEAN, '''
await assertHasFixAllFix(CompileTimeErrorCode.undefinedClassBoolean, '''
void f() {
bool v;
bool w;
@@ -140,7 +140,7 @@ Future<List<int>> f() async {}
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.ILLEGAL_ASYNC_RETURN_TYPE;
CompileTimeErrorCode.illegalAsyncReturnType;
},
);
}
@@ -166,7 +166,7 @@ al.Future<int> f() async {}
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.ILLEGAL_ASYNC_RETURN_TYPE;
CompileTimeErrorCode.illegalAsyncReturnType;
},
);
}
@@ -196,7 +196,7 @@ Future<int> f() async {}
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.ILLEGAL_ASYNC_RETURN_TYPE;
CompileTimeErrorCode.illegalAsyncReturnType;
},
);
}
@@ -32,7 +32,7 @@ Stream<List<int>> f() async* {}
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE;
CompileTimeErrorCode.illegalAsyncGeneratorReturnType;
},
);
}
@@ -58,7 +58,7 @@ al.Stream<int> f() async* {}
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE;
CompileTimeErrorCode.illegalAsyncGeneratorReturnType;
},
);
}
@@ -75,7 +75,7 @@ Stream<int> f() async* {}
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE;
CompileTimeErrorCode.illegalAsyncGeneratorReturnType;
},
);
}
@@ -93,7 +93,7 @@ void top() {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_FUNCTION;
CompileTimeErrorCode.returnOfInvalidTypeFromFunction;
},
);
}
@@ -137,7 +137,7 @@ class B extends A {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_METHOD;
CompileTimeErrorCode.returnOfInvalidTypeFromMethod;
},
);
}
@@ -215,7 +215,7 @@ num f() {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_FUNCTION;
CompileTimeErrorCode.returnOfInvalidTypeFromFunction;
},
);
}
@@ -244,7 +244,7 @@ class A {
''',
errorFilter: (error) {
return error.diagnosticCode ==
CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_METHOD;
CompileTimeErrorCode.returnOfInvalidTypeFromMethod;
},
);
}
@@ -33,7 +33,7 @@ class A {
}
''',
errorFilter: (error) {
return error.diagnosticCode == ParserErrorCode.VAR_AS_TYPE_NAME;
return error.diagnosticCode == ParserErrorCode.varAsTypeName;
},
);
}
@@ -28,7 +28,7 @@ void f(p, q) {
q is Null;
}
''');
await assertHasFixAllFix(WarningCode.TYPE_CHECK_IS_NULL, '''
await assertHasFixAllFix(WarningCode.typeCheckIsNull, '''
void f(p, q) {
p == null;
q == null;
@@ -28,7 +28,7 @@ void f(p, q) {
q is! Null;
}
''');
await assertHasFixAllFix(WarningCode.TYPE_CHECK_IS_NOT_NULL, '''
await assertHasFixAllFix(WarningCode.typeCheckIsNotNull, '''
void f(p, q) {
p != null;
q != null;
@@ -78,13 +78,13 @@ class SingleUnitTest with ResourceProviderMixin {
var testUnit = result.unit;
expect(result.diagnostics.where((d) {
return d.diagnosticCode != WarningCode.DEAD_CODE &&
d.diagnosticCode != WarningCode.UNUSED_CATCH_CLAUSE &&
d.diagnosticCode != WarningCode.UNUSED_CATCH_STACK &&
d.diagnosticCode != WarningCode.UNUSED_ELEMENT &&
d.diagnosticCode != WarningCode.UNUSED_FIELD &&
d.diagnosticCode != WarningCode.UNUSED_IMPORT &&
d.diagnosticCode != WarningCode.UNUSED_LOCAL_VARIABLE;
return d.diagnosticCode != WarningCode.deadCode &&
d.diagnosticCode != WarningCode.unusedCatchClause &&
d.diagnosticCode != WarningCode.unusedCatchStack &&
d.diagnosticCode != WarningCode.unusedElement &&
d.diagnosticCode != WarningCode.unusedField &&
d.diagnosticCode != WarningCode.unusedImport &&
d.diagnosticCode != WarningCode.unusedLocalVariable;
}), isEmpty);
findNode = FindNode(testCode, testUnit);
@@ -37,7 +37,7 @@ class AnalysisOptionsErrorCode extends DiagnosticCode {
/// Object p2: the ending offset of the text in the file that contains the
/// error
/// Object p3: the error message
static const AnalysisOptionsErrorCode INCLUDED_FILE_PARSE_ERROR =
static const AnalysisOptionsErrorCode includedFileParseError =
AnalysisOptionsErrorCode(
'INCLUDED_FILE_PARSE_ERROR',
"{3} in {0}({1}..{2})",
@@ -47,7 +47,7 @@ class AnalysisOptionsErrorCode extends DiagnosticCode {
///
/// Parameters:
/// Object p0: the error message from the parse error
static const AnalysisOptionsErrorCode PARSE_ERROR = AnalysisOptionsErrorCode(
static const AnalysisOptionsErrorCode parseError = AnalysisOptionsErrorCode(
'PARSE_ERROR',
"{0}",
);
@@ -78,7 +78,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
///
/// Parameters:
/// Object p0: the option name
static const AnalysisOptionsWarningCode ANALYSIS_OPTION_DEPRECATED =
static const AnalysisOptionsWarningCode analysisOptionDeprecated =
AnalysisOptionsWarningCode(
'ANALYSIS_OPTION_DEPRECATED',
"The option '{0}' is no longer supported.",
@@ -90,7 +90,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
/// Object p0: the option name
/// Object p1: the replacement option name
static const AnalysisOptionsWarningCode
ANALYSIS_OPTION_DEPRECATED_WITH_REPLACEMENT = AnalysisOptionsWarningCode(
analysisOptionDeprecatedWithReplacement = AnalysisOptionsWarningCode(
'ANALYSIS_OPTION_DEPRECATED',
"The option '{0}' is no longer supported.",
correctionMessage: "Try using the new '{1}' option.",
@@ -101,7 +101,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
///
/// Parameters:
/// String p0: the rule name
static const AnalysisOptionsWarningCode DEPRECATED_LINT =
static const AnalysisOptionsWarningCode deprecatedLint =
AnalysisOptionsWarningCode(
'DEPRECATED_LINT',
"'{0}' is a deprecated lint rule and should not be used.",
@@ -113,7 +113,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
/// Parameters:
/// String p0: the deprecated lint name
/// String p1: the replacing rule name
static const AnalysisOptionsWarningCode DEPRECATED_LINT_WITH_REPLACEMENT =
static const AnalysisOptionsWarningCode deprecatedLintWithReplacement =
AnalysisOptionsWarningCode(
'DEPRECATED_LINT_WITH_REPLACEMENT',
"'{0}' is deprecated and should be replaced by '{1}'.",
@@ -125,7 +125,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
/// Parameters:
/// String p0: the rule name
static const AnalysisOptionsWarningCode
DUPLICATE_RULE = AnalysisOptionsWarningCode(
duplicateRule = AnalysisOptionsWarningCode(
'DUPLICATE_RULE',
"The rule {0} is already specified and doesn't need to be specified again.",
correctionMessage: "Try removing all but one specification of the rule.",
@@ -140,7 +140,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
/// Object p2: the ending offset of the text in the file that contains the
/// warning
/// Object p3: the warning message
static const AnalysisOptionsWarningCode INCLUDED_FILE_WARNING =
static const AnalysisOptionsWarningCode includedFileWarning =
AnalysisOptionsWarningCode(
'INCLUDED_FILE_WARNING',
"Warning in the included options file {0}({1}..{2}): {3}",
@@ -152,7 +152,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
/// Object p0: the URI of the file to be included
/// Object p1: the path of the file containing the include directive
/// Object p2: the path of the context being analyzed
static const AnalysisOptionsWarningCode INCLUDE_FILE_NOT_FOUND =
static const AnalysisOptionsWarningCode includeFileNotFound =
AnalysisOptionsWarningCode(
'INCLUDE_FILE_NOT_FOUND',
"The include file '{0}' in '{1}' can't be found when analyzing '{2}'.",
@@ -163,7 +163,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
/// Parameters:
/// String p0: the rule name
/// String p1: the incompatible rule
static const AnalysisOptionsWarningCode INCOMPATIBLE_LINT =
static const AnalysisOptionsWarningCode incompatibleLint =
AnalysisOptionsWarningCode(
'INCOMPATIBLE_LINT',
"The rule '{0}' is incompatible with the rule '{1}'.",
@@ -176,7 +176,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
/// Parameters:
/// String p0: the option name
/// String p1: the detail message
static const AnalysisOptionsWarningCode INVALID_OPTION =
static const AnalysisOptionsWarningCode invalidOption =
AnalysisOptionsWarningCode(
'INVALID_OPTION',
"Invalid option specified for '{0}': {1}",
@@ -186,7 +186,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
///
/// Parameters:
/// String p0: the section name
static const AnalysisOptionsWarningCode INVALID_SECTION_FORMAT =
static const AnalysisOptionsWarningCode invalidSectionFormat =
AnalysisOptionsWarningCode(
'INVALID_SECTION_FORMAT',
"Invalid format for the '{0}' section.",
@@ -196,7 +196,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
///
/// Parameters:
/// String p0: the name of the first plugin
static const AnalysisOptionsWarningCode MULTIPLE_PLUGINS =
static const AnalysisOptionsWarningCode multiplePlugins =
AnalysisOptionsWarningCode(
'MULTIPLE_PLUGINS',
"Multiple plugins can't be enabled.",
@@ -208,7 +208,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
/// Parameters:
/// Object p0: the URI of the file to be included
/// Object p1: the path of the file containing the include directive
static const AnalysisOptionsWarningCode RECURSIVE_INCLUDE_FILE =
static const AnalysisOptionsWarningCode recursiveIncludeFile =
AnalysisOptionsWarningCode(
'RECURSIVE_INCLUDE_FILE',
"The include file '{0}' in '{1}' includes itself recursively.",
@@ -221,7 +221,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
/// Parameters:
/// String p0: the rule name
/// String p1: the SDK version in which the lint was removed
static const AnalysisOptionsWarningCode REMOVED_LINT =
static const AnalysisOptionsWarningCode removedLint =
AnalysisOptionsWarningCode(
'REMOVED_LINT',
"'{0}' was removed in Dart '{1}'",
@@ -234,7 +234,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
/// String p0: the rule name
/// String p1: the SDK version in which the lint was removed
/// String p2: the name of a replacing lint
static const AnalysisOptionsWarningCode REPLACED_LINT =
static const AnalysisOptionsWarningCode replacedLint =
AnalysisOptionsWarningCode(
'REPLACED_LINT',
"'{0}' was replaced by '{2}' in Dart '{1}'.",
@@ -245,7 +245,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
///
/// Parameters:
/// String p0: the rule name
static const AnalysisOptionsWarningCode UNDEFINED_LINT =
static const AnalysisOptionsWarningCode undefinedLint =
AnalysisOptionsWarningCode(
'UNDEFINED_LINT',
"'{0}' is not a recognized lint rule.",
@@ -257,7 +257,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
///
/// Parameters:
/// String p0: the unrecognized error code
static const AnalysisOptionsWarningCode UNRECOGNIZED_ERROR_CODE =
static const AnalysisOptionsWarningCode unrecognizedErrorCode =
AnalysisOptionsWarningCode(
'UNRECOGNIZED_ERROR_CODE',
"'{0}' isn't a recognized error code.",
@@ -269,7 +269,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
/// Parameters:
/// String p0: the plugin name
/// String p1: the unsupported option key
static const AnalysisOptionsWarningCode UNSUPPORTED_OPTION_WITHOUT_VALUES =
static const AnalysisOptionsWarningCode unsupportedOptionWithoutValues =
AnalysisOptionsWarningCode(
'UNSUPPORTED_OPTION_WITHOUT_VALUES',
"The option '{1}' isn't supported by '{0}'.",
@@ -283,7 +283,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
/// String p1: the unsupported option key
/// String p2: the legal value
static const AnalysisOptionsWarningCode
UNSUPPORTED_OPTION_WITH_LEGAL_VALUE = AnalysisOptionsWarningCode(
unsupportedOptionWithLegalValue = AnalysisOptionsWarningCode(
'UNSUPPORTED_OPTION_WITH_LEGAL_VALUE',
"The option '{1}' isn't supported by '{0}'. Try using the only supported "
"option: '{2}'.",
@@ -296,7 +296,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
/// String p0: the section name
/// String p1: the unsupported option key
/// String p2: legal values
static const AnalysisOptionsWarningCode UNSUPPORTED_OPTION_WITH_LEGAL_VALUES =
static const AnalysisOptionsWarningCode unsupportedOptionWithLegalValues =
AnalysisOptionsWarningCode(
'UNSUPPORTED_OPTION_WITH_LEGAL_VALUES',
"The option '{1}' isn't supported by '{0}'.",
@@ -310,7 +310,7 @@ class AnalysisOptionsWarningCode extends DiagnosticCode {
/// String p0: the option name
/// int p1: the unsupported value
/// String p2: legal values
static const AnalysisOptionsWarningCode UNSUPPORTED_VALUE =
static const AnalysisOptionsWarningCode unsupportedValue =
AnalysisOptionsWarningCode(
'UNSUPPORTED_VALUE',
"The value '{1}' isn't supported by '{0}'.",
@@ -62,7 +62,7 @@ List<Diagnostic> analyzeAnalysisOptions(
source: initialSource,
offset: initialIncludeSpan!.start.offset,
length: initialIncludeSpan!.length,
diagnosticCode: AnalysisOptionsWarningCode.INCLUDED_FILE_WARNING,
diagnosticCode: AnalysisOptionsWarningCode.includedFileWarning,
arguments: args,
),
);
@@ -121,7 +121,7 @@ List<Diagnostic> analyzeAnalysisOptions(
source: initialSource,
offset: initialIncludeSpan!.start.offset,
length: initialIncludeSpan!.length,
diagnosticCode: AnalysisOptionsWarningCode.RECURSIVE_INCLUDE_FILE,
diagnosticCode: AnalysisOptionsWarningCode.recursiveIncludeFile,
arguments: [includeUri, source.fullName],
),
);
@@ -133,7 +133,7 @@ List<Diagnostic> analyzeAnalysisOptions(
source: initialSource,
offset: initialIncludeSpan!.start.offset,
length: initialIncludeSpan!.length,
diagnosticCode: AnalysisOptionsWarningCode.INCLUDE_FILE_NOT_FOUND,
diagnosticCode: AnalysisOptionsWarningCode.includeFileNotFound,
arguments: [includeUri, source.fullName, contextRoot],
),
);
@@ -146,7 +146,7 @@ List<Diagnostic> analyzeAnalysisOptions(
source: initialSource,
offset: initialIncludeSpan!.start.offset,
length: initialIncludeSpan!.length,
diagnosticCode: AnalysisOptionsWarningCode.INCLUDED_FILE_WARNING,
diagnosticCode: AnalysisOptionsWarningCode.includedFileWarning,
arguments: [
includedSource,
spanInChain.start.offset,
@@ -190,7 +190,7 @@ List<Diagnostic> analyzeAnalysisOptions(
source: initialSource,
offset: initialIncludeSpan!.start.offset,
length: initialIncludeSpan!.length,
diagnosticCode: AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR,
diagnosticCode: AnalysisOptionsErrorCode.includedFileParseError,
arguments: args,
),
);
@@ -218,7 +218,7 @@ List<Diagnostic> analyzeAnalysisOptions(
source: source,
offset: span.start.offset,
length: span.length,
diagnosticCode: AnalysisOptionsErrorCode.PARSE_ERROR,
diagnosticCode: AnalysisOptionsErrorCode.parseError,
arguments: [e.message],
),
);
@@ -354,7 +354,7 @@ class _CannotIgnoreOptionValidator extends OptionsValidator {
!_removedDiagnosticCodes.contains(upperCaseName)) {
reporter.atSourceSpan(
unignorableNameNode.span,
AnalysisOptionsWarningCode.UNRECOGNIZED_ERROR_CODE,
AnalysisOptionsWarningCode.unrecognizedErrorCode,
arguments: [unignorableName],
);
} else if (listedNames.contains(upperCaseName)) {
@@ -366,7 +366,7 @@ class _CannotIgnoreOptionValidator extends OptionsValidator {
} else {
reporter.atSourceSpan(
unignorableNameNode.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.cannotIgnore],
);
}
@@ -374,7 +374,7 @@ class _CannotIgnoreOptionValidator extends OptionsValidator {
} else if (unignorableNames != null) {
reporter.atSourceSpan(
unignorableNames.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.cannotIgnore],
);
}
@@ -395,7 +395,7 @@ class _CodeStyleOptionsValidator extends OptionsValidator {
} else {
reporter.atSourceSpan(
keyNode.span,
AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITHOUT_VALUES,
AnalysisOptionsWarningCode.unsupportedOptionWithoutValues,
arguments: [AnalysisOptionsFile.codeStyle, keyNode.toString()],
);
}
@@ -403,13 +403,13 @@ class _CodeStyleOptionsValidator extends OptionsValidator {
} else if (codeStyle is YamlScalar && codeStyle.value != null) {
reporter.atSourceSpan(
codeStyle.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.codeStyle],
);
} else if (codeStyle is YamlList) {
reporter.atSourceSpan(
codeStyle.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.codeStyle],
);
}
@@ -419,7 +419,7 @@ class _CodeStyleOptionsValidator extends OptionsValidator {
if (format is! YamlScalar) {
reporter.atSourceSpan(
format.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.format],
);
return;
@@ -428,7 +428,7 @@ class _CodeStyleOptionsValidator extends OptionsValidator {
if (formatValue == null) {
reporter.atSourceSpan(
format.span,
AnalysisOptionsWarningCode.UNSUPPORTED_VALUE,
AnalysisOptionsWarningCode.unsupportedValue,
arguments: [
AnalysisOptionsFile.format,
format.valueOrThrow,
@@ -471,7 +471,7 @@ class _EnableExperimentsValidator extends OptionsValidator {
if (validationResult is UnrecognizedFlag) {
reporter.atSourceSpan(
span,
AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITHOUT_VALUES,
AnalysisOptionsWarningCode.unsupportedOptionWithoutValues,
arguments: [
AnalysisOptionsFile.enableExperiment,
flags[flagIndex],
@@ -480,7 +480,7 @@ class _EnableExperimentsValidator extends OptionsValidator {
} else {
reporter.atSourceSpan(
span,
AnalysisOptionsWarningCode.INVALID_OPTION,
AnalysisOptionsWarningCode.invalidOption,
arguments: [
AnalysisOptionsFile.enableExperiment,
validationResult.message,
@@ -491,7 +491,7 @@ class _EnableExperimentsValidator extends OptionsValidator {
} else if (experimentNames != null) {
reporter.atSourceSpan(
experimentNames.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.enableExperiment],
);
}
@@ -502,13 +502,13 @@ class _EnableExperimentsValidator extends OptionsValidator {
/// Builds error reports with value proposals.
class _ErrorBuilder {
static AnalysisOptionsWarningCode get noProposalCode =>
AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITHOUT_VALUES;
AnalysisOptionsWarningCode.unsupportedOptionWithoutValues;
static AnalysisOptionsWarningCode get pluralProposalCode =>
AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUES;
AnalysisOptionsWarningCode.unsupportedOptionWithLegalValues;
static AnalysisOptionsWarningCode get singularProposalCode =>
AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE;
AnalysisOptionsWarningCode.unsupportedOptionWithLegalValue;
final String proposal;
@@ -593,7 +593,7 @@ class _ErrorFilterOptionValidator extends OptionsValidator {
!_removedDiagnosticCodes.contains(value)) {
reporter.atSourceSpan(
k.span,
AnalysisOptionsWarningCode.UNRECOGNIZED_ERROR_CODE,
AnalysisOptionsWarningCode.unrecognizedErrorCode,
arguments: [k.value.toString()],
);
}
@@ -603,7 +603,7 @@ class _ErrorFilterOptionValidator extends OptionsValidator {
if (!legalValues.contains(value)) {
reporter.atSourceSpan(
v.span,
AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUES,
AnalysisOptionsWarningCode.unsupportedOptionWithLegalValues,
arguments: [
AnalysisOptionsFile.errors,
v.value.toString(),
@@ -614,7 +614,7 @@ class _ErrorFilterOptionValidator extends OptionsValidator {
} else {
reporter.atSourceSpan(
v.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.enableExperiment],
);
}
@@ -622,7 +622,7 @@ class _ErrorFilterOptionValidator extends OptionsValidator {
} else if (filters != null) {
reporter.atSourceSpan(
filters.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.enableExperiment],
);
}
@@ -649,7 +649,7 @@ class _FormatterOptionsValidator extends OptionsValidator {
} else {
reporter.atSourceSpan(
keyNode.span,
AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITHOUT_VALUES,
AnalysisOptionsWarningCode.unsupportedOptionWithoutValues,
arguments: [AnalysisOptionsFile.formatter, keyNode.toString()],
);
}
@@ -657,7 +657,7 @@ class _FormatterOptionsValidator extends OptionsValidator {
} else if (formatter.value != null) {
reporter.atSourceSpan(
formatter.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.formatter],
);
}
@@ -672,7 +672,7 @@ class _FormatterOptionsValidator extends OptionsValidator {
if (value is! int || value <= 0) {
reporter.atSourceSpan(
valueNode.span,
AnalysisOptionsWarningCode.INVALID_OPTION,
AnalysisOptionsWarningCode.invalidOption,
arguments: [
keyNode.toString(),
'"page_width" must be a positive integer.',
@@ -691,7 +691,7 @@ class _FormatterOptionsValidator extends OptionsValidator {
if (!TrailingCommas.values.any((item) => item.name == value)) {
reporter.atSourceSpan(
valueNode.span,
AnalysisOptionsWarningCode.INVALID_OPTION,
AnalysisOptionsWarningCode.invalidOption,
arguments: [
keyNode.toString(),
'"trailing_commas" must be "automate" or "preserve".',
@@ -732,7 +732,7 @@ class _LanguageOptionValidator extends OptionsValidator {
if (!AnalysisOptionsFile.trueOrFalse.contains(value)) {
reporter.atSourceSpan(
v.span,
AnalysisOptionsWarningCode.UNSUPPORTED_VALUE,
AnalysisOptionsWarningCode.unsupportedValue,
arguments: [
key!,
v.valueOrThrow,
@@ -745,13 +745,13 @@ class _LanguageOptionValidator extends OptionsValidator {
} else if (language is YamlScalar && language.value != null) {
reporter.atSourceSpan(
language.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.language],
);
} else if (language is YamlList) {
reporter.atSourceSpan(
language.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.language],
);
}
@@ -780,7 +780,7 @@ class _LegacyPluginsOptionValidator extends OptionsValidator {
_firstIncludedPluginName != plugins.value) {
reporter.atSourceSpan(
plugins.span,
AnalysisOptionsWarningCode.MULTIPLE_PLUGINS,
AnalysisOptionsWarningCode.multiplePlugins,
arguments: [_firstIncludedPluginName],
);
}
@@ -792,7 +792,7 @@ class _LegacyPluginsOptionValidator extends OptionsValidator {
if (plugin.value != _firstIncludedPluginName) {
reporter.atSourceSpan(
plugin.span,
AnalysisOptionsWarningCode.MULTIPLE_PLUGINS,
AnalysisOptionsWarningCode.multiplePlugins,
arguments: [_firstIncludedPluginName],
);
}
@@ -812,7 +812,7 @@ class _LegacyPluginsOptionValidator extends OptionsValidator {
} else if (plugin.value != firstPlugin) {
reporter.atSourceSpan(
plugin.span,
AnalysisOptionsWarningCode.MULTIPLE_PLUGINS,
AnalysisOptionsWarningCode.multiplePlugins,
arguments: [firstPlugin],
);
}
@@ -826,7 +826,7 @@ class _LegacyPluginsOptionValidator extends OptionsValidator {
if (plugin != null && plugin.value != _firstIncludedPluginName) {
reporter.atSourceSpan(
plugin.span,
AnalysisOptionsWarningCode.MULTIPLE_PLUGINS,
AnalysisOptionsWarningCode.multiplePlugins,
arguments: [_firstIncludedPluginName],
);
}
@@ -846,7 +846,7 @@ class _LegacyPluginsOptionValidator extends OptionsValidator {
} else if (plugin != null && plugin.value != firstPlugin) {
reporter.atSourceSpan(
plugin.span,
AnalysisOptionsWarningCode.MULTIPLE_PLUGINS,
AnalysisOptionsWarningCode.multiplePlugins,
arguments: [firstPlugin],
);
}
@@ -898,7 +898,7 @@ class _OptionalChecksValueValidator extends OptionsValidator {
if (!AnalysisOptionsFile.trueOrFalse.contains(value)) {
reporter.atSourceSpan(
v.span,
AnalysisOptionsWarningCode.UNSUPPORTED_VALUE,
AnalysisOptionsWarningCode.unsupportedValue,
arguments: [
key!,
v.valueOrThrow,
@@ -912,7 +912,7 @@ class _OptionalChecksValueValidator extends OptionsValidator {
} else if (v != null) {
reporter.atSourceSpan(
v.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.enableExperiment],
);
}
@@ -945,7 +945,7 @@ class _PluginsOptionsValidator extends OptionsValidator {
default:
reporter.atSourceSpan(
plugins.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: ['${AnalysisOptionsFile.plugins}/$pluginName'],
);
}
@@ -953,14 +953,14 @@ class _PluginsOptionsValidator extends OptionsValidator {
case YamlList():
reporter.atSourceSpan(
plugins.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.plugins],
);
case YamlScalar(:var value):
if (value != null) {
reporter.atSourceSpan(
plugins.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.plugins],
);
}
@@ -1005,7 +1005,7 @@ class _StrongModeOptionValueValidator extends OptionsValidator {
} else if (strongModeNode != null) {
reporter.atSourceSpan(
strongModeNode.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.strongMode],
);
}
@@ -1024,7 +1024,7 @@ class _StrongModeOptionValueValidator extends OptionsValidator {
} else if (key == AnalysisOptionsFile.declarationCasts) {
reporter.atSourceSpan(
v.span,
AnalysisOptionsWarningCode.UNSUPPORTED_VALUE,
AnalysisOptionsWarningCode.unsupportedValue,
arguments: [
AnalysisOptionsFile.strongMode,
v.valueOrThrow,
@@ -1038,7 +1038,7 @@ class _StrongModeOptionValueValidator extends OptionsValidator {
if (!AnalysisOptionsFile.trueOrFalse.contains(value)) {
reporter.atSourceSpan(
v.span,
AnalysisOptionsWarningCode.UNSUPPORTED_VALUE,
AnalysisOptionsWarningCode.unsupportedValue,
arguments: [
key!,
v.valueOrThrow,
@@ -1071,8 +1071,8 @@ class _TopLevelOptionValidator extends OptionsValidator {
_valueProposal = supportedOptions.quotedAndCommaSeparatedWithAnd,
_warningCode =
supportedOptions.length == 1
? AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE
: AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUES;
? AnalysisOptionsWarningCode.unsupportedOptionWithLegalValue
: AnalysisOptionsWarningCode.unsupportedOptionWithLegalValues;
@override
void validate(DiagnosticReporter reporter, YamlMap options) {
@@ -1083,7 +1083,7 @@ class _TopLevelOptionValidator extends OptionsValidator {
if (node is! YamlMap) {
reporter.atSourceSpan(
node.span,
AnalysisOptionsWarningCode.INVALID_SECTION_FORMAT,
AnalysisOptionsWarningCode.invalidSectionFormat,
arguments: [AnalysisOptionsFile.cannotIgnore],
);
return;
@@ -1975,7 +1975,7 @@ class AnalysisDriver {
source: file.source,
offset: 0,
length: 0,
diagnosticCode: CompileTimeErrorCode.MISSING_DART_LIBRARY,
diagnosticCode: CompileTimeErrorCode.missingDartLibrary,
arguments: [missingUri],
),
],
@@ -282,7 +282,7 @@ class LibraryAnalyzer {
if (shouldReport) {
libraryUnitAnalysis.diagnosticReporter.atNode(
directive.uri,
CompileTimeErrorCode.INCONSISTENT_LANGUAGE_VERSION_OVERRIDE,
CompileTimeErrorCode.inconsistentLanguageVersionOverride,
);
}
}
@@ -618,20 +618,20 @@ class LibraryAnalyzer {
for (var errorCode in errorCodes) {
if (const {
CompileTimeErrorCode.AMBIGUOUS_IMPORT,
CompileTimeErrorCode.CONST_WITH_NON_TYPE,
CompileTimeErrorCode.EXTENDS_NON_CLASS,
CompileTimeErrorCode.IMPLEMENTS_NON_CLASS,
CompileTimeErrorCode.MIXIN_OF_NON_CLASS,
CompileTimeErrorCode.NEW_WITH_NON_TYPE,
CompileTimeErrorCode.NOT_A_TYPE,
CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT,
CompileTimeErrorCode.UNDEFINED_ANNOTATION,
CompileTimeErrorCode.UNDEFINED_CLASS,
CompileTimeErrorCode.UNDEFINED_FUNCTION,
CompileTimeErrorCode.UNDEFINED_IDENTIFIER,
CompileTimeErrorCode.UNDEFINED_PREFIXED_NAME,
WarningCode.DEPRECATED_EXPORT_USE,
CompileTimeErrorCode.ambiguousImport,
CompileTimeErrorCode.constWithNonType,
CompileTimeErrorCode.extendsNonClass,
CompileTimeErrorCode.implementsNonClass,
CompileTimeErrorCode.mixinOfNonClass,
CompileTimeErrorCode.newWithNonType,
CompileTimeErrorCode.notAType,
CompileTimeErrorCode.prefixIdentifierNotFollowedByDot,
CompileTimeErrorCode.undefinedAnnotation,
CompileTimeErrorCode.undefinedClass,
CompileTimeErrorCode.undefinedFunction,
CompileTimeErrorCode.undefinedIdentifier,
CompileTimeErrorCode.undefinedPrefixedName,
WarningCode.deprecatedExportUse,
}.contains(errorCode)) {
return true;
}
@@ -696,13 +696,13 @@ class LibraryAnalyzer {
if (selectedUriStr.startsWith('dart-ext:')) {
diagnosticReporter.atNode(
directive.uri,
CompileTimeErrorCode.USE_OF_NATIVE_EXTENSION,
CompileTimeErrorCode.useOfNativeExtension,
);
} else if (state.importedSource == null) {
var errorCode =
state.isDocImport
? WarningCode.URI_DOES_NOT_EXIST_IN_DOC_IMPORT
: CompileTimeErrorCode.URI_DOES_NOT_EXIST;
? WarningCode.uriDoesNotExistInDocImport
: CompileTimeErrorCode.uriDoesNotExist;
diagnosticReporter.atNode(
directive.uri,
errorCode,
@@ -711,10 +711,10 @@ class LibraryAnalyzer {
} else if (state is LibraryImportWithFile && !state.importedFile.exists) {
var errorCode =
state.isDocImport
? WarningCode.URI_DOES_NOT_EXIST_IN_DOC_IMPORT
? WarningCode.uriDoesNotExistInDocImport
: state.importedSource.isGenerated
? CompileTimeErrorCode.URI_HAS_NOT_BEEN_GENERATED
: CompileTimeErrorCode.URI_DOES_NOT_EXIST;
? CompileTimeErrorCode.uriHasNotBeenGenerated
: CompileTimeErrorCode.uriDoesNotExist;
diagnosticReporter.atNode(
directive.uri,
errorCode,
@@ -723,20 +723,20 @@ class LibraryAnalyzer {
} else if (state.importedLibrarySource == null) {
diagnosticReporter.atNode(
directive.uri,
CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY,
CompileTimeErrorCode.importOfNonLibrary,
arguments: [selectedUriStr],
);
}
} else if (state is LibraryImportWithUriStr) {
diagnosticReporter.atNode(
directive.uri,
CompileTimeErrorCode.INVALID_URI,
CompileTimeErrorCode.invalidUri,
arguments: [state.selectedUri.relativeUriStr],
);
} else {
diagnosticReporter.atNode(
directive.uri,
CompileTimeErrorCode.URI_WITH_INTERPOLATION,
CompileTimeErrorCode.uriWithInterpolation,
);
}
}
@@ -920,19 +920,19 @@ class LibraryAnalyzer {
if (selectedUriStr.startsWith('dart-ext:')) {
diagnosticReporter.atNode(
directive.uri,
CompileTimeErrorCode.USE_OF_NATIVE_EXTENSION,
CompileTimeErrorCode.useOfNativeExtension,
);
} else if (state.exportedSource == null) {
diagnosticReporter.atNode(
directive.uri,
CompileTimeErrorCode.URI_DOES_NOT_EXIST,
CompileTimeErrorCode.uriDoesNotExist,
arguments: [selectedUriStr],
);
} else if (state is LibraryExportWithFile && !state.exportedFile.exists) {
var errorCode =
isGeneratedSource(state.exportedSource)
? CompileTimeErrorCode.URI_HAS_NOT_BEEN_GENERATED
: CompileTimeErrorCode.URI_DOES_NOT_EXIST;
? CompileTimeErrorCode.uriHasNotBeenGenerated
: CompileTimeErrorCode.uriDoesNotExist;
diagnosticReporter.atNode(
directive.uri,
errorCode,
@@ -941,20 +941,20 @@ class LibraryAnalyzer {
} else if (state.exportedLibrarySource == null) {
diagnosticReporter.atNode(
directive.uri,
CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY,
CompileTimeErrorCode.exportOfNonLibrary,
arguments: [selectedUriStr],
);
}
} else if (state is LibraryExportWithUriStr) {
diagnosticReporter.atNode(
directive.uri,
CompileTimeErrorCode.INVALID_URI,
CompileTimeErrorCode.invalidUri,
arguments: [state.selectedUri.relativeUriStr],
);
} else {
diagnosticReporter.atNode(
directive.uri,
CompileTimeErrorCode.URI_WITH_INTERPOLATION,
CompileTimeErrorCode.uriWithInterpolation,
);
}
}
@@ -1001,13 +1001,13 @@ class LibraryAnalyzer {
}
if (partState is! PartIncludeWithUriStr) {
reportOnDirectiveUri(CompileTimeErrorCode.URI_WITH_INTERPOLATION);
reportOnDirectiveUri(CompileTimeErrorCode.uriWithInterpolation);
return;
}
if (partState is! PartIncludeWithUri) {
reportOnDirectiveUri(
CompileTimeErrorCode.INVALID_URI,
CompileTimeErrorCode.invalidUri,
arguments: [partState.selectedUri.relativeUriStr],
);
return;
@@ -1015,7 +1015,7 @@ class LibraryAnalyzer {
if (partState is! PartIncludeWithFile) {
reportOnDirectiveUri(
CompileTimeErrorCode.URI_DOES_NOT_EXIST,
CompileTimeErrorCode.uriDoesNotExist,
arguments: [partState.selectedUri.relativeUriStr],
);
return;
@@ -1027,11 +1027,11 @@ class LibraryAnalyzer {
if (includedKind is! PartFileKind) {
DiagnosticCode diagnosticCode;
if (includedFile.exists) {
diagnosticCode = CompileTimeErrorCode.PART_OF_NON_PART;
diagnosticCode = CompileTimeErrorCode.partOfNonPart;
} else if (isGeneratedSource(includedFile.source)) {
diagnosticCode = CompileTimeErrorCode.URI_HAS_NOT_BEEN_GENERATED;
diagnosticCode = CompileTimeErrorCode.uriHasNotBeenGenerated;
} else {
diagnosticCode = CompileTimeErrorCode.URI_DOES_NOT_EXIST;
diagnosticCode = CompileTimeErrorCode.uriDoesNotExist;
}
reportOnDirectiveUri(diagnosticCode, arguments: [includedFile.uriStr]);
return;
@@ -1042,7 +1042,7 @@ class LibraryAnalyzer {
//
if (_libraryFiles.containsKey(includedFile)) {
reportOnDirectiveUri(
CompileTimeErrorCode.DUPLICATE_PART,
CompileTimeErrorCode.duplicatePart,
arguments: [includedFile.uri],
);
return;
@@ -1057,19 +1057,19 @@ class LibraryAnalyzer {
var libraryName = _libraryElement.name;
if (libraryName.isEmpty) {
reportOnDirectiveUri(
CompileTimeErrorCode.PART_OF_UNNAMED_LIBRARY,
CompileTimeErrorCode.partOfUnnamedLibrary,
arguments: [name],
);
} else {
reportOnDirectiveUri(
CompileTimeErrorCode.PART_OF_DIFFERENT_LIBRARY,
CompileTimeErrorCode.partOfDifferentLibrary,
arguments: [libraryName, name],
);
}
}
case PartOfUriFileKind():
reportOnDirectiveUri(
CompileTimeErrorCode.PART_OF_DIFFERENT_LIBRARY,
CompileTimeErrorCode.partOfDifferentLibrary,
arguments: [enclosingFile.file.uriStr, includedFile.uriStr],
);
}
+1 -1
View File
@@ -7899,7 +7899,7 @@ sealed class ExpressionImpl extends CollectionElementImpl
var constant = visitor.evaluateAndReportInvalidConstant(this);
var isInvalidConstant = diagnosticListener.diagnostics.any(
(e) => e.diagnosticCode == CompileTimeErrorCode.INVALID_CONSTANT,
(e) => e.diagnosticCode == CompileTimeErrorCode.invalidConstant,
);
if (isInvalidConstant) {
return null;
@@ -112,7 +112,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
if (!element.isConst) {
_diagnosticReporter.atNode(
node,
CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCTOR,
CompileTimeErrorCode.nonConstantAnnotationConstructor,
);
return;
}
@@ -121,7 +121,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
if (argumentList == null) {
_diagnosticReporter.atNode(
node,
CompileTimeErrorCode.NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS,
CompileTimeErrorCode.noAnnotationConstructorArguments,
);
return;
}
@@ -139,7 +139,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
var value = _evaluateAndReportError(
expression,
CompileTimeErrorCode.CONSTANT_PATTERN_WITH_NON_CONSTANT_EXPRESSION,
CompileTimeErrorCode.constantPatternWithNonConstantExpression,
);
if (value is DartObjectImpl) {
if (_currentLibrary.featureSet.isEnabled(Feature.patterns)) {
@@ -152,7 +152,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
if (!_canBeEqual(constantType, matchedValueType)) {
_diagnosticReporter.atNode(
node,
WarningCode.CONSTANT_PATTERN_NEVER_MATCHES_VALUE_TYPE,
WarningCode.constantPatternNeverMatchesValueType,
arguments: [matchedValueType, constantType],
);
return;
@@ -177,7 +177,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
!element.isFactory) {
_diagnosticReporter.atNode(
node.returnType,
CompileTimeErrorCode.RECURSIVE_CONSTANT_CONSTRUCTOR,
CompileTimeErrorCode.recursiveConstantConstructor,
);
}
@@ -200,7 +200,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
if (node.inConstantContext || node.inConstantExpression) {
_checkForConstWithTypeParameters(
node.constructorName.type,
CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS_CONSTRUCTOR_TEAROFF,
CompileTimeErrorCode.constWithTypeParametersConstructorTearoff,
);
}
}
@@ -252,7 +252,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
for (var typeArgument in typeArguments.arguments) {
_checkForConstWithTypeParameters(
typeArgument,
CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS_FUNCTION_TEAROFF,
CompileTimeErrorCode.constWithTypeParametersFunctionTearoff,
);
}
}
@@ -267,7 +267,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
(parent as Expression).inConstantContext) {
_checkForConstWithTypeParameters(
node,
CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS,
CompileTimeErrorCode.constWithTypeParameters,
);
}
}
@@ -280,7 +280,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
var namedType = node.constructorName.type;
_checkForConstWithTypeParameters(
namedType,
CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS,
CompileTimeErrorCode.constWithTypeParameters,
);
var constructor = node.constructorName.element;
@@ -300,7 +300,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
var elementType = nodeType.typeArguments[0];
var verifier = _ConstLiteralVerifier(
this,
diagnosticCode: CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT,
diagnosticCode: CompileTimeErrorCode.nonConstantListElement,
listElementType: elementType,
);
for (var element in node.elements) {
@@ -334,7 +334,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
var key = element.key;
var keyValue = _evaluateAndReportError(
key,
CompileTimeErrorCode.NON_CONSTANT_MAP_PATTERN_KEY,
CompileTimeErrorCode.nonConstantMapPatternKey,
);
if (keyValue is DartObjectImpl) {
_mapPatternKeyValues?[key] = keyValue;
@@ -373,7 +373,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
for (var field in node.fields) {
_evaluateAndReportError(
field,
CompileTimeErrorCode.NON_CONSTANT_RECORD_FIELD,
CompileTimeErrorCode.nonConstantRecordField,
);
}
}
@@ -385,7 +385,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
_evaluateAndReportError(
node.operand,
CompileTimeErrorCode.NON_CONSTANT_RELATIONAL_PATTERN_EXPRESSION,
CompileTimeErrorCode.nonConstantRelationalPatternExpression,
);
}
@@ -399,7 +399,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
var config = _SetVerifierConfig(elementType: elementType);
var verifier = _ConstLiteralVerifier(
this,
diagnosticCode: CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT,
diagnosticCode: CompileTimeErrorCode.nonConstantSetElement,
setConfig: config,
);
for (CollectionElement element in node.elements) {
@@ -423,7 +423,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
var config = _MapVerifierConfig(keyType: keyType, valueType: valueType);
var verifier = _ConstLiteralVerifier(
this,
diagnosticCode: CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT,
diagnosticCode: CompileTimeErrorCode.nonConstantMapElement,
mapConfig: config,
);
for (var entry in node.elements) {
@@ -514,7 +514,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
if (node.isConst) {
_reportError(
result,
CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE,
CompileTimeErrorCode.constInitializedWithNonConstantValue,
);
} else {
_reportError(result, null);
@@ -562,7 +562,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
///
/// A generic function type is allowed to reference its own type parameter(s).
///
/// See [CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS].
/// See [CompileTimeErrorCode.constWithTypeParameters].
void _checkForConstWithTypeParameters(
TypeAnnotation type,
DiagnosticCode diagnosticCode, {
@@ -678,150 +678,133 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
DiagnosticCode diagnosticCode = error.diagnosticCode;
if (identical(
diagnosticCode,
CompileTimeErrorCode.CONST_EVAL_EXTENSION_METHOD,
CompileTimeErrorCode.constEvalExtensionMethod,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_EVAL_EXTENSION_TYPE_METHOD,
CompileTimeErrorCode.constEvalExtensionTypeMethod,
) ||
identical(diagnosticCode, CompileTimeErrorCode.constEvalForElement) ||
identical(
diagnosticCode,
CompileTimeErrorCode.constEvalMethodInvocation,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_EVAL_FOR_ELEMENT,
CompileTimeErrorCode.constEvalPrimitiveEquality,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION,
CompileTimeErrorCode.constEvalPropertyAccess,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_EVAL_PRIMITIVE_EQUALITY,
CompileTimeErrorCode.constEvalThrowsException,
) ||
identical(diagnosticCode, CompileTimeErrorCode.constEvalThrowsIdbze) ||
identical(
diagnosticCode,
CompileTimeErrorCode.constEvalTypeBoolNumString,
) ||
identical(diagnosticCode, CompileTimeErrorCode.constEvalTypeBool) ||
identical(diagnosticCode, CompileTimeErrorCode.constEvalTypeBoolInt) ||
identical(diagnosticCode, CompileTimeErrorCode.constEvalTypeInt) ||
identical(diagnosticCode, CompileTimeErrorCode.constEvalTypeNum) ||
identical(
diagnosticCode,
CompileTimeErrorCode.constEvalTypeNumString,
) ||
identical(diagnosticCode, CompileTimeErrorCode.constEvalTypeString) ||
identical(
diagnosticCode,
CompileTimeErrorCode.recursiveCompileTimeConstant,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_EVAL_PROPERTY_ACCESS,
CompileTimeErrorCode.constConstructorFieldTypeMismatch,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
CompileTimeErrorCode.constConstructorParamTypeMismatch,
) ||
identical(diagnosticCode, CompileTimeErrorCode.constTypeParameter) ||
identical(
diagnosticCode,
CompileTimeErrorCode.constWithTypeParametersFunctionTearoff,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE,
CompileTimeErrorCode.constSpreadExpectedListOrSet,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING,
CompileTimeErrorCode.constSpreadExpectedMap,
) ||
identical(diagnosticCode, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL) ||
identical(diagnosticCode, CompileTimeErrorCode.expressionInMap) ||
identical(diagnosticCode, CompileTimeErrorCode.variableTypeMismatch) ||
identical(diagnosticCode, CompileTimeErrorCode.nonBoolCondition) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_INT,
) ||
identical(diagnosticCode, CompileTimeErrorCode.CONST_EVAL_TYPE_INT) ||
identical(diagnosticCode, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_EVAL_TYPE_NUM_STRING,
CompileTimeErrorCode.nonConstantDefaultValueFromDeferredLibrary,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_EVAL_TYPE_STRING,
CompileTimeErrorCode.nonConstantMapKeyFromDeferredLibrary,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT,
CompileTimeErrorCode.nonConstantMapValueFromDeferredLibrary,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
CompileTimeErrorCode.setElementFromDeferredLibrary,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
) ||
identical(diagnosticCode, CompileTimeErrorCode.CONST_TYPE_PARAMETER) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS_FUNCTION_TEAROFF,
CompileTimeErrorCode.spreadExpressionFromDeferredLibrary,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.CONST_SPREAD_EXPECTED_MAP,
) ||
identical(diagnosticCode, CompileTimeErrorCode.EXPRESSION_IN_MAP) ||
identical(
diagnosticCode,
CompileTimeErrorCode.VARIABLE_TYPE_MISMATCH,
) ||
identical(diagnosticCode, CompileTimeErrorCode.NON_BOOL_CONDITION) ||
identical(
diagnosticCode,
CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.SET_ELEMENT_FROM_DEFERRED_LIBRARY,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.SPREAD_EXPRESSION_FROM_DEFERRED_LIBRARY,
CompileTimeErrorCode.nonConstantCaseExpressionFromDeferredLibrary,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode
.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY,
.invalidAnnotationConstantValueFromDeferredLibrary,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.ifElementConditionFromDeferredLibrary,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode
.INVALID_ANNOTATION_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY,
.constInitializedWithNonConstantValueFromDeferredLibrary,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.IF_ELEMENT_CONDITION_FROM_DEFERRED_LIBRARY,
CompileTimeErrorCode.nonConstantListElementFromDeferredLibrary,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.nonConstantRecordFieldFromDeferredLibrary,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode
.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY,
.constInitializedWithNonConstantValueFromDeferredLibrary,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY,
CompileTimeErrorCode.patternConstantFromDeferredLibrary,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.NON_CONSTANT_RECORD_FIELD_FROM_DEFERRED_LIBRARY,
CompileTimeErrorCode.wrongNumberOfTypeArgumentsFunction,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode
.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.PATTERN_CONSTANT_FROM_DEFERRED_LIBRARY,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_FUNCTION,
) ||
identical(
diagnosticCode,
CompileTimeErrorCode
.WRONG_NUMBER_OF_TYPE_ARGUMENTS_ANONYMOUS_FUNCTION,
CompileTimeErrorCode.wrongNumberOfTypeArgumentsAnonymousFunction,
)) {
_diagnosticReporter.reportError(
Diagnostic.tmp(
@@ -855,7 +838,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
for (var notConst in notPotentiallyConstants) {
_diagnosticReporter.atNode(
notConst,
CompileTimeErrorCode.INVALID_CONSTANT,
CompileTimeErrorCode.invalidConstant,
);
}
}
@@ -881,7 +864,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
argument is NamedExpression ? argument.expression : argument;
_evaluateAndReportError(
realArgument,
CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT,
CompileTimeErrorCode.constWithNonConstantArgument,
);
}
}
@@ -965,7 +948,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
} else {
result = _evaluateAndReportError(
defaultValue,
CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE,
CompileTimeErrorCode.nonConstantDefaultValue,
);
}
var element = parameter.declaredFragment!.element;
@@ -1012,7 +995,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
_diagnosticReporter.atToken(
constKeyword,
CompileTimeErrorCode
.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST,
.constConstructorWithFieldInitializedByNonConst,
arguments: [variableDeclaration.name.lexeme],
);
}
@@ -1091,7 +1074,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
};
_diagnosticReporter.atToken(
errorToken,
WarningCode.UNREACHABLE_SWITCH_CASE,
WarningCode.unreachableSwitchCase,
);
}
if (nonExhaustiveness != null) {
@@ -1118,8 +1101,8 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
var diagnostic = _diagnosticReporter.atToken(
switchKeyword,
isSwitchExpression
? CompileTimeErrorCode.NON_EXHAUSTIVE_SWITCH_EXPRESSION
: CompileTimeErrorCode.NON_EXHAUSTIVE_SWITCH_STATEMENT,
? CompileTimeErrorCode.nonExhaustiveSwitchExpression
: CompileTimeErrorCode.nonExhaustiveSwitchStatement,
arguments: [
scrutineeType,
errorBuffer.toString(),
@@ -1135,7 +1118,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
// Default node is unreachable
_diagnosticReporter.atToken(
defaultNode.keyword,
WarningCode.UNREACHABLE_SWITCH_DEFAULT,
WarningCode.unreachableSwitchDefault,
);
}
}
@@ -1166,7 +1149,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
void validateExpression(Expression expression) {
var expressionValue = _evaluateAndReportError(
expression,
CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION,
CompileTimeErrorCode.nonConstantCaseExpression,
);
if (expressionValue is! DartObjectImpl) {
return;
@@ -1178,7 +1161,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
if (!expressionValue.hasPrimitiveEquality(featureSet)) {
_diagnosticReporter.atNode(
expression,
CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS,
CompileTimeErrorCode.caseExpressionTypeImplementsEquals,
arguments: [expressionType],
);
}
@@ -1253,7 +1236,7 @@ class _ConstLiteralVerifier {
} else if (element is ForElement) {
verifier._diagnosticReporter.atNode(
element,
CompileTimeErrorCode.CONST_EVAL_FOR_ELEMENT,
CompileTimeErrorCode.constEvalForElement,
);
return false;
} else if (element is IfElement) {
@@ -1359,9 +1342,9 @@ class _ConstLiteralVerifier {
for (var notConst in notPotentiallyConstants) {
CompileTimeErrorCode errorCode;
if (listElementType != null) {
errorCode = CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT;
errorCode = CompileTimeErrorCode.nonConstantListElement;
} else if (mapConfig != null) {
errorCode = CompileTimeErrorCode.NON_CONSTANT_MAP_ELEMENT;
errorCode = CompileTimeErrorCode.nonConstantMapElement;
for (
AstNode? parent = notConst;
parent != null;
@@ -1369,15 +1352,15 @@ class _ConstLiteralVerifier {
) {
if (parent is MapLiteralEntry) {
if (parent.key == notConst) {
errorCode = CompileTimeErrorCode.NON_CONSTANT_MAP_KEY;
errorCode = CompileTimeErrorCode.nonConstantMapKey;
} else {
errorCode = CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE;
errorCode = CompileTimeErrorCode.nonConstantMapValue;
}
break;
}
}
} else if (setConfig != null) {
errorCode = CompileTimeErrorCode.NON_CONSTANT_SET_ELEMENT;
errorCode = CompileTimeErrorCode.nonConstantSetElement;
} else {
throw UnimplementedError();
}
@@ -1399,13 +1382,13 @@ class _ConstLiteralVerifier {
)) {
verifier._diagnosticReporter.atNode(
expression,
CompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE_NULLABILITY,
CompileTimeErrorCode.listElementTypeNotAssignableNullability,
arguments: [value.type, listElementType],
);
} else {
verifier._diagnosticReporter.atNode(
expression,
CompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE,
CompileTimeErrorCode.listElementTypeNotAssignable,
arguments: [value.type, listElementType],
);
}
@@ -1429,7 +1412,7 @@ class _ConstLiteralVerifier {
// _addElementsTo methods..
verifier._diagnosticReporter.atNode(
element.expression,
CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET,
CompileTimeErrorCode.constSpreadExpectedListOrSet,
);
return false;
}
@@ -1444,7 +1427,7 @@ class _ConstLiteralVerifier {
if (!listValue.every((e) => e.hasPrimitiveEquality(featureSet))) {
verifier._diagnosticReporter.atNode(
element,
CompileTimeErrorCode.CONST_SET_ELEMENT_NOT_PRIMITIVE_EQUALITY,
CompileTimeErrorCode.constSetElementNotPrimitiveEquality,
arguments: [value.type],
);
return false;
@@ -1476,11 +1459,11 @@ class _ConstLiteralVerifier {
var keyValue = verifier._evaluateAndReportError(
keyExpression,
CompileTimeErrorCode.NON_CONSTANT_MAP_KEY,
CompileTimeErrorCode.nonConstantMapKey,
);
var valueValue = verifier._evaluateAndReportError(
valueExpression,
CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE,
CompileTimeErrorCode.nonConstantMapValue,
);
if (keyValue is DartObjectImpl) {
@@ -1498,13 +1481,13 @@ class _ConstLiteralVerifier {
)) {
verifier._diagnosticReporter.atNode(
keyExpression,
CompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE_NULLABILITY,
CompileTimeErrorCode.mapKeyTypeNotAssignableNullability,
arguments: [keyType, expectedKeyType],
);
} else {
verifier._diagnosticReporter.atNode(
keyExpression,
CompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE,
CompileTimeErrorCode.mapKeyTypeNotAssignable,
arguments: [keyType, expectedKeyType],
);
}
@@ -1514,7 +1497,7 @@ class _ConstLiteralVerifier {
if (!keyValue.hasPrimitiveEquality(featureSet)) {
verifier._diagnosticReporter.atNode(
keyExpression,
CompileTimeErrorCode.CONST_MAP_KEY_NOT_PRIMITIVE_EQUALITY,
CompileTimeErrorCode.constMapKeyNotPrimitiveEquality,
arguments: [keyType],
);
}
@@ -1548,13 +1531,13 @@ class _ConstLiteralVerifier {
)) {
verifier._diagnosticReporter.atNode(
valueExpression,
CompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE_NULLABILITY,
CompileTimeErrorCode.mapValueTypeNotAssignableNullability,
arguments: [valueValue.type, expectedValueType],
);
} else {
verifier._diagnosticReporter.atNode(
valueExpression,
CompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE,
CompileTimeErrorCode.mapValueTypeNotAssignable,
arguments: [valueValue.type, expectedValueType],
);
}
@@ -1590,7 +1573,7 @@ class _ConstLiteralVerifier {
}
verifier._diagnosticReporter.atNode(
element.expression,
CompileTimeErrorCode.CONST_SPREAD_EXPECTED_MAP,
CompileTimeErrorCode.constSpreadExpectedMap,
);
return false;
}
@@ -1607,13 +1590,13 @@ class _ConstLiteralVerifier {
)) {
verifier._diagnosticReporter.atNode(
expression,
CompileTimeErrorCode.SET_ELEMENT_TYPE_NOT_ASSIGNABLE_NULLABILITY,
CompileTimeErrorCode.setElementTypeNotAssignableNullability,
arguments: [value.type, config.elementType],
);
} else {
verifier._diagnosticReporter.atNode(
expression,
CompileTimeErrorCode.SET_ELEMENT_TYPE_NOT_ASSIGNABLE,
CompileTimeErrorCode.setElementTypeNotAssignable,
arguments: [value.type, config.elementType],
);
}
@@ -1624,7 +1607,7 @@ class _ConstLiteralVerifier {
if (!value.hasPrimitiveEquality(featureSet)) {
verifier._diagnosticReporter.atNode(
expression,
CompileTimeErrorCode.CONST_SET_ELEMENT_NOT_PRIMITIVE_EQUALITY,
CompileTimeErrorCode.constSetElementNotPrimitiveEquality,
arguments: [value.type],
);
return false;
@@ -133,7 +133,7 @@ class ConstantEvaluationEngine {
)) {
constant.evaluationResult = InvalidConstant.forEntity(
entity: constantInitializer,
diagnosticCode: CompileTimeErrorCode.VARIABLE_TYPE_MISMATCH,
diagnosticCode: CompileTimeErrorCode.variableTypeMismatch,
arguments: [
dartConstant.type.getDisplayString(),
constant.type.getDisplayString(),
@@ -389,7 +389,7 @@ class ConstantEvaluationEngine {
var errorNode = configuration.errorNode(node);
result = InvalidConstant.forEntity(
entity: errorNode,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
diagnosticCode: CompileTimeErrorCode.constEvalThrowsException,
contextMessages: [...result.contextMessages, contextMessage],
);
}
@@ -437,11 +437,11 @@ class ConstantEvaluationEngine {
// description of the cycle.
diagnosticReporter.atElement2(
constant,
CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT,
CompileTimeErrorCode.recursiveCompileTimeConstant,
);
constant.evaluationResult = InvalidConstant.forElement(
element: constant,
diagnosticCode: CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT,
diagnosticCode: CompileTimeErrorCode.recursiveCompileTimeConstant,
);
} else if (constant is ConstructorElementImpl) {
// We don't report cycle errors on constructor declarations here since
@@ -651,12 +651,12 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
case ExtensionElement():
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_EXTENSION_METHOD,
diagnosticCode: CompileTimeErrorCode.constEvalExtensionMethod,
);
case ExtensionTypeElement():
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_EXTENSION_TYPE_METHOD,
diagnosticCode: CompileTimeErrorCode.constEvalExtensionTypeMethod,
);
}
@@ -784,7 +784,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
if (!conditionConstant.isBool) {
return InvalidConstant.forEntity(
entity: condition,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL,
diagnosticCode: CompileTimeErrorCode.constEvalTypeBool,
);
}
conditionConstant = _dartObjectComputer.applyBooleanConversion(
@@ -827,7 +827,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
if (constructorFunctionType is! FunctionTypeImpl) {
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.INVALID_CONSTANT,
diagnosticCode: CompileTimeErrorCode.invalidConstant,
);
}
var classType = constructorFunctionType.returnType as InterfaceTypeImpl;
@@ -853,7 +853,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
if (constructorElement == null) {
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.INVALID_CONSTANT,
diagnosticCode: CompileTimeErrorCode.invalidConstant,
);
}
@@ -896,7 +896,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
// problem - the error has already been reported.
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.INVALID_CONSTANT,
diagnosticCode: CompileTimeErrorCode.invalidConstant,
);
}
@@ -951,8 +951,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
return InvalidConstant.forEntity(
entity: node,
diagnosticCode:
CompileTimeErrorCode
.CONST_WITH_TYPE_PARAMETERS_FUNCTION_TEAROFF,
CompileTimeErrorCode.constWithTypeParametersFunctionTearoff,
);
}
}
@@ -968,15 +967,14 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
var typeArgumentConstant = evaluateConstant(typeArgument);
switch (typeArgumentConstant) {
case InvalidConstant(
diagnosticCode: CompileTimeErrorCode.CONST_TYPE_PARAMETER,
diagnosticCode: CompileTimeErrorCode.constTypeParameter,
):
// If there's a type parameter error in the evaluated constant, we
// convert the message to a more specific function reference error.
return InvalidConstant.forEntity(
entity: typeArgument,
diagnosticCode:
CompileTimeErrorCode
.CONST_WITH_TYPE_PARAMETERS_FUNCTION_TEAROFF,
CompileTimeErrorCode.constWithTypeParametersFunctionTearoff,
);
case InvalidConstant():
return typeArgumentConstant;
@@ -985,7 +983,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
if (typeArgumentType == null) {
return InvalidConstant.forEntity(
entity: typeArgument,
diagnosticCode: CompileTimeErrorCode.INVALID_CONSTANT,
diagnosticCode: CompileTimeErrorCode.invalidConstant,
);
}
// TODO(srawlins): Test type alias types (`typedef i = int`) used as
@@ -1027,7 +1025,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
// TODO(kallentu): Use a better error code for this.
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.INVALID_CONSTANT,
diagnosticCode: CompileTimeErrorCode.invalidConstant,
);
}
@@ -1067,7 +1065,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
if (!result.isBoolNumStringOrNull) {
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING,
diagnosticCode: CompileTimeErrorCode.constEvalTypeBoolNumString,
);
}
return _dartObjectComputer.performToString(node, result);
@@ -1100,7 +1098,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
if (!node.isConst) {
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.MISSING_CONST_IN_LIST_LITERAL,
diagnosticCode: CompileTimeErrorCode.missingConstInListLiteral,
);
}
var nodeType = node.staticType;
@@ -1150,7 +1148,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
hasTypeParameterReference(type)) {
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.CONST_TYPE_PARAMETER,
diagnosticCode: CompileTimeErrorCode.constTypeParameter,
);
} else if (node.isDeferred) {
return _getDeferredLibraryError(node, node.name);
@@ -1232,12 +1230,12 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
case ExtensionElement():
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_EXTENSION_METHOD,
diagnosticCode: CompileTimeErrorCode.constEvalExtensionMethod,
);
case ExtensionTypeElement():
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_EXTENSION_TYPE_METHOD,
diagnosticCode: CompileTimeErrorCode.constEvalExtensionTypeMethod,
);
}
@@ -1357,7 +1355,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
if (!node.isConst) {
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.MISSING_CONST_IN_MAP_LITERAL,
diagnosticCode: CompileTimeErrorCode.missingConstInMapLiteral,
);
}
var keyType = _typeProvider.dynamicType;
@@ -1385,7 +1383,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
if (!node.isConst) {
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.MISSING_CONST_IN_SET_LITERAL,
diagnosticCode: CompileTimeErrorCode.missingConstInSetLiteral,
);
}
var nodeType = node.staticType;
@@ -1473,7 +1471,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
case ForElement():
return InvalidConstant.forEntity(
entity: element,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_FOR_ELEMENT,
diagnosticCode: CompileTimeErrorCode.constEvalForElement,
);
case IfElement():
var condition = evaluateConstant(element.expression);
@@ -1495,7 +1493,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
if (conditionValue == null) {
return InvalidConstant.forEntity(
entity: element.expression,
diagnosticCode: CompileTimeErrorCode.NON_BOOL_CONDITION,
diagnosticCode: CompileTimeErrorCode.nonBoolCondition,
);
} else if (conditionValue) {
branchResult = _buildListConstant(
@@ -1519,7 +1517,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
case MapLiteralEntry():
return InvalidConstant.forEntity(
entity: element,
diagnosticCode: CompileTimeErrorCode.MAP_ENTRY_NOT_IN_MAP,
diagnosticCode: CompileTimeErrorCode.mapEntryNotInMap,
);
case SpreadElement():
var spread = evaluateConstant(element.expression);
@@ -1536,7 +1534,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
return InvalidConstant.forEntity(
entity: element.expression,
diagnosticCode:
CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET,
CompileTimeErrorCode.constSpreadExpectedListOrSet,
);
}
list.addAll(listValue);
@@ -1586,12 +1584,12 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
case Expression():
return InvalidConstant.forEntity(
entity: element,
diagnosticCode: CompileTimeErrorCode.EXPRESSION_IN_MAP,
diagnosticCode: CompileTimeErrorCode.expressionInMap,
);
case ForElement():
return InvalidConstant.forEntity(
entity: element,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_FOR_ELEMENT,
diagnosticCode: CompileTimeErrorCode.constEvalForElement,
);
case IfElement():
var condition = evaluateConstant(element.expression);
@@ -1614,7 +1612,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
if (conditionValue == null) {
return InvalidConstant.forEntity(
entity: element.expression,
diagnosticCode: CompileTimeErrorCode.NON_BOOL_CONDITION,
diagnosticCode: CompileTimeErrorCode.nonBoolCondition,
);
} else if (conditionValue) {
branchResult = _buildMapConstant(
@@ -1663,8 +1661,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
if (mapValue == null) {
return InvalidConstant.forEntity(
entity: element.expression,
diagnosticCode:
CompileTimeErrorCode.CONST_SPREAD_EXPECTED_MAP,
diagnosticCode: CompileTimeErrorCode.constSpreadExpectedMap,
);
}
map.addAll(mapValue);
@@ -1674,7 +1671,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
// `CompileTimeErrorCode.NULL_AWARE_ELEMENT_IN_MAP`?
return InvalidConstant.forEntity(
entity: element,
diagnosticCode: CompileTimeErrorCode.EXPRESSION_IN_MAP,
diagnosticCode: CompileTimeErrorCode.expressionInMap,
);
}
}
@@ -1713,7 +1710,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
case ForElement():
return InvalidConstant.forEntity(
entity: element,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_FOR_ELEMENT,
diagnosticCode: CompileTimeErrorCode.constEvalForElement,
);
case IfElement():
var condition = evaluateConstant(element.expression);
@@ -1735,7 +1732,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
if (conditionValue == null) {
return InvalidConstant.forEntity(
entity: element.expression,
diagnosticCode: CompileTimeErrorCode.NON_BOOL_CONDITION,
diagnosticCode: CompileTimeErrorCode.nonBoolCondition,
);
} else if (conditionValue) {
branchResult = _buildSetConstant(
@@ -1759,7 +1756,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
case MapLiteralEntry():
return InvalidConstant.forEntity(
entity: element,
diagnosticCode: CompileTimeErrorCode.MAP_ENTRY_NOT_IN_MAP,
diagnosticCode: CompileTimeErrorCode.mapEntryNotInMap,
);
case SpreadElement():
var spread = evaluateConstant(element.expression);
@@ -1776,7 +1773,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
return InvalidConstant.forEntity(
entity: element.expression,
diagnosticCode:
CompileTimeErrorCode.CONST_SPREAD_EXPECTED_LIST_OR_SET,
CompileTimeErrorCode.constSpreadExpectedListOrSet,
);
}
set.addAll(setValue);
@@ -1862,12 +1859,12 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
case ExtensionElement():
return InvalidConstant.forEntity(
entity: errorNode,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_EXTENSION_METHOD,
diagnosticCode: CompileTimeErrorCode.constEvalExtensionMethod,
);
case ExtensionTypeElement():
return InvalidConstant.forEntity(
entity: errorNode,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_EXTENSION_TYPE_METHOD,
diagnosticCode: CompileTimeErrorCode.constEvalExtensionTypeMethod,
);
}
@@ -1890,7 +1887,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
// No other property access is allowed except for `.length` of a `String`.
return InvalidConstant.forEntity(
entity: errorNode,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_PROPERTY_ACCESS,
diagnosticCode: CompileTimeErrorCode.constEvalPropertyAccess,
arguments: [identifier.name, targetType.getDisplayString()],
);
}
@@ -1922,7 +1919,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
false)) {
return InvalidConstant.forEntity(
entity: expression,
diagnosticCode: CompileTimeErrorCode.CONST_TYPE_PARAMETER,
diagnosticCode: CompileTimeErrorCode.constTypeParameter,
);
}
@@ -1947,7 +1944,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
if (identifier == null) {
return InvalidConstant.forEntity(
entity: errorNode,
diagnosticCode: CompileTimeErrorCode.INVALID_CONSTANT,
diagnosticCode: CompileTimeErrorCode.invalidConstant,
);
}
return _instantiateFunctionTypeForSimpleIdentifier(
@@ -1959,7 +1956,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
// if we remove `avoidReporting`.
return InvalidConstant.forEntity(
entity: errorNode,
diagnosticCode: CompileTimeErrorCode.INVALID_CONSTANT,
diagnosticCode: CompileTimeErrorCode.invalidConstant,
avoidReporting: true,
isUnresolved: true,
);
@@ -1982,7 +1979,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
if (identifier == null) {
return InvalidConstant.forEntity(
entity: errorNode,
diagnosticCode: CompileTimeErrorCode.INVALID_CONSTANT,
diagnosticCode: CompileTimeErrorCode.invalidConstant,
);
}
return _instantiateFunctionTypeForSimpleIdentifier(identifier, rawType);
@@ -2043,7 +2040,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
}
return InvalidConstant.forEntity(
entity: errorNode2,
diagnosticCode: CompileTimeErrorCode.CONST_TYPE_PARAMETER,
diagnosticCode: CompileTimeErrorCode.constTypeParameter,
);
}
}
@@ -2063,7 +2060,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
/// library.
///
/// If no specific error can be chosen, an [InvalidConstant] error using
/// [CompileTimeErrorCode.INVALID_CONSTANT] is returned.
/// [CompileTimeErrorCode.invalidConstant] is returned.
InvalidConstant _getDeferredLibraryError(
AstNode node,
SyntacticEntity errorTarget,
@@ -2073,45 +2070,40 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
for (AstNode? current = node; current != null;) {
if (current is Annotation) {
return CompileTimeErrorCode
.INVALID_ANNOTATION_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY;
.invalidAnnotationConstantValueFromDeferredLibrary;
} else if (current is ConstantContextForExpressionImpl) {
return CompileTimeErrorCode
.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY;
.constInitializedWithNonConstantValueFromDeferredLibrary;
} else if (current is DefaultFormalParameter) {
return CompileTimeErrorCode
.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY;
.nonConstantDefaultValueFromDeferredLibrary;
} else if (current is IfElement && current.expression == node) {
return CompileTimeErrorCode
.IF_ELEMENT_CONDITION_FROM_DEFERRED_LIBRARY;
return CompileTimeErrorCode.ifElementConditionFromDeferredLibrary;
} else if (current is InstanceCreationExpression) {
return CompileTimeErrorCode
.CONST_CONSTRUCTOR_CONSTANT_FROM_DEFERRED_LIBRARY;
.constConstructorConstantFromDeferredLibrary;
} else if (current is ListLiteral) {
return CompileTimeErrorCode
.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY;
return CompileTimeErrorCode.nonConstantListElementFromDeferredLibrary;
} else if (current is MapLiteralEntry) {
if (previous == current.key) {
return CompileTimeErrorCode
.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY;
return CompileTimeErrorCode.nonConstantMapKeyFromDeferredLibrary;
} else {
return CompileTimeErrorCode
.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY;
return CompileTimeErrorCode.nonConstantMapValueFromDeferredLibrary;
}
} else if (current is RecordLiteral) {
return CompileTimeErrorCode
.NON_CONSTANT_RECORD_FIELD_FROM_DEFERRED_LIBRARY;
return CompileTimeErrorCode.nonConstantRecordFieldFromDeferredLibrary;
} else if (current is SetOrMapLiteral) {
return CompileTimeErrorCode.SET_ELEMENT_FROM_DEFERRED_LIBRARY;
return CompileTimeErrorCode.setElementFromDeferredLibrary;
} else if (current is SpreadElement) {
return CompileTimeErrorCode.SPREAD_EXPRESSION_FROM_DEFERRED_LIBRARY;
return CompileTimeErrorCode.spreadExpressionFromDeferredLibrary;
} else if (current is SwitchCase) {
return CompileTimeErrorCode
.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY;
.nonConstantCaseExpressionFromDeferredLibrary;
} else if (current is SwitchPatternCase) {
return CompileTimeErrorCode.PATTERN_CONSTANT_FROM_DEFERRED_LIBRARY;
return CompileTimeErrorCode.patternConstantFromDeferredLibrary;
} else if (current is VariableDeclaration) {
return CompileTimeErrorCode
.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY;
.constInitializedWithNonConstantValueFromDeferredLibrary;
}
previous = current;
current = current.parent;
@@ -2125,7 +2117,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
}
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.INVALID_CONSTANT,
diagnosticCode: CompileTimeErrorCode.invalidConstant,
);
}
@@ -2201,14 +2193,14 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
if (node.staticType is InvalidType) {
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.INVALID_CONSTANT,
diagnosticCode: CompileTimeErrorCode.invalidConstant,
isUnresolved: true,
);
}
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_METHOD_INVOCATION,
diagnosticCode: CompileTimeErrorCode.constEvalMethodInvocation,
);
}
@@ -2224,7 +2216,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
// Only report the first invalid constant we see.
return InvalidConstant.forEntity(
entity: notPotentiallyConstants.first,
diagnosticCode: CompileTimeErrorCode.INVALID_CONSTANT,
diagnosticCode: CompileTimeErrorCode.invalidConstant,
);
}
@@ -2706,7 +2698,7 @@ class DartObjectComputer {
return InvalidConstant.forEntity(
entity: typeArgumentsErrorNode,
diagnosticCode:
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_FUNCTION,
CompileTimeErrorCode.wrongNumberOfTypeArgumentsFunction,
arguments: [
node.name,
rawType.typeParameters.length,
@@ -2717,8 +2709,7 @@ class DartObjectComputer {
return InvalidConstant.forEntity(
entity: typeArgumentsErrorNode,
diagnosticCode:
CompileTimeErrorCode
.WRONG_NUMBER_OF_TYPE_ARGUMENTS_ANONYMOUS_FUNCTION,
CompileTimeErrorCode.wrongNumberOfTypeArgumentsAnonymousFunction,
arguments: [rawType.typeParameters.length, typeArguments.length],
);
}
@@ -2727,7 +2718,7 @@ class DartObjectComputer {
} else {
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.INVALID_CONSTANT,
diagnosticCode: CompileTimeErrorCode.invalidConstant,
);
}
}
@@ -2892,7 +2883,7 @@ class _InstanceCreationEvaluator {
if (!_checkFromEnvironmentArguments(arguments, definingType)) {
return InvalidConstant.forEntity(
entity: _errorNode,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
diagnosticCode: CompileTimeErrorCode.constEvalThrowsException,
);
}
String? variableName =
@@ -2935,7 +2926,7 @@ class _InstanceCreationEvaluator {
if (!_checkSymbolArguments(arguments)) {
return InvalidConstant.forEntity(
entity: _errorNode,
diagnosticCode: CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
diagnosticCode: CompileTimeErrorCode.constEvalThrowsException,
);
}
return DartObjectImpl(
@@ -3060,7 +3051,7 @@ class _InstanceCreationEvaluator {
return InvalidConstant.forEntity(
entity: errorNode,
diagnosticCode:
CompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
CompileTimeErrorCode.constConstructorFieldTypeMismatch,
arguments: [
fieldValue.type.getDisplayString(),
field.name ?? '',
@@ -3137,8 +3128,7 @@ class _InstanceCreationEvaluator {
return _InitializersEvaluationResult(
InvalidConstant.forEntity(
entity: _errorNode,
diagnosticCode:
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
diagnosticCode: CompileTimeErrorCode.constEvalThrowsException,
),
evaluationIsComplete: true,
);
@@ -3161,8 +3151,7 @@ class _InstanceCreationEvaluator {
InvalidConstant.forEntity(
entity: errorNode,
diagnosticCode:
CompileTimeErrorCode
.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH,
CompileTimeErrorCode.constConstructorFieldTypeMismatch,
arguments: [
evaluationResult.type.getDisplayString(),
fieldName,
@@ -3259,7 +3248,7 @@ class _InstanceCreationEvaluator {
entity: initializer,
diagnosticCode:
CompileTimeErrorCode
.CONST_EVAL_ASSERTION_FAILURE_WITH_MESSAGE,
.constEvalAssertionFailureWithMessage,
arguments: [assertMessage],
isRuntimeException: true,
);
@@ -3269,8 +3258,7 @@ class _InstanceCreationEvaluator {
invalidConstant ??= InvalidConstant.forEntity(
entity: initializer,
diagnosticCode:
CompileTimeErrorCode.CONST_EVAL_ASSERTION_FAILURE,
diagnosticCode: CompileTimeErrorCode.constEvalAssertionFailure,
isRuntimeException: true,
);
return _InitializersEvaluationResult(
@@ -3377,7 +3365,7 @@ class _InstanceCreationEvaluator {
return InvalidConstant.forEntity(
entity: errorTarget,
diagnosticCode:
CompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
CompileTimeErrorCode.constConstructorParamTypeMismatch,
arguments: [
argumentValue.type.getDisplayString(),
parameter.type.getDisplayString(),
@@ -3398,8 +3386,7 @@ class _InstanceCreationEvaluator {
return InvalidConstant.forEntity(
entity: errorTarget,
diagnosticCode:
CompileTimeErrorCode
.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH,
CompileTimeErrorCode.constConstructorParamTypeMismatch,
arguments: [
argumentValue.type.getDisplayString(),
fieldType.getDisplayString(),
@@ -3411,8 +3398,7 @@ class _InstanceCreationEvaluator {
if (_fieldMap.containsKey(fieldName)) {
return InvalidConstant.forEntity(
entity: _errorNode,
diagnosticCode:
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
diagnosticCode: CompileTimeErrorCode.constEvalThrowsException,
);
}
_fieldMap[fieldName] = argumentValue;
@@ -3574,7 +3560,7 @@ class _InstanceCreationEvaluator {
}
return InvalidConstant.forEntity(
entity: keyword ?? node,
diagnosticCode: CompileTimeErrorCode.CONST_WITH_NON_CONST,
diagnosticCode: CompileTimeErrorCode.constWithNonConst,
);
}
+64 -68
View File
@@ -365,9 +365,7 @@ class DartObjectImpl implements DartObject, Constant {
if (!typeSystem.isSubtypeOf(type, resultType)) {
// TODO(kallentu): Make a more specific error for casting.
throw EvaluationException(
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
return this;
}
@@ -449,7 +447,7 @@ class DartObjectImpl implements DartObject, Constant {
state.bitAnd(rightOperand.state),
);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_INT);
throw EvaluationException(CompileTimeErrorCode.constEvalTypeBoolInt);
}
/// Return the result of invoking the '|' operator on this object with the
@@ -474,7 +472,7 @@ class DartObjectImpl implements DartObject, Constant {
state.bitOr(rightOperand.state),
);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_INT);
throw EvaluationException(CompileTimeErrorCode.constEvalTypeBoolInt);
}
/// Return the result of invoking the '^' operator on this object with the
@@ -499,7 +497,7 @@ class DartObjectImpl implements DartObject, Constant {
state.bitXor(rightOperand.state),
);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_INT);
throw EvaluationException(CompileTimeErrorCode.constEvalTypeBoolInt);
}
/// Returns the result of invoking the '==' operator on this object with the
@@ -540,8 +538,8 @@ class DartObjectImpl implements DartObject, Constant {
}
throw EvaluationException(
featureSet.isEnabled(Feature.patterns)
? CompileTimeErrorCode.CONST_EVAL_PRIMITIVE_EQUALITY
: CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING,
? CompileTimeErrorCode.constEvalPrimitiveEquality
: CompileTimeErrorCode.constEvalTypeBoolNumString,
);
}
@@ -1072,7 +1070,7 @@ class DartObjectImpl implements DartObject, Constant {
/// value.
void _assertType(DartObjectImpl object) {
if (object.state is! TypeState) {
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_TYPE);
throw EvaluationException(CompileTimeErrorCode.constEvalTypeType);
}
}
}
@@ -1121,7 +1119,7 @@ class DoubleState extends NumState {
}
return DoubleState(value! + rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -1151,7 +1149,7 @@ class DoubleState extends NumState {
}
return DoubleState(value! / rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -1173,7 +1171,7 @@ class DoubleState extends NumState {
}
return BoolState.from(value! > rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -1195,7 +1193,7 @@ class DoubleState extends NumState {
}
return BoolState.from(value! >= rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -1223,7 +1221,7 @@ class DoubleState extends NumState {
return IntState(result.toInt());
}
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -1273,7 +1271,7 @@ class DoubleState extends NumState {
}
return BoolState.from(value! < rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -1295,7 +1293,7 @@ class DoubleState extends NumState {
}
return BoolState.from(value! <= rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -1317,7 +1315,7 @@ class DoubleState extends NumState {
}
return DoubleState(value! - rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -1347,7 +1345,7 @@ class DoubleState extends NumState {
}
return DoubleState(value! % rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -1369,7 +1367,7 @@ class DoubleState extends NumState {
}
return DoubleState(value! * rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -1654,14 +1652,14 @@ abstract class InstanceState {
}
assertNumStringOrNull(this);
assertNumStringOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Throws an exception if the given [state] does not represent a `bool`
/// value.
void assertBool(InstanceState? state) {
if (state is! BoolState) {
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL);
throw EvaluationException(CompileTimeErrorCode.constEvalTypeBool);
}
}
@@ -1669,7 +1667,7 @@ abstract class InstanceState {
/// `null` value.
void assertIntOrNull(InstanceState state) {
if (!(state is IntState || state is NullState)) {
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_INT);
throw EvaluationException(CompileTimeErrorCode.constEvalTypeInt);
}
}
@@ -1677,7 +1675,7 @@ abstract class InstanceState {
/// `null` value.
void assertNumOrNull(InstanceState state) {
if (!(state is NumState || state is NullState)) {
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_NUM);
throw EvaluationException(CompileTimeErrorCode.constEvalTypeNum);
}
}
@@ -1685,9 +1683,7 @@ abstract class InstanceState {
/// `String`, or `null` value.
void assertNumStringOrNull(InstanceState state) {
if (!(state is NumState || state is StringState || state is NullState)) {
throw EvaluationException(
CompileTimeErrorCode.CONST_EVAL_TYPE_NUM_STRING,
);
throw EvaluationException(CompileTimeErrorCode.constEvalTypeNumString);
}
}
@@ -1695,7 +1691,7 @@ abstract class InstanceState {
/// value.
void assertString(InstanceState state) {
if (state is! StringState) {
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_TYPE_STRING);
throw EvaluationException(CompileTimeErrorCode.constEvalTypeString);
}
}
@@ -1707,7 +1703,7 @@ abstract class InstanceState {
IntState bitAnd(InstanceState rightOperand) {
assertIntOrNull(this);
assertIntOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the '~' operator on this object.
@@ -1716,7 +1712,7 @@ abstract class InstanceState {
/// object of this kind.
IntState bitNot() {
assertIntOrNull(this);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the '|' operator on this object with the
@@ -1727,7 +1723,7 @@ abstract class InstanceState {
IntState bitOr(InstanceState rightOperand) {
assertIntOrNull(this);
assertIntOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the '^' operator on this object with the
@@ -1738,7 +1734,7 @@ abstract class InstanceState {
IntState bitXor(InstanceState rightOperand) {
assertIntOrNull(this);
assertIntOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the ' ' operator on this object with the
@@ -1748,7 +1744,7 @@ abstract class InstanceState {
/// object of this kind.
StringState concatenate(InstanceState rightOperand) {
assertString(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of applying boolean conversion to this object.
@@ -1771,7 +1767,7 @@ abstract class InstanceState {
NumState divide(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the '==' operator on this object with the
@@ -1789,7 +1785,7 @@ abstract class InstanceState {
BoolState greaterThan(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the '&gt;=' operator on this object with the
@@ -1800,7 +1796,7 @@ abstract class InstanceState {
BoolState greaterThanOrEqual(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Returns `true` if this value, inside a library with the [featureSet],
@@ -1815,7 +1811,7 @@ abstract class InstanceState {
IntState integerDivide(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the identical function on this object with
@@ -1860,7 +1856,7 @@ abstract class InstanceState {
BoolState lessThan(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the '&lt;=' operator on this object with the
@@ -1871,7 +1867,7 @@ abstract class InstanceState {
BoolState lessThanOrEqual(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the '&' operator on this object with the
@@ -1923,7 +1919,7 @@ abstract class InstanceState {
IntState logicalShiftRight(InstanceState rightOperand) {
assertIntOrNull(this);
assertIntOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the '^' operator on this object with the
@@ -1950,7 +1946,7 @@ abstract class InstanceState {
NumState minus(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the '-' operator on this object.
@@ -1959,7 +1955,7 @@ abstract class InstanceState {
/// object of this kind.
NumState negated() {
assertNumOrNull(this);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the '%' operator on this object with the
@@ -1970,7 +1966,7 @@ abstract class InstanceState {
NumState remainder(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the '&lt;&lt;' operator on this object with
@@ -1981,7 +1977,7 @@ abstract class InstanceState {
IntState shiftLeft(InstanceState rightOperand) {
assertIntOrNull(this);
assertIntOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the '&gt;&gt;' operator on this object with
@@ -1992,7 +1988,7 @@ abstract class InstanceState {
IntState shiftRight(InstanceState rightOperand) {
assertIntOrNull(this);
assertIntOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the 'length' getter on this object.
@@ -2001,7 +1997,7 @@ abstract class InstanceState {
/// object of this kind.
IntState stringLength() {
assertString(this);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
/// Return the result of invoking the '*' operator on this object with the
@@ -2012,7 +2008,7 @@ abstract class InstanceState {
NumState times(InstanceState rightOperand) {
assertNumOrNull(this);
assertNumOrNull(rightOperand);
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
}
@@ -2065,7 +2061,7 @@ class IntState extends NumState {
}
return DoubleState(value!.toDouble() + rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2081,7 +2077,7 @@ class IntState extends NumState {
}
return IntState(value! & rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2105,7 +2101,7 @@ class IntState extends NumState {
}
return IntState(value! | rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2121,7 +2117,7 @@ class IntState extends NumState {
}
return IntState(value! ^ rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2152,7 +2148,7 @@ class IntState extends NumState {
}
return DoubleState(value!.toDouble() / rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2174,7 +2170,7 @@ class IntState extends NumState {
}
return BoolState.from(value!.toDouble() > rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2196,7 +2192,7 @@ class IntState extends NumState {
}
return BoolState.from(value!.toDouble() >= rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2214,7 +2210,7 @@ class IntState extends NumState {
return UNKNOWN_VALUE;
} else if (rightValue == 0) {
throw EvaluationException(
CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE,
CompileTimeErrorCode.constEvalThrowsIdbze,
isRuntimeException: true,
);
}
@@ -2229,7 +2225,7 @@ class IntState extends NumState {
return IntState(result.toInt());
}
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2272,7 +2268,7 @@ class IntState extends NumState {
}
return BoolState.from(value!.toDouble() < rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2294,7 +2290,7 @@ class IntState extends NumState {
}
return BoolState.from(value!.toDouble() <= rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2317,7 +2313,7 @@ class IntState extends NumState {
);
}
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2342,7 +2338,7 @@ class IntState extends NumState {
}
return DoubleState(value!.toDouble() - rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2377,7 +2373,7 @@ class IntState extends NumState {
}
return DoubleState(value!.toDouble() % rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2397,7 +2393,7 @@ class IntState extends NumState {
return IntState(value! << rightValue);
}
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2417,7 +2413,7 @@ class IntState extends NumState {
return IntState(value! >> rightValue);
}
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2442,7 +2438,7 @@ class IntState extends NumState {
}
return DoubleState(value!.toDouble() * rightValue);
}
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2481,7 +2477,7 @@ class InvalidConstant implements Constant {
///
/// In [ConstantEvaluationEngine.evaluateAndFormatErrorsInConstructorCall],
/// we convert this error into a
/// [CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION] with a context message
/// [CompileTimeErrorCode.constEvalThrowsException] with a context message
/// pointing to where the exception was thrown.
final bool isRuntimeException;
@@ -2557,13 +2553,13 @@ class InvalidConstant implements Constant {
parent2.isConst) {
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT,
diagnosticCode: CompileTimeErrorCode.constWithNonConstantArgument,
isUnresolved: isUnresolved,
);
}
return InvalidConstant.forEntity(
entity: node,
diagnosticCode: CompileTimeErrorCode.INVALID_CONSTANT,
diagnosticCode: CompileTimeErrorCode.invalidConstant,
isUnresolved: isUnresolved,
);
}
@@ -2819,7 +2815,7 @@ class NullState extends InstanceState {
@override
BoolState convertToBool() {
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -2840,7 +2836,7 @@ class NullState extends InstanceState {
@override
BoolState logicalNot() {
throw EvaluationException(CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
throw EvaluationException(CompileTimeErrorCode.constEvalThrowsException);
}
@override
@@ -323,7 +323,7 @@ class GenericInferrer {
_diagnosticReporter?.atEntity(
errorEntity!,
CompileTimeErrorCode.COULD_NOT_INFER,
CompileTimeErrorCode.couldNotInfer,
arguments: [name, _formatError(parameter, inferred, constraints)],
);
@@ -352,7 +352,7 @@ class GenericInferrer {
var typeParametersStr = typeParameters.map(_elementStr).join(', ');
_diagnosticReporter.atEntity(
errorEntity!,
CompileTimeErrorCode.COULD_NOT_INFER,
CompileTimeErrorCode.couldNotInfer,
arguments: [
name,
' Inferred candidate type ${_typeStr(inferred)} has type parameters'
@@ -409,7 +409,7 @@ class GenericInferrer {
// TODO(jmesserly): improve this error message.
_diagnosticReporter?.atEntity(
errorEntity!,
CompileTimeErrorCode.COULD_NOT_INFER,
CompileTimeErrorCode.couldNotInfer,
arguments: [
name,
"\nRecursive bound cannot be instantiated: '$typeParamBound'."
@@ -461,7 +461,7 @@ class GenericInferrer {
if (!_typeSystem.isSubtypeOf(argument, bound)) {
diagnosticReporter?.atEntity(
errorEntity!,
CompileTimeErrorCode.COULD_NOT_INFER,
CompileTimeErrorCode.couldNotInfer,
arguments: [
name,
"\n'${_typeStr(argument)}' doesn't conform to "
@@ -735,7 +735,7 @@ class GenericInferrer {
: '${errorEntity.type}.${errorEntity.name}';
diagnosticReporter.atNode(
errorEntity,
WarningCode.INFERENCE_FAILURE_ON_INSTANCE_CREATION,
WarningCode.inferenceFailureOnInstanceCreation,
arguments: [constructorName],
);
} else if (errorEntity is Annotation) {
@@ -749,7 +749,7 @@ class GenericInferrer {
: '${errorEntity.name.name}.${errorEntity.constructorName}';
diagnosticReporter.atNode(
errorEntity,
WarningCode.INFERENCE_FAILURE_ON_INSTANCE_CREATION,
WarningCode.inferenceFailureOnInstanceCreation,
arguments: [constructorName],
);
}
@@ -773,7 +773,7 @@ class GenericInferrer {
if (!element.metadata.hasOptionalTypeArgs) {
diagnosticReporter.atNode(
errorEntity,
WarningCode.INFERENCE_FAILURE_ON_FUNCTION_INVOCATION,
WarningCode.inferenceFailureOnFunctionInvocation,
arguments: [errorEntity.name],
);
return;
@@ -785,7 +785,7 @@ class GenericInferrer {
var typeDisplayString = _typeStr(type);
diagnosticReporter.atNode(
errorEntity,
WarningCode.INFERENCE_FAILURE_ON_GENERIC_INVOCATION,
WarningCode.inferenceFailureOnGenericInvocation,
arguments: [typeDisplayString],
);
return;
+50 -50
View File
@@ -28,7 +28,7 @@ import "package:_fe_analyzer_shared/src/base/errors.dart";
class FfiCode extends DiagnosticCode {
/// No parameters.
static const FfiCode ABI_SPECIFIC_INTEGER_INVALID = FfiCode(
static const FfiCode abiSpecificIntegerInvalid = FfiCode(
'ABI_SPECIFIC_INTEGER_INVALID',
"Classes extending 'AbiSpecificInteger' must have exactly one const "
"constructor, no other members, and no type parameters.",
@@ -39,7 +39,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode ABI_SPECIFIC_INTEGER_MAPPING_EXTRA = FfiCode(
static const FfiCode abiSpecificIntegerMappingExtra = FfiCode(
'ABI_SPECIFIC_INTEGER_MAPPING_EXTRA',
"Classes extending 'AbiSpecificInteger' must have exactly one "
"'AbiSpecificIntegerMapping' annotation specifying the mapping from "
@@ -49,7 +49,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode ABI_SPECIFIC_INTEGER_MAPPING_MISSING = FfiCode(
static const FfiCode abiSpecificIntegerMappingMissing = FfiCode(
'ABI_SPECIFIC_INTEGER_MAPPING_MISSING',
"Classes extending 'AbiSpecificInteger' must have exactly one "
"'AbiSpecificIntegerMapping' annotation specifying the mapping from "
@@ -60,7 +60,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// String p0: the value of the invalid mapping
static const FfiCode ABI_SPECIFIC_INTEGER_MAPPING_UNSUPPORTED = FfiCode(
static const FfiCode abiSpecificIntegerMappingUnsupported = FfiCode(
'ABI_SPECIFIC_INTEGER_MAPPING_UNSUPPORTED',
"Invalid mapping to '{0}'; only mappings to 'Int8', 'Int16', 'Int32', "
"'Int64', 'Uint8', 'Uint16', 'UInt32', and 'Uint64' are supported.",
@@ -71,14 +71,14 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode ADDRESS_POSITION = FfiCode(
static const FfiCode addressPosition = FfiCode(
'ADDRESS_POSITION',
"The '.address' expression can only be used as argument to a leaf native "
"external call.",
);
/// No parameters.
static const FfiCode ADDRESS_RECEIVER = FfiCode(
static const FfiCode addressReceiver = FfiCode(
'ADDRESS_RECEIVER',
"The receiver of '.address' must be a concrete 'TypedData', a concrete "
"'TypedData' '[]', an 'Array', an 'Array' '[]', a Struct field, or a "
@@ -88,7 +88,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode ANNOTATION_ON_POINTER_FIELD = FfiCode(
static const FfiCode annotationOnPointerField = FfiCode(
'ANNOTATION_ON_POINTER_FIELD',
"Fields in a struct class whose type is 'Pointer' shouldn't have any "
"annotations.",
@@ -98,7 +98,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// String p0: the name of the argument
static const FfiCode ARGUMENT_MUST_BE_A_CONSTANT = FfiCode(
static const FfiCode argumentMustBeAConstant = FfiCode(
'ARGUMENT_MUST_BE_A_CONSTANT',
"Argument '{0}' must be a constant.",
correctionMessage: "Try replacing the value with a literal or const.",
@@ -106,7 +106,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode ARGUMENT_MUST_BE_NATIVE = FfiCode(
static const FfiCode argumentMustBeNative = FfiCode(
'ARGUMENT_MUST_BE_NATIVE',
"Argument to 'Native.addressOf' must be annotated with @Native",
correctionMessage:
@@ -116,7 +116,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// String p0: the name of the struct or union class
static const FfiCode COMPOUND_IMPLEMENTS_FINALIZABLE = FfiCode(
static const FfiCode compoundImplementsFinalizable = FfiCode(
'COMPOUND_IMPLEMENTS_FINALIZABLE',
"The class '{0}' can't implement Finalizable.",
correctionMessage: "Try removing the implements clause from '{0}'.",
@@ -124,7 +124,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode CREATION_OF_STRUCT_OR_UNION = FfiCode(
static const FfiCode creationOfStructOrUnion = FfiCode(
'CREATION_OF_STRUCT_OR_UNION',
"Subclasses of 'Struct' and 'Union' are backed by native memory, and can't "
"be instantiated by a generative constructor.",
@@ -136,7 +136,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// String p0: the name of the subclass
/// String p1: the name of the superclass
static const FfiCode EMPTY_STRUCT = FfiCode(
static const FfiCode emptyStruct = FfiCode(
'EMPTY_STRUCT',
"The class '{0}' can't be empty because it's a subclass of '{1}'.",
correctionMessage:
@@ -145,7 +145,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode EXTRA_ANNOTATION_ON_STRUCT_FIELD = FfiCode(
static const FfiCode extraAnnotationOnStructField = FfiCode(
'EXTRA_ANNOTATION_ON_STRUCT_FIELD',
"Fields in a struct class must have exactly one annotation indicating the "
"native type.",
@@ -154,7 +154,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode EXTRA_SIZE_ANNOTATION_CARRAY = FfiCode(
static const FfiCode extraSizeAnnotationCarray = FfiCode(
'EXTRA_SIZE_ANNOTATION_CARRAY',
"'Array's must have exactly one 'Array' annotation.",
correctionMessage: "Try removing the extra annotation.",
@@ -162,7 +162,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode FFI_NATIVE_INVALID_DUPLICATE_DEFAULT_ASSET = FfiCode(
static const FfiCode ffiNativeInvalidDuplicateDefaultAsset = FfiCode(
'FFI_NATIVE_INVALID_DUPLICATE_DEFAULT_ASSET',
"There may be at most one @DefaultAsset annotation on a library.",
correctionMessage: "Try removing the extra annotation.",
@@ -170,7 +170,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode FFI_NATIVE_INVALID_MULTIPLE_ANNOTATIONS = FfiCode(
static const FfiCode ffiNativeInvalidMultipleAnnotations = FfiCode(
'FFI_NATIVE_INVALID_MULTIPLE_ANNOTATIONS',
"Native functions and fields must have exactly one `@Native` annotation.",
correctionMessage: "Try removing the extra annotation.",
@@ -178,7 +178,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode FFI_NATIVE_MUST_BE_EXTERNAL = FfiCode(
static const FfiCode ffiNativeMustBeExternal = FfiCode(
'FFI_NATIVE_MUST_BE_EXTERNAL',
"Native functions must be declared external.",
correctionMessage: "Add the `external` keyword to the function.",
@@ -187,7 +187,7 @@ class FfiCode extends DiagnosticCode {
/// No parameters.
static const FfiCode
FFI_NATIVE_ONLY_CLASSES_EXTENDING_NATIVEFIELDWRAPPERCLASS1_CAN_BE_POINTER = FfiCode(
ffiNativeOnlyClassesExtendingNativefieldwrapperclass1CanBePointer = FfiCode(
'FFI_NATIVE_ONLY_CLASSES_EXTENDING_NATIVEFIELDWRAPPERCLASS1_CAN_BE_POINTER',
"Only classes extending NativeFieldWrapperClass1 can be passed as Pointer.",
correctionMessage: "Pass as Handle instead.",
@@ -196,7 +196,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// int p0: the expected number of parameters
/// int p1: the actual number of parameters
static const FfiCode FFI_NATIVE_UNEXPECTED_NUMBER_OF_PARAMETERS = FfiCode(
static const FfiCode ffiNativeUnexpectedNumberOfParameters = FfiCode(
'FFI_NATIVE_UNEXPECTED_NUMBER_OF_PARAMETERS',
"Unexpected number of Native annotation parameters. Expected {0} but has "
"{1}.",
@@ -208,7 +208,7 @@ class FfiCode extends DiagnosticCode {
/// int p0: the expected number of parameters
/// int p1: the actual number of parameters
static const FfiCode
FFI_NATIVE_UNEXPECTED_NUMBER_OF_PARAMETERS_WITH_RECEIVER = FfiCode(
ffiNativeUnexpectedNumberOfParametersWithReceiver = FfiCode(
'FFI_NATIVE_UNEXPECTED_NUMBER_OF_PARAMETERS_WITH_RECEIVER',
"Unexpected number of Native annotation parameters. Expected {0} but has "
"{1}. Native instance method annotation must have receiver as first "
@@ -220,7 +220,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode FIELD_MUST_BE_EXTERNAL_IN_STRUCT = FfiCode(
static const FfiCode fieldMustBeExternalInStruct = FfiCode(
'FIELD_MUST_BE_EXTERNAL_IN_STRUCT',
"Fields of 'Struct' and 'Union' subclasses must be marked external.",
correctionMessage: "Try adding the 'external' modifier.",
@@ -229,7 +229,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// String p0: the name of the struct class
static const FfiCode GENERIC_STRUCT_SUBCLASS = FfiCode(
static const FfiCode genericStructSubclass = FfiCode(
'GENERIC_STRUCT_SUBCLASS',
"The class '{0}' can't extend 'Struct' or 'Union' because '{0}' is "
"generic.",
@@ -239,7 +239,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// String p0: the name of the method
static const FfiCode INVALID_EXCEPTION_VALUE = FfiCode(
static const FfiCode invalidExceptionValue = FfiCode(
'INVALID_EXCEPTION_VALUE',
"The method {0} can't have an exceptional return value (the second "
"argument) when the return type of the function is either 'void', "
@@ -250,7 +250,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// String p0: the type of the field
static const FfiCode INVALID_FIELD_TYPE_IN_STRUCT = FfiCode(
static const FfiCode invalidFieldTypeInStruct = FfiCode(
'INVALID_FIELD_TYPE_IN_STRUCT',
"Fields in struct classes can't have the type '{0}'. They can only be "
"declared as 'int', 'double', 'Array', 'Pointer', or subtype of "
@@ -262,7 +262,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode LEAF_CALL_MUST_NOT_RETURN_HANDLE = FfiCode(
static const FfiCode leafCallMustNotReturnHandle = FfiCode(
'LEAF_CALL_MUST_NOT_RETURN_HANDLE',
"FFI leaf call can't return a 'Handle'.",
correctionMessage: "Try changing the return type to primitive or struct.",
@@ -270,7 +270,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode LEAF_CALL_MUST_NOT_TAKE_HANDLE = FfiCode(
static const FfiCode leafCallMustNotTakeHandle = FfiCode(
'LEAF_CALL_MUST_NOT_TAKE_HANDLE',
"FFI leaf call can't take arguments of type 'Handle'.",
correctionMessage: "Try changing the argument type to primitive or struct.",
@@ -278,7 +278,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode MISMATCHED_ANNOTATION_ON_STRUCT_FIELD = FfiCode(
static const FfiCode mismatchedAnnotationOnStructField = FfiCode(
'MISMATCHED_ANNOTATION_ON_STRUCT_FIELD',
"The annotation doesn't match the declared type of the field.",
correctionMessage:
@@ -290,7 +290,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// Type p0: the type that is missing a native type annotation
/// String p1: the superclass which is extended by this field's class
static const FfiCode MISSING_ANNOTATION_ON_STRUCT_FIELD = FfiCode(
static const FfiCode missingAnnotationOnStructField = FfiCode(
'MISSING_ANNOTATION_ON_STRUCT_FIELD',
"Fields of type '{0}' in a subclass of '{1}' must have an annotation "
"indicating the native type.",
@@ -300,7 +300,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// String p0: the name of the method
static const FfiCode MISSING_EXCEPTION_VALUE = FfiCode(
static const FfiCode missingExceptionValue = FfiCode(
'MISSING_EXCEPTION_VALUE',
"The method {0} must have an exceptional return value (the second "
"argument) when the return type of the function is neither 'void', "
@@ -310,7 +310,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode MISSING_FIELD_TYPE_IN_STRUCT = FfiCode(
static const FfiCode missingFieldTypeInStruct = FfiCode(
'MISSING_FIELD_TYPE_IN_STRUCT',
"Fields in struct classes must have an explicitly declared type of 'int', "
"'double' or 'Pointer'.",
@@ -319,7 +319,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode MISSING_SIZE_ANNOTATION_CARRAY = FfiCode(
static const FfiCode missingSizeAnnotationCarray = FfiCode(
'MISSING_SIZE_ANNOTATION_CARRAY',
"Fields of type 'Array' must have exactly one 'Array' annotation.",
correctionMessage:
@@ -332,7 +332,7 @@ class FfiCode extends DiagnosticCode {
/// Object p0: the type that should be a valid dart:ffi native type.
/// String p1: the name of the function whose invocation depends on this
/// relationship
static const FfiCode MUST_BE_A_NATIVE_FUNCTION_TYPE = FfiCode(
static const FfiCode mustBeANativeFunctionType = FfiCode(
'MUST_BE_A_NATIVE_FUNCTION_TYPE',
"The type '{0}' given to '{1}' must be a valid 'dart:ffi' native function "
"type.",
@@ -346,7 +346,7 @@ class FfiCode extends DiagnosticCode {
/// Type p1: the supertype that the subtype is compared to
/// String p2: the name of the function whose invocation depends on this
/// relationship
static const FfiCode MUST_BE_A_SUBTYPE = FfiCode(
static const FfiCode mustBeASubtype = FfiCode(
'MUST_BE_A_SUBTYPE',
"The type '{0}' must be a subtype of '{1}' for '{2}'.",
correctionMessage: "Try changing one or both of the type arguments.",
@@ -355,7 +355,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// Type p0: the return type that should be 'void'.
static const FfiCode MUST_RETURN_VOID = FfiCode(
static const FfiCode mustReturnVoid = FfiCode(
'MUST_RETURN_VOID',
"The return type of the function passed to 'NativeCallable.listener' must "
"be 'void' rather than '{0}'.",
@@ -365,7 +365,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// Type p0: The invalid type.
static const FfiCode NATIVE_FIELD_INVALID_TYPE = FfiCode(
static const FfiCode nativeFieldInvalidType = FfiCode(
'NATIVE_FIELD_INVALID_TYPE',
"'{0}' is an unsupported type for native fields. Native fields only "
"support pointers, arrays or numeric and compound types.",
@@ -376,7 +376,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode NATIVE_FIELD_MISSING_TYPE = FfiCode(
static const FfiCode nativeFieldMissingType = FfiCode(
'NATIVE_FIELD_MISSING_TYPE',
"The native type of this field could not be inferred and must be specified "
"in the annotation.",
@@ -387,7 +387,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode NATIVE_FIELD_NOT_STATIC = FfiCode(
static const FfiCode nativeFieldNotStatic = FfiCode(
'NATIVE_FIELD_NOT_STATIC',
"Native fields must be static.",
correctionMessage: "Try adding the modifier 'static' to this field.",
@@ -395,7 +395,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode NATIVE_FUNCTION_MISSING_TYPE = FfiCode(
static const FfiCode nativeFunctionMissingType = FfiCode(
'NATIVE_FUNCTION_MISSING_TYPE',
"The native type of this function couldn't be inferred so it must be "
"specified in the annotation.",
@@ -406,7 +406,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode NEGATIVE_VARIABLE_DIMENSION = FfiCode(
static const FfiCode negativeVariableDimension = FfiCode(
'NEGATIVE_VARIABLE_DIMENSION',
"The variable dimension of a variable-length array must be non-negative.",
correctionMessage: "Try using a value that is zero or greater.",
@@ -416,7 +416,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// String p0: the name of the function, method, or constructor having type
/// arguments
static const FfiCode NON_CONSTANT_TYPE_ARGUMENT = FfiCode(
static const FfiCode nonConstantTypeArgument = FfiCode(
'NON_CONSTANT_TYPE_ARGUMENT',
"The type arguments to '{0}' must be known at compile time, so they can't "
"be type parameters.",
@@ -426,7 +426,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// Type p0: the type that should be a valid dart:ffi native type.
static const FfiCode NON_NATIVE_FUNCTION_TYPE_ARGUMENT_TO_POINTER = FfiCode(
static const FfiCode nonNativeFunctionTypeArgumentToPointer = FfiCode(
'NON_NATIVE_FUNCTION_TYPE_ARGUMENT_TO_POINTER',
"Can't invoke 'asFunction' because the function signature '{0}' for the "
"pointer isn't a valid C function signature.",
@@ -437,7 +437,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode NON_POSITIVE_ARRAY_DIMENSION = FfiCode(
static const FfiCode nonPositiveArrayDimension = FfiCode(
'NON_POSITIVE_ARRAY_DIMENSION',
"Array dimensions must be positive numbers.",
correctionMessage: "Try changing the input to a positive number.",
@@ -447,7 +447,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// String p0: the name of the field
/// Type p1: the type of the field
static const FfiCode NON_SIZED_TYPE_ARGUMENT = FfiCode(
static const FfiCode nonSizedTypeArgument = FfiCode(
'NON_SIZED_TYPE_ARGUMENT',
"The type '{1}' isn't a valid type argument for '{0}'. The type argument "
"must be a native integer, 'Float', 'Double', 'Pointer', or subtype of "
@@ -459,7 +459,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode PACKED_ANNOTATION = FfiCode(
static const FfiCode packedAnnotation = FfiCode(
'PACKED_ANNOTATION',
"Structs must have at most one 'Packed' annotation.",
correctionMessage: "Try removing extra 'Packed' annotations.",
@@ -467,7 +467,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode PACKED_ANNOTATION_ALIGNMENT = FfiCode(
static const FfiCode packedAnnotationAlignment = FfiCode(
'PACKED_ANNOTATION_ALIGNMENT',
"Only packing to 1, 2, 4, 8, and 16 bytes is supported.",
correctionMessage:
@@ -476,7 +476,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode SIZE_ANNOTATION_DIMENSIONS = FfiCode(
static const FfiCode sizeAnnotationDimensions = FfiCode(
'SIZE_ANNOTATION_DIMENSIONS',
"'Array's must have an 'Array' annotation that matches the dimensions.",
correctionMessage: "Try adjusting the arguments in the 'Array' annotation.",
@@ -486,7 +486,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// String p0: the name of the subclass
/// String p1: the name of the class being extended, implemented, or mixed in
static const FfiCode SUBTYPE_OF_STRUCT_CLASS_IN_EXTENDS = FfiCode(
static const FfiCode subtypeOfStructClassInExtends = FfiCode(
'SUBTYPE_OF_STRUCT_CLASS',
"The class '{0}' can't extend '{1}' because '{1}' is a subtype of "
"'Struct', 'Union', or 'AbiSpecificInteger'.",
@@ -499,7 +499,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// String p0: the name of the subclass
/// String p1: the name of the class being extended, implemented, or mixed in
static const FfiCode SUBTYPE_OF_STRUCT_CLASS_IN_IMPLEMENTS = FfiCode(
static const FfiCode subtypeOfStructClassInImplements = FfiCode(
'SUBTYPE_OF_STRUCT_CLASS',
"The class '{0}' can't implement '{1}' because '{1}' is a subtype of "
"'Struct', 'Union', or 'AbiSpecificInteger'.",
@@ -512,7 +512,7 @@ class FfiCode extends DiagnosticCode {
/// Parameters:
/// String p0: the name of the subclass
/// String p1: the name of the class being extended, implemented, or mixed in
static const FfiCode SUBTYPE_OF_STRUCT_CLASS_IN_WITH = FfiCode(
static const FfiCode subtypeOfStructClassInWith = FfiCode(
'SUBTYPE_OF_STRUCT_CLASS',
"The class '{0}' can't mix in '{1}' because '{1}' is a subtype of "
"'Struct', 'Union', or 'AbiSpecificInteger'.",
@@ -523,7 +523,7 @@ class FfiCode extends DiagnosticCode {
);
/// No parameters.
static const FfiCode VARIABLE_LENGTH_ARRAY_NOT_LAST = FfiCode(
static const FfiCode variableLengthArrayNotLast = FfiCode(
'VARIABLE_LENGTH_ARRAY_NOT_LAST',
"Variable length 'Array's must only occur as the last field of Structs.",
correctionMessage: "Try adjusting the arguments in the 'Array' annotation.",
@@ -31,7 +31,7 @@ class HintCode extends DiagnosticCode {
/// plan to go through the exercise of converting it to a Warning.
///
/// No parameters.
static const HintCode DEPRECATED_COLON_FOR_DEFAULT_VALUE = HintCode(
static const HintCode deprecatedColonForDefaultValue = HintCode(
'DEPRECATED_COLON_FOR_DEFAULT_VALUE',
"Using a colon as the separator before a default value is deprecated and "
"will not be supported in language version 3.0 and later.",
@@ -41,7 +41,7 @@ class HintCode extends DiagnosticCode {
/// Parameters:
/// String p0: the name of the member
static const HintCode DEPRECATED_MEMBER_USE = HintCode(
static const HintCode deprecatedMemberUse = HintCode(
'DEPRECATED_MEMBER_USE',
"'{0}' is deprecated and shouldn't be used.",
correctionMessage:
@@ -54,7 +54,7 @@ class HintCode extends DiagnosticCode {
///
/// Parameters:
/// String p0: the name of the member
static const HintCode DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE = HintCode(
static const HintCode deprecatedMemberUseFromSamePackage = HintCode(
'DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE',
"'{0}' is deprecated and shouldn't be used.",
correctionMessage:
@@ -69,7 +69,7 @@ class HintCode extends DiagnosticCode {
/// Object p0: the name of the member
/// Object p1: message details
static const HintCode
DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE_WITH_MESSAGE = HintCode(
deprecatedMemberUseFromSamePackageWithMessage = HintCode(
'DEPRECATED_MEMBER_USE_FROM_SAME_PACKAGE',
"'{0}' is deprecated and shouldn't be used. {1}",
correctionMessage:
@@ -81,7 +81,7 @@ class HintCode extends DiagnosticCode {
/// Parameters:
/// String p0: the name of the member
/// String p1: message details
static const HintCode DEPRECATED_MEMBER_USE_WITH_MESSAGE = HintCode(
static const HintCode deprecatedMemberUseWithMessage = HintCode(
'DEPRECATED_MEMBER_USE',
"'{0}' is deprecated and shouldn't be used. {1}",
correctionMessage:
@@ -91,7 +91,7 @@ class HintCode extends DiagnosticCode {
);
/// No parameters.
static const HintCode IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION = HintCode(
static const HintCode importDeferredLibraryWithLoadFunction = HintCode(
'IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION',
"The imported library defines a top-level function named 'loadLibrary' "
"that is hidden by deferring this library.",
@@ -104,7 +104,7 @@ class HintCode extends DiagnosticCode {
/// Parameters:
/// String p0: the URI that is not necessary
/// String p1: the URI that makes it unnecessary
static const HintCode UNNECESSARY_IMPORT = HintCode(
static const HintCode unnecessaryImport = HintCode(
'UNNECESSARY_IMPORT',
"The import of '{0}' is unnecessary because all of the used elements are "
"also provided by the import of '{1}'.",
@@ -112,6 +112,9 @@ class HintCode extends DiagnosticCode {
hasPublishedDocs: true,
);
@Deprecated("Please use unnecessaryImport")
static const HintCode UNNECESSARY_IMPORT = unnecessaryImport;
/// Initialize a newly created error code to have the given [name].
const HintCode(
String name,
File diff suppressed because it is too large Load Diff
+10 -10
View File
@@ -11,10 +11,10 @@ import 'package:analyzer/error/error.dart';
/// Static helper methods and properties for working with [TodoCode]s.
class Todo {
static const _codes = {
'TODO': TodoCode.TODO,
'FIXME': TodoCode.FIXME,
'HACK': TodoCode.HACK,
'UNDONE': TodoCode.UNDONE,
'TODO': TodoCode.todo,
'FIXME': TodoCode.fixme,
'HACK': TodoCode.hack,
'UNDONE': TodoCode.undone,
};
/// This matches the two common Dart task styles
@@ -50,8 +50,8 @@ class Todo {
throw UnimplementedError('Do not construct');
}
/// Returns the TodoCode for [kind], falling back to [TodoCode.TODO].
static TodoCode forKind(String kind) => _codes[kind] ?? TodoCode.TODO;
/// Returns the TodoCode for [kind], falling back to [TodoCode.todo].
static TodoCode forKind(String kind) => _codes[kind] ?? TodoCode.todo;
}
/**
@@ -62,22 +62,22 @@ class TodoCode extends DiagnosticCode {
/**
* A standard TODO comment marked as TODO.
*/
static const TodoCode TODO = TodoCode('TODO');
static const TodoCode todo = TodoCode('TODO');
/**
* A TODO comment marked as FIXME.
*/
static const TodoCode FIXME = TodoCode('FIXME');
static const TodoCode fixme = TodoCode('FIXME');
/**
* A TODO comment marked as HACK.
*/
static const TodoCode HACK = TodoCode('HACK');
static const TodoCode hack = TodoCode('HACK');
/**
* A TODO comment marked as UNDONE.
*/
static const TodoCode UNDONE = TodoCode('UNDONE');
static const TodoCode undone = TodoCode('UNDONE');
/**
* Initialize a newly created error code to have the given [name].
@@ -93,7 +93,7 @@ class AnnotationResolver {
);
_resolveAnnotationElementGetter(node, getter);
} else if (getter is! ConstructorElement) {
_diagnosticReporter.atNode(node, CompileTimeErrorCode.INVALID_ANNOTATION);
_diagnosticReporter.atNode(node, CompileTimeErrorCode.invalidAnnotation);
}
_visitArguments(
@@ -117,7 +117,7 @@ class AnnotationResolver {
node.element = constructorElement;
if (constructorElement == null) {
_diagnosticReporter.atNode(node, CompileTimeErrorCode.INVALID_ANNOTATION);
_diagnosticReporter.atNode(node, CompileTimeErrorCode.invalidAnnotation);
AnnotationInferrer(
resolver: _resolver,
node: node,
@@ -172,7 +172,7 @@ class AnnotationResolver {
);
_resolveAnnotationElementGetter(node, getter);
} else {
_diagnosticReporter.atNode(node, CompileTimeErrorCode.INVALID_ANNOTATION);
_diagnosticReporter.atNode(node, CompileTimeErrorCode.invalidAnnotation);
}
_visitArguments(
@@ -188,7 +188,7 @@ class AnnotationResolver {
List<WhyNotPromotedGetter> whyNotPromotedArguments,
) {
if (!element.isConst || node.arguments != null) {
_diagnosticReporter.atNode(node, CompileTimeErrorCode.INVALID_ANNOTATION);
_diagnosticReporter.atNode(node, CompileTimeErrorCode.invalidAnnotation);
}
_visitArguments(
@@ -239,7 +239,7 @@ class AnnotationResolver {
if (element1 == null) {
_diagnosticReporter.atNode(
node,
CompileTimeErrorCode.UNDEFINED_ANNOTATION,
CompileTimeErrorCode.undefinedAnnotation,
arguments: [name1.name],
);
_visitArguments(
@@ -331,7 +331,7 @@ class AnnotationResolver {
if (element == null) {
_diagnosticReporter.atNode(
node,
CompileTimeErrorCode.UNDEFINED_ANNOTATION,
CompileTimeErrorCode.undefinedAnnotation,
arguments: [name2.name],
);
_visitArguments(
@@ -375,7 +375,7 @@ class AnnotationResolver {
return;
}
_diagnosticReporter.atNode(node, CompileTimeErrorCode.INVALID_ANNOTATION);
_diagnosticReporter.atNode(node, CompileTimeErrorCode.invalidAnnotation);
_visitArguments(
node,
@@ -395,7 +395,7 @@ class AnnotationResolver {
annotation.arguments != null) {
_diagnosticReporter.atNode(
annotation,
CompileTimeErrorCode.INVALID_ANNOTATION,
CompileTimeErrorCode.invalidAnnotation,
);
}
}
@@ -459,7 +459,7 @@ class AnnotationResolver {
);
_resolveAnnotationElementGetter(node, getter);
} else if (getter is! ConstructorElement) {
_diagnosticReporter.atNode(node, CompileTimeErrorCode.INVALID_ANNOTATION);
_diagnosticReporter.atNode(node, CompileTimeErrorCode.invalidAnnotation);
}
_visitArguments(
@@ -152,7 +152,7 @@ class AssignmentExpressionResolver {
)) {
_diagnosticReporter.atNode(
right,
CompileTimeErrorCode.RECORD_LITERAL_ONE_POSITIONAL_NO_TRAILING_COMMA,
CompileTimeErrorCode.recordLiteralOnePositionalNoTrailingComma,
);
return;
}
@@ -160,7 +160,7 @@ class AssignmentExpressionResolver {
_diagnosticReporter.atNode(
right,
CompileTimeErrorCode.INVALID_ASSIGNMENT,
CompileTimeErrorCode.invalidAssignment,
arguments: [rightType, writeType],
contextMessages: _resolver.computeWhyNotPromotedMessages(
right,
@@ -173,7 +173,7 @@ class AssignmentExpressionResolver {
/// when it returns 'void'. Or, in rare cases, when other types of expressions
/// are void, such as identifiers.
///
/// See [CompileTimeErrorCode.USE_OF_VOID_RESULT].
/// See [CompileTimeErrorCode.useOfVoidResult].
// TODO(scheglov): this is duplicate
bool _checkForUseOfVoidResult(Expression expression) {
if (!identical(expression.staticType, VoidTypeImpl.instance)) {
@@ -184,12 +184,12 @@ class AssignmentExpressionResolver {
SimpleIdentifier methodName = expression.methodName;
_diagnosticReporter.atNode(
methodName,
CompileTimeErrorCode.USE_OF_VOID_RESULT,
CompileTimeErrorCode.useOfVoidResult,
);
} else {
_diagnosticReporter.atNode(
expression,
CompileTimeErrorCode.USE_OF_VOID_RESULT,
CompileTimeErrorCode.useOfVoidResult,
);
}
@@ -242,7 +242,7 @@ class AssignmentExpressionResolver {
if (leftType is VoidType) {
_diagnosticReporter.atToken(
operator,
CompileTimeErrorCode.USE_OF_VOID_RESULT,
CompileTimeErrorCode.useOfVoidResult,
);
return;
}
@@ -274,7 +274,7 @@ class AssignmentExpressionResolver {
if (result.needsGetterError) {
_diagnosticReporter.atToken(
operator,
CompileTimeErrorCode.UNDEFINED_OPERATOR,
CompileTimeErrorCode.undefinedOperator,
arguments: [methodName, leftType],
);
}
@@ -402,14 +402,14 @@ class AssignmentExpressionShared {
if (isForEachIdentifier || assigned) {
_errorReporter.atNode(
left,
CompileTimeErrorCode.LATE_FINAL_LOCAL_ALREADY_ASSIGNED,
CompileTimeErrorCode.lateFinalLocalAlreadyAssigned,
);
}
} else {
if (isForEachIdentifier || !unassigned) {
_errorReporter.atNode(
left,
CompileTimeErrorCode.ASSIGNMENT_TO_FINAL_LOCAL,
CompileTimeErrorCode.assignmentToFinalLocal,
arguments: [element.name!],
);
}
@@ -435,7 +435,7 @@ class AstRewriter {
if (typeArguments != null) {
_diagnosticReporter.atNode(
typeArguments,
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR,
CompileTimeErrorCode.wrongNumberOfTypeArgumentsConstructor,
arguments: [typeNameIdentifier.toString(), constructorIdentifier.name],
);
}
@@ -602,7 +602,7 @@ class AstRewriter {
if (typeArguments != null) {
_diagnosticReporter.atNode(
typeArguments,
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR,
CompileTimeErrorCode.wrongNumberOfTypeArgumentsConstructor,
arguments: [typeIdentifier.name, constructorIdentifier.name],
);
}
@@ -70,7 +70,7 @@ class BinaryExpressionResolver {
if (operator != TokenType.BANG_EQ_EQ && operator != TokenType.EQ_EQ_EQ) {
_diagnosticReporter.atToken(
node.operator,
CompileTimeErrorCode.NOT_BINARY_OPERATOR,
CompileTimeErrorCode.notBinaryOperator,
arguments: [operator.lexeme],
);
}
@@ -85,7 +85,7 @@ class BinaryExpressionResolver {
}) {
_resolver.boolExpressionVerifier.checkForNonBoolExpression(
operand,
diagnosticCode: CompileTimeErrorCode.NON_BOOL_OPERAND,
diagnosticCode: CompileTimeErrorCode.nonBoolOperand,
arguments: [operator],
whyNotPromoted: whyNotPromoted,
);
@@ -148,8 +148,8 @@ class BinaryExpressionResolver {
void reportNullComparison(SyntacticEntity start, SyntacticEntity end) {
var errorCode =
notEqual
? WarningCode.UNNECESSARY_NULL_COMPARISON_ALWAYS_NULL_FALSE
: WarningCode.UNNECESSARY_NULL_COMPARISON_ALWAYS_NULL_TRUE;
? WarningCode.unnecessaryNullComparisonAlwaysNullFalse
: WarningCode.unnecessaryNullComparisonAlwaysNullTrue;
var offset = start.offset;
_diagnosticReporter.atOffset(
offset: offset,
@@ -407,7 +407,7 @@ class BinaryExpressionResolver {
// safe to assume `extension.name` is non-`null`.
_diagnosticReporter.atToken(
node.operator,
CompileTimeErrorCode.UNDEFINED_EXTENSION_OPERATOR,
CompileTimeErrorCode.undefinedExtensionOperator,
arguments: [methodName, extension.name!],
);
}
@@ -421,7 +421,7 @@ class BinaryExpressionResolver {
if (identical(leftType, NeverTypeImpl.instance)) {
_resolver.diagnosticReporter.atNode(
leftOperand,
WarningCode.RECEIVER_OF_TYPE_NEVER,
WarningCode.receiverOfTypeNever,
);
return;
}
@@ -446,13 +446,13 @@ class BinaryExpressionResolver {
if (leftOperand is SuperExpression) {
_diagnosticReporter.atToken(
node.operator,
CompileTimeErrorCode.UNDEFINED_SUPER_OPERATOR,
CompileTimeErrorCode.undefinedSuperOperator,
arguments: [methodName, leftType],
);
} else {
_diagnosticReporter.atToken(
node.operator,
CompileTimeErrorCode.UNDEFINED_OPERATOR,
CompileTimeErrorCode.undefinedOperator,
arguments: [methodName, leftType],
);
}
@@ -25,7 +25,7 @@ class ConstructorReferenceResolver {
// the parser has already reported an error.
_resolver.diagnosticReporter.atNode(
node,
WarningCode.SDK_VERSION_CONSTRUCTOR_TEAROFFS,
WarningCode.sdkVersionConstructorTearoffs,
);
}
node.constructorName.accept(_resolver);
@@ -35,8 +35,7 @@ class ConstructorReferenceResolver {
if (enclosingElement is ClassElementImpl && enclosingElement.isAbstract) {
_resolver.diagnosticReporter.atNode(
node,
CompileTimeErrorCode
.TEAROFF_OF_GENERATIVE_CONSTRUCTOR_OF_ABSTRACT_CLASS,
CompileTimeErrorCode.tearoffOfGenerativeConstructorOfAbstractClass,
);
}
}
@@ -68,10 +67,9 @@ class ConstructorReferenceResolver {
if (method != null) {
var error =
method.isStatic
? CompileTimeErrorCode
.CLASS_INSTANTIATION_ACCESS_TO_STATIC_MEMBER
? CompileTimeErrorCode.classInstantiationAccessToStaticMember
: CompileTimeErrorCode
.CLASS_INSTANTIATION_ACCESS_TO_INSTANCE_MEMBER;
.classInstantiationAccessToInstanceMember;
_resolver.diagnosticReporter.atNode(
node,
error,
@@ -80,7 +78,7 @@ class ConstructorReferenceResolver {
} else if (!name.isSynthetic) {
_resolver.diagnosticReporter.atNode(
node,
CompileTimeErrorCode.CLASS_INSTANTIATION_ACCESS_TO_UNKNOWN_MEMBER,
CompileTimeErrorCode.classInstantiationAccessToUnknownMember,
arguments: [enclosingElement.name!, name.name],
);
}
@@ -118,7 +118,7 @@ class ExtensionMemberResolver {
if (mostSpecific.length == 2) {
_diagnosticReporter.atEntity(
nameEntity,
CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO,
CompileTimeErrorCode.ambiguousExtensionMemberAccessTwo,
arguments: [
name.name,
mostSpecific[0].extension,
@@ -129,7 +129,7 @@ class ExtensionMemberResolver {
var extensions = mostSpecific.map((e) => e.extension).toList();
_diagnosticReporter.atEntity(
nameEntity,
CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_THREE_OR_MORE,
CompileTimeErrorCode.ambiguousExtensionMemberAccessThreeOrMore,
arguments: [
name.name,
mostSpecific.map((e) {
@@ -207,7 +207,7 @@ class ExtensionMemberResolver {
if (!_isCascadeTarget(node)) {
_diagnosticReporter.atNode(
node,
CompileTimeErrorCode.EXTENSION_OVERRIDE_WITHOUT_ACCESS,
CompileTimeErrorCode.extensionOverrideWithoutAccess,
);
}
nodeImpl.setPseudoExpressionStaticType(DynamicTypeImpl.instance);
@@ -217,7 +217,7 @@ class ExtensionMemberResolver {
if (arguments.length != 1) {
_diagnosticReporter.atNode(
node.argumentList,
CompileTimeErrorCode.INVALID_EXTENSION_ARGUMENT_COUNT,
CompileTimeErrorCode.invalidExtensionArgumentCount,
);
nodeImpl.typeArgumentTypes = _listOfDynamic(typeParameters);
nodeImpl.extendedType = DynamicTypeImpl.instance;
@@ -260,7 +260,7 @@ class ExtensionMemberResolver {
if (receiverType is VoidType) {
_diagnosticReporter.atNode(
receiverExpression,
CompileTimeErrorCode.USE_OF_VOID_RESULT,
CompileTimeErrorCode.useOfVoidResult,
);
} else if (!_typeSystem.isAssignableTo(
receiverType,
@@ -271,7 +271,7 @@ class ExtensionMemberResolver {
whyNotPromotedArguments.isEmpty ? null : whyNotPromotedArguments[0];
_diagnosticReporter.atNode(
receiverExpression,
CompileTimeErrorCode.EXTENSION_OVERRIDE_ARGUMENT_NOT_ASSIGNABLE,
CompileTimeErrorCode.extensionOverrideArgumentNotAssignable,
arguments: [receiverType, extendedType],
contextMessages: _resolver.computeWhyNotPromotedMessages(
receiverExpression,
@@ -298,7 +298,7 @@ class ExtensionMemberResolver {
if (!_typeSystem.isSubtypeOf(argument, parameterBound)) {
_diagnosticReporter.atNode(
typeArgumentList.arguments[i],
CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS,
CompileTimeErrorCode.typeArgumentNotMatchingBounds,
arguments: [argument, name, parameterBound],
);
}
@@ -381,7 +381,7 @@ class ExtensionMemberResolver {
// explicit extension overrides cannot refer to unnamed extensions.
_diagnosticReporter.atNode(
typeArguments,
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_EXTENSION,
CompileTimeErrorCode.wrongNumberOfTypeArgumentsExtension,
arguments: [element.name!, typeParameters.length, arguments.length],
);
return _listOfDynamic(typeParameters);
@@ -85,7 +85,7 @@ class ForResolver {
);
_resolver.popRewrite();
_resolver.nullableDereferenceVerifier.expression(
CompileTimeErrorCode.UNCHECKED_USE_OF_NULLABLE_VALUE_AS_ITERATOR,
CompileTimeErrorCode.uncheckedUseOfNullableValueAsIterator,
forLoopParts.iterable,
);
}
@@ -177,7 +177,7 @@ class ForResolver {
iterable = _resolver.popRewrite()!;
_resolver.nullableDereferenceVerifier.expression(
CompileTimeErrorCode.UNCHECKED_USE_OF_NULLABLE_VALUE_AS_ITERATOR,
CompileTimeErrorCode.uncheckedUseOfNullableValueAsIterator,
iterable,
);
@@ -65,7 +65,7 @@ class FunctionExpressionInvocationResolver {
receiverType = _typeSystem.resolveToBound(receiverType);
if (receiverType is FunctionTypeImpl) {
_nullableDereferenceVerifier.expression(
CompileTimeErrorCode.UNCHECKED_INVOCATION_OF_NULLABLE_VALUE,
CompileTimeErrorCode.uncheckedInvocationOfNullableValue,
function,
);
_resolve(
@@ -78,7 +78,7 @@ class FunctionExpressionInvocationResolver {
}
if (identical(receiverType, NeverTypeImpl.instance)) {
_diagnosticReporter.atNode(function, WarningCode.RECEIVER_OF_TYPE_NEVER);
_diagnosticReporter.atNode(function, WarningCode.receiverOfTypeNever);
_unresolved(
node,
NeverTypeImpl.instance,
@@ -103,7 +103,7 @@ class FunctionExpressionInvocationResolver {
if (result.needsGetterError) {
_diagnosticReporter.atNode(
function,
CompileTimeErrorCode.INVOCATION_OF_NON_FUNCTION_EXPRESSION,
CompileTimeErrorCode.invocationOfNonFunctionExpression,
);
}
var type =
@@ -122,7 +122,7 @@ class FunctionExpressionInvocationResolver {
if (callElement.kind != ElementKind.METHOD) {
_diagnosticReporter.atNode(
function,
CompileTimeErrorCode.INVOCATION_OF_NON_FUNCTION_EXPRESSION,
CompileTimeErrorCode.invocationOfNonFunctionExpression,
);
_unresolved(
node,
@@ -142,7 +142,7 @@ class FunctionExpressionInvocationResolver {
/// when it returns 'void'. Or, in rare cases, when other types of expressions
/// are void, such as identifiers.
///
/// See [CompileTimeErrorCode.USE_OF_VOID_RESULT].
/// See [CompileTimeErrorCode.useOfVoidResult].
///
// TODO(scheglov): this is duplicate
bool _checkForUseOfVoidResult(Expression expression, DartType type) {
@@ -154,12 +154,12 @@ class FunctionExpressionInvocationResolver {
SimpleIdentifier methodName = expression.methodName;
_diagnosticReporter.atNode(
methodName,
CompileTimeErrorCode.USE_OF_VOID_RESULT,
CompileTimeErrorCode.useOfVoidResult,
);
} else {
_diagnosticReporter.atNode(
expression,
CompileTimeErrorCode.USE_OF_VOID_RESULT,
CompileTimeErrorCode.useOfVoidResult,
);
}
@@ -203,7 +203,7 @@ class FunctionExpressionInvocationResolver {
if (callElement == null) {
_diagnosticReporter.atNode(
function,
CompileTimeErrorCode.INVOCATION_OF_EXTENSION_WITHOUT_CALL,
CompileTimeErrorCode.invocationOfExtensionWithoutCall,
arguments: [function.name.lexeme],
);
return _unresolved(
@@ -217,7 +217,7 @@ class FunctionExpressionInvocationResolver {
if (callElement.isStatic) {
_diagnosticReporter.atNode(
node.argumentList,
CompileTimeErrorCode.EXTENSION_OVERRIDE_ACCESS_TO_STATIC_MEMBER,
CompileTimeErrorCode.extensionOverrideAccessToStaticMember,
);
}
@@ -57,7 +57,7 @@ class FunctionReferenceResolver {
// interpreted as a type literal (e.g. `List<int>`).
_diagnosticReporter.atNode(
typeArguments,
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR,
CompileTimeErrorCode.wrongNumberOfTypeArgumentsConstructor,
arguments: [
function.constructorName.type.qualifiedName,
function.constructorName.name!.name,
@@ -105,7 +105,7 @@ class FunctionReferenceResolver {
if (prefixType is DynamicType) {
_diagnosticReporter.atNode(
function,
CompileTimeErrorCode.GENERIC_METHOD_TYPE_INSTANTIATION_ON_DYNAMIC,
CompileTimeErrorCode.genericMethodTypeInstantiationOnDynamic,
);
node.recordStaticType(InvalidTypeImpl.instance, resolver: _resolver);
return true;
@@ -122,10 +122,9 @@ class FunctionReferenceResolver {
if (typeArgumentList.arguments.length != typeParameters.length) {
if (name == null &&
errorCode ==
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_FUNCTION) {
CompileTimeErrorCode.wrongNumberOfTypeArgumentsFunction) {
errorCode =
CompileTimeErrorCode
.WRONG_NUMBER_OF_TYPE_ARGUMENTS_ANONYMOUS_FUNCTION;
CompileTimeErrorCode.wrongNumberOfTypeArgumentsAnonymousFunction;
_diagnosticReporter.atNode(
typeArgumentList,
errorCode,
@@ -188,14 +187,13 @@ class FunctionReferenceResolver {
if (_resolver.enclosingExtension != null) {
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode
.UNQUALIFIED_REFERENCE_TO_STATIC_MEMBER_OF_EXTENDED_TYPE,
CompileTimeErrorCode.unqualifiedReferenceToStaticMemberOfExtendedType,
arguments: [enclosingElement.displayName],
);
} else {
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER,
CompileTimeErrorCode.unqualifiedReferenceToNonLocalStaticMember,
arguments: [enclosingElement.displayName],
);
}
@@ -203,8 +201,7 @@ class FunctionReferenceResolver {
enclosingElement.name == null) {
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode
.INSTANCE_ACCESS_TO_STATIC_MEMBER_OF_UNNAMED_EXTENSION,
CompileTimeErrorCode.instanceAccessToStaticMemberOfUnnamedExtension,
arguments: [nameNode.name, element.kind.displayName],
);
} else {
@@ -212,7 +209,7 @@ class FunctionReferenceResolver {
// it can only be `null` for extensions, and we handle that case above.
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode.INSTANCE_ACCESS_TO_STATIC_MEMBER,
CompileTimeErrorCode.instanceAccessToStaticMember,
arguments: [
nameNode.name,
element.kind.displayName,
@@ -264,7 +261,7 @@ class FunctionReferenceResolver {
typeArguments,
name,
rawType.typeParameters,
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_FUNCTION,
CompileTimeErrorCode.wrongNumberOfTypeArgumentsFunction,
);
var invokeType = rawType.instantiate(typeArgumentTypes);
@@ -278,7 +275,7 @@ class FunctionReferenceResolver {
// tearoff feature is enabled.
_diagnosticReporter.atNode(
node.function,
CompileTimeErrorCode.DISALLOWED_TYPE_INSTANTIATION_EXPRESSION,
CompileTimeErrorCode.disallowedTypeInstantiationExpression,
);
node.recordStaticType(InvalidTypeImpl.instance, resolver: _resolver);
} else if (rawType is DynamicType) {
@@ -300,7 +297,7 @@ class FunctionReferenceResolver {
node.typeArguments!,
MethodElement.CALL_METHOD_NAME,
callMethodType.typeParameters,
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_FUNCTION,
CompileTimeErrorCode.wrongNumberOfTypeArgumentsFunction,
);
var callReference = ImplicitCallReferenceImpl(
expression: node.function,
@@ -331,7 +328,7 @@ class FunctionReferenceResolver {
node.typeArguments!,
name.name,
element.typeParameters,
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS,
CompileTimeErrorCode.wrongNumberOfTypeArguments,
);
var type = element.instantiateImpl(
typeArguments: typeArguments,
@@ -353,7 +350,7 @@ class FunctionReferenceResolver {
// tearoff feature is enabled.
_diagnosticReporter.atNode(
node.function,
CompileTimeErrorCode.DISALLOWED_TYPE_INSTANTIATION_EXPRESSION,
CompileTimeErrorCode.disallowedTypeInstantiationExpression,
);
}
_resolve(node: node, rawType: rawType);
@@ -379,7 +376,7 @@ class FunctionReferenceResolver {
if (member.isStatic) {
_resolver.diagnosticReporter.atNode(
function.propertyName,
CompileTimeErrorCode.EXTENSION_OVERRIDE_ACCESS_TO_STATIC_MEMBER,
CompileTimeErrorCode.extensionOverrideAccessToStaticMember,
);
// Continue to resolve type.
}
@@ -387,7 +384,7 @@ class FunctionReferenceResolver {
if (function.isCascaded) {
_resolver.diagnosticReporter.atToken(
override.name,
CompileTimeErrorCode.EXTENSION_OVERRIDE_WITH_CASCADE,
CompileTimeErrorCode.extensionOverrideWithCascade,
);
// Continue to resolve type.
}
@@ -441,7 +438,7 @@ class FunctionReferenceResolver {
if (prefixElement == null) {
_diagnosticReporter.atNode(
function.prefix,
CompileTimeErrorCode.UNDEFINED_IDENTIFIER,
CompileTimeErrorCode.undefinedIdentifier,
arguments: [function.name],
);
function.setPseudoExpressionStaticType(InvalidTypeImpl.instance);
@@ -465,7 +462,7 @@ class FunctionReferenceResolver {
if (functionElement == null) {
_diagnosticReporter.atNode(
function.identifier,
CompileTimeErrorCode.UNDEFINED_PREFIXED_NAME,
CompileTimeErrorCode.undefinedPrefixedName,
arguments: [functionName, function.prefix.name],
);
function.setPseudoExpressionStaticType(InvalidTypeImpl.instance);
@@ -510,7 +507,7 @@ class FunctionReferenceResolver {
// If it is known, we must report the bad type instantiation here.
_diagnosticReporter.atNode(
function.identifier,
CompileTimeErrorCode.DISALLOWED_TYPE_INSTANTIATION_EXPRESSION,
CompileTimeErrorCode.disallowedTypeInstantiationExpression,
);
}
_resolver.analyzeExpression(function, _resolver.operations.unknownType);
@@ -555,7 +552,7 @@ class FunctionReferenceResolver {
if (targetType is DynamicType) {
_diagnosticReporter.atNode(
node,
CompileTimeErrorCode.GENERIC_METHOD_TYPE_INSTANTIATION_ON_DYNAMIC,
CompileTimeErrorCode.genericMethodTypeInstantiationOnDynamic,
);
node.recordStaticType(InvalidTypeImpl.instance, resolver: _resolver);
return;
@@ -582,7 +579,7 @@ class FunctionReferenceResolver {
// If it is known, we must report the bad type instantiation here.
_diagnosticReporter.atNode(
function.propertyName,
CompileTimeErrorCode.DISALLOWED_TYPE_INSTANTIATION_EXPRESSION,
CompileTimeErrorCode.disallowedTypeInstantiationExpression,
);
}
@@ -703,7 +700,7 @@ class FunctionReferenceResolver {
} else {
_diagnosticReporter.atNode(
function,
CompileTimeErrorCode.UNDEFINED_IDENTIFIER,
CompileTimeErrorCode.undefinedIdentifier,
arguments: [function.name],
);
function.setPseudoExpressionStaticType(InvalidTypeImpl.instance);
@@ -747,7 +744,7 @@ class FunctionReferenceResolver {
} else {
_resolver.diagnosticReporter.atNode(
function,
CompileTimeErrorCode.UNDEFINED_METHOD,
CompileTimeErrorCode.undefinedMethod,
arguments: [function.name, receiverType],
);
function.setPseudoExpressionStaticType(InvalidTypeImpl.instance);
@@ -862,7 +859,7 @@ class FunctionReferenceResolver {
node.typeArguments!,
element.name,
element.typeParameters,
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS,
CompileTimeErrorCode.wrongNumberOfTypeArguments,
);
var type = element.instantiateImpl(
typeArguments: typeArguments,
@@ -86,7 +86,7 @@ class InstanceCreationExpressionResolver {
} else {
_resolver.diagnosticReporter.atNode(
node.constructorName,
CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR,
CompileTimeErrorCode.constWithUndefinedConstructor,
arguments: [contextType, node.constructorName.name],
);
}
@@ -98,14 +98,14 @@ class InstanceCreationExpressionResolver {
if (constructorElement != null && !constructorElement.isFactory) {
_resolver.diagnosticReporter.atNode(
node,
CompileTimeErrorCode.INSTANTIATE_ABSTRACT_CLASS,
CompileTimeErrorCode.instantiateAbstractClass,
);
}
} else if (typeArguments != null) {
_resolver.diagnosticReporter.atNode(
typeArguments,
CompileTimeErrorCode
.WRONG_NUMBER_OF_TYPE_ARGUMENTS_DOT_SHORTHAND_CONSTRUCTOR,
.wrongNumberOfTypeArgumentsDotShorthandConstructor,
arguments: [
dotShorthandContextType.getDisplayString(),
node.constructorName.name,
@@ -115,7 +115,7 @@ class InstanceCreationExpressionResolver {
} else {
_resolver.diagnosticReporter.atNode(
node,
CompileTimeErrorCode.DOT_SHORTHAND_MISSING_CONTEXT,
CompileTimeErrorCode.dotShorthandMissingContext,
);
}
@@ -88,7 +88,7 @@ class AnnotationInferrer extends FullInvocationInferrer<AnnotationImpl> {
@override
DiagnosticCode get _wrongNumberOfTypeArgumentsErrorCode =>
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS;
CompileTimeErrorCode.wrongNumberOfTypeArguments;
@override
List<FormalParameterElement>? _storeResult(
@@ -197,7 +197,7 @@ abstract class FullInvocationInferrer<Node extends AstNodeImpl>
TypeArgumentListImpl? get _typeArguments;
DiagnosticCode get _wrongNumberOfTypeArgumentsErrorCode =>
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_METHOD;
CompileTimeErrorCode.wrongNumberOfTypeArgumentsMethod;
@override
DartType resolveInvocation({required FunctionTypeImpl? rawType}) {
@@ -252,7 +252,7 @@ abstract class FullInvocationInferrer<Node extends AstNodeImpl>
if (!resolver.typeSystem.isSubtypeOf(typeArgument, bound)) {
resolver.diagnosticReporter.atNode(
typeArgumentList.arguments[i],
CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS,
CompileTimeErrorCode.typeArgumentNotMatchingBounds,
arguments: [typeArgument, typeParameter.name!, bound],
);
}
@@ -26,7 +26,7 @@ class ListPatternResolver {
if (length != 1) {
resolverVisitor.diagnosticReporter.atNode(
typeArguments,
CompileTimeErrorCode.EXPECTED_ONE_LIST_PATTERN_TYPE_ARGUMENTS,
CompileTimeErrorCode.expectedOneListPatternTypeArguments,
arguments: [length],
);
}
@@ -227,7 +227,7 @@ class MethodInvocationResolver with ScopeHelpers {
// of a function type).
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode.UNDEFINED_METHOD_ON_FUNCTION_TYPE,
CompileTimeErrorCode.undefinedMethodOnFunctionType,
arguments: [name, receiver.type.qualifiedName],
);
_setInvalidTypeResolution(
@@ -286,7 +286,7 @@ class MethodInvocationResolver with ScopeHelpers {
_resolver.diagnosticReporter.atNode(
node.memberName,
CompileTimeErrorCode.DOT_SHORTHAND_UNDEFINED_INVOCATION,
CompileTimeErrorCode.dotShorthandUndefinedInvocation,
arguments: [node.memberName.name, contextType.getDisplayString()],
);
_setInvalidTypeResolutionForDotShorthand(
@@ -321,14 +321,13 @@ class MethodInvocationResolver with ScopeHelpers {
if (_resolver.enclosingExtension != null) {
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode
.UNQUALIFIED_REFERENCE_TO_STATIC_MEMBER_OF_EXTENDED_TYPE,
CompileTimeErrorCode.unqualifiedReferenceToStaticMemberOfExtendedType,
arguments: [enclosingElement.displayString()],
);
} else {
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode.UNQUALIFIED_REFERENCE_TO_NON_LOCAL_STATIC_MEMBER,
CompileTimeErrorCode.unqualifiedReferenceToNonLocalStaticMember,
arguments: [enclosingElement.displayString()],
);
}
@@ -336,8 +335,7 @@ class MethodInvocationResolver with ScopeHelpers {
enclosingElement.name == null) {
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode
.INSTANCE_ACCESS_TO_STATIC_MEMBER_OF_UNNAMED_EXTENSION,
CompileTimeErrorCode.instanceAccessToStaticMemberOfUnnamedExtension,
arguments: [nameNode.name, element.kind.displayName],
);
} else {
@@ -345,7 +343,7 @@ class MethodInvocationResolver with ScopeHelpers {
// it can only be `null` for extensions, and we handle that case above.
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode.INSTANCE_ACCESS_TO_STATIC_MEMBER,
CompileTimeErrorCode.instanceAccessToStaticMember,
arguments: [
nameNode.name,
element.kind.displayName,
@@ -361,7 +359,7 @@ class MethodInvocationResolver with ScopeHelpers {
void _reportInvocationOfNonFunction(SimpleIdentifierImpl methodName) {
_resolver.diagnosticReporter.atNode(
methodName,
CompileTimeErrorCode.INVOCATION_OF_NON_FUNCTION,
CompileTimeErrorCode.invocationOfNonFunction,
arguments: [methodName.name],
);
}
@@ -369,7 +367,7 @@ class MethodInvocationResolver with ScopeHelpers {
void _reportPrefixIdentifierNotFollowedByDot(SimpleIdentifier target) {
_resolver.diagnosticReporter.atNode(
target,
CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT,
CompileTimeErrorCode.prefixIdentifierNotFollowedByDot,
arguments: [target.name],
);
}
@@ -381,7 +379,7 @@ class MethodInvocationResolver with ScopeHelpers {
if (!element.isStatic) {
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode.STATIC_ACCESS_TO_INSTANCE_MEMBER,
CompileTimeErrorCode.staticAccessToInstanceMember,
arguments: [nameNode.name],
);
}
@@ -406,7 +404,7 @@ class MethodInvocationResolver with ScopeHelpers {
_resolver.diagnosticReporter.atNode(
node.methodName,
CompileTimeErrorCode.UNDEFINED_FUNCTION,
CompileTimeErrorCode.undefinedFunction,
arguments: [node.methodName.name],
);
}
@@ -420,7 +418,7 @@ class MethodInvocationResolver with ScopeHelpers {
if (_resolver.isConstructorTearoffsEnabled) {
_resolver.diagnosticReporter.atNode(
methodName,
CompileTimeErrorCode.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT,
CompileTimeErrorCode.newWithUndefinedConstructorDefault,
arguments: [receiver.displayName],
);
} else {
@@ -430,7 +428,7 @@ class MethodInvocationResolver with ScopeHelpers {
} else {
_resolver.diagnosticReporter.atNode(
methodName,
CompileTimeErrorCode.UNDEFINED_METHOD,
CompileTimeErrorCode.undefinedMethod,
arguments: [methodName.name, receiver.displayName],
);
}
@@ -439,7 +437,7 @@ class MethodInvocationResolver with ScopeHelpers {
void _reportUseOfVoidType(AstNode errorNode) {
_resolver.diagnosticReporter.atNode(
errorNode,
CompileTimeErrorCode.USE_OF_VOID_RESULT,
CompileTimeErrorCode.useOfVoidResult,
);
}
@@ -546,7 +544,7 @@ class MethodInvocationResolver with ScopeHelpers {
// `extension.name` is non-`null`.
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode.UNDEFINED_EXTENSION_METHOD,
CompileTimeErrorCode.undefinedExtensionMethod,
arguments: [name, extension.name!],
);
return null;
@@ -578,7 +576,7 @@ class MethodInvocationResolver with ScopeHelpers {
// assume `override.staticElement!.name` is non-`null`.
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode.UNDEFINED_EXTENSION_METHOD,
CompileTimeErrorCode.undefinedExtensionMethod,
arguments: [name, override.element.name!],
);
return null;
@@ -587,7 +585,7 @@ class MethodInvocationResolver with ScopeHelpers {
if (member.isStatic) {
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode.EXTENSION_OVERRIDE_ACCESS_TO_STATIC_MEMBER,
CompileTimeErrorCode.extensionOverrideAccessToStaticMember,
);
}
@@ -595,7 +593,7 @@ class MethodInvocationResolver with ScopeHelpers {
// Report this error and recover by treating it like a non-cascade.
_resolver.diagnosticReporter.atToken(
override.name,
CompileTimeErrorCode.EXTENSION_OVERRIDE_WITH_CASCADE,
CompileTimeErrorCode.extensionOverrideWithCascade,
);
}
@@ -723,7 +721,7 @@ class MethodInvocationResolver with ScopeHelpers {
_resolver.diagnosticReporter.atNode(
receiver,
WarningCode.RECEIVER_OF_TYPE_NEVER,
WarningCode.receiverOfTypeNever,
);
node.methodName.setPseudoExpressionStaticType(_dynamicType);
@@ -856,7 +854,7 @@ class MethodInvocationResolver with ScopeHelpers {
};
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode.UNDEFINED_METHOD,
CompileTimeErrorCode.undefinedMethod,
arguments: [name, receiverTypeName],
);
return null;
@@ -1027,7 +1025,7 @@ class MethodInvocationResolver with ScopeHelpers {
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode.ABSTRACT_SUPER_MEMBER_REFERENCE,
CompileTimeErrorCode.abstractSuperMemberReference,
arguments: [target.kind.displayName, name],
);
return null;
@@ -1041,7 +1039,7 @@ class MethodInvocationResolver with ScopeHelpers {
);
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode.UNDEFINED_SUPER_METHOD,
CompileTimeErrorCode.undefinedSuperMethod,
arguments: [name, enclosingClass.firstFragment.displayName],
);
return null;
@@ -1165,7 +1163,7 @@ class MethodInvocationResolver with ScopeHelpers {
if (!nameNode.isSynthetic) {
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode.UNDEFINED_METHOD,
CompileTimeErrorCode.undefinedMethod,
arguments: [name, receiverClassName],
);
}
@@ -1271,7 +1269,7 @@ class MethodInvocationResolver with ScopeHelpers {
} else {
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode.DOT_SHORTHAND_UNDEFINED_INVOCATION,
CompileTimeErrorCode.dotShorthandUndefinedInvocation,
arguments: [nameNode.name, receiver.displayName],
);
_setInvalidTypeResolutionForDotShorthand(
@@ -1305,7 +1303,7 @@ class MethodInvocationResolver with ScopeHelpers {
_resolver.diagnosticReporter.atNode(
nameNode,
CompileTimeErrorCode.DOT_SHORTHAND_UNDEFINED_INVOCATION,
CompileTimeErrorCode.dotShorthandUndefinedInvocation,
arguments: [nameNode.name, receiver.displayName],
);
_setInvalidTypeResolutionForDotShorthand(

Some files were not shown because too many files have changed in this diff Show More