@@ -50,14 +50,18 @@ sealed class AbstractAnalysisRule {
5050 this .state = const State .stable (),
5151 });
5252
53- /// Indicates whether the lint rule can work with just the parsed information
54- /// or if it requires a resolved unit.
53+ /// Indicates whether this analysis rule can work with just the parsed
54+ /// information or if it requires a resolved unit.
5555 bool get canUseParsedResult => false ;
5656
57+ /// The diagnostic codes associated with this analysis rule.
58+ List <DiagnosticCode > get diagnosticCodes => lintCodes;
59+
5760 /// A list of incompatible rule ids.
5861 List <String > get incompatibleRules => const [];
5962
60- /// The lint codes associated with this lint rule.
63+ /// The lint codes associated with this analysis rule.
64+ // TODO(srawlins): Deprecate this in favor of `diagnosticCodes`.
6165 List <LintCode > get lintCodes;
6266
6367 /// Returns a visitor that visits a [Pubspec] to perform analysis.
@@ -66,7 +70,7 @@ sealed class AbstractAnalysisRule {
6670 PubspecVisitor ? get pubspecVisitor => null ;
6771
6872 @protected
69- // Protected so that lint rule visitors do not access this directly.
73+ // Protected so that analysis rule visitors do not access this directly.
7074 // TODO(srawlins): With the new availability of an ErrorReporter on
7175 // LinterContextUnit, we should probably remove this reporter. But whatever
7276 // the new API would be is not yet decided. It might also change with the
@@ -123,16 +127,16 @@ sealed class AbstractAnalysisRule {
123127 List <DiagnosticMessage > contextMessages = const [],
124128 required DiagnosticCode errorCode,
125129 }) {
126- // Cache error and location info for creating `AnalysisErrorInfo`s.
127- var error = Diagnostic .tmp (
130+ // Cache diagnostic and location info for creating `AnalysisErrorInfo`s.
131+ var diagnostic = Diagnostic .tmp (
128132 source: node.source,
129133 offset: node.span.start.offset,
130134 length: node.span.length,
131135 errorCode: errorCode,
132136 arguments: arguments,
133137 contextMessages: contextMessages,
134138 );
135- reporter.reportError (error );
139+ reporter.reportError (diagnostic );
136140 }
137141
138142 void _reportAtToken (
@@ -157,6 +161,11 @@ sealed class AbstractAnalysisRule {
157161abstract class AnalysisRule extends AbstractAnalysisRule {
158162 AnalysisRule ({required super .name, required super .description, super .state});
159163
164+ /// The code to report for a violation.
165+ DiagnosticCode get diagnosticCode => lintCode;
166+
167+ /// The code to report for a violation.
168+ // TODO(srawlins): Deprecate this in favor of `diagnosticCode`.
160169 LintCode get lintCode;
161170
162171 @override
@@ -170,7 +179,7 @@ abstract class AnalysisRule extends AbstractAnalysisRule {
170179 List <DiagnosticMessage >? contextMessages,
171180 }) => _reportAtNode (
172181 node,
173- diagnosticCode: lintCode ,
182+ diagnosticCode: diagnosticCode ,
174183 arguments: arguments,
175184 contextMessages: contextMessages,
176185 );
@@ -185,7 +194,7 @@ abstract class AnalysisRule extends AbstractAnalysisRule {
185194 }) => _reportAtOffset (
186195 offset,
187196 length,
188- diagnosticCode: lintCode ,
197+ diagnosticCode: diagnosticCode ,
189198 arguments: arguments,
190199 contextMessages: contextMessages,
191200 );
@@ -198,7 +207,7 @@ abstract class AnalysisRule extends AbstractAnalysisRule {
198207 List <DiagnosticMessage > contextMessages = const [],
199208 }) => _reportAtPubNode (
200209 node,
201- errorCode: lintCode ,
210+ errorCode: diagnosticCode ,
202211 arguments: arguments,
203212 contextMessages: contextMessages,
204213 );
@@ -211,7 +220,7 @@ abstract class AnalysisRule extends AbstractAnalysisRule {
211220 List <DiagnosticMessage >? contextMessages,
212221 }) => _reportAtToken (
213222 token,
214- diagnosticCode: lintCode ,
223+ diagnosticCode: diagnosticCode ,
215224 arguments: arguments,
216225 contextMessages: contextMessages,
217226 );
0 commit comments