Skip to content

Commit d9923e4

Browse files
stereotype441Commit Queue
authored andcommitted
[messages] Store lint codes in Registry as DiagnosticCodes.
Changes the static type of values in `Registry._codeMap` from `LintCode` to `DiagnosticCode`, and removes some casts that become unnecessary as a result. The return type of `Registry.codeForUniqueName` is similarly changed to `DiagnosticCode?`. This paves the way for a follow-up CL that will change the runtime types of lint codes from `LintCode` to `DiagnosticCode`. Change-Id: I6a6a6964262b80324ddf6b2cf445217eef521bec Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459522 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
1 parent b8b41cb commit d9923e4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pkg/analyzer/lib/src/lint/registry.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import 'dart:collection';
66

7+
import 'package:analyzer/error/error.dart';
78
import 'package:analyzer/src/analysis_rule/rule_context.dart';
8-
import 'package:analyzer/src/dart/error/lint_codes.dart';
99
import 'package:analyzer/src/lint/config.dart';
1010

1111
/// Registry of lint rules and warning rules.
@@ -20,7 +20,7 @@ class Registry with IterableMixin<AbstractAnalysisRule> {
2020
final Map<String, AbstractAnalysisRule> _warningRules = {};
2121

2222
/// A table mapping unique names to lint codes.
23-
final Map<String, LintCode> _codeMap = {};
23+
final Map<String, DiagnosticCode> _codeMap = {};
2424

2525
@override
2626
Iterator<AbstractAnalysisRule> get iterator => _rules.values.iterator;
@@ -39,7 +39,7 @@ class Registry with IterableMixin<AbstractAnalysisRule> {
3939
AbstractAnalysisRule? operator [](String name) => _rules[name];
4040

4141
/// Returns the lint code that has the given [uniqueName].
42-
LintCode? codeForUniqueName(String uniqueName) => _codeMap[uniqueName];
42+
DiagnosticCode? codeForUniqueName(String uniqueName) => _codeMap[uniqueName];
4343

4444
/// Returns a list of the enabled rules.
4545
///
@@ -70,15 +70,15 @@ class Registry with IterableMixin<AbstractAnalysisRule> {
7070
void registerLintRule(AbstractAnalysisRule rule) {
7171
_lintRules[rule.name] = rule;
7272
for (var code in rule.diagnosticCodes) {
73-
_codeMap[code.uniqueName] = code as LintCode;
73+
_codeMap[code.uniqueName] = code;
7474
}
7575
}
7676

7777
/// Adds the given warning [rule] to this registry.
7878
void registerWarningRule(AbstractAnalysisRule rule) {
7979
_warningRules[rule.name] = rule;
8080
for (var code in rule.diagnosticCodes) {
81-
_codeMap[code.uniqueName] = code as LintCode;
81+
_codeMap[code.uniqueName] = code;
8282
}
8383
}
8484

0 commit comments

Comments
 (0)