diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart index 7ad067a2adc..89a85924e1f 100644 --- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart +++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart @@ -1381,24 +1381,9 @@ class FixProcessor extends BaseProcessor { HintCode.DIVISION_OPTIMIZATION: [ UseEffectiveIntegerDivision.new, ], - HintCode.UNNECESSARY_CAST: [ - RemoveUnnecessaryCast.new, - ], - HintCode.UNNECESSARY_FINAL: [ - RemoveUnnecessaryFinal.new, - ], HintCode.UNNECESSARY_IMPORT: [ RemoveUnusedImport.new, ], - HintCode.UNREACHABLE_SWITCH_CASE: [ - RemoveDeadCode.new, - ], - HintCode.UNUSED_ELEMENT: [ - RemoveUnusedElement.new, - ], - HintCode.UNUSED_ELEMENT_PARAMETER: [ - RemoveUnusedParameter.new, - ], ParserErrorCode.ABSTRACT_CLASS_MEMBER: [ RemoveAbstract.bulkFixable, ], @@ -1616,6 +1601,12 @@ class FixProcessor extends BaseProcessor { WarningCode.UNDEFINED_SHOWN_NAME: [ RemoveNameFromCombinator.new, ], + WarningCode.UNNECESSARY_CAST: [ + RemoveUnnecessaryCast.new, + ], + WarningCode.UNNECESSARY_FINAL: [ + RemoveUnnecessaryFinal.new, + ], WarningCode.UNNECESSARY_NAN_COMPARISON_FALSE: [ RemoveComparison.new, ReplaceWithIsNan.new, @@ -1645,12 +1636,21 @@ class FixProcessor extends BaseProcessor { WarningCode.UNNECESSARY_WILDCARD_PATTERN: [ RemoveUnnecessaryWildcardPattern.new, ], + WarningCode.UNREACHABLE_SWITCH_CASE: [ + RemoveDeadCode.new, + ], WarningCode.UNUSED_CATCH_CLAUSE: [ RemoveUnusedCatchClause.new, ], WarningCode.UNUSED_CATCH_STACK: [ RemoveUnusedCatchStack.new, ], + WarningCode.UNUSED_ELEMENT: [ + RemoveUnusedElement.new, + ], + WarningCode.UNUSED_ELEMENT_PARAMETER: [ + RemoveUnusedParameter.new, + ], WarningCode.UNUSED_FIELD: [ RemoveUnusedField.new, ], diff --git a/pkg/analysis_server/test/abstract_single_unit.dart b/pkg/analysis_server/test/abstract_single_unit.dart index f6304dd7d5b..7ca6d2f3412 100644 --- a/pkg/analysis_server/test/abstract_single_unit.dart +++ b/pkg/analysis_server/test/abstract_single_unit.dart @@ -7,7 +7,6 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/error/error.dart'; import 'package:analyzer/file_system/file_system.dart'; -import 'package:analyzer/src/dart/error/hint_codes.dart'; import 'package:analyzer/src/error/codes.g.dart'; import 'package:analyzer/src/test_utilities/find_element.dart'; import 'package:analyzer/src/test_utilities/find_node.dart'; @@ -74,7 +73,7 @@ class AbstractSingleUnitTest extends AbstractContextTest { return error.errorCode != WarningCode.DEAD_CODE && error.errorCode != WarningCode.UNUSED_CATCH_CLAUSE && error.errorCode != WarningCode.UNUSED_CATCH_STACK && - error.errorCode != HintCode.UNUSED_ELEMENT && + error.errorCode != WarningCode.UNUSED_ELEMENT && error.errorCode != WarningCode.UNUSED_FIELD && error.errorCode != WarningCode.UNUSED_IMPORT && error.errorCode != WarningCode.UNUSED_LOCAL_VARIABLE; diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_cast_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_cast_test.dart index 24cb208bb03..f57e734fa7e 100644 --- a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_cast_test.dart +++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_cast_test.dart @@ -57,7 +57,7 @@ void f(Object p, Object q) { } } '''); - await assertHasFixAllFix(HintCode.UNNECESSARY_CAST, ''' + await assertHasFixAllFix(WarningCode.UNNECESSARY_CAST, ''' void f(Object p, Object q) { if (p is String) { var v = p; diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_final_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_final_test.dart index 70f9035f961..f7feb5f2fd9 100644 --- a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_final_test.dart +++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_final_test.dart @@ -54,7 +54,7 @@ class A { int v2; } '''); - await assertHasFixAllFix(HintCode.UNNECESSARY_FINAL, ''' + await assertHasFixAllFix(WarningCode.UNNECESSARY_FINAL, ''' class A { A(this.v1, this.v2); int v1; diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_element_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_element_test.dart index 4c86e8219b4..3fea18e95c7 100644 --- a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_element_test.dart +++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_element_test.dart @@ -61,7 +61,7 @@ enum _MyEnum {A, B, C} '''); await assertHasFix(r''' ''', errorFilter: (AnalysisError error) { - return error.errorCode == HintCode.UNUSED_ELEMENT; + return error.errorCode == WarningCode.UNUSED_ELEMENT; }); } diff --git a/pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart b/pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart index f3881936103..d1d1e49e8ed 100644 --- a/pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart +++ b/pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart @@ -11,6 +11,10 @@ // code, as they match names declared in the source configuration files. // ignore_for_file: constant_identifier_names +// While transitioning `HintCodes` to `WarningCodes`, we refer to deprecated +// codes here. +// ignore_for_file: deprecated_member_use_from_same_package + import "package:analyzer/error/error.dart"; class AnalysisOptionsErrorCode extends ErrorCode { diff --git a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart index a70bc22d1be..b26128fc648 100644 --- a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart +++ b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart @@ -826,7 +826,7 @@ class ConstantVerifier extends RecursiveAstVisitor { throw UnimplementedError('(${caseNode.runtimeType}) $caseNode'); } _errorReporter.reportErrorForToken( - HintCode.UNREACHABLE_SWITCH_CASE, + WarningCode.UNREACHABLE_SWITCH_CASE, errorToken, ); } else if (error is NonExhaustiveError && reportNonExhaustive) { diff --git a/pkg/analyzer/lib/src/dart/error/ffi_code.g.dart b/pkg/analyzer/lib/src/dart/error/ffi_code.g.dart index a148aa5588d..847e5b58174 100644 --- a/pkg/analyzer/lib/src/dart/error/ffi_code.g.dart +++ b/pkg/analyzer/lib/src/dart/error/ffi_code.g.dart @@ -11,6 +11,10 @@ // code, as they match names declared in the source configuration files. // ignore_for_file: constant_identifier_names +// While transitioning `HintCodes` to `WarningCodes`, we refer to deprecated +// codes here. +// ignore_for_file: deprecated_member_use_from_same_package + import "package:analyzer/error/error.dart"; import "package:analyzer/src/error/analyzer_error_code.dart"; diff --git a/pkg/analyzer/lib/src/dart/error/hint_codes.g.dart b/pkg/analyzer/lib/src/dart/error/hint_codes.g.dart index 99046678310..1c1a7d1c597 100644 --- a/pkg/analyzer/lib/src/dart/error/hint_codes.g.dart +++ b/pkg/analyzer/lib/src/dart/error/hint_codes.g.dart @@ -11,6 +11,10 @@ // code, as they match names declared in the source configuration files. // ignore_for_file: constant_identifier_names +// While transitioning `HintCodes` to `WarningCodes`, we refer to deprecated +// codes here. +// ignore_for_file: deprecated_member_use_from_same_package + import "package:analyzer/error/error.dart"; import "package:analyzer/src/error/analyzer_error_code.dart"; import "package:analyzer/src/error/codes.g.dart"; @@ -144,6 +148,7 @@ class HintCode extends AnalyzerErrorCode { ); /// No parameters. + @Deprecated("Use 'WarningCode.UNNECESSARY_CAST' instead.") static const HintCode UNNECESSARY_CAST = HintCode( 'UNNECESSARY_CAST', "Unnecessary cast.", @@ -152,6 +157,7 @@ class HintCode extends AnalyzerErrorCode { ); /// No parameters. + @Deprecated("Use 'WarningCode.UNNECESSARY_FINAL' instead.") static const HintCode UNNECESSARY_FINAL = HintCode( 'UNNECESSARY_FINAL', "The keyword 'final' isn't necessary because the parameter is implicitly " @@ -183,6 +189,7 @@ class HintCode extends AnalyzerErrorCode { ); /// No parameters. + @Deprecated("Use 'WarningCode.UNREACHABLE_SWITCH_CASE' instead.") static const HintCode UNREACHABLE_SWITCH_CASE = HintCode( 'UNREACHABLE_SWITCH_CASE', "This case is covered by the previous cases.", @@ -194,6 +201,7 @@ class HintCode extends AnalyzerErrorCode { /// Parameters: /// 0: the name that is declared but not referenced + @Deprecated("Use 'WarningCode.UNUSED_ELEMENT' instead.") static const HintCode UNUSED_ELEMENT = HintCode( 'UNUSED_ELEMENT', "The declaration '{0}' isn't referenced.", @@ -203,6 +211,7 @@ class HintCode extends AnalyzerErrorCode { /// Parameters: /// 0: the name of the parameter that is declared but not used + @Deprecated("Use 'WarningCode.UNUSED_ELEMENT_PARAMETER' instead.") static const HintCode UNUSED_ELEMENT_PARAMETER = HintCode( 'UNUSED_ELEMENT', "A value for optional parameter '{0}' isn't ever given.", diff --git a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart index b0b5512ff91..75d97547eea 100644 --- a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart +++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart @@ -11,6 +11,10 @@ // code, as they match names declared in the source configuration files. // ignore_for_file: constant_identifier_names +// While transitioning `HintCodes` to `WarningCodes`, we refer to deprecated +// codes here. +// ignore_for_file: deprecated_member_use_from_same_package + import "package:analyzer/error/error.dart"; final fastaAnalyzerErrorCodes = [ diff --git a/pkg/analyzer/lib/src/error/best_practices_verifier.dart b/pkg/analyzer/lib/src/error/best_practices_verifier.dart index b7153c23706..0094627706b 100644 --- a/pkg/analyzer/lib/src/error/best_practices_verifier.dart +++ b/pkg/analyzer/lib/src/error/best_practices_verifier.dart @@ -146,7 +146,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor { @override void visitAsExpression(AsExpression node) { if (isUnnecessaryCast(node, _typeSystem)) { - _errorReporter.reportErrorForNode(HintCode.UNNECESSARY_CAST, node); + _errorReporter.reportErrorForNode(WarningCode.UNNECESSARY_CAST, node); } var type = node.type.type; if (_isNonNullableByDefault && @@ -794,7 +794,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor { void _checkFinalParameter(FormalParameter node, Token? keyword) { if (node.isFinal) { _errorReporter.reportErrorForToken( - HintCode.UNNECESSARY_FINAL, + WarningCode.UNNECESSARY_FINAL, keyword!, ); } @@ -1588,11 +1588,11 @@ class BestPracticesVerifier extends RecursiveAstVisitor { return _workspacePackage!.contains(library.source); } - /// Checks for the passed as expression for the [HintCode.UNNECESSARY_CAST] + /// Checks for the passed as expression for the [WarningCode.UNNECESSARY_CAST] /// hint code. /// /// Returns `true` if and only if an unnecessary cast hint should be generated - /// on [node]. See [HintCode.UNNECESSARY_CAST]. + /// on [node]. See [WarningCode.UNNECESSARY_CAST]. static bool isUnnecessaryCast(AsExpression node, TypeSystemImpl typeSystem) { var leftType = node.expression.typeOrThrow; var rightType = node.type.typeOrThrow; diff --git a/pkg/analyzer/lib/src/error/codes.g.dart b/pkg/analyzer/lib/src/error/codes.g.dart index ff751b160e0..24381a51a36 100644 --- a/pkg/analyzer/lib/src/error/codes.g.dart +++ b/pkg/analyzer/lib/src/error/codes.g.dart @@ -11,6 +11,10 @@ // code, as they match names declared in the source configuration files. // ignore_for_file: constant_identifier_names +// While transitioning `HintCodes` to `WarningCodes`, we refer to deprecated +// codes here. +// ignore_for_file: deprecated_member_use_from_same_package + import "package:analyzer/error/error.dart"; import "package:analyzer/src/dart/error/hint_codes.g.dart"; import "package:analyzer/src/error/analyzer_error_code.dart"; diff --git a/pkg/analyzer/lib/src/error/error_code_values.g.dart b/pkg/analyzer/lib/src/error/error_code_values.g.dart index 2a7da875f07..bdd3508cbd0 100644 --- a/pkg/analyzer/lib/src/error/error_code_values.g.dart +++ b/pkg/analyzer/lib/src/error/error_code_values.g.dart @@ -11,6 +11,10 @@ // code, as they match names declared in the source configuration files. // ignore_for_file: constant_identifier_names +// While transitioning `HintCodes` to `WarningCodes`, we refer to deprecated +// codes here. +// ignore_for_file: deprecated_member_use_from_same_package + import 'package:_fe_analyzer_shared/src/base/errors.dart'; import 'package:_fe_analyzer_shared/src/scanner/errors.dart'; import 'package:analyzer/src/dart/error/ffi_code.dart'; diff --git a/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart b/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart index 148edeb3d15..96acc160e29 100644 --- a/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart +++ b/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart @@ -549,8 +549,8 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor { void visitFormalParameterList(FormalParameterList node) { for (var element in node.parameterElements) { if (!_isUsedElement(element!)) { - _reportErrorForElement( - HintCode.UNUSED_ELEMENT_PARAMETER, element, [element.displayName]); + _reportErrorForElement(WarningCode.UNUSED_ELEMENT_PARAMETER, element, + [element.displayName]); } } super.visitFormalParameterList(node); @@ -890,7 +890,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor { void _visitClassElement(InterfaceElement element) { if (!_isUsedElement(element)) { _reportErrorForElement( - HintCode.UNUSED_ELEMENT, element, [element.displayName]); + WarningCode.UNUSED_ELEMENT, element, [element.displayName]); } } @@ -902,7 +902,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor { if (element.enclosingElement.constructors.length > 1 && !_isUsedMember(element)) { _reportErrorForElement( - HintCode.UNUSED_ELEMENT, element, [element.displayName]); + WarningCode.UNUSED_ELEMENT, element, [element.displayName]); } } @@ -916,7 +916,7 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor { void _visitFunctionElement(FunctionElement element) { if (!_isUsedElement(element)) { _reportErrorForElement( - HintCode.UNUSED_ELEMENT, element, [element.displayName]); + WarningCode.UNUSED_ELEMENT, element, [element.displayName]); } } @@ -937,28 +937,28 @@ class UnusedLocalElementsVerifier extends RecursiveAstVisitor { void _visitMethodElement(MethodElement element) { if (!_isUsedMember(element)) { _reportErrorForElement( - HintCode.UNUSED_ELEMENT, element, [element.displayName]); + WarningCode.UNUSED_ELEMENT, element, [element.displayName]); } } void _visitPropertyAccessorElement(PropertyAccessorElement element) { if (!_isUsedMember(element)) { _reportErrorForElement( - HintCode.UNUSED_ELEMENT, element, [element.displayName]); + WarningCode.UNUSED_ELEMENT, element, [element.displayName]); } } void _visitTopLevelVariableElement(TopLevelVariableElement element) { if (!_isUsedElement(element)) { _reportErrorForElement( - HintCode.UNUSED_ELEMENT, element, [element.displayName]); + WarningCode.UNUSED_ELEMENT, element, [element.displayName]); } } void _visitTypeAliasElement(TypeAliasElement element) { if (!_isUsedElement(element)) { _reportErrorForElement( - HintCode.UNUSED_ELEMENT, element, [element.displayName]); + WarningCode.UNUSED_ELEMENT, element, [element.displayName]); } } diff --git a/pkg/analyzer/lib/src/manifest/manifest_warning_code.g.dart b/pkg/analyzer/lib/src/manifest/manifest_warning_code.g.dart index d9627e5abe9..d1c9c89cf0c 100644 --- a/pkg/analyzer/lib/src/manifest/manifest_warning_code.g.dart +++ b/pkg/analyzer/lib/src/manifest/manifest_warning_code.g.dart @@ -11,6 +11,10 @@ // code, as they match names declared in the source configuration files. // ignore_for_file: constant_identifier_names +// While transitioning `HintCodes` to `WarningCodes`, we refer to deprecated +// codes here. +// ignore_for_file: deprecated_member_use_from_same_package + import "package:analyzer/error/error.dart"; class ManifestWarningCode extends ErrorCode { diff --git a/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.g.dart b/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.g.dart index 152b0e369f7..5602fc99390 100644 --- a/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.g.dart +++ b/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.g.dart @@ -11,6 +11,10 @@ // code, as they match names declared in the source configuration files. // ignore_for_file: constant_identifier_names +// While transitioning `HintCodes` to `WarningCodes`, we refer to deprecated +// codes here. +// ignore_for_file: deprecated_member_use_from_same_package + import "package:analyzer/error/error.dart"; class PubspecWarningCode extends ErrorCode { diff --git a/pkg/analyzer/messages.yaml b/pkg/analyzer/messages.yaml index 9af8ac863a2..ff9acfab073 100644 --- a/pkg/analyzer/messages.yaml +++ b/pkg/analyzer/messages.yaml @@ -19786,6 +19786,7 @@ HintCode: UNNECESSARY_CAST: problemMessage: Unnecessary cast. correctionMessage: Try removing the cast. + deprecatedMessage: Use 'WarningCode.UNNECESSARY_CAST' instead. hasPublishedDocs: true comment: No parameters. documentation: |- @@ -19821,6 +19822,7 @@ HintCode: UNNECESSARY_FINAL: problemMessage: The keyword 'final' isn't necessary because the parameter is implicitly 'final'. correctionMessage: Try removing the 'final'. + deprecatedMessage: Use 'WarningCode.UNNECESSARY_FINAL' instead. hasPublishedDocs: true comment: No parameters. documentation: |- @@ -19930,6 +19932,7 @@ HintCode: UNREACHABLE_SWITCH_CASE: problemMessage: "This case is covered by the previous cases." correctionMessage: Try removing the case clause, or restructuring the preceding patterns. + deprecatedMessage: Use 'WarningCode.UNREACHABLE_SWITCH_CASE' instead. hasPublishedDocs: true comment: No parameters. documentation: |- @@ -19972,6 +19975,7 @@ HintCode: UNUSED_ELEMENT: problemMessage: "The declaration '{0}' isn't referenced." correctionMessage: "Try removing the declaration of '{0}'." + deprecatedMessage: Use 'WarningCode.UNUSED_ELEMENT' instead. hasPublishedDocs: true comment: |- Parameters: @@ -20034,6 +20038,7 @@ HintCode: sharedName: UNUSED_ELEMENT problemMessage: "A value for optional parameter '{0}' isn't ever given." correctionMessage: Try removing the unused parameter. + deprecatedMessage: Use 'WarningCode.UNUSED_ELEMENT_PARAMETER' instead. hasPublishedDocs: true comment: |- Parameters: diff --git a/pkg/analyzer/test/generated/error_suppression_test.dart b/pkg/analyzer/test/generated/error_suppression_test.dart index 01bcf82ef6e..ee6c983d790 100644 --- a/pkg/analyzer/test/generated/error_suppression_test.dart +++ b/pkg/analyzer/test/generated/error_suppression_test.dart @@ -39,7 +39,7 @@ int x = ''; int _y = 0; //INVALID_ASSIGNMENT ''', [ error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 34, 2), - error(HintCode.UNUSED_ELEMENT, 42, 2), + error(WarningCode.UNUSED_ELEMENT, 42, 2), ]); } @@ -98,7 +98,7 @@ int x = (0 as int); // ignore: unused_element String _foo = ''; //UNUSED_ELEMENT ''', [ - error(HintCode.UNNECESSARY_CAST, 28, 8), + error(WarningCode.UNNECESSARY_CAST, 28, 8), ]); } @@ -108,7 +108,7 @@ String _foo = ''; //UNUSED_ELEMENT int x = (0 as int); String _foo = ''; // ignore: $ignoredCode ''', [ - error(HintCode.UNNECESSARY_CAST, 28, 8), + error(WarningCode.UNNECESSARY_CAST, 28, 8), ]); } @@ -169,7 +169,7 @@ int x = (0 as int); //This is the first comment... // ignore: $ignoredCode String _foo = ''; //UNUSED_ELEMENT ''', [ - error(HintCode.UNNECESSARY_CAST, 9, 8), + error(WarningCode.UNNECESSARY_CAST, 9, 8), ]); } @@ -236,7 +236,7 @@ const y = x; //CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE int x = (0 as int); // ignore: unnecessary_cast int y = (0 as int); ''', [ - error(HintCode.UNNECESSARY_CAST, 57, 8), + error(WarningCode.UNNECESSARY_CAST, 57, 8), ]); } @@ -261,7 +261,7 @@ void f(arg1(int)) {} // AVOID_TYPES_AS_PARAMETER_NAMES // ignore: type=lint int _x = 1; ''', [ - error(HintCode.UNUSED_ELEMENT, 25, 2), + error(WarningCode.UNUSED_ELEMENT, 25, 2), ]); } @@ -292,7 +292,7 @@ void f(arg1(int)) {} // AVOID_TYPES_AS_PARAMETER_NAMES int a = 0; int _x = 1; ''', [ - error(HintCode.UNUSED_ELEMENT, 45, 2), + error(WarningCode.UNUSED_ELEMENT, 45, 2), ]); } diff --git a/pkg/analyzer/test/generated/non_error_resolver_test.dart b/pkg/analyzer/test/generated/non_error_resolver_test.dart index b402d136e53..3ee71a16eb5 100644 --- a/pkg/analyzer/test/generated/non_error_resolver_test.dart +++ b/pkg/analyzer/test/generated/non_error_resolver_test.dart @@ -1837,7 +1837,7 @@ class B extends A { _m() {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 41, 2), + error(WarningCode.UNUSED_ELEMENT, 41, 2), ]); } @@ -1854,7 +1854,7 @@ class B extends A { _m() {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 41, 2), + error(WarningCode.UNUSED_ELEMENT, 41, 2), ]); } @@ -2877,7 +2877,7 @@ f() { } h(x) {} ''', [ - error(HintCode.UNUSED_ELEMENT, 8, 1), + error(WarningCode.UNUSED_ELEMENT, 8, 1), ]); } @@ -3099,7 +3099,7 @@ main() { }; } ''', [ - error(HintCode.UNUSED_ELEMENT, 11, 1), + error(WarningCode.UNUSED_ELEMENT, 11, 1), ]); } diff --git a/pkg/analyzer/test/generated/static_type_warning_code_test.dart b/pkg/analyzer/test/generated/static_type_warning_code_test.dart index e548423582b..143c47ec1fa 100644 --- a/pkg/analyzer/test/generated/static_type_warning_code_test.dart +++ b/pkg/analyzer/test/generated/static_type_warning_code_test.dart @@ -577,7 +577,7 @@ g(Object p) { } ''', [ error(CompileTimeErrorCode.UNDEFINED_GETTER, 41, 6), - error(HintCode.UNUSED_ELEMENT, 55, 1), + error(WarningCode.UNUSED_ELEMENT, 55, 1), ]); } } diff --git a/pkg/analyzer/test/generated/strong_mode_test.dart b/pkg/analyzer/test/generated/strong_mode_test.dart index 73e81b6a69f..676d5b77e6a 100644 --- a/pkg/analyzer/test/generated/strong_mode_test.dart +++ b/pkg/analyzer/test/generated/strong_mode_test.dart @@ -428,7 +428,7 @@ mixin StrongModeLocalInferenceTestCases on PubPackageResolutionTest { } '''; await assertErrorsInCode(code, [ - error(HintCode.UNUSED_ELEMENT, 144, 5), + error(WarningCode.UNUSED_ELEMENT, 144, 5), ]); Asserter assertListOfInt = _isListOf(_isInt); @@ -1527,7 +1527,7 @@ void _mergeSort(T Function(T) list, int compare(T a, T b), T Function(T) targ } '''; await assertErrorsInCode(code, [ - error(HintCode.UNUSED_ELEMENT, 5, 10), + error(WarningCode.UNUSED_ELEMENT, 5, 10), ]); final node = findNode.singleBlock; @@ -1849,7 +1849,7 @@ void _mergeSort(List list, int compare(T a, T b), List target) { } '''; await assertErrorsInCode(code, [ - error(HintCode.UNUSED_ELEMENT, 5, 10), + error(WarningCode.UNUSED_ELEMENT, 5, 10), ]); final node = findNode.singleBlock; @@ -2171,7 +2171,7 @@ void _mergeSort(T list, int compare(T a, T b), T target) { } '''; await assertErrorsInCode(code, [ - error(HintCode.UNUSED_ELEMENT, 5, 10), + error(WarningCode.UNUSED_ELEMENT, 5, 10), ]); final node = findNode.singleBlock; @@ -5473,7 +5473,7 @@ S f(S x) { return null; } ''', [ - error(HintCode.UNUSED_ELEMENT, 16, 1), + error(WarningCode.UNUSED_ELEMENT, 16, 1), if (isNullSafetyEnabled) error(CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_FUNCTION, 41, 4), ]); diff --git a/pkg/analyzer/test/src/dart/resolution/function_declaration_statement_test.dart b/pkg/analyzer/test/src/dart/resolution/function_declaration_statement_test.dart index f2b4e59d657..e37125160a3 100644 --- a/pkg/analyzer/test/src/dart/resolution/function_declaration_statement_test.dart +++ b/pkg/analyzer/test/src/dart/resolution/function_declaration_statement_test.dart @@ -22,7 +22,7 @@ void f() { T g(T a, U b) => a; } ''', [ - error(HintCode.UNUSED_ELEMENT, 15, 1), + error(WarningCode.UNUSED_ELEMENT, 15, 1), ]); final node = findNode.singleFunctionDeclarationStatement; @@ -91,7 +91,7 @@ void f() { void g(T x, U y, V z) {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 18, 1), + error(WarningCode.UNUSED_ELEMENT, 18, 1), ]); final node = findNode.singleFunctionDeclarationStatement; @@ -184,7 +184,7 @@ void f() { void g({T? a}) {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 18, 1), + error(WarningCode.UNUSED_ELEMENT, 18, 1), ]); final node = findNode.singleFunctionDeclarationStatement; @@ -243,7 +243,7 @@ void f() { void g([T? a]) {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 18, 1), + error(WarningCode.UNUSED_ELEMENT, 18, 1), ]); final node = findNode.singleFunctionDeclarationStatement; @@ -302,7 +302,7 @@ void f() { void g({required T? a}) {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 18, 1), + error(WarningCode.UNUSED_ELEMENT, 18, 1), ]); final node = findNode.singleFunctionDeclarationStatement; @@ -362,7 +362,7 @@ void f() { void g(T a) {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 18, 1), + error(WarningCode.UNUSED_ELEMENT, 18, 1), ]); final node = findNode.singleFunctionDeclarationStatement; @@ -415,7 +415,7 @@ void f() { g() {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 13, 1), + error(WarningCode.UNUSED_ELEMENT, 13, 1), ]); final node = findNode.singleFunctionDeclarationStatement; @@ -445,7 +445,7 @@ void f() { g() => 0; } ''', [ - error(HintCode.UNUSED_ELEMENT, 13, 1), + error(WarningCode.UNUSED_ELEMENT, 13, 1), ]); final node = findNode.singleFunctionDeclarationStatement; diff --git a/pkg/analyzer/test/src/dart/resolution/function_reference_test.dart b/pkg/analyzer/test/src/dart/resolution/function_reference_test.dart index 8a1c748a817..9cafdd8ae07 100644 --- a/pkg/analyzer/test/src/dart/resolution/function_reference_test.dart +++ b/pkg/analyzer/test/src/dart/resolution/function_reference_test.dart @@ -864,7 +864,7 @@ extension on double { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 24, 3), + error(WarningCode.UNUSED_ELEMENT, 24, 3), error(CompileTimeErrorCode.UNDEFINED_METHOD, 36, 3, messageContains: ["for the type 'double'"]), ]); diff --git a/pkg/analyzer/test/src/dart/resolution/local_function_test.dart b/pkg/analyzer/test/src/dart/resolution/local_function_test.dart index 72abcb131f4..2b803596c03 100644 --- a/pkg/analyzer/test/src/dart/resolution/local_function_test.dart +++ b/pkg/analyzer/test/src/dart/resolution/local_function_test.dart @@ -37,7 +37,7 @@ f() { g() {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 23, 1), + error(WarningCode.UNUSED_ELEMENT, 23, 1), ]); var node = findNode.functionDeclaration('g() {}'); var element = node.declaredElement!; diff --git a/pkg/analyzer/test/src/dart/resolution/non_nullable_test.dart b/pkg/analyzer/test/src/dart/resolution/non_nullable_test.dart index 164f5ae5a93..0556643933e 100644 --- a/pkg/analyzer/test/src/dart/resolution/non_nullable_test.dart +++ b/pkg/analyzer/test/src/dart/resolution/non_nullable_test.dart @@ -5,6 +5,7 @@ import 'package:analyzer/src/dart/element/type_system.dart'; import 'package:analyzer/src/dart/error/hint_codes.dart'; import 'package:analyzer/src/dart/error/syntactic_errors.dart'; +import 'package:analyzer/src/error/codes.g.dart'; import 'package:test/test.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; @@ -195,7 +196,7 @@ main() { f(int? a, int b) {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 11, 1), + error(WarningCode.UNUSED_ELEMENT, 11, 1), ]); assertType(findNode.namedType('int? a'), 'int?'); @@ -209,8 +210,8 @@ main() { int g() => 0; } ''', [ - error(HintCode.UNUSED_ELEMENT, 16, 1), - error(HintCode.UNUSED_ELEMENT, 32, 1), + error(WarningCode.UNUSED_ELEMENT, 16, 1), + error(WarningCode.UNUSED_ELEMENT, 32, 1), ]); assertType(findNode.namedType('int? f'), 'int?'); @@ -276,9 +277,9 @@ f() { void f3({void p3()?}) {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 13, 2), - error(HintCode.UNUSED_ELEMENT, 37, 2), - error(HintCode.UNUSED_ELEMENT, 62, 2), + error(WarningCode.UNUSED_ELEMENT, 13, 2), + error(WarningCode.UNUSED_ELEMENT, 37, 2), + error(WarningCode.UNUSED_ELEMENT, 62, 2), ]); assertType(findElement.parameter('p1').type, 'void Function()'); assertType(findElement.parameter('p2').type, 'void Function()?'); diff --git a/pkg/analyzer/test/src/dart/resolution/switch_statement_test.dart b/pkg/analyzer/test/src/dart/resolution/switch_statement_test.dart index 26214d333aa..d9c4d47c7f9 100644 --- a/pkg/analyzer/test/src/dart/resolution/switch_statement_test.dart +++ b/pkg/analyzer/test/src/dart/resolution/switch_statement_test.dart @@ -1110,7 +1110,7 @@ void f(Object? x) { } ''', [ error(WarningCode.DEAD_CODE, 55, 4), - error(HintCode.UNREACHABLE_SWITCH_CASE, 55, 4), + error(WarningCode.UNREACHABLE_SWITCH_CASE, 55, 4), error(WarningCode.DEAD_CODE, 71, 7), error(CompileTimeErrorCode.PATTERN_VARIABLE_SHARED_CASE_SCOPE_HAS_LABEL, 86, 1), diff --git a/pkg/analyzer/test/src/diagnostics/cast_from_null_always_fails_test.dart b/pkg/analyzer/test/src/diagnostics/cast_from_null_always_fails_test.dart index ba5bf85e848..5a4df9ec2b4 100644 --- a/pkg/analyzer/test/src/diagnostics/cast_from_null_always_fails_test.dart +++ b/pkg/analyzer/test/src/diagnostics/cast_from_null_always_fails_test.dart @@ -88,7 +88,7 @@ void f(Null n) { n as int?; } ''', [ - error(HintCode.UNNECESSARY_CAST, 19, 9), + error(WarningCode.UNNECESSARY_CAST, 19, 9), ]); } @@ -109,7 +109,7 @@ void f(Null n) { n as int; } ''', [ - error(HintCode.UNNECESSARY_CAST, 33, 8), + error(WarningCode.UNNECESSARY_CAST, 33, 8), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/dead_code_test.dart b/pkg/analyzer/test/src/diagnostics/dead_code_test.dart index 9f8747020bf..a312f428811 100644 --- a/pkg/analyzer/test/src/diagnostics/dead_code_test.dart +++ b/pkg/analyzer/test/src/diagnostics/dead_code_test.dart @@ -72,9 +72,9 @@ Object f(int x) { ''', [ error(WarningCode.DEAD_CODE, 50, 4), error(WarningCode.DEAD_CODE, 65, 10), - error(HintCode.UNREACHABLE_SWITCH_CASE, 71, 2), + error(WarningCode.UNREACHABLE_SWITCH_CASE, 71, 2), error(WarningCode.DEAD_CODE, 81, 6), - error(HintCode.UNREACHABLE_SWITCH_CASE, 83, 2), + error(WarningCode.UNREACHABLE_SWITCH_CASE, 83, 2), ]); } @@ -104,7 +104,7 @@ void f(int x) { ''', [ error(WarningCode.DEAD_CODE, 46, 4), error(WarningCode.DEAD_CODE, 56, 4), - error(HintCode.UNREACHABLE_SWITCH_CASE, 56, 4), + error(WarningCode.UNREACHABLE_SWITCH_CASE, 56, 4), error(WarningCode.DEAD_CODE, 68, 7), ]); } @@ -122,9 +122,9 @@ void f(int x) { ''', [ error(WarningCode.DEAD_CODE, 46, 5), error(WarningCode.DEAD_CODE, 57, 4), - error(HintCode.UNREACHABLE_SWITCH_CASE, 57, 4), + error(WarningCode.UNREACHABLE_SWITCH_CASE, 57, 4), error(WarningCode.DEAD_CODE, 78, 4), - error(HintCode.UNREACHABLE_SWITCH_CASE, 78, 4), + error(WarningCode.UNREACHABLE_SWITCH_CASE, 78, 4), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart b/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart index 3fd7c4b34b7..a766d617570 100644 --- a/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart +++ b/pkg/analyzer/test/src/diagnostics/duplicate_definition_test.dart @@ -1497,7 +1497,7 @@ Map _globalMap = { 'b' : () {} }; ''', [ - error(HintCode.UNUSED_ELEMENT, 4, 10), + error(WarningCode.UNUSED_ELEMENT, 4, 10), ]); } @@ -1568,7 +1568,7 @@ main() { }; } ''', [ - error(HintCode.UNUSED_ELEMENT, 11, 1), + error(WarningCode.UNUSED_ELEMENT, 11, 1), error(CompileTimeErrorCode.DUPLICATE_DEFINITION, 27, 1, contextMessages: [message('/home/test/lib/test.dart', 17, 1)]), ]); diff --git a/pkg/analyzer/test/src/diagnostics/extension_conflicting_static_and_instance_test.dart b/pkg/analyzer/test/src/diagnostics/extension_conflicting_static_and_instance_test.dart index d307fc7914f..d59010921e6 100644 --- a/pkg/analyzer/test/src/diagnostics/extension_conflicting_static_and_instance_test.dart +++ b/pkg/analyzer/test/src/diagnostics/extension_conflicting_static_and_instance_test.dart @@ -88,14 +88,12 @@ extension E on String { test_field_getter_unnamed() async { await assertErrorsInCode(''' -extension on String { +extension E on String { static int foo = 0; int get foo => 0; } ''', [ - error(WarningCode.UNUSED_FIELD, 35, 3), - error(_errorCode, 35, 3), - error(HintCode.UNUSED_ELEMENT, 54, 3), + error(_errorCode, 37, 3), ]); } @@ -134,14 +132,12 @@ extension E on String { test_getter_getter_unnamed() async { await assertErrorsInCode(''' -extension on String { +extension E on String { static int get foo => 0; int get foo => 0; } ''', [ - error(HintCode.UNUSED_ELEMENT, 39, 3), - error(_errorCode, 39, 3), - error(HintCode.UNUSED_ELEMENT, 59, 3), + error(_errorCode, 41, 3), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/extra_positional_arguments_test.dart b/pkg/analyzer/test/src/diagnostics/extra_positional_arguments_test.dart index e8ac6347475..f7ee2f98121 100644 --- a/pkg/analyzer/test/src/diagnostics/extra_positional_arguments_test.dart +++ b/pkg/analyzer/test/src/diagnostics/extra_positional_arguments_test.dart @@ -86,7 +86,7 @@ enum E { ''', [ error(CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS_COULD_BE_NAMED, 13, 1), - error(HintCode.UNUSED_ELEMENT_PARAMETER, 33, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 33, 1), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/getter_not_assignable_setter_types_test.dart b/pkg/analyzer/test/src/diagnostics/getter_not_assignable_setter_types_test.dart index c63e730ee43..08a3e3af67a 100644 --- a/pkg/analyzer/test/src/diagnostics/getter_not_assignable_setter_types_test.dart +++ b/pkg/analyzer/test/src/diagnostics/getter_not_assignable_setter_types_test.dart @@ -66,7 +66,7 @@ class B extends A { set _foo(String _) {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 44, 4), + error(WarningCode.UNUSED_ELEMENT, 44, 4), ]); } @@ -119,7 +119,7 @@ class B extends A { int get _foo => 0; } ''', [ - error(HintCode.UNUSED_ELEMENT, 48, 4), + error(WarningCode.UNUSED_ELEMENT, 48, 4), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/getter_not_subtype_setter_types_test.dart b/pkg/analyzer/test/src/diagnostics/getter_not_subtype_setter_types_test.dart index cd0b7744de1..f93acd31907 100644 --- a/pkg/analyzer/test/src/diagnostics/getter_not_subtype_setter_types_test.dart +++ b/pkg/analyzer/test/src/diagnostics/getter_not_subtype_setter_types_test.dart @@ -86,7 +86,7 @@ class B extends A { set _foo(String _) {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 44, 4), + error(WarningCode.UNUSED_ELEMENT, 44, 4), ]); } @@ -139,7 +139,7 @@ class B extends A { int get _foo => 0; } ''', [ - error(HintCode.UNUSED_ELEMENT, 48, 4), + error(WarningCode.UNUSED_ELEMENT, 48, 4), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/inference_failure_on_collection_literal_test.dart b/pkg/analyzer/test/src/diagnostics/inference_failure_on_collection_literal_test.dart index a4525de4302..f34651614f0 100644 --- a/pkg/analyzer/test/src/diagnostics/inference_failure_on_collection_literal_test.dart +++ b/pkg/analyzer/test/src/diagnostics/inference_failure_on_collection_literal_test.dart @@ -94,9 +94,9 @@ void main() { error(HintCode.UNUSED_LOCAL_VARIABLE, 30, 1), error(HintCode.UNUSED_LOCAL_VARIABLE, 53, 1), error(HintCode.UNUSED_LOCAL_VARIABLE, 85, 1), - error(HintCode.UNUSED_ELEMENT, 172, 1), - error(HintCode.UNUSED_ELEMENT, 194, 1), - error(HintCode.UNUSED_ELEMENT, 221, 1), + error(WarningCode.UNUSED_ELEMENT, 172, 1), + error(WarningCode.UNUSED_ELEMENT, 194, 1), + error(WarningCode.UNUSED_ELEMENT, 221, 1), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_return_type_test.dart b/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_return_type_test.dart index e5196f81626..7d882d59f1d 100644 --- a/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_return_type_test.dart +++ b/pkg/analyzer/test/src/diagnostics/inference_failure_on_function_return_type_test.dart @@ -175,7 +175,7 @@ class C { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 27, 1), + error(WarningCode.UNUSED_ELEMENT, 27, 1), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/initializing_formal_for_non_existent_field_test.dart b/pkg/analyzer/test/src/diagnostics/initializing_formal_for_non_existent_field_test.dart index 01c03c34a4d..9f75ebe59eb 100644 --- a/pkg/analyzer/test/src/diagnostics/initializing_formal_for_non_existent_field_test.dart +++ b/pkg/analyzer/test/src/diagnostics/initializing_formal_for_non_existent_field_test.dart @@ -83,7 +83,7 @@ enum E { ''', [ error(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD, 25, 6), - error(HintCode.UNUSED_ELEMENT_PARAMETER, 30, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 30, 1), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/invalid_internal_annotation_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_internal_annotation_test.dart index c6607e6eff4..b18c0ad75d8 100644 --- a/pkg/analyzer/test/src/diagnostics/invalid_internal_annotation_test.dart +++ b/pkg/analyzer/test/src/diagnostics/invalid_internal_annotation_test.dart @@ -96,7 +96,7 @@ import 'package:meta/meta.dart'; assertErrorsInResult([ error(WarningCode.INVALID_INTERNAL_ANNOTATION, 33, 9), - error(HintCode.UNUSED_ELEMENT, 49, 4), + error(WarningCode.UNUSED_ELEMENT, 49, 4), ]); } @@ -109,7 +109,7 @@ class _C { '''); assertErrorsInResult([ - error(HintCode.UNUSED_ELEMENT, 39, 2), + error(WarningCode.UNUSED_ELEMENT, 39, 2), error(WarningCode.INVALID_INTERNAL_ANNOTATION, 46, 9), ]); } @@ -123,7 +123,7 @@ class _C { '''); assertErrorsInResult([ - error(HintCode.UNUSED_ELEMENT, 39, 2), + error(WarningCode.UNUSED_ELEMENT, 39, 2), error(WarningCode.INVALID_INTERNAL_ANNOTATION, 46, 9), ]); } @@ -149,7 +149,7 @@ import 'package:meta/meta.dart'; assertErrorsInResult([ error(WarningCode.INVALID_INTERNAL_ANNOTATION, 33, 9), - error(HintCode.UNUSED_ELEMENT, 48, 2), + error(WarningCode.UNUSED_ELEMENT, 48, 2), error(WarningCode.UNUSED_FIELD, 52, 3), ]); } @@ -226,7 +226,7 @@ class C { assertErrorsInResult([ error(WarningCode.INVALID_INTERNAL_ANNOTATION, 45, 9), - error(HintCode.UNUSED_ELEMENT, 63, 2), + error(WarningCode.UNUSED_ELEMENT, 63, 2), ]); } @@ -240,7 +240,7 @@ class C { assertErrorsInResult([ error(WarningCode.INVALID_INTERNAL_ANNOTATION, 45, 9), - error(HintCode.UNUSED_ELEMENT, 60, 2), + error(WarningCode.UNUSED_ELEMENT, 60, 2), ]); } @@ -254,7 +254,7 @@ class C { assertErrorsInResult([ error(WarningCode.INVALID_INTERNAL_ANNOTATION, 45, 9), - error(HintCode.UNUSED_ELEMENT, 67, 2), + error(WarningCode.UNUSED_ELEMENT, 67, 2), ]); } @@ -266,7 +266,7 @@ import 'package:meta/meta.dart'; assertErrorsInResult([ error(WarningCode.INVALID_INTERNAL_ANNOTATION, 33, 9), - error(HintCode.UNUSED_ELEMENT, 49, 4), + error(WarningCode.UNUSED_ELEMENT, 49, 4), ]); } @@ -278,7 +278,7 @@ import 'package:meta/meta.dart'; assertErrorsInResult([ error(WarningCode.INVALID_INTERNAL_ANNOTATION, 33, 9), - error(HintCode.UNUSED_ELEMENT, 48, 2), + error(WarningCode.UNUSED_ELEMENT, 48, 2), ]); } @@ -290,7 +290,7 @@ import 'package:meta/meta.dart'; assertErrorsInResult([ error(WarningCode.INVALID_INTERNAL_ANNOTATION, 47, 6), - error(HintCode.UNUSED_ELEMENT, 47, 2), + error(WarningCode.UNUSED_ELEMENT, 47, 2), ]); } @@ -302,7 +302,7 @@ import 'package:meta/meta.dart'; assertErrorsInResult([ error(WarningCode.INVALID_INTERNAL_ANNOTATION, 33, 9), - error(HintCode.UNUSED_ELEMENT, 51, 2), + error(WarningCode.UNUSED_ELEMENT, 51, 2), ]); } @@ -315,7 +315,7 @@ class _C { '''); assertErrorsInResult([ - error(HintCode.UNUSED_ELEMENT, 39, 2), + error(WarningCode.UNUSED_ELEMENT, 39, 2), ]); } @@ -328,8 +328,8 @@ class _C { '''); assertErrorsInResult([ - error(HintCode.UNUSED_ELEMENT, 39, 2), - error(HintCode.UNUSED_ELEMENT, 68, 1), + error(WarningCode.UNUSED_ELEMENT, 39, 2), + error(WarningCode.UNUSED_ELEMENT, 68, 1), ]); } } diff --git a/pkg/analyzer/test/src/diagnostics/invalid_use_of_covariant_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_use_of_covariant_test.dart index 20b7d5cb394..759d4cf3dd3 100644 --- a/pkg/analyzer/test/src/diagnostics/invalid_use_of_covariant_test.dart +++ b/pkg/analyzer/test/src/diagnostics/invalid_use_of_covariant_test.dart @@ -2,7 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:analyzer/src/dart/error/hint_codes.g.dart'; import 'package:analyzer/src/error/codes.g.dart'; import 'package:analyzer/src/generated/parser.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; @@ -83,7 +82,7 @@ void foo() { void f(covariant int x) {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 20, 1), + error(WarningCode.UNUSED_ELEMENT, 20, 1), error(CompileTimeErrorCode.INVALID_USE_OF_COVARIANT, 22, 9), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/invalid_visibility_annotation_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_visibility_annotation_test.dart index 73b02eea431..1671db917b3 100644 --- a/pkg/analyzer/test/src/diagnostics/invalid_visibility_annotation_test.dart +++ b/pkg/analyzer/test/src/diagnostics/invalid_visibility_annotation_test.dart @@ -62,7 +62,7 @@ import 'package:meta/meta.dart'; @visibleForTesting class _C {} ''', [ error(WarningCode.INVALID_VISIBILITY_ANNOTATION, 33, 18), - error(HintCode.UNUSED_ELEMENT, 58, 2), + error(WarningCode.UNUSED_ELEMENT, 58, 2), ]); } @@ -107,7 +107,7 @@ class C { } ''', [ error(WarningCode.INVALID_VISIBILITY_ANNOTATION, 45, 18), - error(HintCode.UNUSED_ELEMENT, 69, 2), + error(WarningCode.UNUSED_ELEMENT, 69, 2), ]); } @@ -117,7 +117,7 @@ import 'package:meta/meta.dart'; @visibleForTesting mixin _M {} ''', [ error(WarningCode.INVALID_VISIBILITY_ANNOTATION, 33, 18), - error(HintCode.UNUSED_ELEMENT, 58, 2), + error(WarningCode.UNUSED_ELEMENT, 58, 2), ]); } @@ -127,7 +127,7 @@ import 'package:meta/meta.dart'; @visibleForTesting void _f() {} ''', [ error(WarningCode.INVALID_VISIBILITY_ANNOTATION, 33, 18), - error(HintCode.UNUSED_ELEMENT, 57, 2), + error(WarningCode.UNUSED_ELEMENT, 57, 2), ]); } @@ -137,7 +137,7 @@ import 'package:meta/meta.dart'; @visibleForTesting final _a = 1; ''', [ error(WarningCode.INVALID_VISIBILITY_ANNOTATION, 33, 18), - error(HintCode.UNUSED_ELEMENT, 58, 2), + error(WarningCode.UNUSED_ELEMENT, 58, 2), ]); } @@ -147,7 +147,7 @@ import 'package:meta/meta.dart'; @visibleForTesting typedef _T = Function(); ''', [ error(WarningCode.INVALID_VISIBILITY_ANNOTATION, 33, 18), - error(HintCode.UNUSED_ELEMENT, 60, 2), + error(WarningCode.UNUSED_ELEMENT, 60, 2), ]); } @@ -157,7 +157,7 @@ import 'package:meta/meta.dart'; @visibleForTesting final _a = 1, b = 2; ''', [ error(WarningCode.INVALID_VISIBILITY_ANNOTATION, 33, 18), - error(HintCode.UNUSED_ELEMENT, 58, 2), + error(WarningCode.UNUSED_ELEMENT, 58, 2), ]); } @@ -168,8 +168,8 @@ import 'package:meta/meta.dart'; ''', [ error(WarningCode.INVALID_VISIBILITY_ANNOTATION, 33, 18), error(WarningCode.INVALID_VISIBILITY_ANNOTATION, 33, 18), - error(HintCode.UNUSED_ELEMENT, 58, 2), - error(HintCode.UNUSED_ELEMENT, 66, 2), + error(WarningCode.UNUSED_ELEMENT, 58, 2), + error(WarningCode.UNUSED_ELEMENT, 66, 2), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/label_in_outer_scope_test.dart b/pkg/analyzer/test/src/diagnostics/label_in_outer_scope_test.dart index 2c1f3cf8580..e0c4d3cb3a5 100644 --- a/pkg/analyzer/test/src/diagnostics/label_in_outer_scope_test.dart +++ b/pkg/analyzer/test/src/diagnostics/label_in_outer_scope_test.dart @@ -27,7 +27,7 @@ class A { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 62, 1), + error(WarningCode.UNUSED_ELEMENT, 62, 1), error(CompileTimeErrorCode.LABEL_IN_OUTER_SCOPE, 82, 1), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/missing_variable_pattern_test.dart b/pkg/analyzer/test/src/diagnostics/missing_variable_pattern_test.dart index 013c87965f0..86bbd398cd5 100644 --- a/pkg/analyzer/test/src/diagnostics/missing_variable_pattern_test.dart +++ b/pkg/analyzer/test/src/diagnostics/missing_variable_pattern_test.dart @@ -630,7 +630,7 @@ void f(int x) { ''', [ error(HintCode.UNUSED_LOCAL_VARIABLE, 52, 1), error(WarningCode.DEAD_CODE, 59, 4), - error(HintCode.UNREACHABLE_SWITCH_CASE, 59, 4), + error(WarningCode.UNREACHABLE_SWITCH_CASE, 59, 4), error(HintCode.UNUSED_LOCAL_VARIABLE, 76, 1), ]); diff --git a/pkg/analyzer/test/src/diagnostics/mixin_application_not_implemented_interface_test.dart b/pkg/analyzer/test/src/diagnostics/mixin_application_not_implemented_interface_test.dart index fa75b608b11..c56c0ec0daa 100644 --- a/pkg/analyzer/test/src/diagnostics/mixin_application_not_implemented_interface_test.dart +++ b/pkg/analyzer/test/src/diagnostics/mixin_application_not_implemented_interface_test.dart @@ -119,7 +119,7 @@ abstract class Directory implements FileSystemEntity, ioDirectory {} mixin DirectoryAddOnsMixin implements Directory {} ''', [ - error(HintCode.UNUSED_ELEMENT, 96, 15), + error(WarningCode.UNUSED_ELEMENT, 96, 15), ]); var mixins = result.unit.declaredElement!.getClass('_LocalDirectory')!.mixins; diff --git a/pkg/analyzer/test/src/diagnostics/not_assigned_potentially_non_nullable_local_variable_test.dart b/pkg/analyzer/test/src/diagnostics/not_assigned_potentially_non_nullable_local_variable_test.dart index 5af2f06e14f..bfe6f45d374 100644 --- a/pkg/analyzer/test/src/diagnostics/not_assigned_potentially_non_nullable_local_variable_test.dart +++ b/pkg/analyzer/test/src/diagnostics/not_assigned_potentially_non_nullable_local_variable_test.dart @@ -644,7 +644,7 @@ void f() { } ''', [ error(HintCode.UNUSED_LOCAL_VARIABLE, 17, 1), - error(HintCode.UNUSED_ELEMENT, 38, 1), + error(WarningCode.UNUSED_ELEMENT, 38, 1), _notAssignedError(64, 1), ]); } @@ -665,7 +665,7 @@ void f() { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 40, 1), + error(WarningCode.UNUSED_ELEMENT, 40, 1), _notAssignedError(94, 2), ]); } @@ -685,7 +685,7 @@ void f() { v2 = 0; } ''', [ - error(HintCode.UNUSED_ELEMENT, 44, 1), + error(WarningCode.UNUSED_ELEMENT, 44, 1), _notAssignedError(62, 2), ]); } @@ -702,7 +702,7 @@ void f() { v; } ''', [ - error(HintCode.UNUSED_ELEMENT, 28, 1), + error(WarningCode.UNUSED_ELEMENT, 28, 1), _notAssignedError(52, 1), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/private_collision_in_mixin_application_test.dart b/pkg/analyzer/test/src/diagnostics/private_collision_in_mixin_application_test.dart index 264b9beb840..e3f31a92fed 100644 --- a/pkg/analyzer/test/src/diagnostics/private_collision_in_mixin_application_test.dart +++ b/pkg/analyzer/test/src/diagnostics/private_collision_in_mixin_application_test.dart @@ -331,8 +331,8 @@ mixin B { class C extends Object with A, B {} ''', [ - error(HintCode.UNUSED_ELEMENT, 17, 4), - error(HintCode.UNUSED_ELEMENT, 47, 4), + error(WarningCode.UNUSED_ELEMENT, 17, 4), + error(WarningCode.UNUSED_ELEMENT, 47, 4), ]); } @@ -348,8 +348,8 @@ mixin class B { class C extends Object with A, B {} ''', [ - error(HintCode.UNUSED_ELEMENT, 23, 4), - error(HintCode.UNUSED_ELEMENT, 59, 4), + error(WarningCode.UNUSED_ELEMENT, 23, 4), + error(WarningCode.UNUSED_ELEMENT, 59, 4), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/super_in_extension_test.dart b/pkg/analyzer/test/src/diagnostics/super_in_extension_test.dart index b0fb84bd45f..214d7bcef2e 100644 --- a/pkg/analyzer/test/src/diagnostics/super_in_extension_test.dart +++ b/pkg/analyzer/test/src/diagnostics/super_in_extension_test.dart @@ -34,7 +34,7 @@ extension on T { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 23, 1), + error(WarningCode.UNUSED_ELEMENT, 23, 1), error(CompileTimeErrorCode.SUPER_IN_EXTENSION, 33, 5), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/unnecessary_cast_test.dart b/pkg/analyzer/test/src/diagnostics/unnecessary_cast_test.dart index 29b39a4ae02..95100b51ee1 100644 --- a/pkg/analyzer/test/src/diagnostics/unnecessary_cast_test.dart +++ b/pkg/analyzer/test/src/diagnostics/unnecessary_cast_test.dart @@ -47,7 +47,7 @@ dynamic f(bool c, int a, int b) { return c ? a : b as int; } ''', [ - error(HintCode.UNNECESSARY_CAST, 51, 8), + error(WarningCode.UNNECESSARY_CAST, 51, 8), ]); } @@ -57,7 +57,7 @@ dynamic f(bool c, int a, int b) { return c ? a as int : b; } ''', [ - error(HintCode.UNNECESSARY_CAST, 47, 8), + error(WarningCode.UNNECESSARY_CAST, 47, 8), ]); } @@ -67,7 +67,7 @@ dynamic f(bool c, int a, dynamic b) { return c ? a as int : b; } ''', [ - error(HintCode.UNNECESSARY_CAST, 51, 8), + error(WarningCode.UNNECESSARY_CAST, 51, 8), ]); } @@ -77,8 +77,8 @@ dynamic f(bool c, int a, int b) { return c ? a as int : b as int; } ''', [ - error(HintCode.UNNECESSARY_CAST, 47, 8), - error(HintCode.UNNECESSARY_CAST, 58, 8), + error(WarningCode.UNNECESSARY_CAST, 47, 8), + error(WarningCode.UNNECESSARY_CAST, 58, 8), ]); } @@ -88,7 +88,7 @@ dynamic f(bool c, int a, int b) { return c ? a : b as int; } ''', [ - error(HintCode.UNNECESSARY_CAST, 51, 8), + error(WarningCode.UNNECESSARY_CAST, 51, 8), ]); } @@ -122,7 +122,7 @@ void f(void Function(num) a) { (a as void Function(int))(3); } ''', [ - error(HintCode.UNNECESSARY_CAST, 34, 23), + error(WarningCode.UNNECESSARY_CAST, 34, 23), ]); } @@ -132,7 +132,7 @@ void f(int Function() a) { (a as num Function())(); } ''', [ - error(HintCode.UNNECESSARY_CAST, 30, 19), + error(WarningCode.UNNECESSARY_CAST, 30, 19), ]); } @@ -166,7 +166,7 @@ void f(int a) { a as Object; } ''', [ - error(HintCode.UNNECESSARY_CAST, 18, 11), + error(WarningCode.UNNECESSARY_CAST, 18, 11), ]); } @@ -176,7 +176,7 @@ void f(num a) { a as num; } ''', [ - error(HintCode.UNNECESSARY_CAST, 18, 8), + error(WarningCode.UNNECESSARY_CAST, 18, 8), ]); } @@ -186,7 +186,7 @@ void f(T a) { a as num; } ''', [ - error(HintCode.UNNECESSARY_CAST, 31, 8), + error(WarningCode.UNNECESSARY_CAST, 31, 8), ]); } @@ -196,7 +196,7 @@ void f(T a) { a as num; } ''', [ - error(HintCode.UNNECESSARY_CAST, 31, 8), + error(WarningCode.UNNECESSARY_CAST, 31, 8), ]); } @@ -235,7 +235,7 @@ void f() { } ''', [ error(HintCode.IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE, 7, 8), - error(HintCode.UNNECESSARY_CAST, 39, 8), + error(WarningCode.UNNECESSARY_CAST, 39, 8), ]); } @@ -264,7 +264,7 @@ void f(num a) { a as N; } ''', [ - error(HintCode.UNNECESSARY_CAST, 35, 6), + error(WarningCode.UNNECESSARY_CAST, 35, 6), ]); } } diff --git a/pkg/analyzer/test/src/diagnostics/unnecessary_final_test.dart b/pkg/analyzer/test/src/diagnostics/unnecessary_final_test.dart index 8d586e9114b..e47212fee88 100644 --- a/pkg/analyzer/test/src/diagnostics/unnecessary_final_test.dart +++ b/pkg/analyzer/test/src/diagnostics/unnecessary_final_test.dart @@ -30,7 +30,7 @@ class C { int value; } ''', [ - error(HintCode.UNNECESSARY_FINAL, 15, 5), + error(WarningCode.UNNECESSARY_FINAL, 15, 5), ]); } @@ -45,7 +45,7 @@ class B extends A { B(final super.value); } ''', [ - error(HintCode.UNNECESSARY_FINAL, 67, 5), + error(WarningCode.UNNECESSARY_FINAL, 67, 5), ]); } @@ -56,7 +56,7 @@ class C { int value; } ''', [ - error(HintCode.UNNECESSARY_FINAL, 14, 5), + error(WarningCode.UNNECESSARY_FINAL, 14, 5), ]); } } diff --git a/pkg/analyzer/test/src/diagnostics/unreachable_switch_case_test.dart b/pkg/analyzer/test/src/diagnostics/unreachable_switch_case_test.dart index a4ad4c2182f..a85c986fead 100644 --- a/pkg/analyzer/test/src/diagnostics/unreachable_switch_case_test.dart +++ b/pkg/analyzer/test/src/diagnostics/unreachable_switch_case_test.dart @@ -27,7 +27,7 @@ Object f(bool x) { }; } ''', [ - error(HintCode.UNREACHABLE_SWITCH_CASE, 82, 2), + error(WarningCode.UNREACHABLE_SWITCH_CASE, 82, 2), ]); } @@ -42,9 +42,9 @@ Object f(bool x) { } ''', [ error(WarningCode.DEAD_CODE, 57, 9), - error(HintCode.UNREACHABLE_SWITCH_CASE, 62, 2), + error(WarningCode.UNREACHABLE_SWITCH_CASE, 62, 2), error(WarningCode.DEAD_CODE, 72, 10), - error(HintCode.UNREACHABLE_SWITCH_CASE, 78, 2), + error(WarningCode.UNREACHABLE_SWITCH_CASE, 78, 2), ]); } } @@ -63,7 +63,7 @@ void f(bool x) { } } ''', [ - error(HintCode.UNREACHABLE_SWITCH_CASE, 67, 4), + error(WarningCode.UNREACHABLE_SWITCH_CASE, 67, 4), ]); } @@ -80,9 +80,9 @@ void f(int x) { } ''', [ error(WarningCode.DEAD_CODE, 64, 4), - error(HintCode.UNREACHABLE_SWITCH_CASE, 64, 4), + error(WarningCode.UNREACHABLE_SWITCH_CASE, 64, 4), error(WarningCode.DEAD_CODE, 80, 4), - error(HintCode.UNREACHABLE_SWITCH_CASE, 80, 4), + error(WarningCode.UNREACHABLE_SWITCH_CASE, 80, 4), error(WarningCode.DEAD_CODE, 98, 6), ]); } diff --git a/pkg/analyzer/test/src/diagnostics/unused_element_test.dart b/pkg/analyzer/test/src/diagnostics/unused_element_test.dart index 5f58457c87c..a8b21638bd5 100644 --- a/pkg/analyzer/test/src/diagnostics/unused_element_test.dart +++ b/pkg/analyzer/test/src/diagnostics/unused_element_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:analyzer/src/dart/error/hint_codes.dart'; +import 'package:analyzer/src/error/codes.g.dart'; import 'package:test/expect.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; @@ -91,7 +92,7 @@ void f(Object p) { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 6, 2), + error(WarningCode.UNUSED_ELEMENT, 6, 2), ]); } @@ -103,7 +104,7 @@ void f(Object p) { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 6, 2), + error(WarningCode.UNUSED_ELEMENT, 6, 2), ]); } @@ -115,7 +116,7 @@ void f(Object p) { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 6, 2), + error(WarningCode.UNUSED_ELEMENT, 6, 2), ]); } @@ -128,7 +129,7 @@ void f() { } print(x) {} ''', [ - error(HintCode.UNUSED_ELEMENT, 6, 2), + error(WarningCode.UNUSED_ELEMENT, 6, 2), ]); } @@ -141,7 +142,7 @@ main() { } print(x) {} ''', [ - error(HintCode.UNUSED_ELEMENT, 6, 2), + error(WarningCode.UNUSED_ELEMENT, 6, 2), ]); } @@ -161,7 +162,7 @@ enum E { const E({int? a}); } ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 37, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 37, 1), ]); } @@ -181,7 +182,7 @@ enum E { const E([int? a]); } ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 37, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 37, 1), ]); } @@ -364,7 +365,7 @@ class _A { } f() => _A(); ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 38, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 38, 1), ]); } @@ -377,7 +378,7 @@ class _A { } f() => _A.named(); ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 38, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 38, 1), ]); } @@ -436,7 +437,7 @@ class _A { } f() => _A(); ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 38, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 38, 1), ]); } @@ -449,7 +450,7 @@ class _A { } f() => _A.named(); ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 38, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 38, 1), ]); } @@ -491,7 +492,7 @@ void f() { _E.v; } ''', [ - error(HintCode.UNUSED_ELEMENT, 52, 4), + error(WarningCode.UNUSED_ELEMENT, 52, 4), ]); } @@ -519,7 +520,7 @@ void f() { _E.v; } ''', [ - error(HintCode.UNUSED_ELEMENT, 25, 4), + error(WarningCode.UNUSED_ELEMENT, 25, 4), ]); } @@ -547,7 +548,7 @@ void f() { _E.v; } ''', [ - error(HintCode.UNUSED_ELEMENT, 22, 4), + error(WarningCode.UNUSED_ELEMENT, 22, 4), ]); } @@ -575,7 +576,7 @@ void f() { _E.v._foo(); } ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 33, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 33, 1), ]); } @@ -603,7 +604,7 @@ void f() { _E.v._foo(); } ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 33, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 33, 1), ]); } @@ -631,7 +632,7 @@ void f() { _E.v; } ''', [ - error(HintCode.UNUSED_ELEMENT, 21, 4), + error(WarningCode.UNUSED_ELEMENT, 21, 4), ]); } @@ -660,7 +661,7 @@ void f() { _E.v; } ''', [ - error(HintCode.UNUSED_ELEMENT, 32, 4), + error(WarningCode.UNUSED_ELEMENT, 32, 4), ]); } @@ -689,7 +690,7 @@ void f() { _E.v; } ''', [ - error(HintCode.UNUSED_ELEMENT, 29, 4), + error(WarningCode.UNUSED_ELEMENT, 29, 4), ]); } @@ -718,7 +719,7 @@ void f() { _E.v; } ''', [ - error(HintCode.UNUSED_ELEMENT, 28, 4), + error(WarningCode.UNUSED_ELEMENT, 28, 4), ]); } @@ -734,7 +735,7 @@ void f() { _E.v; } ''', [ - error(HintCode.UNUSED_ELEMENT, 50, 3), + error(WarningCode.UNUSED_ELEMENT, 50, 3), ]); } @@ -828,7 +829,7 @@ void f() { _E.v; } ''', [ - error(HintCode.UNUSED_ELEMENT, 32, 3), + error(WarningCode.UNUSED_ELEMENT, 32, 3), ]); } @@ -857,7 +858,7 @@ void f() { _E.v; } ''', [ - error(HintCode.UNUSED_ELEMENT, 29, 3), + error(WarningCode.UNUSED_ELEMENT, 29, 3), ]); } @@ -886,7 +887,7 @@ void f() { _E.v; } ''', [ - error(HintCode.UNUSED_ELEMENT, 28, 3), + error(WarningCode.UNUSED_ELEMENT, 28, 3), ]); } @@ -908,7 +909,7 @@ enum E { const E._bar(); } ''', [ - error(HintCode.UNUSED_ELEMENT, 49, 4), + error(WarningCode.UNUSED_ELEMENT, 49, 4), ]); } @@ -932,7 +933,7 @@ enum E { static int get _foo => 0; } ''', [ - error(HintCode.UNUSED_ELEMENT, 31, 4), + error(WarningCode.UNUSED_ELEMENT, 31, 4), ]); } @@ -956,7 +957,7 @@ enum E { static void _foo() {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 28, 4), + error(WarningCode.UNUSED_ELEMENT, 28, 4), ]); } @@ -980,7 +981,7 @@ enum E { static set _foo(int _) {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 27, 4), + error(WarningCode.UNUSED_ELEMENT, 27, 4), ]); } @@ -1015,7 +1016,7 @@ enum E { factory E.baz() => throw 0; } ''', [ - error(HintCode.UNUSED_ELEMENT, 47, 3), + error(WarningCode.UNUSED_ELEMENT, 47, 3), ]); } @@ -1078,7 +1079,7 @@ void f() { await assertErrorsInCode(r''' typedef _A = List; ''', [ - error(HintCode.UNUSED_ELEMENT, 8, 2), + error(WarningCode.UNUSED_ELEMENT, 8, 2), ]); } } @@ -1170,8 +1171,8 @@ class _A { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 6, 2), - error(HintCode.UNUSED_ELEMENT, 20, 12), + error(WarningCode.UNUSED_ELEMENT, 6, 2), + error(WarningCode.UNUSED_ELEMENT, 20, 12), ]); } @@ -1182,8 +1183,8 @@ class _A { _A.named() {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 6, 2), - error(HintCode.UNUSED_ELEMENT, 26, 5), + error(WarningCode.UNUSED_ELEMENT, 6, 2), + error(WarningCode.UNUSED_ELEMENT, 26, 5), ]); } @@ -1195,7 +1196,7 @@ main(p) { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 6, 2), + error(WarningCode.UNUSED_ELEMENT, 6, 2), ]); } @@ -1205,7 +1206,7 @@ class _A {} main() { } ''', [ - error(HintCode.UNUSED_ELEMENT, 6, 2), + error(WarningCode.UNUSED_ELEMENT, 6, 2), ]); } @@ -1218,7 +1219,7 @@ main() { } print(x) {} ''', [ - error(HintCode.UNUSED_ELEMENT, 6, 2), + error(WarningCode.UNUSED_ELEMENT, 6, 2), ]); } @@ -1293,7 +1294,7 @@ class A { A(); } ''', [ - error(HintCode.UNUSED_ELEMENT, 14, 12), + error(WarningCode.UNUSED_ELEMENT, 14, 12), ]); } @@ -1322,7 +1323,7 @@ void f(d) { d.B; } ''', [ - error(HintCode.UNUSED_ELEMENT, 5, 7), + error(WarningCode.UNUSED_ELEMENT, 5, 7), ]); } @@ -1333,7 +1334,7 @@ class A { A(); } ''', [ - error(HintCode.UNUSED_ELEMENT, 22, 8), + error(WarningCode.UNUSED_ELEMENT, 22, 8), ]); } @@ -1388,7 +1389,7 @@ main() { f() {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 11, 1), + error(WarningCode.UNUSED_ELEMENT, 11, 1), ]); } @@ -1400,7 +1401,7 @@ main() { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 11, 2), + error(WarningCode.UNUSED_ELEMENT, 11, 2), ]); } @@ -1448,7 +1449,7 @@ typedef _F(a, b); main() { } ''', [ - error(HintCode.UNUSED_ELEMENT, 8, 2), + error(WarningCode.UNUSED_ELEMENT, 8, 2), ]); } @@ -1580,8 +1581,8 @@ class B extends A { int get _a => 3; } ''', [ - error(HintCode.UNUSED_ELEMENT, 35, 2), - error(HintCode.UNUSED_ELEMENT, 155, 2), + error(WarningCode.UNUSED_ELEMENT, 35, 2), + error(WarningCode.UNUSED_ELEMENT, 155, 2), ]); } @@ -1591,7 +1592,7 @@ class A { get _g => null; } ''', [ - error(HintCode.UNUSED_ELEMENT, 16, 2), + error(WarningCode.UNUSED_ELEMENT, 16, 2), ]); } @@ -1603,7 +1604,7 @@ class A { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 16, 2), + error(WarningCode.UNUSED_ELEMENT, 16, 2), ]); } @@ -1992,7 +1993,7 @@ class B { void _m1() {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 17, 3), + error(WarningCode.UNUSED_ELEMENT, 17, 3), ]); } @@ -2002,7 +2003,7 @@ class A { static _m() {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 19, 2), + error(WarningCode.UNUSED_ELEMENT, 19, 2), ]); } @@ -2012,7 +2013,7 @@ extension _A on String { void m() {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 32, 1), + error(WarningCode.UNUSED_ELEMENT, 32, 1), ]); } @@ -2024,7 +2025,7 @@ extension _A on bool { operator []=(int index, int value) {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 34, 3), + error(WarningCode.UNUSED_ELEMENT, 34, 3), ]); } @@ -2034,7 +2035,7 @@ extension _A on bool { int operator [](int index) => 7; } ''', [ - error(HintCode.UNUSED_ELEMENT, 38, 2), + error(WarningCode.UNUSED_ELEMENT, 38, 2), ]); } @@ -2044,7 +2045,7 @@ extension _E on int { void call() {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 29, 4), + error(WarningCode.UNUSED_ELEMENT, 29, 4), ]); } @@ -2056,7 +2057,7 @@ extension _A on String { int operator -(int other) => other; } ''', [ - error(HintCode.UNUSED_ELEMENT, 40, 1), + error(WarningCode.UNUSED_ELEMENT, 40, 1), ]); } @@ -2066,7 +2067,7 @@ extension _A on String { int operator ~() => 7; } ''', [ - error(HintCode.UNUSED_ELEMENT, 40, 1), + error(WarningCode.UNUSED_ELEMENT, 40, 1), ]); } @@ -2078,7 +2079,7 @@ class A { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 19, 2), + error(WarningCode.UNUSED_ELEMENT, 19, 2), ]); } @@ -2089,7 +2090,7 @@ class A { int _f(int p) => 7; } ''', [ - error(HintCode.UNUSED_ELEMENT, 44, 2), + error(WarningCode.UNUSED_ELEMENT, 44, 2), ]); } @@ -2101,7 +2102,7 @@ class A { /// This is similar to [A._f]. int g() => 7; ''', [ - error(HintCode.UNUSED_ELEMENT, 16, 2), + error(WarningCode.UNUSED_ELEMENT, 16, 2), ]); } @@ -2111,7 +2112,7 @@ extension on String { void m() {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 29, 1), + error(WarningCode.UNUSED_ELEMENT, 29, 1), ]); } @@ -2121,7 +2122,7 @@ extension on String { int operator -(int other) => other; } ''', [ - error(HintCode.UNUSED_ELEMENT, 37, 1), + error(WarningCode.UNUSED_ELEMENT, 37, 1), ]); } @@ -2136,7 +2137,7 @@ class C with _M {} await assertErrorsInCode(r''' mixin _M {} ''', [ - error(HintCode.UNUSED_ELEMENT, 6, 2), + error(WarningCode.UNUSED_ELEMENT, 6, 2), ]); } @@ -2198,7 +2199,7 @@ f() { B()._m(0); } ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 25, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 25, 1), ]); } @@ -2281,7 +2282,7 @@ class A { } f() => A._(); ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 21, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 21, 1), ]); } @@ -2292,7 +2293,7 @@ class _A { } f() => _A(); ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 21, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 21, 1), ]); } @@ -2303,7 +2304,7 @@ extension E on String { } f() => "hello"._m(); ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 39, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 39, 1), ]); } @@ -2314,7 +2315,7 @@ class A { } f() => A()._m(); ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 25, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 25, 1), ]); } @@ -2328,7 +2329,7 @@ class B implements A { } f() => A()._m(); ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 65, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 65, 1), ]); } @@ -2339,7 +2340,7 @@ class A { } f() => A()._m(); ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 25, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 25, 1), ]); } @@ -2350,7 +2351,7 @@ extension _E on String { } f() => "hello".m(); ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 39, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 39, 1), ]); } @@ -2361,7 +2362,7 @@ extension on String { } f() => "hello".m(); ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 36, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 36, 1), ]); } @@ -2372,7 +2373,7 @@ class A { } f() => A._m(); ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 32, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 32, 1), ]); } @@ -2383,7 +2384,7 @@ class _A { } f() => _A.m(); ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 32, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 32, 1), ]); } @@ -2399,7 +2400,7 @@ f() => _m(1); void _m([int a]) {} f() => _m(); ''', [ - error(HintCode.UNUSED_ELEMENT_PARAMETER, 13, 1), + error(WarningCode.UNUSED_ELEMENT_PARAMETER, 13, 1), ]); } @@ -2428,7 +2429,7 @@ class _A { } void f(_A a) {} ''', [ - error(HintCode.UNUSED_ELEMENT, 25, 1), + error(WarningCode.UNUSED_ELEMENT, 25, 1), ]); } @@ -2449,7 +2450,7 @@ extension _A on String { static void m() {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 39, 1), + error(WarningCode.UNUSED_ELEMENT, 39, 1), ]); } @@ -2473,7 +2474,7 @@ void main() { _A; } ''', [ - error(HintCode.UNUSED_ELEMENT, 25, 1), + error(WarningCode.UNUSED_ELEMENT, 25, 1), ]); } @@ -2522,7 +2523,7 @@ class A { set _s(x) {} } ''', [ - error(HintCode.UNUSED_ELEMENT, 16, 2), + error(WarningCode.UNUSED_ELEMENT, 16, 2), ]); } @@ -2536,7 +2537,7 @@ class A { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 16, 2), + error(WarningCode.UNUSED_ELEMENT, 16, 2), ]); } @@ -2582,7 +2583,7 @@ _f() {} main() { } ''', [ - error(HintCode.UNUSED_ELEMENT, 0, 2), + error(WarningCode.UNUSED_ELEMENT, 0, 2), ]); } @@ -2594,7 +2595,7 @@ _f(int p) { main() { } ''', [ - error(HintCode.UNUSED_ELEMENT, 0, 2), + error(WarningCode.UNUSED_ELEMENT, 0, 2), ]); } @@ -2603,7 +2604,7 @@ main() { /// [_f] is a great function. _f(int p) => 7; ''', [ - error(HintCode.UNUSED_ELEMENT, 30, 2), + error(WarningCode.UNUSED_ELEMENT, 30, 2), ]); } @@ -2654,7 +2655,7 @@ void f() { await assertErrorsInCode(r''' set _foo(int _) {} ''', [ - error(HintCode.UNUSED_ELEMENT, 4, 4), + error(WarningCode.UNUSED_ELEMENT, 4, 4), ]); } @@ -2693,7 +2694,7 @@ main() { _a = 2; } ''', [ - error(HintCode.UNUSED_ELEMENT, 4, 2), + error(WarningCode.UNUSED_ELEMENT, 4, 2), ]); } @@ -2704,7 +2705,7 @@ f() { _a += 1; } ''', [ - error(HintCode.UNUSED_ELEMENT, 4, 2), + error(WarningCode.UNUSED_ELEMENT, 4, 2), ]); } @@ -2713,7 +2714,7 @@ f() { /// [_a] is a great variable. int _a = 7; ''', [ - error(HintCode.UNUSED_ELEMENT, 34, 2), + error(WarningCode.UNUSED_ELEMENT, 34, 2), ]); } @@ -2761,7 +2762,7 @@ typedef _F = void Function(); main() { } ''', [ - error(HintCode.UNUSED_ELEMENT, 8, 2), + error(WarningCode.UNUSED_ELEMENT, 8, 2), ]); } } diff --git a/pkg/analyzer/test/src/diagnostics/use_of_void_result_test.dart b/pkg/analyzer/test/src/diagnostics/use_of_void_result_test.dart index 7048e2e0375..89f1e9d9ea9 100644 --- a/pkg/analyzer/test/src/diagnostics/use_of_void_result_test.dart +++ b/pkg/analyzer/test/src/diagnostics/use_of_void_result_test.dart @@ -579,7 +579,7 @@ extension on void { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 22, 8), + error(WarningCode.UNUSED_ELEMENT, 22, 8), error(CompileTimeErrorCode.USE_OF_VOID_RESULT, 96, 4), ]); } diff --git a/pkg/analyzer/test/src/lint/linter/resolve_name_in_scope_test.dart b/pkg/analyzer/test/src/lint/linter/resolve_name_in_scope_test.dart index 2e4f23625de..86cf521ca6a 100644 --- a/pkg/analyzer/test/src/lint/linter/resolve_name_in_scope_test.dart +++ b/pkg/analyzer/test/src/lint/linter/resolve_name_in_scope_test.dart @@ -632,7 +632,7 @@ extension on A { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 53, 3), + error(WarningCode.UNUSED_ELEMENT, 53, 3), ]); _checkMethodNone(); } @@ -649,7 +649,7 @@ extension on A { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 53, 3), + error(WarningCode.UNUSED_ELEMENT, 53, 3), ]); _checkMethodRequested(findElement.parameter('foo')); } @@ -668,7 +668,7 @@ extension on A { var foo = 0; ''', [ - error(HintCode.UNUSED_ELEMENT, 53, 3), + error(WarningCode.UNUSED_ELEMENT, 53, 3), ]); _checkMethodRequested(findElement.topGet('foo')); } @@ -685,7 +685,7 @@ extension on A { } } ''', [ - error(HintCode.UNUSED_ELEMENT, 53, 3), + error(WarningCode.UNUSED_ELEMENT, 53, 3), ]); _checkMethodRequested(findElement.method('foo')); } diff --git a/pkg/analyzer/test/src/task/strong/checker_test.dart b/pkg/analyzer/test/src/task/strong/checker_test.dart index 6437fc43bdb..2b1c8407018 100644 --- a/pkg/analyzer/test/src/task/strong/checker_test.dart +++ b/pkg/analyzer/test/src/task/strong/checker_test.dart @@ -634,13 +634,13 @@ void main() { error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 1256, 4), error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 1331, 6), error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 1359, 4), - error(HintCode.UNNECESSARY_CAST, 1526, 11), + error(WarningCode.UNNECESSARY_CAST, 1526, 11), error(HintCode.UNUSED_LOCAL_VARIABLE, 1591, 1), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 1616, 6), error(CompileTimeErrorCode.INVALID_CAST_FUNCTION, 1644, 4), error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 1735, 6), error(CompileTimeErrorCode.INVALID_CAST_FUNCTION, 1763, 4), - error(HintCode.UNNECESSARY_CAST, 1960, 11), + error(WarningCode.UNNECESSARY_CAST, 1960, 11), error(HintCode.UNUSED_LOCAL_VARIABLE, 2047, 1), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 2088, 2), error(CompileTimeErrorCode.INVALID_CAST_FUNCTION, 2100, 4), @@ -650,7 +650,7 @@ void main() { error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 2255, 4), error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 2380, 10), error(CompileTimeErrorCode.INVALID_CAST_FUNCTION_EXPR, 2400, 22), - error(HintCode.UNNECESSARY_CAST, 2410, 11), + error(WarningCode.UNNECESSARY_CAST, 2410, 11), error(CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 2450, 4), error(HintCode.UNUSED_LOCAL_VARIABLE, 2495, 1), error(CompileTimeErrorCode.INVALID_CAST_FUNCTION, 2520, 6), @@ -661,7 +661,7 @@ void main() { error(CompileTimeErrorCode.INVALID_CAST_FUNCTION, 2741, 4), error(CompileTimeErrorCode.INVALID_CAST_FUNCTION_EXPR, 2914, 10), error(CompileTimeErrorCode.INVALID_CAST_FUNCTION_EXPR, 2952, 22), - error(HintCode.UNNECESSARY_CAST, 2962, 11), + error(WarningCode.UNNECESSARY_CAST, 2962, 11), ]); } @@ -1340,30 +1340,30 @@ void main() { error(HintCode.UNUSED_LOCAL_VARIABLE, 192, 1), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 222, 7), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 254, 3), - error(HintCode.UNNECESSARY_CAST, 268, 13), - error(HintCode.UNNECESSARY_CAST, 292, 15), + error(WarningCode.UNNECESSARY_CAST, 268, 13), + error(WarningCode.UNNECESSARY_CAST, 292, 15), error(HintCode.UNUSED_LOCAL_VARIABLE, 328, 1), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 340, 7), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 376, 3), - error(HintCode.UNNECESSARY_CAST, 404, 13), - error(HintCode.UNNECESSARY_CAST, 428, 15), + error(WarningCode.UNNECESSARY_CAST, 404, 13), + error(WarningCode.UNNECESSARY_CAST, 428, 15), error(HintCode.UNUSED_LOCAL_VARIABLE, 462, 1), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 492, 7), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 510, 3), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 524, 3), - error(HintCode.UNNECESSARY_CAST, 538, 13), - error(HintCode.UNNECESSARY_CAST, 562, 15), + error(WarningCode.UNNECESSARY_CAST, 538, 13), + error(WarningCode.UNNECESSARY_CAST, 562, 15), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 562, 15), error(HintCode.UNUSED_LOCAL_VARIABLE, 596, 1), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 608, 7), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 644, 3), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 658, 3), - error(HintCode.UNNECESSARY_CAST, 672, 13), + error(WarningCode.UNNECESSARY_CAST, 672, 13), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 696, 15), - error(HintCode.UNNECESSARY_CAST, 696, 15), + error(WarningCode.UNNECESSARY_CAST, 696, 15), error(HintCode.UNUSED_LOCAL_VARIABLE, 737, 1), - error(HintCode.UNNECESSARY_CAST, 813, 13), - error(HintCode.UNNECESSARY_CAST, 837, 15), + error(WarningCode.UNNECESSARY_CAST, 813, 13), + error(WarningCode.UNNECESSARY_CAST, 837, 15), ]); } @@ -1725,8 +1725,8 @@ var fe1 = (int x) => x; messageContains: ["'f0'"]), error(LanguageCode.IMPLICIT_DYNAMIC_RETURN, 96, 2, messageContains: ["'g0'"]), - error(HintCode.UNUSED_ELEMENT, 96, 2), - error(HintCode.UNUSED_ELEMENT, 126, 2), + error(WarningCode.UNUSED_ELEMENT, 96, 2), + error(WarningCode.UNUSED_ELEMENT, 126, 2), error(LanguageCode.IMPLICIT_DYNAMIC_RETURN, 212, 2, messageContains: ["'m0'"]), error(LanguageCode.IMPLICIT_DYNAMIC_RETURN, 304, 2, @@ -2264,10 +2264,10 @@ void main() { ''', [ error(HintCode.UNUSED_LOCAL_VARIABLE, 365, 1), error(HintCode.UNUSED_LOCAL_VARIABLE, 665, 1), - error(HintCode.UNNECESSARY_CAST, 674, 10), - error(HintCode.UNNECESSARY_CAST, 710, 10), - error(HintCode.UNNECESSARY_CAST, 747, 11), - error(HintCode.UNNECESSARY_CAST, 804, 11), + error(WarningCode.UNNECESSARY_CAST, 674, 10), + error(WarningCode.UNNECESSARY_CAST, 710, 10), + error(WarningCode.UNNECESSARY_CAST, 747, 11), + error(WarningCode.UNNECESSARY_CAST, 804, 11), ]); } @@ -2631,7 +2631,7 @@ class Child extends helper.Base { ''', [ error(WarningCode.UNUSED_FIELD, 83, 3), error(WarningCode.UNUSED_FIELD, 94, 3), - error(HintCode.UNUSED_ELEMENT, 109, 3), + error(WarningCode.UNUSED_ELEMENT, 109, 3), ]); } diff --git a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart index 4a783d7f84d..912eaeab655 100644 --- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart +++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart @@ -2547,7 +2547,7 @@ $declared foo() => new $declared.value(1); error(HintCode.UNUSED_LOCAL_VARIABLE, 309, 2), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 314, 1), error(HintCode.UNUSED_LOCAL_VARIABLE, 475, 2), - error(HintCode.UNNECESSARY_CAST, 480, 47), + error(WarningCode.UNNECESSARY_CAST, 480, 47), ], ); await disposeAnalysisContextCollection(); @@ -2567,7 +2567,7 @@ $declared foo() => new $declared.value(1); error(HintCode.UNUSED_LOCAL_VARIABLE, 311, 2), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 316, 1), error(HintCode.UNUSED_LOCAL_VARIABLE, 479, 2), - error(HintCode.UNNECESSARY_CAST, 484, 49), + error(WarningCode.UNNECESSARY_CAST, 484, 49), ], ); await disposeAnalysisContextCollection(); @@ -2587,7 +2587,7 @@ $declared foo() => new $declared.value(1); error(HintCode.UNUSED_LOCAL_VARIABLE, 309, 2), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 314, 1), error(HintCode.UNUSED_LOCAL_VARIABLE, 475, 2), - error(HintCode.UNNECESSARY_CAST, 480, 47), + error(WarningCode.UNNECESSARY_CAST, 480, 47), ], ); await disposeAnalysisContextCollection(); @@ -3068,7 +3068,7 @@ main() { contextMessages: [message('/home/test/lib/test.dart', 12, 1)]), error(CompileTimeErrorCode.INVALID_OVERRIDE, 94, 1, contextMessages: [message('/home/test/lib/test.dart', 33, 1)]), - error(HintCode.UNNECESSARY_CAST, 132, 12), + error(WarningCode.UNNECESSARY_CAST, 132, 12), ]); } @@ -3604,7 +3604,7 @@ test1() { error( isNullSafetyEnabled ? WarningCode.CAST_FROM_NULL_ALWAYS_FAILS - : HintCode.UNNECESSARY_CAST, + : WarningCode.UNNECESSARY_CAST, 591, 9), error(CompileTimeErrorCode.INVALID_ASSIGNMENT, 619, 4), @@ -3917,14 +3917,14 @@ main() { f9 () => f5(); } ''', [ - error(HintCode.UNUSED_ELEMENT, 11, 2), - error(HintCode.UNUSED_ELEMENT, 26, 2), - error(HintCode.UNUSED_ELEMENT, 48, 2), - error(HintCode.UNUSED_ELEMENT, 71, 2), - error(HintCode.UNUSED_ELEMENT, 100, 2), - error(HintCode.UNUSED_ELEMENT, 162, 2), - error(HintCode.UNUSED_ELEMENT, 177, 2), - error(HintCode.UNUSED_ELEMENT, 194, 2), + error(WarningCode.UNUSED_ELEMENT, 11, 2), + error(WarningCode.UNUSED_ELEMENT, 26, 2), + error(WarningCode.UNUSED_ELEMENT, 48, 2), + error(WarningCode.UNUSED_ELEMENT, 71, 2), + error(WarningCode.UNUSED_ELEMENT, 100, 2), + error(WarningCode.UNUSED_ELEMENT, 162, 2), + error(WarningCode.UNUSED_ELEMENT, 177, 2), + error(WarningCode.UNUSED_ELEMENT, 194, 2), error(CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION, 203, 2, contextMessages: [message(testFile.path, 211, 2)]), ]); diff --git a/pkg/analyzer/tool/messages/error_code_info.dart b/pkg/analyzer/tool/messages/error_code_info.dart index 7e87c5f361a..4b02bbde9a4 100644 --- a/pkg/analyzer/tool/messages/error_code_info.dart +++ b/pkg/analyzer/tool/messages/error_code_info.dart @@ -286,6 +286,7 @@ class AnalyzerErrorCodeInfo extends ErrorCodeInfo { AnalyzerErrorCodeInfo( {super.comment, super.correctionMessage, + super.deprecatedMessage, super.documentation, super.hasPublishedDocs, super.isUnresolvedIdentifier, @@ -438,6 +439,9 @@ abstract class ErrorCodeInfo { /// it. final String? correctionMessage; + /// If non-null, the deprecation message for this error code. + final String? deprecatedMessage; + /// If present, user-facing documentation for the error. final String? documentation; @@ -468,6 +472,7 @@ abstract class ErrorCodeInfo { this.sharedName, required this.problemMessage, this.correctionMessage, + this.deprecatedMessage, this.previousName}); /// Decodes an [ErrorCodeInfo] object from its YAML representation. @@ -475,6 +480,7 @@ abstract class ErrorCodeInfo { : this( comment: yaml['comment'] as String?, correctionMessage: yaml['correctionMessage'] as String?, + deprecatedMessage: yaml['deprecatedMessage'] as String?, documentation: yaml['documentation'] as String?, hasPublishedDocs: yaml['hasPublishedDocs'] as bool? ?? false, isUnresolvedIdentifier: diff --git a/pkg/analyzer/tool/messages/generate.dart b/pkg/analyzer/tool/messages/generate.dart index 4944846614d..4b0aa214306 100644 --- a/pkg/analyzer/tool/messages/generate.dart +++ b/pkg/analyzer/tool/messages/generate.dart @@ -81,6 +81,10 @@ class _AnalyzerErrorGenerator { // We allow some snake_case and SCREAMING_SNAKE_CASE identifiers in generated // code, as they match names declared in the source configuration files. // ignore_for_file: constant_identifier_names + +// While transitioning `HintCodes` to `WarningCodes`, we refer to deprecated +// codes here. +// ignore_for_file: deprecated_member_use_from_same_package '''); _AnalyzerErrorGenerator(this.errorClasses, this.generatedCodes); @@ -128,6 +132,10 @@ class _AnalyzerErrorGenerator { out.writeln('${errorCodeInfo.aliasFor};'); } else { generatedCodes.add('${errorClass.name}.$errorName'); + var deprecatedMessage = errorCodeInfo.deprecatedMessage; + if (deprecatedMessage != null) { + out.writeln(' @Deprecated("$deprecatedMessage")'); + } out.writeln(' static const ${errorClass.name} $errorName ='); out.writeln(errorCodeInfo.toAnalyzerCode(errorClass.name, errorName)); } @@ -183,6 +191,10 @@ class _ErrorCodeValuesGenerator { // We allow some snake_case and SCREAMING_SNAKE_CASE identifiers in generated // code, as they match names declared in the source configuration files. // ignore_for_file: constant_identifier_names + +// While transitioning `HintCodes` to `WarningCodes`, we refer to deprecated +// codes here. +// ignore_for_file: deprecated_member_use_from_same_package '''); _ErrorCodeValuesGenerator(this.generatedCodes); diff --git a/pkg/nnbd_migration/test/edge_builder_test.dart b/pkg/nnbd_migration/test/edge_builder_test.dart index c15668acbbf..d263c8e59e0 100644 --- a/pkg/nnbd_migration/test/edge_builder_test.dart +++ b/pkg/nnbd_migration/test/edge_builder_test.dart @@ -14,7 +14,7 @@ import 'package:analyzer/src/dart/element/element.dart'; import 'package:analyzer/src/dart/element/type.dart'; import 'package:analyzer/src/dart/element/type_provider.dart'; import 'package:analyzer/src/dart/element/type_system.dart' show TypeSystemImpl; -import 'package:analyzer/src/dart/error/hint_codes.dart'; +import 'package:analyzer/src/error/codes.g.dart'; import 'package:analyzer/src/generated/source.dart'; import 'package:analyzer/src/generated/testing/test_type_provider.dart'; import 'package:nnbd_migration/fix_reason_target.dart'; @@ -681,8 +681,8 @@ void f(int i) { (i as int).gcd(1); } '''); - expect( - testAnalysisResult.errors.single.errorCode, HintCode.UNNECESSARY_CAST); + expect(testAnalysisResult.errors.single.errorCode, + WarningCode.UNNECESSARY_CAST); assertEdge(decoratedTypeAnnotation('int i').node, decoratedTypeAnnotation('int)').node, hard: true); diff --git a/pkg/nnbd_migration/test/fix_builder_test.dart b/pkg/nnbd_migration/test/fix_builder_test.dart index 66524c31548..eb895b65fcc 100644 --- a/pkg/nnbd_migration/test/fix_builder_test.dart +++ b/pkg/nnbd_migration/test/fix_builder_test.dart @@ -7,7 +7,7 @@ import 'package:analyzer/dart/element/type.dart'; import 'package:analyzer/dart/element/type_provider.dart'; import 'package:analyzer/src/dart/element/element.dart'; import 'package:analyzer/src/dart/element/type_provider.dart'; -import 'package:analyzer/src/dart/error/hint_codes.dart'; +import 'package:analyzer/src/error/codes.g.dart'; import 'package:analyzer/src/generated/element_type_provider.dart'; import 'package:nnbd_migration/fix_reason_target.dart'; import 'package:nnbd_migration/nnbd_migration.dart'; @@ -177,8 +177,8 @@ f(int i) { print((i as int) + 1); } '''); - expect( - testAnalysisResult.errors.single.errorCode, HintCode.UNNECESSARY_CAST); + expect(testAnalysisResult.errors.single.errorCode, + WarningCode.UNNECESSARY_CAST); var asExpression = findNode.simple('i as').parent as Expression; visitSubexpression(asExpression, 'int'); } diff --git a/tools/verify_docs/bin/verify_docs.dart b/tools/verify_docs/bin/verify_docs.dart index 509d52d4f78..752f7a65002 100755 --- a/tools/verify_docs/bin/verify_docs.dart +++ b/tools/verify_docs/bin/verify_docs.dart @@ -345,7 +345,7 @@ class ValidateCommentCodeSamplesVisitor extends GeneralizingAstVisitor { errors.removeWhere( (e) => e.errorCode == HintCode.UNUSED_LOCAL_VARIABLE || - e.errorCode == HintCode.UNUSED_ELEMENT, + e.errorCode == WarningCode.UNUSED_ELEMENT, ); // Handle edge case around dart:_http