mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[analyzer] Don't generate error codes for removed diagnostics
Also renames 'removed' to 'removedIn' to better indicate it is looking for a version, not a boolean. Change-Id: If3a6708ba32460305e89ba59c4a58ce2ad284e6a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319282 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
1e12b09a59
commit
1b8870bbb1
|
@ -44,9 +44,9 @@
|
|||
# issue created for it.
|
||||
#
|
||||
# Stats:
|
||||
# - 0 "needsEvaluation"
|
||||
# - 381 "needsFix"
|
||||
# - 348 "hasFix"
|
||||
# - 19 "needsEvaluation"
|
||||
# - 372 "needsFix"
|
||||
# - 359 "hasFix"
|
||||
# - 490 "noFix"
|
||||
|
||||
AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR:
|
||||
|
@ -1760,12 +1760,6 @@ FfiCode.PACKED_ANNOTATION_ALIGNMENT:
|
|||
status: noFix
|
||||
FfiCode.SIZE_ANNOTATION_DIMENSIONS:
|
||||
status: noFix
|
||||
FfiCode.SUBTYPE_OF_FFI_CLASS_IN_EXTENDS:
|
||||
status: noFix
|
||||
FfiCode.SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS:
|
||||
status: noFix
|
||||
FfiCode.SUBTYPE_OF_FFI_CLASS_IN_WITH:
|
||||
status: noFix
|
||||
FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_EXTENDS:
|
||||
status: hasFix
|
||||
FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_IMPLEMENTS:
|
||||
|
|
|
@ -394,39 +394,6 @@ class FfiCode extends AnalyzerErrorCode {
|
|||
hasPublishedDocs: true,
|
||||
);
|
||||
|
||||
/// Parameters:
|
||||
/// 0: the name of the subclass
|
||||
/// 1: the name of the class being extended, implemented, or mixed in
|
||||
static const FfiCode SUBTYPE_OF_FFI_CLASS_IN_EXTENDS = FfiCode(
|
||||
'SUBTYPE_OF_FFI_CLASS',
|
||||
"The class '{0}' can't extend '{1}'.",
|
||||
correctionMessage: "Try extending 'Struct' or 'Union'.",
|
||||
hasPublishedDocs: true,
|
||||
uniqueName: 'SUBTYPE_OF_FFI_CLASS_IN_EXTENDS',
|
||||
);
|
||||
|
||||
/// Parameters:
|
||||
/// 0: the name of the subclass
|
||||
/// 1: the name of the class being extended, implemented, or mixed in
|
||||
static const FfiCode SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS = FfiCode(
|
||||
'SUBTYPE_OF_FFI_CLASS',
|
||||
"The class '{0}' can't implement '{1}'.",
|
||||
correctionMessage: "Try implementing 'Allocator' or 'Finalizable'.",
|
||||
hasPublishedDocs: true,
|
||||
uniqueName: 'SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS',
|
||||
);
|
||||
|
||||
/// Parameters:
|
||||
/// 0: the name of the subclass
|
||||
/// 1: the name of the class being extended, implemented, or mixed in
|
||||
static const FfiCode SUBTYPE_OF_FFI_CLASS_IN_WITH = FfiCode(
|
||||
'SUBTYPE_OF_FFI_CLASS',
|
||||
"The class '{0}' can't mix in '{1}'.",
|
||||
correctionMessage: "Try extending 'Struct' or 'Union'.",
|
||||
hasPublishedDocs: true,
|
||||
uniqueName: 'SUBTYPE_OF_FFI_CLASS_IN_WITH',
|
||||
);
|
||||
|
||||
/// Parameters:
|
||||
/// 0: the name of the subclass
|
||||
/// 1: the name of the class being extended, implemented, or mixed in
|
||||
|
|
|
@ -682,6 +682,7 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
|
|||
correctionMessage:
|
||||
"Try removing the keyword 'const' from the constructor or removing the "
|
||||
"keyword 'deferred' from the import.",
|
||||
hasPublishedDocs: true,
|
||||
uniqueName: 'CONST_CONSTRUCTOR_CONSTANT_FROM_DEFERRED_LIBRARY',
|
||||
);
|
||||
|
||||
|
|
|
@ -595,9 +595,6 @@ const List<ErrorCode> errorCodeValues = [
|
|||
FfiCode.PACKED_ANNOTATION,
|
||||
FfiCode.PACKED_ANNOTATION_ALIGNMENT,
|
||||
FfiCode.SIZE_ANNOTATION_DIMENSIONS,
|
||||
FfiCode.SUBTYPE_OF_FFI_CLASS_IN_EXTENDS,
|
||||
FfiCode.SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS,
|
||||
FfiCode.SUBTYPE_OF_FFI_CLASS_IN_WITH,
|
||||
FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_EXTENDS,
|
||||
FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_IMPLEMENTS,
|
||||
FfiCode.SUBTYPE_OF_STRUCT_CLASS_IN_WITH,
|
||||
|
|
|
@ -2271,6 +2271,7 @@ CompileTimeErrorCode:
|
|||
sharedName: COLLECTION_ELEMENT_FROM_DEFERRED_LIBRARY
|
||||
problemMessage: "Constant values from a deferred library can't be used as values in a 'const' constructor."
|
||||
correctionMessage: "Try removing the keyword 'const' from the constructor or removing the keyword 'deferred' from the import."
|
||||
hasPublishedDocs: true
|
||||
comment: No parameters.
|
||||
CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH:
|
||||
problemMessage: "A value of type '{0}' can't be assigned to a parameter of type '{1}' in a const constructor."
|
||||
|
@ -19422,7 +19423,7 @@ FfiCode:
|
|||
}
|
||||
```
|
||||
SUBTYPE_OF_FFI_CLASS_IN_EXTENDS:
|
||||
removed: 3.0
|
||||
removedIn: "3.0"
|
||||
sharedName: SUBTYPE_OF_FFI_CLASS
|
||||
problemMessage: "The class '{0}' can't extend '{1}'."
|
||||
correctionMessage: "Try extending 'Struct' or 'Union'."
|
||||
|
@ -19473,7 +19474,7 @@ FfiCode:
|
|||
final class C {}
|
||||
```
|
||||
SUBTYPE_OF_FFI_CLASS_IN_IMPLEMENTS:
|
||||
removed: 3.0
|
||||
removedIn: "3.0"
|
||||
sharedName: SUBTYPE_OF_FFI_CLASS
|
||||
problemMessage: "The class '{0}' can't implement '{1}'."
|
||||
correctionMessage: "Try implementing 'Allocator' or 'Finalizable'."
|
||||
|
@ -19483,7 +19484,7 @@ FfiCode:
|
|||
1: the name of the class being extended, implemented, or mixed in
|
||||
hasPublishedDocs: true
|
||||
SUBTYPE_OF_FFI_CLASS_IN_WITH:
|
||||
removed: 3.0
|
||||
removedIn: "3.0"
|
||||
sharedName: SUBTYPE_OF_FFI_CLASS
|
||||
problemMessage: "The class '{0}' can't mix in '{1}'."
|
||||
correctionMessage: "Try extending 'Struct' or 'Union'."
|
||||
|
|
|
@ -99,8 +99,6 @@ class DocumentationValidator {
|
|||
// Produces two diagnostics when it should only produce one (see
|
||||
// https://github.com/dart-lang/sdk/issues/43051)
|
||||
'HintCode.UNNECESSARY_NULL_COMPARISON_FALSE',
|
||||
// Also produces FINAL_CLASS_EXTENDED_OUTSIDE_OF_LIBRARY.
|
||||
'FfiCode.SUBTYPE_OF_FFI_CLASS_IN_EXTENDS',
|
||||
|
||||
// Produces two diagnostics when it should only produce one (see
|
||||
// https://github.com/dart-lang/sdk/issues/43263)
|
||||
|
@ -274,6 +272,13 @@ class DocumentationValidator {
|
|||
for (var errorEntry in messages.entries) {
|
||||
var errorName = errorEntry.key;
|
||||
var errorCodeInfo = errorEntry.value;
|
||||
|
||||
// If the error code is no longer generated,
|
||||
// the corresponding code snippets won't report it.
|
||||
if (errorCodeInfo.isRemoved) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var docs = parseErrorCodeDocumentation(
|
||||
'$className.$errorName', errorCodeInfo.documentation);
|
||||
if (docs != null) {
|
||||
|
|
|
@ -2088,6 +2088,9 @@ class C with M {}
|
|||
_Constant values from a deferred library can't be used as keys in a 'const' map
|
||||
literal._
|
||||
|
||||
_Constant values from a deferred library can't be used as values in a 'const'
|
||||
constructor._
|
||||
|
||||
_Constant values from a deferred library can't be used as values in a 'const'
|
||||
list literal._
|
||||
|
||||
|
|
|
@ -283,15 +283,17 @@ class AliasErrorCodeInfo extends AnalyzerErrorCodeInfo {
|
|||
/// In-memory representation of error code information obtained from the
|
||||
/// analyzer's `messages.yaml` file.
|
||||
class AnalyzerErrorCodeInfo extends ErrorCodeInfo {
|
||||
AnalyzerErrorCodeInfo(
|
||||
{super.comment,
|
||||
super.correctionMessage,
|
||||
super.deprecatedMessage,
|
||||
super.documentation,
|
||||
super.hasPublishedDocs,
|
||||
super.isUnresolvedIdentifier,
|
||||
required super.problemMessage,
|
||||
super.sharedName});
|
||||
AnalyzerErrorCodeInfo({
|
||||
super.comment,
|
||||
super.correctionMessage,
|
||||
super.deprecatedMessage,
|
||||
super.documentation,
|
||||
super.hasPublishedDocs,
|
||||
super.isUnresolvedIdentifier,
|
||||
required super.problemMessage,
|
||||
super.removedIn,
|
||||
super.sharedName,
|
||||
});
|
||||
|
||||
AnalyzerErrorCodeInfo.fromYaml(super.yaml) : super.fromYaml();
|
||||
}
|
||||
|
@ -455,6 +457,10 @@ abstract class ErrorCodeInfo {
|
|||
/// The problemMessage for the error code.
|
||||
final String problemMessage;
|
||||
|
||||
/// If present, the SDK version this error code stopped being reported in.
|
||||
/// If not null, error codes will not be generated for this error.
|
||||
final String? removedIn;
|
||||
|
||||
/// If present, indicates that this error code has a special name for
|
||||
/// presentation to the user, that is potentially shared with other error
|
||||
/// codes.
|
||||
|
@ -464,16 +470,18 @@ abstract class ErrorCodeInfo {
|
|||
/// [previousName] to its current name (or [sharedName]).
|
||||
final String? previousName;
|
||||
|
||||
ErrorCodeInfo(
|
||||
{this.comment,
|
||||
this.documentation,
|
||||
this.hasPublishedDocs = false,
|
||||
this.isUnresolvedIdentifier = false,
|
||||
this.sharedName,
|
||||
required this.problemMessage,
|
||||
this.correctionMessage,
|
||||
this.deprecatedMessage,
|
||||
this.previousName});
|
||||
ErrorCodeInfo({
|
||||
this.comment,
|
||||
this.documentation,
|
||||
this.hasPublishedDocs = false,
|
||||
this.isUnresolvedIdentifier = false,
|
||||
this.sharedName,
|
||||
required this.problemMessage,
|
||||
this.correctionMessage,
|
||||
this.deprecatedMessage,
|
||||
this.previousName,
|
||||
this.removedIn,
|
||||
});
|
||||
|
||||
/// Decodes an [ErrorCodeInfo] object from its YAML representation.
|
||||
ErrorCodeInfo.fromYaml(Map<Object?, Object?> yaml)
|
||||
|
@ -487,8 +495,13 @@ abstract class ErrorCodeInfo {
|
|||
yaml['isUnresolvedIdentifier'] as bool? ?? false,
|
||||
problemMessage: yaml['problemMessage'] as String,
|
||||
sharedName: yaml['sharedName'] as String?,
|
||||
removedIn: yaml['removedIn'] as String?,
|
||||
previousName: yaml['previousName'] as String?);
|
||||
|
||||
/// If this error is no longer reported and
|
||||
/// its error codes should no longer be generated.
|
||||
bool get isRemoved => removedIn != null;
|
||||
|
||||
/// Given a messages.yaml entry, come up with a mapping from placeholder
|
||||
/// patterns in its message strings to their corresponding indices.
|
||||
Map<String, int> computePlaceholderToIndexMap() {
|
||||
|
@ -556,6 +569,7 @@ abstract class ErrorCodeInfo {
|
|||
|
||||
/// Encodes this object into a YAML representation.
|
||||
Map<Object?, Object?> toYaml() => {
|
||||
if (removedIn != null) 'removedIn': removedIn,
|
||||
if (sharedName != null) 'sharedName': sharedName,
|
||||
'problemMessage': problemMessage,
|
||||
if (correctionMessage != null) 'correctionMessage': correctionMessage,
|
||||
|
|
|
@ -22,6 +22,7 @@ import 'dart:io';
|
|||
import 'package:_fe_analyzer_shared/src/scanner/scanner.dart';
|
||||
import 'package:analyzer_utilities/package_root.dart' as pkg_root;
|
||||
import 'package:analyzer_utilities/tools.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:path/path.dart';
|
||||
|
||||
import 'error_code_info.dart';
|
||||
|
@ -119,8 +120,8 @@ class _AnalyzerErrorGenerator {
|
|||
...analyzerMessages[errorClass.name]!.entries,
|
||||
if (errorClass.includeCfeMessages)
|
||||
...cfeToAnalyzerErrorCodeTables.analyzerCodeToInfo.entries
|
||||
];
|
||||
for (var entry in entries..sort((a, b) => a.key.compareTo(b.key))) {
|
||||
].where((error) => !error.value.isRemoved).sortedBy((e) => e.key);
|
||||
for (var entry in entries) {
|
||||
var errorName = entry.key;
|
||||
var errorCodeInfo = entry.value;
|
||||
|
||||
|
|
Loading…
Reference in a new issue