| Index: pkg/analyzer/lib/src/generated/resolver.dart
|
| ===================================================================
|
| --- pkg/analyzer/lib/src/generated/resolver.dart (revision 42896)
|
| +++ pkg/analyzer/lib/src/generated/resolver.dart (working copy)
|
| @@ -8,6 +8,7 @@
|
| import 'dart:collection';
|
|
|
| import 'package:analyzer/src/generated/utilities_collection.dart';
|
| +import 'package:analyzer/src/generated/visitors.dart';
|
|
|
| import 'ast.dart';
|
| import 'constant.dart';
|
| @@ -4470,54 +4471,6 @@
|
| }
|
|
|
|
|
| -/// Traverses a library's worth of dart code at a time to generate lint warnings
|
| -/// over the set of sources.
|
| -///
|
| -/// See [LintCode].
|
| -class LintGenerator {
|
| -
|
| - /// 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,
|
| - [Iterable<LintVerifier> verifiers])
|
| - : _verifiers = verifiers != null ? verifiers : VERIFIERS;
|
| -
|
| - void generate() {
|
| - TimeCounter_TimeCounterHandle timeCounter =
|
| - PerformanceStatistics.lint.start();
|
| - try {
|
| - _compilationUnits.forEach((cu) {
|
| - if (cu.element != null) {
|
| - _generate(cu, cu.element.source);
|
| - }
|
| - });
|
| - } finally {
|
| - timeCounter.stop();
|
| - }
|
| - }
|
| -
|
| - void _generate(CompilationUnit unit, Source source) {
|
| - ErrorReporter errorReporter = new ErrorReporter(_errorListener, source);
|
| - _verifiers.forEach((verifier) {
|
| - verifier.reporter = errorReporter;
|
| - return unit.accept(verifier);
|
| - });
|
| - }
|
| -}
|
| -
|
| -/// 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;
|
| -}
|
| -
|
| -
|
| /**
|
| * Instances of the class {@code HtmlTagInfo} record information about the tags used in an HTML
|
| * file.
|
| @@ -9249,6 +9202,57 @@
|
| }
|
| }
|
|
|
| +/// Implementers contribute lint warnings via the provided error [reporter].
|
| +abstract class Linter {
|
| + /// Used to report lint warnings.
|
| + /// NOTE: this is set by the framework before visit begins.
|
| + ErrorReporter reporter;
|
| +
|
| + /// Return a visitor to be passed to compilation units to perform lint
|
| + /// analysis.
|
| + /// Lint errors are reported via this [Linter]'s error [reporter].
|
| + AstVisitor getVisitor();
|
| +}
|
| +
|
| +/// Traverses a library's worth of dart code at a time to generate lint warnings
|
| +/// over the set of sources.
|
| +///
|
| +/// See [LintCode].
|
| +class LintGenerator {
|
| +
|
| + /// A global container for contributed linters.
|
| + static final List<Linter> LINTERS = <Linter>[];
|
| +
|
| + final Iterable<CompilationUnit> _compilationUnits;
|
| + final AnalysisErrorListener _errorListener;
|
| + final Iterable<Linter> _linters;
|
| +
|
| + LintGenerator(this._compilationUnits, this._errorListener,
|
| + [Iterable<Linter> linters])
|
| + : _linters = linters != null ? linters : LINTERS;
|
| +
|
| + void generate() {
|
| + TimeCounter_TimeCounterHandle timeCounter =
|
| + PerformanceStatistics.lint.start();
|
| + try {
|
| + _compilationUnits.forEach((cu) {
|
| + if (cu.element != null) {
|
| + _generate(cu, cu.element.source);
|
| + }
|
| + });
|
| + } finally {
|
| + timeCounter.stop();
|
| + }
|
| + }
|
| +
|
| + void _generate(CompilationUnit unit, Source source) {
|
| + ErrorReporter errorReporter = new ErrorReporter(_errorListener, source);
|
| + _linters.forEach((l) => l.reporter = errorReporter);
|
| + Iterable<AstVisitor> visitors = _linters.map((l) => l.getVisitor());
|
| + unit.accept(new DelegatingAstVisitor(visitors.where((v) => v != null)));
|
| + }
|
| +}
|
| +
|
| /**
|
| * This class is used to replace uses of `HashMap<String, ExecutableElement>` which are not as
|
| * performant as this class.
|
|
|