Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 848463003: Pluggable lint verifiers first step and basic lint task tests. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698