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

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

Issue 954013002: Replace try/finally with PerformanceTag.makeCurrentWhile(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 18 matching lines...) Expand all
29 /** 29 /**
30 * Callback signature used by ImplicitConstructorBuilder to register 30 * Callback signature used by ImplicitConstructorBuilder to register
31 * computations to be performed, and their dependencies. A call to this 31 * computations to be performed, and their dependencies. A call to this
32 * callback indicates that [computation] may be used to compute implicit 32 * callback indicates that [computation] may be used to compute implicit
33 * constructors for [classElement], but that the computation may not be invoked 33 * constructors for [classElement], but that the computation may not be invoked
34 * until after implicit constructors have been built for [superclassElement]. 34 * until after implicit constructors have been built for [superclassElement].
35 */ 35 */
36 typedef void ImplicitConstructorBuilderCallback(ClassElement classElement, 36 typedef void ImplicitConstructorBuilderCallback(ClassElement classElement,
37 ClassElement superclassElement, void computation()); 37 ClassElement superclassElement, void computation());
38 38
39 typedef ResolverVisitor ResolverVisitorFactory(Library library, Source source,
40 TypeProvider typeProvider);
41
42 typedef StaticTypeAnalyzer StaticTypeAnalyzerFactory(ResolverVisitor visitor);
43
44 typedef TypeResolverVisitor TypeResolverVisitorFactory(Library library,
45 Source source, TypeProvider typeProvider);
46
39 typedef void VoidFunction(); 47 typedef void VoidFunction();
40 48
41 /** 49 /**
42 * Instances of the class `BestPracticesVerifier` traverse an AST structure look ing for 50 * Instances of the class `BestPracticesVerifier` traverse an AST structure look ing for
43 * violations of Dart best practices. 51 * violations of Dart best practices.
44 */ 52 */
45 class BestPracticesVerifier extends RecursiveAstVisitor<Object> { 53 class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
46 // static String _HASHCODE_GETTER_NAME = "hashCode"; 54 // static String _HASHCODE_GETTER_NAME = "hashCode";
47 55
48 static String _NULL_TYPE_NAME = "Null"; 56 static String _NULL_TYPE_NAME = "Null";
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 * unit. 802 * unit.
795 */ 803 */
796 class CompilationUnitBuilder { 804 class CompilationUnitBuilder {
797 /** 805 /**
798 * Build the compilation unit element for the given [source] based on the 806 * Build the compilation unit element for the given [source] based on the
799 * compilation [unit] associated with the source. Throw an AnalysisException 807 * compilation [unit] associated with the source. Throw an AnalysisException
800 * if the element could not be built. 808 * if the element could not be built.
801 */ 809 */
802 CompilationUnitElementImpl buildCompilationUnit(Source source, 810 CompilationUnitElementImpl buildCompilationUnit(Source source,
803 CompilationUnit unit) { 811 CompilationUnit unit) {
804 PerformanceTag prevTag = PerformanceStatistics.resolve.makeCurrent(); 812 return PerformanceStatistics.resolve.makeCurrentWhile(() {
805 try {
806 if (unit == null) { 813 if (unit == null) {
807 return null; 814 return null;
808 } 815 }
809 ElementHolder holder = new ElementHolder(); 816 ElementHolder holder = new ElementHolder();
810 ElementBuilder builder = new ElementBuilder(holder); 817 ElementBuilder builder = new ElementBuilder(holder);
811 unit.accept(builder); 818 unit.accept(builder);
812 CompilationUnitElementImpl element = 819 CompilationUnitElementImpl element =
813 new CompilationUnitElementImpl(source.shortName); 820 new CompilationUnitElementImpl(source.shortName);
814 element.accessors = holder.accessors; 821 element.accessors = holder.accessors;
815 element.enums = holder.enums; 822 element.enums = holder.enums;
816 element.functions = holder.functions; 823 element.functions = holder.functions;
817 element.source = source; 824 element.source = source;
818 element.typeAliases = holder.typeAliases; 825 element.typeAliases = holder.typeAliases;
819 element.types = holder.types; 826 element.types = holder.types;
820 element.topLevelVariables = holder.topLevelVariables; 827 element.topLevelVariables = holder.topLevelVariables;
821 unit.element = element; 828 unit.element = element;
822 holder.validate(); 829 holder.validate();
823 return element; 830 return element;
824 } finally { 831 });
825 prevTag.makeCurrent();
826 }
827 } 832 }
828 } 833 }
829 834
830 /** 835 /**
831 * Instances of the class `ConstantVerifier` traverse an AST structure looking f or additional 836 * Instances of the class `ConstantVerifier` traverse an AST structure looking f or additional
832 * errors and warnings not covered by the parser and resolver. In particular, it looks for errors 837 * errors and warnings not covered by the parser and resolver. In particular, it looks for errors
833 * and warnings related to constant expressions. 838 * and warnings related to constant expressions.
834 */ 839 */
835 class ConstantVerifier extends RecursiveAstVisitor<Object> { 840 class ConstantVerifier extends RecursiveAstVisitor<Object> {
836 /** 841 /**
(...skipping 3498 matching lines...) Expand 10 before | Expand all | Expand 10 after
4335 } 4340 }
4336 4341
4337 /** 4342 /**
4338 * Return `true` if the given [node] exits. 4343 * Return `true` if the given [node] exits.
4339 */ 4344 */
4340 static bool exits(AstNode node) { 4345 static bool exits(AstNode node) {
4341 return new ExitDetector()._nodeExits(node); 4346 return new ExitDetector()._nodeExits(node);
4342 } 4347 }
4343 } 4348 }
4344 4349
4350
4345 /** 4351 /**
4346 * Instances of the class `FunctionScope` implement the scope defined by a funct ion. 4352 * Instances of the class `FunctionScope` implement the scope defined by a funct ion.
4347 */ 4353 */
4348 class FunctionScope extends EnclosedScope { 4354 class FunctionScope extends EnclosedScope {
4349 final ExecutableElement _functionElement; 4355 final ExecutableElement _functionElement;
4350 4356
4351 bool _parametersDefined = false; 4357 bool _parametersDefined = false;
4352 4358
4353 /** 4359 /**
4354 * Initialize a newly created scope enclosed within another scope. 4360 * Initialize a newly created scope enclosed within another scope.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
4456 4462
4457 HintGenerator(this._compilationUnits, this._context, this._errorListener) { 4463 HintGenerator(this._compilationUnits, this._context, this._errorListener) {
4458 _library = _compilationUnits[0].element.library; 4464 _library = _compilationUnits[0].element.library;
4459 _importsVerifier = new ImportsVerifier(_library); 4465 _importsVerifier = new ImportsVerifier(_library);
4460 _enableDart2JSHints = _context.analysisOptions.dart2jsHint; 4466 _enableDart2JSHints = _context.analysisOptions.dart2jsHint;
4461 _manager = new InheritanceManager(_compilationUnits[0].element.library); 4467 _manager = new InheritanceManager(_compilationUnits[0].element.library);
4462 _usedElementsVisitor = new _GatherUsedElementsVisitor(_library); 4468 _usedElementsVisitor = new _GatherUsedElementsVisitor(_library);
4463 } 4469 }
4464 4470
4465 void generateForLibrary() { 4471 void generateForLibrary() {
4466 PerformanceTag prevTag = PerformanceStatistics.hints.makeCurrent(); 4472 PerformanceStatistics.hints.makeCurrentWhile(() {
4467 try {
4468 for (int i = 0; i < _compilationUnits.length; i++) { 4473 for (int i = 0; i < _compilationUnits.length; i++) {
4469 CompilationUnitElement element = _compilationUnits[i].element; 4474 CompilationUnitElement element = _compilationUnits[i].element;
4470 if (element != null) { 4475 if (element != null) {
4471 if (i == 0) { 4476 if (i == 0) {
4472 _importsVerifier.inDefiningCompilationUnit = true; 4477 _importsVerifier.inDefiningCompilationUnit = true;
4473 _generateForCompilationUnit(_compilationUnits[i], element.source); 4478 _generateForCompilationUnit(_compilationUnits[i], element.source);
4474 _importsVerifier.inDefiningCompilationUnit = false; 4479 _importsVerifier.inDefiningCompilationUnit = false;
4475 } else { 4480 } else {
4476 _generateForCompilationUnit(_compilationUnits[i], element.source); 4481 _generateForCompilationUnit(_compilationUnits[i], element.source);
4477 } 4482 }
4478 } 4483 }
4479 } 4484 }
4480 ErrorReporter definingCompilationUnitErrorReporter = 4485 ErrorReporter definingCompilationUnitErrorReporter =
4481 new ErrorReporter(_errorListener, _compilationUnits[0].element.source) ; 4486 new ErrorReporter(_errorListener, _compilationUnits[0].element.source) ;
4482 _importsVerifier.generateDuplicateImportHints( 4487 _importsVerifier.generateDuplicateImportHints(
4483 definingCompilationUnitErrorReporter); 4488 definingCompilationUnitErrorReporter);
4484 _importsVerifier.generateUnusedImportHints( 4489 _importsVerifier.generateUnusedImportHints(
4485 definingCompilationUnitErrorReporter); 4490 definingCompilationUnitErrorReporter);
4486 _library.accept( 4491 _library.accept(
4487 new _UnusedElementsVerifier(_errorListener, _usedElementsVisitor.usedE lements)); 4492 new _UnusedElementsVerifier(_errorListener, _usedElementsVisitor.usedE lements));
4488 } finally { 4493 });
4489 prevTag.makeCurrent();
4490 }
4491 } 4494 }
4492 4495
4493 void _generateForCompilationUnit(CompilationUnit unit, Source source) { 4496 void _generateForCompilationUnit(CompilationUnit unit, Source source) {
4494 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source); 4497 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source);
4495 unit.accept(_importsVerifier); 4498 unit.accept(_importsVerifier);
4496 // dead code analysis 4499 // dead code analysis
4497 unit.accept(new DeadCodeVerifier(errorReporter)); 4500 unit.accept(new DeadCodeVerifier(errorReporter));
4498 unit.accept(_usedElementsVisitor); 4501 unit.accept(_usedElementsVisitor);
4499 // dart2js analysis 4502 // dart2js analysis
4500 if (_enableDart2JSHints) { 4503 if (_enableDart2JSHints) {
4501 unit.accept(new Dart2JSVerifier(errorReporter)); 4504 unit.accept(new Dart2JSVerifier(errorReporter));
4502 } 4505 }
4503 // Dart best practices 4506 // Dart best practices
4504 unit.accept( 4507 unit.accept(
4505 new BestPracticesVerifier(errorReporter, _context.typeProvider)); 4508 new BestPracticesVerifier(errorReporter, _context.typeProvider));
4506 unit.accept(new OverrideVerifier(_manager, errorReporter)); 4509 unit.accept(new OverrideVerifier(_manager, errorReporter));
4507 // Find to-do comments 4510 // Find to-do comments
4508 new ToDoFinder(errorReporter).findIn(unit); 4511 new ToDoFinder(errorReporter).findIn(unit);
4509 // pub analysis 4512 // pub analysis
4510 // TODO(danrubel/jwren) Commented out until bugs in the pub verifier are 4513 // TODO(danrubel/jwren) Commented out until bugs in the pub verifier are
4511 // fixed 4514 // fixed
4512 // unit.accept(new PubVerifier(context, errorReporter)); 4515 // unit.accept(new PubVerifier(context, errorReporter));
4513 } 4516 }
4514 } 4517 }
4515 4518
4516
4517 /** 4519 /**
4518 * Instances of the class {@code HtmlTagInfo} record information about the tags used in an HTML 4520 * Instances of the class {@code HtmlTagInfo} record information about the tags used in an HTML
4519 * file. 4521 * file.
4520 */ 4522 */
4521 class HtmlTagInfo { 4523 class HtmlTagInfo {
4522 /** 4524 /**
4523 * An array containing all of the tags used in the HTML file. 4525 * An array containing all of the tags used in the HTML file.
4524 */ 4526 */
4525 List<String> allTags; 4527 List<String> allTags;
4526 4528
(...skipping 3690 matching lines...) Expand 10 before | Expand all | Expand 10 after
8217 } 8219 }
8218 8220
8219 /** 8221 /**
8220 * Build the members in enum declarations. This cannot be done while building the rest of the 8222 * Build the members in enum declarations. This cannot be done while building the rest of the
8221 * element model because it depends on being able to access core types, which cannot happen until 8223 * element model because it depends on being able to access core types, which cannot happen until
8222 * the rest of the element model has been built (when resolving the core libra ry). 8224 * the rest of the element model has been built (when resolving the core libra ry).
8223 * 8225 *
8224 * @throws AnalysisException if any of the enum members could not be built 8226 * @throws AnalysisException if any of the enum members could not be built
8225 */ 8227 */
8226 void _buildEnumMembers() { 8228 void _buildEnumMembers() {
8227 PerformanceTag prevTag = 8229 PerformanceStatistics.resolve.makeCurrentWhile(() {
8228 PerformanceStatistics.resolve.makeCurrent();
8229 try {
8230 for (Library library in _librariesInCycles) { 8230 for (Library library in _librariesInCycles) {
8231 for (Source source in library.compilationUnitSources) { 8231 for (Source source in library.compilationUnitSources) {
8232 EnumMemberBuilder builder = new EnumMemberBuilder(_typeProvider); 8232 EnumMemberBuilder builder = new EnumMemberBuilder(_typeProvider);
8233 library.getAST(source).accept(builder); 8233 library.getAST(source).accept(builder);
8234 } 8234 }
8235 } 8235 }
8236 } finally { 8236 });
8237 prevTag.makeCurrent();
8238 }
8239 } 8237 }
8240 8238
8241 /** 8239 /**
8242 * Finish steps that the [buildTypeHierarchies] could not perform, see 8240 * Finish steps that the [buildTypeHierarchies] could not perform, see
8243 * [ImplicitConstructorBuilder]. 8241 * [ImplicitConstructorBuilder].
8244 * 8242 *
8245 * @throws AnalysisException if any of the type hierarchies could not be resol ved 8243 * @throws AnalysisException if any of the type hierarchies could not be resol ved
8246 */ 8244 */
8247 void _buildImplicitConstructors() { 8245 void _buildImplicitConstructors() {
8248 PerformanceTag prevTag= 8246 PerformanceStatistics.resolve.makeCurrentWhile(() {
8249 PerformanceStatistics.resolve.makeCurrent();
8250 try {
8251 ImplicitConstructorComputer computer = 8247 ImplicitConstructorComputer computer =
8252 new ImplicitConstructorComputer(_typeProvider); 8248 new ImplicitConstructorComputer(_typeProvider);
8253 for (Library library in _librariesInCycles) { 8249 for (Library library in _librariesInCycles) {
8254 for (Source source in library.compilationUnitSources) { 8250 for (Source source in library.compilationUnitSources) {
8255 computer.add( 8251 computer.add(
8256 library.getAST(source), 8252 library.getAST(source),
8257 source, 8253 source,
8258 library.libraryElement, 8254 library.libraryElement,
8259 library.libraryScope); 8255 library.libraryScope);
8260 } 8256 }
8261 } 8257 }
8262 computer.compute(); 8258 computer.compute();
8263 } finally { 8259 });
8264 prevTag.makeCurrent();
8265 }
8266 } 8260 }
8267 8261
8268 /** 8262 /**
8269 * Resolve the types referenced by function type aliases across all of the fun ction type aliases 8263 * Resolve the types referenced by function type aliases across all of the fun ction type aliases
8270 * defined in the current cycle. 8264 * defined in the current cycle.
8271 * 8265 *
8272 * @throws AnalysisException if any of the function type aliases could not be resolved 8266 * @throws AnalysisException if any of the function type aliases could not be resolved
8273 */ 8267 */
8274 void _buildTypeAliases() { 8268 void _buildTypeAliases() {
8275 PerformanceTag prevTag = 8269 PerformanceStatistics.resolve.makeCurrentWhile(() {
8276 PerformanceStatistics.resolve.makeCurrent();
8277 try {
8278 List<LibraryResolver_TypeAliasInfo> typeAliases = 8270 List<LibraryResolver_TypeAliasInfo> typeAliases =
8279 new List<LibraryResolver_TypeAliasInfo>(); 8271 new List<LibraryResolver_TypeAliasInfo>();
8280 for (Library library in _librariesInCycles) { 8272 for (Library library in _librariesInCycles) {
8281 for (Source source in library.compilationUnitSources) { 8273 for (Source source in library.compilationUnitSources) {
8282 CompilationUnit ast = library.getAST(source); 8274 CompilationUnit ast = library.getAST(source);
8283 for (CompilationUnitMember member in ast.declarations) { 8275 for (CompilationUnitMember member in ast.declarations) {
8284 if (member is FunctionTypeAlias) { 8276 if (member is FunctionTypeAlias) {
8285 typeAliases.add( 8277 typeAliases.add(
8286 new LibraryResolver_TypeAliasInfo(library, source, member)); 8278 new LibraryResolver_TypeAliasInfo(library, source, member));
8287 } 8279 }
8288 } 8280 }
8289 } 8281 }
8290 } 8282 }
8291 // TODO(brianwilkerson) We need to sort the type aliases such that all 8283 // TODO(brianwilkerson) We need to sort the type aliases such that all
8292 // aliases referenced by an alias T are resolved before we resolve T. 8284 // aliases referenced by an alias T are resolved before we resolve T.
8293 for (LibraryResolver_TypeAliasInfo info in typeAliases) { 8285 for (LibraryResolver_TypeAliasInfo info in typeAliases) {
8294 TypeResolverVisitor visitor = 8286 TypeResolverVisitor visitor =
8295 new TypeResolverVisitor.con1(info._library, info._source, _typeProvi der); 8287 new TypeResolverVisitor.con1(info._library, info._source, _typeProvi der);
8296 info._typeAlias.accept(visitor); 8288 info._typeAlias.accept(visitor);
8297 } 8289 }
8298 } finally { 8290 });
8299 prevTag.makeCurrent();
8300 }
8301 } 8291 }
8302 8292
8303 /** 8293 /**
8304 * Resolve the type hierarchy across all of the types declared in the librarie s in the current 8294 * Resolve the type hierarchy across all of the types declared in the librarie s in the current
8305 * cycle. 8295 * cycle.
8306 * 8296 *
8307 * @throws AnalysisException if any of the type hierarchies could not be resol ved 8297 * @throws AnalysisException if any of the type hierarchies could not be resol ved
8308 */ 8298 */
8309 void _buildTypeHierarchies() { 8299 void _buildTypeHierarchies() {
8310 PerformanceTag prevTag = 8300 PerformanceStatistics.resolve.makeCurrentWhile(() {
8311 PerformanceStatistics.resolve.makeCurrent();
8312 try {
8313 for (Library library in _librariesInCycles) { 8301 for (Library library in _librariesInCycles) {
8314 for (Source source in library.compilationUnitSources) { 8302 for (Source source in library.compilationUnitSources) {
8315 TypeResolverVisitorFactory typeResolverVisitorFactory = 8303 TypeResolverVisitorFactory typeResolverVisitorFactory =
8316 analysisContext.typeResolverVisitorFactory; 8304 analysisContext.typeResolverVisitorFactory;
8317 TypeResolverVisitor visitor = (typeResolverVisitorFactory == null) 8305 TypeResolverVisitor visitor = (typeResolverVisitorFactory == null) ?
8318 ? new TypeResolverVisitor.con1(library, source, _typeProvider) 8306 new TypeResolverVisitor.con1(library, source, _typeProvider) :
8319 : typeResolverVisitorFactory(library, source, _typeProvider); 8307 typeResolverVisitorFactory(library, source, _typeProvider);
8320 library.getAST(source).accept(visitor); 8308 library.getAST(source).accept(visitor);
8321 } 8309 }
8322 } 8310 }
8323 } finally { 8311 });
8324 prevTag.makeCurrent();
8325 }
8326 } 8312 }
8327 8313
8328 /** 8314 /**
8329 * Compute a dependency map of libraries reachable from the given library. A d ependency map is a 8315 * Compute a dependency map of libraries reachable from the given library. A d ependency map is a
8330 * table that maps individual libraries to a list of the libraries that either import or export 8316 * table that maps individual libraries to a list of the libraries that either import or export
8331 * those libraries. 8317 * those libraries.
8332 * 8318 *
8333 * This map is used to compute all of the libraries involved in a cycle that i nclude the root 8319 * This map is used to compute all of the libraries involved in a cycle that i nclude the root
8334 * library. Given that we only add libraries that are reachable from the root library, when we 8320 * library. Given that we only add libraries that are reachable from the root library, when we
8335 * work backward we are guaranteed to only get libraries in the cycle. 8321 * work backward we are guaranteed to only get libraries in the cycle.
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
8520 for (int i = 0; i < count; i++) { 8506 for (int i = 0; i < count; i++) {
8521 identifiers[i] = names[i].name; 8507 identifiers[i] = names[i].name;
8522 } 8508 }
8523 return identifiers; 8509 return identifiers;
8524 } 8510 }
8525 8511
8526 /** 8512 /**
8527 * Compute a value for all of the constants in the libraries being analyzed. 8513 * Compute a value for all of the constants in the libraries being analyzed.
8528 */ 8514 */
8529 void _performConstantEvaluation() { 8515 void _performConstantEvaluation() {
8530 PerformanceTag prevTag = 8516 PerformanceStatistics.resolve.makeCurrentWhile(() {
8531 PerformanceStatistics.resolve.makeCurrent();
8532 try {
8533 ConstantValueComputer computer = 8517 ConstantValueComputer computer =
8534 new ConstantValueComputer(_typeProvider, analysisContext.declaredVaria bles); 8518 new ConstantValueComputer(_typeProvider, analysisContext.declaredVaria bles);
8535 for (Library library in _librariesInCycles) { 8519 for (Library library in _librariesInCycles) {
8536 for (Source source in library.compilationUnitSources) { 8520 for (Source source in library.compilationUnitSources) {
8537 try { 8521 try {
8538 CompilationUnit unit = library.getAST(source); 8522 CompilationUnit unit = library.getAST(source);
8539 if (unit != null) { 8523 if (unit != null) {
8540 computer.add(unit); 8524 computer.add(unit);
8541 } 8525 }
8542 } on AnalysisException catch (exception, stackTrace) { 8526 } on AnalysisException catch (exception, stackTrace) {
(...skipping 16 matching lines...) Expand all
8559 new ConstantVerifier(errorReporter, library.libraryElement, _typ eProvider); 8543 new ConstantVerifier(errorReporter, library.libraryElement, _typ eProvider);
8560 unit.accept(constantVerifier); 8544 unit.accept(constantVerifier);
8561 } on AnalysisException catch (exception, stackTrace) { 8545 } on AnalysisException catch (exception, stackTrace) {
8562 AnalysisEngine.instance.logger.logError( 8546 AnalysisEngine.instance.logger.logError(
8563 "Internal Error: Could not access AST for ${source.fullName} " 8547 "Internal Error: Could not access AST for ${source.fullName} "
8564 "during constant verification", 8548 "during constant verification",
8565 new CaughtException(exception, stackTrace)); 8549 new CaughtException(exception, stackTrace));
8566 } 8550 }
8567 } 8551 }
8568 } 8552 }
8569 } finally { 8553 });
8570 prevTag.makeCurrent();
8571 }
8572 } 8554 }
8573 8555
8574 /** 8556 /**
8575 * Resolve the identifiers and perform type analysis in the libraries in the c urrent cycle. 8557 * Resolve the identifiers and perform type analysis in the libraries in the c urrent cycle.
8576 * 8558 *
8577 * @throws AnalysisException if any of the identifiers could not be resolved o r if any of the 8559 * @throws AnalysisException if any of the identifiers could not be resolved o r if any of the
8578 * libraries could not have their types analyzed 8560 * libraries could not have their types analyzed
8579 */ 8561 */
8580 void _resolveReferencesAndTypes() { 8562 void _resolveReferencesAndTypes() {
8581 for (Library library in _librariesInCycles) { 8563 for (Library library in _librariesInCycles) {
8582 _resolveReferencesAndTypesInLibrary(library); 8564 _resolveReferencesAndTypesInLibrary(library);
8583 } 8565 }
8584 } 8566 }
8585 8567
8586 /** 8568 /**
8587 * Resolve the identifiers and perform type analysis in the given library. 8569 * Resolve the identifiers and perform type analysis in the given library.
8588 * 8570 *
8589 * @param library the library to be resolved 8571 * @param library the library to be resolved
8590 * @throws AnalysisException if any of the identifiers could not be resolved o r if the types in 8572 * @throws AnalysisException if any of the identifiers could not be resolved o r if the types in
8591 * the library cannot be analyzed 8573 * the library cannot be analyzed
8592 */ 8574 */
8593 void _resolveReferencesAndTypesInLibrary(Library library) { 8575 void _resolveReferencesAndTypesInLibrary(Library library) {
8594 PerformanceTag prevTag = 8576 PerformanceStatistics.resolve.makeCurrentWhile(() {
8595 PerformanceStatistics.resolve.makeCurrent();
8596 try {
8597 for (Source source in library.compilationUnitSources) { 8577 for (Source source in library.compilationUnitSources) {
8598 CompilationUnit ast = library.getAST(source); 8578 CompilationUnit ast = library.getAST(source);
8599 ast.accept( 8579 ast.accept(
8600 new VariableResolverVisitor.con1(library, source, _typeProvider)); 8580 new VariableResolverVisitor.con1(library, source, _typeProvider));
8601 ResolverVisitorFactory visitorFactory = 8581 ResolverVisitorFactory visitorFactory =
8602 analysisContext.resolverVisitorFactory; 8582 analysisContext.resolverVisitorFactory;
8603 ResolverVisitor visitor = visitorFactory != null 8583 ResolverVisitor visitor = visitorFactory != null ?
8604 ? visitorFactory(library, source, _typeProvider) 8584 visitorFactory(library, source, _typeProvider) :
8605 : new ResolverVisitor.con1(library, source, _typeProvider); 8585 new ResolverVisitor.con1(library, source, _typeProvider);
8606 ast.accept(visitor); 8586 ast.accept(visitor);
8607 } 8587 }
8608 } finally { 8588 });
8609 prevTag.makeCurrent();
8610 }
8611 } 8589 }
8612 8590
8613 /** 8591 /**
8614 * Return the result of resolving the URI of the given URI-based directive aga inst the URI of the 8592 * Return the result of resolving the URI of the given URI-based directive aga inst the URI of the
8615 * given library, or `null` if the URI is not valid. 8593 * given library, or `null` if the URI is not valid.
8616 * 8594 *
8617 * @param librarySource the source representing the library containing the dir ective 8595 * @param librarySource the source representing the library containing the dir ective
8618 * @param directive the directive which URI should be resolved 8596 * @param directive the directive which URI should be resolved
8619 * @return the result of resolving the URI against the URI of the library 8597 * @return the result of resolving the URI against the URI of the library
8620 */ 8598 */
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
8958 } 8936 }
8959 8937
8960 /** 8938 /**
8961 * Build the members in enum declarations. This cannot be done while building the rest of the 8939 * Build the members in enum declarations. This cannot be done while building the rest of the
8962 * element model because it depends on being able to access core types, which cannot happen until 8940 * element model because it depends on being able to access core types, which cannot happen until
8963 * the rest of the element model has been built (when resolving the core libra ry). 8941 * the rest of the element model has been built (when resolving the core libra ry).
8964 * 8942 *
8965 * @throws AnalysisException if any of the enum members could not be built 8943 * @throws AnalysisException if any of the enum members could not be built
8966 */ 8944 */
8967 void _buildEnumMembers() { 8945 void _buildEnumMembers() {
8968 PerformanceTag prevTag = 8946 PerformanceStatistics.resolve.makeCurrentWhile(() {
8969 PerformanceStatistics.resolve.makeCurrent();
8970 try {
8971 for (ResolvableLibrary library in _librariesInCycle) { 8947 for (ResolvableLibrary library in _librariesInCycle) {
8972 for (Source source in library.compilationUnitSources) { 8948 for (Source source in library.compilationUnitSources) {
8973 EnumMemberBuilder builder = new EnumMemberBuilder(_typeProvider); 8949 EnumMemberBuilder builder = new EnumMemberBuilder(_typeProvider);
8974 library.getAST(source).accept(builder); 8950 library.getAST(source).accept(builder);
8975 } 8951 }
8976 } 8952 }
8977 } finally { 8953 });
8978 prevTag.makeCurrent();
8979 }
8980 } 8954 }
8981 8955
8982 /** 8956 /**
8983 * Finish steps that the [buildTypeHierarchies] could not perform, see 8957 * Finish steps that the [buildTypeHierarchies] could not perform, see
8984 * [ImplicitConstructorBuilder]. 8958 * [ImplicitConstructorBuilder].
8985 * 8959 *
8986 * @throws AnalysisException if any of the type hierarchies could not be resol ved 8960 * @throws AnalysisException if any of the type hierarchies could not be resol ved
8987 */ 8961 */
8988 void _buildImplicitConstructors() { 8962 void _buildImplicitConstructors() {
8989 PerformanceTag prevTag = 8963 PerformanceStatistics.resolve.makeCurrentWhile(() {
8990 PerformanceStatistics.resolve.makeCurrent();
8991 try {
8992 ImplicitConstructorComputer computer = 8964 ImplicitConstructorComputer computer =
8993 new ImplicitConstructorComputer(_typeProvider); 8965 new ImplicitConstructorComputer(_typeProvider);
8994 for (ResolvableLibrary library in _librariesInCycle) { 8966 for (ResolvableLibrary library in _librariesInCycle) {
8995 for (ResolvableCompilationUnit unit in 8967 for (ResolvableCompilationUnit unit in
8996 library.resolvableCompilationUnits) { 8968 library.resolvableCompilationUnits) {
8997 Source source = unit.source; 8969 Source source = unit.source;
8998 CompilationUnit ast = unit.compilationUnit; 8970 CompilationUnit ast = unit.compilationUnit;
8999 computer.add( 8971 computer.add(
9000 ast, 8972 ast,
9001 source, 8973 source,
9002 library.libraryElement, 8974 library.libraryElement,
9003 library.libraryScope); 8975 library.libraryScope);
9004 } 8976 }
9005 } 8977 }
9006 computer.compute(); 8978 computer.compute();
9007 } finally { 8979 });
9008 prevTag.makeCurrent();
9009 }
9010 } 8980 }
9011 8981
9012 HashMap<Source, ResolvableLibrary> _buildLibraryMap() { 8982 HashMap<Source, ResolvableLibrary> _buildLibraryMap() {
9013 HashMap<Source, ResolvableLibrary> libraryMap = 8983 HashMap<Source, ResolvableLibrary> libraryMap =
9014 new HashMap<Source, ResolvableLibrary>(); 8984 new HashMap<Source, ResolvableLibrary>();
9015 int libraryCount = _librariesInCycle.length; 8985 int libraryCount = _librariesInCycle.length;
9016 for (int i = 0; i < libraryCount; i++) { 8986 for (int i = 0; i < libraryCount; i++) {
9017 ResolvableLibrary library = _librariesInCycle[i]; 8987 ResolvableLibrary library = _librariesInCycle[i];
9018 library.errorListener = _errorListener; 8988 library.errorListener = _errorListener;
9019 libraryMap[library.librarySource] = library; 8989 libraryMap[library.librarySource] = library;
9020 List<ResolvableLibrary> dependencies = library.importsAndExports; 8990 List<ResolvableLibrary> dependencies = library.importsAndExports;
9021 int dependencyCount = dependencies.length; 8991 int dependencyCount = dependencies.length;
9022 for (int j = 0; j < dependencyCount; j++) { 8992 for (int j = 0; j < dependencyCount; j++) {
9023 ResolvableLibrary dependency = dependencies[j]; 8993 ResolvableLibrary dependency = dependencies[j];
9024 //dependency.setErrorListener(errorListener); 8994 //dependency.setErrorListener(errorListener);
9025 libraryMap[dependency.librarySource] = dependency; 8995 libraryMap[dependency.librarySource] = dependency;
9026 } 8996 }
9027 } 8997 }
9028 return libraryMap; 8998 return libraryMap;
9029 } 8999 }
9030 9000
9031 /** 9001 /**
9032 * Resolve the types referenced by function type aliases across all of the fun ction type aliases 9002 * Resolve the types referenced by function type aliases across all of the fun ction type aliases
9033 * defined in the current cycle. 9003 * defined in the current cycle.
9034 * 9004 *
9035 * @throws AnalysisException if any of the function type aliases could not be resolved 9005 * @throws AnalysisException if any of the function type aliases could not be resolved
9036 */ 9006 */
9037 void _buildTypeAliases() { 9007 void _buildTypeAliases() {
9038 PerformanceTag prevTag = 9008 PerformanceStatistics.resolve.makeCurrentWhile(() {
9039 PerformanceStatistics.resolve.makeCurrent();
9040 try {
9041 List<LibraryResolver2_TypeAliasInfo> typeAliases = 9009 List<LibraryResolver2_TypeAliasInfo> typeAliases =
9042 new List<LibraryResolver2_TypeAliasInfo>(); 9010 new List<LibraryResolver2_TypeAliasInfo>();
9043 for (ResolvableLibrary library in _librariesInCycle) { 9011 for (ResolvableLibrary library in _librariesInCycle) {
9044 for (ResolvableCompilationUnit unit in 9012 for (ResolvableCompilationUnit unit in
9045 library.resolvableCompilationUnits) { 9013 library.resolvableCompilationUnits) {
9046 for (CompilationUnitMember member in 9014 for (CompilationUnitMember member in
9047 unit.compilationUnit.declarations) { 9015 unit.compilationUnit.declarations) {
9048 if (member is FunctionTypeAlias) { 9016 if (member is FunctionTypeAlias) {
9049 typeAliases.add( 9017 typeAliases.add(
9050 new LibraryResolver2_TypeAliasInfo(library, unit.source, membe r)); 9018 new LibraryResolver2_TypeAliasInfo(library, unit.source, membe r));
9051 } 9019 }
9052 } 9020 }
9053 } 9021 }
9054 } 9022 }
9055 // TODO(brianwilkerson) We need to sort the type aliases such that all 9023 // TODO(brianwilkerson) We need to sort the type aliases such that all
9056 // aliases referenced by an alias T are resolved before we resolve T. 9024 // aliases referenced by an alias T are resolved before we resolve T.
9057 for (LibraryResolver2_TypeAliasInfo info in typeAliases) { 9025 for (LibraryResolver2_TypeAliasInfo info in typeAliases) {
9058 TypeResolverVisitor visitor = 9026 TypeResolverVisitor visitor =
9059 new TypeResolverVisitor.con4(info._library, info._source, _typeProvi der); 9027 new TypeResolverVisitor.con4(info._library, info._source, _typeProvi der);
9060 info._typeAlias.accept(visitor); 9028 info._typeAlias.accept(visitor);
9061 } 9029 }
9062 } finally { 9030 });
9063 prevTag.makeCurrent();
9064 }
9065 } 9031 }
9066 9032
9067 /** 9033 /**
9068 * Resolve the type hierarchy across all of the types declared in the librarie s in the current 9034 * Resolve the type hierarchy across all of the types declared in the librarie s in the current
9069 * cycle. 9035 * cycle.
9070 * 9036 *
9071 * @throws AnalysisException if any of the type hierarchies could not be resol ved 9037 * @throws AnalysisException if any of the type hierarchies could not be resol ved
9072 */ 9038 */
9073 void _buildTypeHierarchies() { 9039 void _buildTypeHierarchies() {
9074 PerformanceTag prevTag = 9040 PerformanceStatistics.resolve.makeCurrentWhile(() {
9075 PerformanceStatistics.resolve.makeCurrent();
9076 try {
9077 for (ResolvableLibrary library in _librariesInCycle) { 9041 for (ResolvableLibrary library in _librariesInCycle) {
9078 for (ResolvableCompilationUnit unit in 9042 for (ResolvableCompilationUnit unit in
9079 library.resolvableCompilationUnits) { 9043 library.resolvableCompilationUnits) {
9080 Source source = unit.source; 9044 Source source = unit.source;
9081 CompilationUnit ast = unit.compilationUnit; 9045 CompilationUnit ast = unit.compilationUnit;
9082 TypeResolverVisitor visitor = 9046 TypeResolverVisitor visitor =
9083 new TypeResolverVisitor.con4(library, source, _typeProvider); 9047 new TypeResolverVisitor.con4(library, source, _typeProvider);
9084 ast.accept(visitor); 9048 ast.accept(visitor);
9085 } 9049 }
9086 } 9050 }
9087 } finally { 9051 });
9088 prevTag.makeCurrent();
9089 }
9090 } 9052 }
9091 9053
9092 /** 9054 /**
9093 * Return an array containing the lexical identifiers associated with the node s in the given list. 9055 * Return an array containing the lexical identifiers associated with the node s in the given list.
9094 * 9056 *
9095 * @param names the AST nodes representing the identifiers 9057 * @param names the AST nodes representing the identifiers
9096 * @return the lexical identifiers associated with the nodes in the list 9058 * @return the lexical identifiers associated with the nodes in the list
9097 */ 9059 */
9098 List<String> _getIdentifiers(NodeList<SimpleIdentifier> names) { 9060 List<String> _getIdentifiers(NodeList<SimpleIdentifier> names) {
9099 int count = names.length; 9061 int count = names.length;
9100 List<String> identifiers = new List<String>(count); 9062 List<String> identifiers = new List<String>(count);
9101 for (int i = 0; i < count; i++) { 9063 for (int i = 0; i < count; i++) {
9102 identifiers[i] = names[i].name; 9064 identifiers[i] = names[i].name;
9103 } 9065 }
9104 return identifiers; 9066 return identifiers;
9105 } 9067 }
9106 9068
9107 /** 9069 /**
9108 * Compute a value for all of the constants in the libraries being analyzed. 9070 * Compute a value for all of the constants in the libraries being analyzed.
9109 */ 9071 */
9110 void _performConstantEvaluation() { 9072 void _performConstantEvaluation() {
9111 PerformanceTag prevTag = 9073 PerformanceStatistics.resolve.makeCurrentWhile(() {
9112 PerformanceStatistics.resolve.makeCurrent();
9113 try {
9114 ConstantValueComputer computer = 9074 ConstantValueComputer computer =
9115 new ConstantValueComputer(_typeProvider, analysisContext.declaredVaria bles); 9075 new ConstantValueComputer(_typeProvider, analysisContext.declaredVaria bles);
9116 for (ResolvableLibrary library in _librariesInCycle) { 9076 for (ResolvableLibrary library in _librariesInCycle) {
9117 for (ResolvableCompilationUnit unit in 9077 for (ResolvableCompilationUnit unit in
9118 library.resolvableCompilationUnits) { 9078 library.resolvableCompilationUnits) {
9119 CompilationUnit ast = unit.compilationUnit; 9079 CompilationUnit ast = unit.compilationUnit;
9120 if (ast != null) { 9080 if (ast != null) {
9121 computer.add(ast); 9081 computer.add(ast);
9122 } 9082 }
9123 } 9083 }
9124 } 9084 }
9125 computer.computeValues(); 9085 computer.computeValues();
9126 // As a temporary workaround for issue 21572, run ConstantVerifier now. 9086 // As a temporary workaround for issue 21572, run ConstantVerifier now.
9127 // TODO(paulberry): remove this workaround once issue 21572 is fixed. 9087 // TODO(paulberry): remove this workaround once issue 21572 is fixed.
9128 for (ResolvableLibrary library in _librariesInCycle) { 9088 for (ResolvableLibrary library in _librariesInCycle) {
9129 for (ResolvableCompilationUnit unit in 9089 for (ResolvableCompilationUnit unit in
9130 library.resolvableCompilationUnits) { 9090 library.resolvableCompilationUnits) {
9131 CompilationUnit ast = unit.compilationUnit; 9091 CompilationUnit ast = unit.compilationUnit;
9132 ErrorReporter errorReporter = 9092 ErrorReporter errorReporter =
9133 new ErrorReporter(_errorListener, unit.source); 9093 new ErrorReporter(_errorListener, unit.source);
9134 ConstantVerifier constantVerifier = 9094 ConstantVerifier constantVerifier =
9135 new ConstantVerifier(errorReporter, library.libraryElement, _typeP rovider); 9095 new ConstantVerifier(errorReporter, library.libraryElement, _typeP rovider);
9136 ast.accept(constantVerifier); 9096 ast.accept(constantVerifier);
9137 } 9097 }
9138 } 9098 }
9139 } finally { 9099 });
9140 prevTag.makeCurrent();
9141 }
9142 } 9100 }
9143 9101
9144 /** 9102 /**
9145 * Resolve the identifiers and perform type analysis in the libraries in the c urrent cycle. 9103 * Resolve the identifiers and perform type analysis in the libraries in the c urrent cycle.
9146 * 9104 *
9147 * @throws AnalysisException if any of the identifiers could not be resolved o r if any of the 9105 * @throws AnalysisException if any of the identifiers could not be resolved o r if any of the
9148 * libraries could not have their types analyzed 9106 * libraries could not have their types analyzed
9149 */ 9107 */
9150 void _resolveReferencesAndTypes() { 9108 void _resolveReferencesAndTypes() {
9151 for (ResolvableLibrary library in _librariesInCycle) { 9109 for (ResolvableLibrary library in _librariesInCycle) {
9152 _resolveReferencesAndTypesInLibrary(library); 9110 _resolveReferencesAndTypesInLibrary(library);
9153 } 9111 }
9154 } 9112 }
9155 9113
9156 /** 9114 /**
9157 * Resolve the identifiers and perform type analysis in the given library. 9115 * Resolve the identifiers and perform type analysis in the given library.
9158 * 9116 *
9159 * @param library the library to be resolved 9117 * @param library the library to be resolved
9160 * @throws AnalysisException if any of the identifiers could not be resolved o r if the types in 9118 * @throws AnalysisException if any of the identifiers could not be resolved o r if the types in
9161 * the library cannot be analyzed 9119 * the library cannot be analyzed
9162 */ 9120 */
9163 void _resolveReferencesAndTypesInLibrary(ResolvableLibrary library) { 9121 void _resolveReferencesAndTypesInLibrary(ResolvableLibrary library) {
9164 PerformanceTag prevTag = 9122 PerformanceStatistics.resolve.makeCurrentWhile(() {
9165 PerformanceStatistics.resolve.makeCurrent();
9166 try {
9167 for (ResolvableCompilationUnit unit in library.resolvableCompilationUnits) 9123 for (ResolvableCompilationUnit unit in library.resolvableCompilationUnits)
9168 { 9124 {
9169 Source source = unit.source; 9125 Source source = unit.source;
9170 CompilationUnit ast = unit.compilationUnit; 9126 CompilationUnit ast = unit.compilationUnit;
9171 ast.accept( 9127 ast.accept(
9172 new VariableResolverVisitor.con3(library, source, _typeProvider)); 9128 new VariableResolverVisitor.con3(library, source, _typeProvider));
9173 ResolverVisitor visitor = 9129 ResolverVisitor visitor =
9174 new ResolverVisitor.con4(library, source, _typeProvider); 9130 new ResolverVisitor.con4(library, source, _typeProvider);
9175 ast.accept(visitor); 9131 ast.accept(visitor);
9176 } 9132 }
9177 } finally { 9133 });
9178 prevTag.makeCurrent();
9179 }
9180 } 9134 }
9181 9135
9182 /** 9136 /**
9183 * Report that the async library could not be resolved in the given 9137 * Report that the async library could not be resolved in the given
9184 * [analysisContext] and throw an exception. [asyncLibrarySource] is the sour ce 9138 * [analysisContext] and throw an exception. [asyncLibrarySource] is the sour ce
9185 * representing the async library. 9139 * representing the async library.
9186 */ 9140 */
9187 static void missingAsyncLibrary(AnalysisContext analysisContext, 9141 static void missingAsyncLibrary(AnalysisContext analysisContext,
9188 Source asyncLibrarySource) { 9142 Source asyncLibrarySource) {
9189 throw new AnalysisException("Could not resolve dart:async"); 9143 throw new AnalysisException("Could not resolve dart:async");
9190 } 9144 }
9191 9145
9192 /** 9146 /**
9193 * Report that the core library could not be resolved in the given analysis co ntext and throw an 9147 * Report that the core library could not be resolved in the given analysis co ntext and throw an
9194 * exception. 9148 * exception.
9195 * 9149 *
9196 * @param analysisContext the analysis context in which the failure occurred 9150 * @param analysisContext the analysis context in which the failure occurred
9197 * @param coreLibrarySource the source representing the core library 9151 * @param coreLibrarySource the source representing the core library
9198 * @throws AnalysisException always 9152 * @throws AnalysisException always
9199 */ 9153 */
9200 static void missingCoreLibrary(AnalysisContext analysisContext, 9154 static void missingCoreLibrary(AnalysisContext analysisContext,
9201 Source coreLibrarySource) { 9155 Source coreLibrarySource) {
9202 throw new AnalysisException("Could not resolve dart:core"); 9156 throw new AnalysisException("Could not resolve dart:core");
9203 } 9157 }
9204 } 9158 }
9205 9159
9160
9206 /** 9161 /**
9207 * Instances of the class `TypeAliasInfo` hold information about a [TypeAlias]. 9162 * Instances of the class `TypeAliasInfo` hold information about a [TypeAlias].
9208 */ 9163 */
9209 class LibraryResolver2_TypeAliasInfo { 9164 class LibraryResolver2_TypeAliasInfo {
9210 final ResolvableLibrary _library; 9165 final ResolvableLibrary _library;
9211 9166
9212 final Source _source; 9167 final Source _source;
9213 9168
9214 final FunctionTypeAlias _typeAlias; 9169 final FunctionTypeAlias _typeAlias;
9215 9170
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
9318 for (PrefixElement prefix in definingLibrary.prefixes) { 9273 for (PrefixElement prefix in definingLibrary.prefixes) {
9319 define(prefix); 9274 define(prefix);
9320 } 9275 }
9321 _defineLocalNames(definingLibrary.definingCompilationUnit); 9276 _defineLocalNames(definingLibrary.definingCompilationUnit);
9322 for (CompilationUnitElement compilationUnit in definingLibrary.parts) { 9277 for (CompilationUnitElement compilationUnit in definingLibrary.parts) {
9323 _defineLocalNames(compilationUnit); 9278 _defineLocalNames(compilationUnit);
9324 } 9279 }
9325 } 9280 }
9326 } 9281 }
9327 9282
9328
9329 /** 9283 /**
9330 * This class is used to replace uses of `HashMap<String, ExecutableElement>` wh ich are not as 9284 * This class is used to replace uses of `HashMap<String, ExecutableElement>` wh ich are not as
9331 * performant as this class. 9285 * performant as this class.
9332 */ 9286 */
9333 class MemberMap { 9287 class MemberMap {
9334 /** 9288 /**
9335 * The current size of this map. 9289 * The current size of this map.
9336 */ 9290 */
9337 int _size = 0; 9291 int _size = 0;
9338 9292
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
10374 const ResolverErrorCode(String name, String message, [String correction]) 10328 const ResolverErrorCode(String name, String message, [String correction])
10375 : super(name, message, correction); 10329 : super(name, message, correction);
10376 10330
10377 @override 10331 @override
10378 ErrorSeverity get errorSeverity => type.severity; 10332 ErrorSeverity get errorSeverity => type.severity;
10379 10333
10380 @override 10334 @override
10381 ErrorType get type => ErrorType.COMPILE_TIME_ERROR; 10335 ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
10382 } 10336 }
10383 10337
10384 typedef ResolverVisitor ResolverVisitorFactory(
10385 Library library, Source source, TypeProvider typeProvider);
10386
10387 typedef TypeResolverVisitor TypeResolverVisitorFactory(
10388 Library library, Source source, TypeProvider typeProvider);
10389
10390 typedef StaticTypeAnalyzer StaticTypeAnalyzerFactory(ResolverVisitor visitor);
10391
10392 /** 10338 /**
10393 * Instances of the class `ResolverVisitor` are used to resolve the nodes within a single 10339 * Instances of the class `ResolverVisitor` are used to resolve the nodes within a single
10394 * compilation unit. 10340 * compilation unit.
10395 */ 10341 */
10396 class ResolverVisitor extends ScopedVisitor { 10342 class ResolverVisitor extends ScopedVisitor {
10397 /** 10343 /**
10398 * The manager for the inheritance mappings. 10344 * The manager for the inheritance mappings.
10399 */ 10345 */
10400 InheritanceManager _inheritanceManager; 10346 InheritanceManager _inheritanceManager;
10401 10347
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
10465 * @param library the library containing the compilation unit being resolved 10411 * @param library the library containing the compilation unit being resolved
10466 * @param source the source representing the compilation unit being visited 10412 * @param source the source representing the compilation unit being visited
10467 * @param typeProvider the object used to access the types from the core libra ry 10413 * @param typeProvider the object used to access the types from the core libra ry
10468 */ 10414 */
10469 ResolverVisitor.con1(Library library, Source source, 10415 ResolverVisitor.con1(Library library, Source source,
10470 TypeProvider typeProvider, {StaticTypeAnalyzer typeAnalyzer, 10416 TypeProvider typeProvider, {StaticTypeAnalyzer typeAnalyzer,
10471 StaticTypeAnalyzerFactory typeAnalyzerFactory}) 10417 StaticTypeAnalyzerFactory typeAnalyzerFactory})
10472 : super.con1(library, source, typeProvider) { 10418 : super.con1(library, source, typeProvider) {
10473 this._inheritanceManager = library.inheritanceManager; 10419 this._inheritanceManager = library.inheritanceManager;
10474 this._elementResolver = new ElementResolver(this); 10420 this._elementResolver = new ElementResolver(this);
10475 this._typeAnalyzer = typeAnalyzer != null 10421 this._typeAnalyzer = typeAnalyzer != null ?
10476 ? typeAnalyzer 10422 typeAnalyzer :
10477 : (typeAnalyzerFactory != null 10423 (typeAnalyzerFactory != null ?
10478 ? typeAnalyzerFactory(this) 10424 typeAnalyzerFactory(this) :
10479 : new StaticTypeAnalyzer(this)); 10425 new StaticTypeAnalyzer(this));
10480 } 10426 }
10481 10427
10482 10428
10483 /** 10429 /**
10484 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 10430 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
10485 * 10431 *
10486 * @param definingLibrary the element for the library containing the compilati on unit being 10432 * @param definingLibrary the element for the library containing the compilati on unit being
10487 * visited 10433 * visited
10488 * @param source the source representing the compilation unit being visited 10434 * @param source the source representing the compilation unit being visited
10489 * @param typeProvider the object used to access the types from the core libra ry 10435 * @param typeProvider the object used to access the types from the core libra ry
(...skipping 3487 matching lines...) Expand 10 before | Expand all | Expand 10 after
13977 _recordType(stackTrace, typeProvider.stackTraceType); 13923 _recordType(stackTrace, typeProvider.stackTraceType);
13978 } 13924 }
13979 return null; 13925 return null;
13980 } 13926 }
13981 13927
13982 @override 13928 @override
13983 Object visitClassDeclaration(ClassDeclaration node) { 13929 Object visitClassDeclaration(ClassDeclaration node) {
13984 _hasReferenceToSuper = false; 13930 _hasReferenceToSuper = false;
13985 super.visitClassDeclaration(node); 13931 super.visitClassDeclaration(node);
13986 ClassElementImpl classElement = _getClassElement(node.name); 13932 ClassElementImpl classElement = _getClassElement(node.name);
13987 if (classElement != null) { 13933 if (classElement != null) {
13988 classElement.hasReferenceToSuper = _hasReferenceToSuper; 13934 classElement.hasReferenceToSuper = _hasReferenceToSuper;
13989 } 13935 }
13990 return null; 13936 return null;
13991 } 13937 }
13992 13938
13993 @override 13939 @override
13994 void visitClassDeclarationInScope(ClassDeclaration node) { 13940 void visitClassDeclarationInScope(ClassDeclaration node) {
13995 super.visitClassDeclarationInScope(node); 13941 super.visitClassDeclarationInScope(node);
13996 ExtendsClause extendsClause = node.extendsClause; 13942 ExtendsClause extendsClause = node.extendsClause;
13997 WithClause withClause = node.withClause; 13943 WithClause withClause = node.withClause;
(...skipping 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after
15725 * library. 15671 * library.
15726 */ 15672 */
15727 final HashSet<String> members = new HashSet<String>(); 15673 final HashSet<String> members = new HashSet<String>();
15728 15674
15729 /** 15675 /**
15730 * Names of resolved or unresolved class members that are read in the 15676 * Names of resolved or unresolved class members that are read in the
15731 * library. 15677 * library.
15732 */ 15678 */
15733 final HashSet<String> readMembers = new HashSet<String>(); 15679 final HashSet<String> readMembers = new HashSet<String>();
15734 } 15680 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698