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

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

Issue 834323006: Revert "Lint contribution refactoring.", r42967 (Closed) Base URL: https://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';
11 import 'package:analyzer/src/generated/visitors.dart';
11 12
12 import 'ast.dart'; 13 import 'ast.dart';
13 import 'constant.dart'; 14 import 'constant.dart';
14 import 'element.dart'; 15 import 'element.dart';
15 import 'element_resolver.dart'; 16 import 'element_resolver.dart';
16 import 'engine.dart'; 17 import 'engine.dart';
17 import 'error.dart'; 18 import 'error.dart';
18 import 'error_verifier.dart'; 19 import 'error_verifier.dart';
19 import 'html.dart' as ht; 20 import 'html.dart' as ht;
20 import 'java_core.dart'; 21 import 'java_core.dart';
(...skipping 9173 matching lines...) Expand 10 before | Expand all | Expand 10 after
9194 for (PrefixElement prefix in definingLibrary.prefixes) { 9195 for (PrefixElement prefix in definingLibrary.prefixes) {
9195 define(prefix); 9196 define(prefix);
9196 } 9197 }
9197 _defineLocalNames(definingLibrary.definingCompilationUnit); 9198 _defineLocalNames(definingLibrary.definingCompilationUnit);
9198 for (CompilationUnitElement compilationUnit in definingLibrary.parts) { 9199 for (CompilationUnitElement compilationUnit in definingLibrary.parts) {
9199 _defineLocalNames(compilationUnit); 9200 _defineLocalNames(compilationUnit);
9200 } 9201 }
9201 } 9202 }
9202 } 9203 }
9203 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 }
9204 9255
9205 /** 9256 /**
9206 * This class is used to replace uses of `HashMap<String, ExecutableElement>` wh ich are not as 9257 * This class is used to replace uses of `HashMap<String, ExecutableElement>` wh ich are not as
9207 * performant as this class. 9258 * performant as this class.
9208 */ 9259 */
9209 class MemberMap { 9260 class MemberMap {
9210 /** 9261 /**
9211 * The current size of this map. 9262 * The current size of this map.
9212 */ 9263 */
9213 int _size = 0; 9264 int _size = 0;
(...skipping 6244 matching lines...) Expand 10 before | Expand all | Expand 10 after
15458 * library. 15509 * library.
15459 */ 15510 */
15460 final HashSet<String> members = new HashSet<String>(); 15511 final HashSet<String> members = new HashSet<String>();
15461 15512
15462 /** 15513 /**
15463 * Names of resolved or unresolved class members that are read in the 15514 * Names of resolved or unresolved class members that are read in the
15464 * library. 15515 * library.
15465 */ 15516 */
15466 final HashSet<String> readMembers = new HashSet<String>(); 15517 final HashSet<String> readMembers = new HashSet<String>();
15467 } 15518 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | pkg/analyzer/lib/src/generated/visitors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698