[messages] Remove diagnostic class names from error_fix_status.yaml.
This is part of a larger effort to remove the diagnostic classes entirely. Change-Id: I6a6a69646c8d604d29d8e62da886628c3c9613ec Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462501 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -54,12 +54,14 @@ String? verifyErrorFixStatus() {
|
||||
var lintRuleCodes = {
|
||||
for (var rule in Registry.ruleRegistry.rules) ...rule.diagnosticCodes,
|
||||
};
|
||||
var lintRuleNames = {for (var lintCode in lintRuleCodes) lintCode.uniqueName};
|
||||
var lintRuleNames = {
|
||||
for (var lintCode in lintRuleCodes) lintCode.uniqueName.suffix,
|
||||
};
|
||||
|
||||
var errorData = ErrorData();
|
||||
for (var code in diagnosticCodeValues) {
|
||||
var name = code.uniqueName;
|
||||
if (name.startsWith('TodoCode.')) {
|
||||
var name = code.uniqueName.suffix;
|
||||
if (code.type == .TODO) {
|
||||
// To-do codes are ignored.
|
||||
continue;
|
||||
}
|
||||
@@ -81,7 +83,7 @@ String? verifyErrorFixStatus() {
|
||||
}
|
||||
}
|
||||
for (var lintCode in lintRuleCodes) {
|
||||
var name = lintCode.uniqueName;
|
||||
var name = lintCode.uniqueName.suffix;
|
||||
var info = statusInfo.nodes[name];
|
||||
if (info == null) {
|
||||
errorData.codesWithNoEntry.add(name);
|
||||
@@ -99,7 +101,9 @@ String? verifyErrorFixStatus() {
|
||||
}
|
||||
}
|
||||
|
||||
var codeNames = {for (var code in diagnosticCodeValues) code.uniqueName};
|
||||
var codeNames = {
|
||||
for (var code in diagnosticCodeValues) code.uniqueName.suffix,
|
||||
};
|
||||
for (var key in statusInfo.keys) {
|
||||
if (key is String) {
|
||||
if (!codeNames.contains(key) && !lintRuleNames.contains(key)) {
|
||||
@@ -202,3 +206,10 @@ extension on DiagnosticCode {
|
||||
PubspecFixGenerator.codesWithFixes.contains(self);
|
||||
}
|
||||
}
|
||||
|
||||
extension on String {
|
||||
String get suffix => switch (split('.')) {
|
||||
[_, var s] => s,
|
||||
_ => throw 'Expected ErrorClass.ERROR_CODE, found $this',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ void main() {
|
||||
// Doc generation reads the fix status map to associate fix status
|
||||
// badges with rule documentation. Here we check one for sanity.
|
||||
// If the file moves or format changes, we'd expect this to fail.
|
||||
expect(fixStatusMap['LintCode.prefer_single_quotes'], 'hasFix');
|
||||
expect(fixStatusMap['prefer_single_quotes'], 'hasFix');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ Future<String> getMachineListing(
|
||||
'incompatible': rule.incompatibleRules,
|
||||
'sets': const [],
|
||||
'fixStatus':
|
||||
fixStatusMap[rule.diagnosticCodes.first.uniqueName] ??
|
||||
fixStatusMap[rule.diagnosticCodes.first.uniqueName.suffix] ??
|
||||
'unregistered',
|
||||
'details': info.deprecatedDetails,
|
||||
'sinceDartSdk': _versionToString(info.states.first.since),
|
||||
@@ -96,7 +96,7 @@ Map<String, String> readFixStatusMap() {
|
||||
var yaml = loadYamlNode(contents) as YamlMap;
|
||||
return <String, String>{
|
||||
for (var MapEntry(key: String code, :YamlMap value) in yaml.entries)
|
||||
if (code.startsWith('LintCode.')) code: value['status'] as String,
|
||||
code: value['status'] as String,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -105,3 +105,19 @@ String _versionToString(Version? version) {
|
||||
|
||||
return '${version.major}.${version.minor}';
|
||||
}
|
||||
|
||||
class _Error extends Error {
|
||||
final String message;
|
||||
|
||||
_Error(this.message);
|
||||
|
||||
@override
|
||||
String toString() => message;
|
||||
}
|
||||
|
||||
extension on String {
|
||||
String get suffix => switch (split('.')) {
|
||||
[_, var s] => s,
|
||||
_ => throw _Error('Expected ErrorClass.ERROR_CODE, found $this'),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user