Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library engine.resolver; | 5 library engine.resolver; |
| 6 | 6 |
| 7 import "dart:math" as math; | 7 import "dart:math" as math; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/utilities_collection.dart'; | 10 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| (...skipping 4452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4463 // Find to-do comments | 4463 // Find to-do comments |
| 4464 new ToDoFinder(errorReporter).findIn(unit); | 4464 new ToDoFinder(errorReporter).findIn(unit); |
| 4465 // pub analysis | 4465 // pub analysis |
| 4466 // TODO(danrubel/jwren) Commented out until bugs in the pub verifier are | 4466 // TODO(danrubel/jwren) Commented out until bugs in the pub verifier are |
| 4467 // fixed | 4467 // fixed |
| 4468 // unit.accept(new PubVerifier(context, errorReporter)); | 4468 // unit.accept(new PubVerifier(context, errorReporter)); |
| 4469 } | 4469 } |
| 4470 } | 4470 } |
| 4471 | 4471 |
| 4472 | 4472 |
| 4473 /** | 4473 /// Traverses a library's worth of dart code at a time to generate lint warnings |
| 4474 * Traverses a library's worth of dart code at a time to generate lint warnings | 4474 /// over the set of sources. |
| 4475 * over the set of sources. | 4475 /// |
| 4476 * | 4476 /// See [LintCode]. |
| 4477 * See [LintCode]. | |
| 4478 */ | |
| 4479 class LintGenerator { | 4477 class LintGenerator { |
| 4480 | 4478 |
| 4481 final List<CompilationUnit> _compilationUnits; | 4479 /// A global container for contributed verifiers. |
| 4480 static final List<LintVerifier> VERIFIERS = <LintVerifier>[]; | |
| 4481 | |
| 4482 final Iterable<CompilationUnit> _compilationUnits; | |
| 4482 final AnalysisErrorListener _errorListener; | 4483 final AnalysisErrorListener _errorListener; |
| 4484 final Iterable<LintVerifier> _verifiers; | |
| 4483 | 4485 |
| 4484 LintGenerator(this._compilationUnits, this._errorListener); | 4486 LintGenerator(this._compilationUnits, this._errorListener, |
| 4487 [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
| |
| 4488 : _verifiers = verifiers != null ? verifiers : VERIFIERS; | |
| 4485 | 4489 |
| 4486 void generate() { | 4490 void generate() { |
| 4487 TimeCounter_TimeCounterHandle timeCounter = | 4491 TimeCounter_TimeCounterHandle timeCounter = |
| 4488 PerformanceStatistics.lint.start(); | 4492 PerformanceStatistics.lint.start(); |
| 4489 try { | 4493 try { |
| 4490 _compilationUnits.forEach((cu) { | 4494 _compilationUnits.forEach((cu) { |
| 4491 if (cu.element != null) { | 4495 if (cu.element != null) { |
| 4492 _generate(cu, cu.element.source); | 4496 _generate(cu, cu.element.source); |
| 4493 } | 4497 } |
| 4494 }); | 4498 }); |
| 4495 } finally { | 4499 } finally { |
| 4496 timeCounter.stop(); | 4500 timeCounter.stop(); |
| 4497 } | 4501 } |
| 4498 } | 4502 } |
| 4499 | 4503 |
| 4500 void _generate(CompilationUnit unit, Source source) { | 4504 void _generate(CompilationUnit unit, Source source) { |
| 4501 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source); | 4505 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source); |
| 4502 unit.accept(new LintVerifier(errorReporter)); | 4506 _verifiers.forEach((verifier) { |
| 4507 verifier.reporter = errorReporter; | |
| 4508 return unit.accept(verifier); | |
| 4509 }); | |
| 4503 } | 4510 } |
| 4504 } | 4511 } |
| 4505 | 4512 |
| 4506 class LintVerifier extends RecursiveAstVisitor<Object> { | 4513 /// Implementers contribute lint warnings via the provided error [reporter]. |
| 4507 | 4514 abstract class LintVerifier extends RecursiveAstVisitor<Object> { |
| 4508 final ErrorReporter _reporter; | 4515 /// Used to report lint warnings. |
| 4509 | 4516 /// NOTE: this is set by the framework before visit begins. |
| 4510 LintVerifier(this._reporter); | 4517 ErrorReporter reporter; |
| 4511 } | 4518 } |
| 4512 | 4519 |
| 4513 | 4520 |
| 4514 /** | 4521 /** |
| 4515 * Instances of the class {@code HtmlTagInfo} record information about the tags used in an HTML | 4522 * Instances of the class {@code HtmlTagInfo} record information about the tags used in an HTML |
| 4516 * file. | 4523 * file. |
| 4517 */ | 4524 */ |
| 4518 class HtmlTagInfo { | 4525 class HtmlTagInfo { |
| 4519 /** | 4526 /** |
| 4520 * An array containing all of the tags used in the HTML file. | 4527 * An array containing all of the tags used in the HTML file. |
| (...skipping 10979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15500 * library. | 15507 * library. |
| 15501 */ | 15508 */ |
| 15502 final HashSet<String> members = new HashSet<String>(); | 15509 final HashSet<String> members = new HashSet<String>(); |
| 15503 | 15510 |
| 15504 /** | 15511 /** |
| 15505 * Names of resolved or unresolved class members that are read in the | 15512 * Names of resolved or unresolved class members that are read in the |
| 15506 * library. | 15513 * library. |
| 15507 */ | 15514 */ |
| 15508 final HashSet<String> readMembers = new HashSet<String>(); | 15515 final HashSet<String> readMembers = new HashSet<String>(); |
| 15509 } | 15516 } |
| OLD | NEW |