Chromium Code Reviews| Index: pkg/analyzer/lib/src/generated/resolver.dart |
| =================================================================== |
| --- pkg/analyzer/lib/src/generated/resolver.dart (revision 42759) |
| +++ pkg/analyzer/lib/src/generated/resolver.dart (working copy) |
| @@ -4470,18 +4470,22 @@ |
| } |
| -/** |
| - * Traverses a library's worth of dart code at a time to generate lint warnings |
| - * over the set of sources. |
| - * |
| - * See [LintCode]. |
| - */ |
| +/// Traverses a library's worth of dart code at a time to generate lint warnings |
| +/// over the set of sources. |
| +/// |
| +/// See [LintCode]. |
| class LintGenerator { |
| - final List<CompilationUnit> _compilationUnits; |
| + /// A global container for contributed verifiers. |
| + static final List<LintVerifier> VERIFIERS = <LintVerifier>[]; |
| + |
| + final Iterable<CompilationUnit> _compilationUnits; |
| final AnalysisErrorListener _errorListener; |
| + final Iterable<LintVerifier> _verifiers; |
| - LintGenerator(this._compilationUnits, this._errorListener); |
| + LintGenerator(this._compilationUnits, this._errorListener, |
| + [Iterable<LintVerifier> verifiers]) |
|
scheglov
2015/01/10 00:58:11
Why is it optional?
Do we expect that we will ever
pquitslund
2015/01/12 16:44:43
Actually, the common use case is to NOT provide th
|
| + : _verifiers = verifiers != null ? verifiers : VERIFIERS; |
| void generate() { |
| TimeCounter_TimeCounterHandle timeCounter = |
| @@ -4499,15 +4503,18 @@ |
| void _generate(CompilationUnit unit, Source source) { |
| ErrorReporter errorReporter = new ErrorReporter(_errorListener, source); |
| - unit.accept(new LintVerifier(errorReporter)); |
| + _verifiers.forEach((verifier) { |
| + verifier.reporter = errorReporter; |
| + return unit.accept(verifier); |
| + }); |
| } |
| } |
| -class LintVerifier extends RecursiveAstVisitor<Object> { |
| - |
| - final ErrorReporter _reporter; |
| - |
| - LintVerifier(this._reporter); |
| +/// Implementers contribute lint warnings via the provided error [reporter]. |
| +abstract class LintVerifier extends RecursiveAstVisitor<Object> { |
| + /// Used to report lint warnings. |
| + /// NOTE: this is set by the framework before visit begins. |
| + ErrorReporter reporter; |
| } |