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

Side by Side Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 850343006: Linter API updates. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 9184 matching lines...) Expand 10 before | Expand all | Expand 10 after
9195 for (PrefixElement prefix in definingLibrary.prefixes) { 9195 for (PrefixElement prefix in definingLibrary.prefixes) {
9196 define(prefix); 9196 define(prefix);
9197 } 9197 }
9198 _defineLocalNames(definingLibrary.definingCompilationUnit); 9198 _defineLocalNames(definingLibrary.definingCompilationUnit);
9199 for (CompilationUnitElement compilationUnit in definingLibrary.parts) { 9199 for (CompilationUnitElement compilationUnit in definingLibrary.parts) {
9200 _defineLocalNames(compilationUnit); 9200 _defineLocalNames(compilationUnit);
9201 } 9201 }
9202 } 9202 }
9203 } 9203 }
9204 9204
9205 /// Implementers contribute lint warnings via the provided error [reporter].
9206 abstract class Linter {
9207 /// Used to report lint warnings.
9208 /// NOTE: this is set by the framework before visit begins.
9209 ErrorReporter reporter;
9210
9211 /// Return a visitor to be passed to compilation units to perform lint
9212 /// analysis.
9213 /// Lint errors are reported via this [Linter]'s error [reporter].
9214 AstVisitor getVisitor();
9215 }
9216
9217 /// Traverses a library's worth of dart code at a time to generate lint warnings
9218 /// over the set of sources.
9219 ///
9220 /// See [LintCode].
9221 class LintGenerator {
9222
9223 /// A global container for contributed linters.
9224 static final List<Linter> LINTERS = <Linter>[];
9225
9226 final Iterable<CompilationUnit> _compilationUnits;
9227 final AnalysisErrorListener _errorListener;
9228 final Iterable<Linter> _linters;
9229
9230 LintGenerator(this._compilationUnits, this._errorListener,
9231 [Iterable<Linter> linters])
9232 : _linters = linters != null ? linters : LINTERS;
9233
9234 void generate() {
9235 TimeCounter_TimeCounterHandle timeCounter =
9236 PerformanceStatistics.lint.start();
9237 try {
9238 _compilationUnits.forEach((cu) {
9239 if (cu.element != null) {
9240 _generate(cu, cu.element.source);
9241 }
9242 });
9243 } finally {
9244 timeCounter.stop();
9245 }
9246 }
9247
9248 void _generate(CompilationUnit unit, Source source) {
9249 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source);
9250 _linters.forEach((l) => l.reporter = errorReporter);
9251 Iterable<AstVisitor> visitors = _linters.map((l) => l.getVisitor());
9252 unit.accept(new DelegatingAstVisitor(visitors.where((v) => v != null)));
9253 }
9254 }
9255 9205
9256 /** 9206 /**
9257 * This class is used to replace uses of `HashMap<String, ExecutableElement>` wh ich are not as 9207 * This class is used to replace uses of `HashMap<String, ExecutableElement>` wh ich are not as
9258 * performant as this class. 9208 * performant as this class.
9259 */ 9209 */
9260 class MemberMap { 9210 class MemberMap {
9261 /** 9211 /**
9262 * The current size of this map. 9212 * The current size of this map.
9263 */ 9213 */
9264 int _size = 0; 9214 int _size = 0;
(...skipping 6244 matching lines...) Expand 10 before | Expand all | Expand 10 after
15509 * library. 15459 * library.
15510 */ 15460 */
15511 final HashSet<String> members = new HashSet<String>(); 15461 final HashSet<String> members = new HashSet<String>();
15512 15462
15513 /** 15463 /**
15514 * Names of resolved or unresolved class members that are read in the 15464 * Names of resolved or unresolved class members that are read in the
15515 * library. 15465 * library.
15516 */ 15466 */
15517 final HashSet<String> readMembers = new HashSet<String>(); 15467 final HashSet<String> readMembers = new HashSet<String>();
15518 } 15468 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | pkg/analyzer/lib/src/services/lint.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698