[messages] Refactor DiagnosticClassInfo.typeCode.
`DiagnosticClassInfo.typeCode` is replaced with a `code` getter on the `AnalyzerDiagnosticType` enum. This is part of a longer term effort to remove the `DiagnosticCode`-derived classes entirely. Change-Id: I6a6a69641b013d7c2ce8af3f4d54c82a9980bdb7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462320 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
@@ -466,6 +466,9 @@ enum AnalyzerDiagnosticType {
|
||||
final DiagnosticBaseClasses baseClasses;
|
||||
|
||||
const AnalyzerDiagnosticType({this.baseClasses = analyzerBaseClasses});
|
||||
|
||||
/// The representation of this type in analyzer source code.
|
||||
String get code => 'DiagnosticType.${name.toSnakeCase().toUpperCase()}';
|
||||
}
|
||||
|
||||
/// In-memory representation of diagnostic information obtained from the
|
||||
@@ -599,10 +602,6 @@ class DiagnosticClassInfo {
|
||||
this.comment = '',
|
||||
});
|
||||
|
||||
/// Generates the code to compute the type of diagnostics of this class.
|
||||
String get typeCode =>
|
||||
'DiagnosticType.${type.name.toSnakeCase().toUpperCase()}';
|
||||
|
||||
static DiagnosticClassInfo byName(String name) =>
|
||||
_diagnosticClassesByName[name] ??
|
||||
(throw 'No diagnostic class named ${json.encode(name)}. Possible names: '
|
||||
@@ -730,7 +729,7 @@ LocatableDiagnostic $withArgumentsName({$withArgumentsParams}) {
|
||||
constant.writeln('isUnresolvedIdentifier:true,');
|
||||
}
|
||||
if (baseClasses.requiresTypeArgument) {
|
||||
constant.writeln('type: ${diagnosticClassInfo.typeCode},');
|
||||
constant.writeln('type: ${diagnosticClassInfo.type.code},');
|
||||
}
|
||||
String uniqueName = analyzerCode.toString().replaceFirst(
|
||||
'LinterLintCode.',
|
||||
|
||||
Reference in New Issue
Block a user