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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 * a class. | 54 * a class. |
55 */ | 55 */ |
56 ClassElement _enclosingClass; | 56 ClassElement _enclosingClass; |
57 | 57 |
58 /** | 58 /** |
59 * The error reporter by which errors will be reported. | 59 * The error reporter by which errors will be reported. |
60 */ | 60 */ |
61 final ErrorReporter _errorReporter; | 61 final ErrorReporter _errorReporter; |
62 | 62 |
63 /** | 63 /** |
64 * The type Future<Null>, which is needed for determining whether it is safe | |
65 * to have a bare "return;" in an async method. | |
66 */ | |
67 final InterfaceType _futureNullType; | |
68 | |
69 /** | |
64 * Create a new instance of the [BestPracticesVerifier]. | 70 * Create a new instance of the [BestPracticesVerifier]. |
65 * | 71 * |
66 * @param errorReporter the error reporter | 72 * @param errorReporter the error reporter |
67 */ | 73 */ |
68 BestPracticesVerifier(this._errorReporter); | 74 BestPracticesVerifier(this._errorReporter, TypeProvider typeProvider) |
75 : _futureNullType = typeProvider.futureType.substitute4( | |
Brian Wilkerson
2015/02/02 19:41:48
Should we make Future<Null> directly accessible th
Paul Berry
2015/02/02 20:55:38
That's a good idea. I need to do more work in thi
| |
76 <DartType>[typeProvider.nullType]); | |
69 | 77 |
70 @override | 78 @override |
71 Object visitArgumentList(ArgumentList node) { | 79 Object visitArgumentList(ArgumentList node) { |
72 _checkForArgumentTypesNotAssignableInList(node); | 80 _checkForArgumentTypesNotAssignableInList(node); |
73 return super.visitArgumentList(node); | 81 return super.visitArgumentList(node); |
74 } | 82 } |
75 | 83 |
76 @override | 84 @override |
77 Object visitAsExpression(AsExpression node) { | 85 Object visitAsExpression(AsExpression node) { |
78 _checkForUnnecessaryCast(node); | 86 _checkForUnnecessaryCast(node); |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 return true; | 559 return true; |
552 } | 560 } |
553 return false; | 561 return false; |
554 } | 562 } |
555 | 563 |
556 /** | 564 /** |
557 * Generate a hint for functions or methods that have a return type, but do no t have a return | 565 * Generate a hint for functions or methods that have a return type, but do no t have a return |
558 * statement on all branches. At the end of blocks with no return, Dart implic itly returns | 566 * statement on all branches. At the end of blocks with no return, Dart implic itly returns |
559 * `null`, avoiding these implicit returns is considered a best practice. | 567 * `null`, avoiding these implicit returns is considered a best practice. |
560 * | 568 * |
569 * Note: for async functions/methods, this hint only applies when the | |
570 * function has a return type that Future<Null> is not assignable to. | |
571 * | |
561 * @param node the binary expression to check | 572 * @param node the binary expression to check |
562 * @param body the function body | 573 * @param body the function body |
563 * @return `true` if and only if a hint code is generated on the passed node | 574 * @return `true` if and only if a hint code is generated on the passed node |
564 * See [HintCode.MISSING_RETURN]. | 575 * See [HintCode.MISSING_RETURN]. |
565 */ | 576 */ |
566 bool _checkForMissingReturn(TypeName returnType, FunctionBody body) { | 577 bool _checkForMissingReturn(TypeName returnType, FunctionBody body) { |
567 // Check that the method or function has a return type, and a function body | 578 // Check that the method or function has a return type, and a function body |
568 if (returnType == null || body == null) { | 579 if (returnType == null || body == null) { |
569 return false; | 580 return false; |
570 } | 581 } |
571 // Check that the body is a BlockFunctionBody | 582 // Check that the body is a BlockFunctionBody |
572 if (body is! BlockFunctionBody) { | 583 if (body is! BlockFunctionBody) { |
573 return false; | 584 return false; |
574 } | 585 } |
575 // Check that the type is resolvable, and is not "void" | 586 // Check that the type is resolvable, and is not "void" |
576 DartType returnTypeType = returnType.type; | 587 DartType returnTypeType = returnType.type; |
577 if (returnTypeType == null || returnTypeType.isVoid) { | 588 if (returnTypeType == null || returnTypeType.isVoid) { |
578 return false; | 589 return false; |
579 } | 590 } |
591 // For async, give no hint if Future<Null> is assignable to the return | |
592 // type. | |
593 if (body.isAsynchronous && _futureNullType.isAssignableTo(returnTypeType)) { | |
594 return false; | |
595 } | |
580 // Check the block for a return statement, if not, create the hint | 596 // Check the block for a return statement, if not, create the hint |
581 BlockFunctionBody blockFunctionBody = body as BlockFunctionBody; | 597 BlockFunctionBody blockFunctionBody = body as BlockFunctionBody; |
582 if (!blockFunctionBody.accept(new ExitDetector())) { | 598 if (!blockFunctionBody.accept(new ExitDetector())) { |
583 _errorReporter.reportErrorForNode( | 599 _errorReporter.reportErrorForNode( |
584 HintCode.MISSING_RETURN, | 600 HintCode.MISSING_RETURN, |
585 returnType, | 601 returnType, |
586 [returnTypeType.displayName]); | 602 [returnTypeType.displayName]); |
587 return true; | 603 return true; |
588 } | 604 } |
589 return false; | 605 return false; |
(...skipping 3796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4386 | 4402 |
4387 /** | 4403 /** |
4388 * Instances of the class `HintGenerator` traverse a library's worth of dart cod e at a time to | 4404 * Instances of the class `HintGenerator` traverse a library's worth of dart cod e at a time to |
4389 * generate hints over the set of sources. | 4405 * generate hints over the set of sources. |
4390 * | 4406 * |
4391 * See [HintCode]. | 4407 * See [HintCode]. |
4392 */ | 4408 */ |
4393 class HintGenerator { | 4409 class HintGenerator { |
4394 final List<CompilationUnit> _compilationUnits; | 4410 final List<CompilationUnit> _compilationUnits; |
4395 | 4411 |
4396 final AnalysisContext _context; | 4412 final InternalAnalysisContext _context; |
4397 | 4413 |
4398 final AnalysisErrorListener _errorListener; | 4414 final AnalysisErrorListener _errorListener; |
4399 | 4415 |
4400 LibraryElement _library; | 4416 LibraryElement _library; |
4401 | 4417 |
4402 ImportsVerifier _importsVerifier; | 4418 ImportsVerifier _importsVerifier; |
4403 | 4419 |
4404 bool _enableDart2JSHints = false; | 4420 bool _enableDart2JSHints = false; |
4405 | 4421 |
4406 /** | 4422 /** |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4451 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source); | 4467 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source); |
4452 unit.accept(_importsVerifier); | 4468 unit.accept(_importsVerifier); |
4453 // dead code analysis | 4469 // dead code analysis |
4454 unit.accept(new DeadCodeVerifier(errorReporter)); | 4470 unit.accept(new DeadCodeVerifier(errorReporter)); |
4455 unit.accept(_usedElementsVisitor); | 4471 unit.accept(_usedElementsVisitor); |
4456 // dart2js analysis | 4472 // dart2js analysis |
4457 if (_enableDart2JSHints) { | 4473 if (_enableDart2JSHints) { |
4458 unit.accept(new Dart2JSVerifier(errorReporter)); | 4474 unit.accept(new Dart2JSVerifier(errorReporter)); |
4459 } | 4475 } |
4460 // Dart best practices | 4476 // Dart best practices |
4461 unit.accept(new BestPracticesVerifier(errorReporter)); | 4477 unit.accept( |
4478 new BestPracticesVerifier(errorReporter, _context.typeProvider)); | |
4462 unit.accept(new OverrideVerifier(_manager, errorReporter)); | 4479 unit.accept(new OverrideVerifier(_manager, errorReporter)); |
4463 // Find to-do comments | 4480 // Find to-do comments |
4464 new ToDoFinder(errorReporter).findIn(unit); | 4481 new ToDoFinder(errorReporter).findIn(unit); |
4465 // pub analysis | 4482 // pub analysis |
4466 // TODO(danrubel/jwren) Commented out until bugs in the pub verifier are | 4483 // TODO(danrubel/jwren) Commented out until bugs in the pub verifier are |
4467 // fixed | 4484 // fixed |
4468 // unit.accept(new PubVerifier(context, errorReporter)); | 4485 // unit.accept(new PubVerifier(context, errorReporter)); |
4469 } | 4486 } |
4470 } | 4487 } |
4471 | 4488 |
(...skipping 3211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7683 * [AnalysisErrorListener] with the [recordingErrorListener]. | 7700 * [AnalysisErrorListener] with the [recordingErrorListener]. |
7684 */ | 7701 */ |
7685 RecordingErrorListener _errorListener; | 7702 RecordingErrorListener _errorListener; |
7686 | 7703 |
7687 /** | 7704 /** |
7688 * A source object representing the core library (dart:core). | 7705 * A source object representing the core library (dart:core). |
7689 */ | 7706 */ |
7690 Source _coreLibrarySource; | 7707 Source _coreLibrarySource; |
7691 | 7708 |
7692 /** | 7709 /** |
7710 * A Source object representing the async library (dart:async). | |
7711 */ | |
7712 Source _asyncLibrarySource; | |
7713 | |
7714 /** | |
7693 * The object representing the core library. | 7715 * The object representing the core library. |
7694 */ | 7716 */ |
7695 Library _coreLibrary; | 7717 Library _coreLibrary; |
7696 | 7718 |
7697 /** | 7719 /** |
7720 * The object representing the async library. | |
7721 */ | |
7722 Library _asyncLibrary; | |
7723 | |
7724 /** | |
7698 * The object used to access the types from the core library. | 7725 * The object used to access the types from the core library. |
7699 */ | 7726 */ |
7700 TypeProvider _typeProvider; | 7727 TypeProvider _typeProvider; |
7701 | 7728 |
7702 /** | 7729 /** |
7703 * A table mapping library sources to the information being maintained for tho se libraries. | 7730 * A table mapping library sources to the information being maintained for tho se libraries. |
7704 */ | 7731 */ |
7705 HashMap<Source, Library> _libraryMap = new HashMap<Source, Library>(); | 7732 HashMap<Source, Library> _libraryMap = new HashMap<Source, Library>(); |
7706 | 7733 |
7707 /** | 7734 /** |
7708 * A collection containing the libraries that are being resolved together. | 7735 * A collection containing the libraries that are being resolved together. |
7709 */ | 7736 */ |
7710 Set<Library> _librariesInCycles; | 7737 Set<Library> _librariesInCycles; |
7711 | 7738 |
7712 /** | 7739 /** |
7713 * Initialize a newly created library resolver to resolve libraries within the given context. | 7740 * Initialize a newly created library resolver to resolve libraries within the given context. |
7714 * | 7741 * |
7715 * @param analysisContext the analysis context in which the library is being a nalyzed | 7742 * @param analysisContext the analysis context in which the library is being a nalyzed |
7716 */ | 7743 */ |
7717 LibraryResolver(this.analysisContext) { | 7744 LibraryResolver(this.analysisContext) { |
7718 this._errorListener = new RecordingErrorListener(); | 7745 this._errorListener = new RecordingErrorListener(); |
7719 _coreLibrarySource = | 7746 _coreLibrarySource = |
7720 analysisContext.sourceFactory.forUri(DartSdk.DART_CORE); | 7747 analysisContext.sourceFactory.forUri(DartSdk.DART_CORE); |
7748 _asyncLibrarySource = | |
7749 analysisContext.sourceFactory.forUri(DartSdk.DART_ASYNC); | |
7721 } | 7750 } |
7722 | 7751 |
7723 /** | 7752 /** |
7724 * Return the listener to which analysis errors will be reported. | 7753 * Return the listener to which analysis errors will be reported. |
7725 * | 7754 * |
7726 * @return the listener to which analysis errors will be reported | 7755 * @return the listener to which analysis errors will be reported |
7727 */ | 7756 */ |
7728 RecordingErrorListener get errorListener => _errorListener; | 7757 RecordingErrorListener get errorListener => _errorListener; |
7729 | 7758 |
7730 /** | 7759 /** |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7762 */ | 7791 */ |
7763 LibraryElement resolveEmbeddedLibrary(Source librarySource, | 7792 LibraryElement resolveEmbeddedLibrary(Source librarySource, |
7764 CompilationUnit unit, bool fullAnalysis) { | 7793 CompilationUnit unit, bool fullAnalysis) { |
7765 // | 7794 // |
7766 // Create the objects representing the library being resolved and the core | 7795 // Create the objects representing the library being resolved and the core |
7767 // library. | 7796 // library. |
7768 // | 7797 // |
7769 Library targetLibrary = _createLibraryWithUnit(librarySource, unit); | 7798 Library targetLibrary = _createLibraryWithUnit(librarySource, unit); |
7770 _coreLibrary = _libraryMap[_coreLibrarySource]; | 7799 _coreLibrary = _libraryMap[_coreLibrarySource]; |
7771 if (_coreLibrary == null) { | 7800 if (_coreLibrary == null) { |
7772 // This will be true unless the library being analyzed is the core | 7801 // This will only happen if the library being analyzed is the core |
7773 // library. | 7802 // library. |
7774 _coreLibrary = createLibrary(_coreLibrarySource); | 7803 _coreLibrary = createLibrary(_coreLibrarySource); |
7775 if (_coreLibrary == null) { | 7804 if (_coreLibrary == null) { |
7776 LibraryResolver2.missingCoreLibrary( | 7805 LibraryResolver2.missingCoreLibrary( |
7777 analysisContext, | 7806 analysisContext, |
7778 _coreLibrarySource); | 7807 _coreLibrarySource); |
7779 } | 7808 } |
7780 } | 7809 } |
7810 _asyncLibrary = _libraryMap[_asyncLibrarySource]; | |
7811 if (_asyncLibrary == null) { | |
7812 // This will only happen if the library being analyzed is the async | |
7813 // library. | |
7814 _asyncLibrary = createLibrary(_asyncLibrarySource); | |
7815 if (_asyncLibrary == null) { | |
7816 LibraryResolver2.missingAsyncLibrary( | |
7817 analysisContext, | |
7818 _asyncLibrarySource); | |
7819 } | |
7820 } | |
7781 // | 7821 // |
7782 // Compute the set of libraries that need to be resolved together. | 7822 // Compute the set of libraries that need to be resolved together. |
7783 // | 7823 // |
7784 _computeEmbeddedLibraryDependencies(targetLibrary, unit); | 7824 _computeEmbeddedLibraryDependencies(targetLibrary, unit); |
7785 _librariesInCycles = _computeLibrariesInCycles(targetLibrary); | 7825 _librariesInCycles = _computeLibrariesInCycles(targetLibrary); |
7786 // | 7826 // |
7787 // Build the element models representing the libraries being resolved. | 7827 // Build the element models representing the libraries being resolved. |
7788 // This is done in three steps: | 7828 // This is done in three steps: |
7789 // | 7829 // |
7790 // 1. Build the basic element models without making any connections | 7830 // 1. Build the basic element models without making any connections |
7791 // between elements other than the basic parent/child relationships. | 7831 // between elements other than the basic parent/child relationships. |
7792 // This includes building the elements representing the libraries. | 7832 // This includes building the elements representing the libraries. |
7793 // 2. Build the elements for the import and export directives. This | 7833 // 2. Build the elements for the import and export directives. This |
7794 // requires that we have the elements built for the referenced | 7834 // requires that we have the elements built for the referenced |
7795 // libraries, but because of the possibility of circular references | 7835 // libraries, but because of the possibility of circular references |
7796 // needs to happen after all of the library elements have been created. | 7836 // needs to happen after all of the library elements have been created. |
7797 // 3. Build the rest of the type model by connecting superclasses, mixins, | 7837 // 3. Build the rest of the type model by connecting superclasses, mixins, |
7798 // and interfaces. This requires that we be able to compute the names | 7838 // and interfaces. This requires that we be able to compute the names |
7799 // visible in the libraries being resolved, which in turn requires that | 7839 // visible in the libraries being resolved, which in turn requires that |
7800 // we have resolved the import directives. | 7840 // we have resolved the import directives. |
7801 // | 7841 // |
7802 _buildElementModels(); | 7842 _buildElementModels(); |
7803 LibraryElement coreElement = _coreLibrary.libraryElement; | 7843 LibraryElement coreElement = _coreLibrary.libraryElement; |
7804 if (coreElement == null) { | 7844 if (coreElement == null) { |
7805 throw new AnalysisException("Could not resolve dart:core"); | 7845 throw new AnalysisException("Could not resolve dart:core"); |
7806 } | 7846 } |
7847 LibraryElement asyncElement = _asyncLibrary.libraryElement; | |
7848 if (asyncElement == null) { | |
7849 throw new AnalysisException("Could not resolve dart:async"); | |
7850 } | |
7807 _buildDirectiveModels(); | 7851 _buildDirectiveModels(); |
7808 _typeProvider = new TypeProviderImpl(coreElement); | 7852 _typeProvider = new TypeProviderImpl(coreElement, asyncElement); |
7809 _buildTypeAliases(); | 7853 _buildTypeAliases(); |
7810 _buildTypeHierarchies(); | 7854 _buildTypeHierarchies(); |
7811 // | 7855 // |
7812 // Perform resolution and type analysis. | 7856 // Perform resolution and type analysis. |
7813 // | 7857 // |
7814 // TODO(brianwilkerson) Decide whether we want to resolve all of the | 7858 // TODO(brianwilkerson) Decide whether we want to resolve all of the |
7815 // libraries or whether we want to only resolve the target library. | 7859 // libraries or whether we want to only resolve the target library. |
7816 // The advantage to resolving everything is that we have already done part | 7860 // The advantage to resolving everything is that we have already done part |
7817 // of the work so we'll avoid duplicated effort. The disadvantage of | 7861 // of the work so we'll avoid duplicated effort. The disadvantage of |
7818 // resolving everything is that we might do extra work that we don't | 7862 // resolving everything is that we might do extra work that we don't |
(...skipping 23 matching lines...) Expand all Loading... | |
7842 * @throws AnalysisException if the library could not be resolved for some rea son | 7886 * @throws AnalysisException if the library could not be resolved for some rea son |
7843 */ | 7887 */ |
7844 LibraryElement resolveLibrary(Source librarySource, bool fullAnalysis) { | 7888 LibraryElement resolveLibrary(Source librarySource, bool fullAnalysis) { |
7845 // | 7889 // |
7846 // Create the objects representing the library being resolved and the core | 7890 // Create the objects representing the library being resolved and the core |
7847 // library. | 7891 // library. |
7848 // | 7892 // |
7849 Library targetLibrary = createLibrary(librarySource); | 7893 Library targetLibrary = createLibrary(librarySource); |
7850 _coreLibrary = _libraryMap[_coreLibrarySource]; | 7894 _coreLibrary = _libraryMap[_coreLibrarySource]; |
7851 if (_coreLibrary == null) { | 7895 if (_coreLibrary == null) { |
7852 // This will be true unless the library being analyzed is the core | 7896 // This should only happen if the library being analyzed is the core |
7853 // library. | 7897 // library. |
7854 _coreLibrary = _createLibraryOrNull(_coreLibrarySource); | 7898 _coreLibrary = _createLibraryOrNull(_coreLibrarySource); |
7855 if (_coreLibrary == null) { | 7899 if (_coreLibrary == null) { |
7856 LibraryResolver2.missingCoreLibrary( | 7900 LibraryResolver2.missingCoreLibrary( |
7857 analysisContext, | 7901 analysisContext, |
7858 _coreLibrarySource); | 7902 _coreLibrarySource); |
7859 } | 7903 } |
7860 } | 7904 } |
7905 _asyncLibrary = _libraryMap[_asyncLibrarySource]; | |
7906 if (_asyncLibrary == null) { | |
7907 // This should only happen if the library being analyzed is the async | |
7908 // library. | |
7909 _asyncLibrary = _createLibraryOrNull(_asyncLibrarySource); | |
7910 if (_asyncLibrary == null) { | |
7911 LibraryResolver2.missingAsyncLibrary( | |
7912 analysisContext, | |
7913 _asyncLibrarySource); | |
7914 } | |
7915 } | |
7861 // | 7916 // |
7862 // Compute the set of libraries that need to be resolved together. | 7917 // Compute the set of libraries that need to be resolved together. |
7863 // | 7918 // |
7864 _computeLibraryDependencies(targetLibrary); | 7919 _computeLibraryDependencies(targetLibrary); |
7865 _librariesInCycles = _computeLibrariesInCycles(targetLibrary); | 7920 _librariesInCycles = _computeLibrariesInCycles(targetLibrary); |
7866 // | 7921 // |
7867 // Build the element models representing the libraries being resolved. | 7922 // Build the element models representing the libraries being resolved. |
7868 // This is done in three steps: | 7923 // This is done in three steps: |
7869 // | 7924 // |
7870 // 1. Build the basic element models without making any connections | 7925 // 1. Build the basic element models without making any connections |
7871 // between elements other than the basic parent/child relationships. | 7926 // between elements other than the basic parent/child relationships. |
7872 // This includes building the elements representing the libraries, but | 7927 // This includes building the elements representing the libraries, but |
7873 // excludes members defined in enums. | 7928 // excludes members defined in enums. |
7874 // 2. Build the elements for the import and export directives. This | 7929 // 2. Build the elements for the import and export directives. This |
7875 // requires that we have the elements built for the referenced | 7930 // requires that we have the elements built for the referenced |
7876 // libraries, but because of the possibility of circular references | 7931 // libraries, but because of the possibility of circular references |
7877 // needs to happen after all of the library elements have been created. | 7932 // needs to happen after all of the library elements have been created. |
7878 // 3. Build the members in enum declarations. | 7933 // 3. Build the members in enum declarations. |
7879 // 4. Build the rest of the type model by connecting superclasses, mixins, | 7934 // 4. Build the rest of the type model by connecting superclasses, mixins, |
7880 // and interfaces. This requires that we be able to compute the names | 7935 // and interfaces. This requires that we be able to compute the names |
7881 // visible in the libraries being resolved, which in turn requires that | 7936 // visible in the libraries being resolved, which in turn requires that |
7882 // we have resolved the import directives. | 7937 // we have resolved the import directives. |
7883 // | 7938 // |
7884 _buildElementModels(); | 7939 _buildElementModels(); |
7885 LibraryElement coreElement = _coreLibrary.libraryElement; | 7940 LibraryElement coreElement = _coreLibrary.libraryElement; |
7886 if (coreElement == null) { | 7941 if (coreElement == null) { |
7887 throw new AnalysisException("Could not resolve dart:core"); | 7942 throw new AnalysisException("Could not resolve dart:core"); |
7888 } | 7943 } |
7944 LibraryElement asyncElement = _asyncLibrary.libraryElement; | |
7945 if (asyncElement == null) { | |
7946 throw new AnalysisException("Coulb not resolve dart:async"); | |
7947 } | |
7889 _buildDirectiveModels(); | 7948 _buildDirectiveModels(); |
7890 _typeProvider = new TypeProviderImpl(coreElement); | 7949 _typeProvider = new TypeProviderImpl(coreElement, asyncElement); |
7891 _buildEnumMembers(); | 7950 _buildEnumMembers(); |
7892 _buildTypeAliases(); | 7951 _buildTypeAliases(); |
7893 _buildTypeHierarchies(); | 7952 _buildTypeHierarchies(); |
7894 _buildImplicitConstructors(); | 7953 _buildImplicitConstructors(); |
7895 // | 7954 // |
7896 // Perform resolution and type analysis. | 7955 // Perform resolution and type analysis. |
7897 // | 7956 // |
7898 // TODO(brianwilkerson) Decide whether we want to resolve all of the | 7957 // TODO(brianwilkerson) Decide whether we want to resolve all of the |
7899 // libraries or whether we want to only resolve the target library. The | 7958 // libraries or whether we want to only resolve the target library. The |
7900 // advantage to resolving everything is that we have already done part of | 7959 // advantage to resolving everything is that we have already done part of |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7959 * to the given dependency map. | 8018 * to the given dependency map. |
7960 * | 8019 * |
7961 * @param library the library currently being added to the dependency map | 8020 * @param library the library currently being added to the dependency map |
7962 * @param dependencyMap the dependency map being computed | 8021 * @param dependencyMap the dependency map being computed |
7963 * @param visitedLibraries the libraries that have already been visited, used to prevent infinite | 8022 * @param visitedLibraries the libraries that have already been visited, used to prevent infinite |
7964 * recursion | 8023 * recursion |
7965 */ | 8024 */ |
7966 void _addToDependencyMap(Library library, HashMap<Library, | 8025 void _addToDependencyMap(Library library, HashMap<Library, |
7967 List<Library>> dependencyMap, Set<Library> visitedLibraries) { | 8026 List<Library>> dependencyMap, Set<Library> visitedLibraries) { |
7968 if (visitedLibraries.add(library)) { | 8027 if (visitedLibraries.add(library)) { |
8028 bool asyncFound = false; | |
7969 for (Library referencedLibrary in library.importsAndExports) { | 8029 for (Library referencedLibrary in library.importsAndExports) { |
7970 _addDependencyToMap(dependencyMap, library, referencedLibrary); | 8030 _addDependencyToMap(dependencyMap, library, referencedLibrary); |
7971 _addToDependencyMap(referencedLibrary, dependencyMap, visitedLibraries); | 8031 _addToDependencyMap(referencedLibrary, dependencyMap, visitedLibraries); |
8032 if (identical(referencedLibrary, _asyncLibrary)) { | |
8033 asyncFound = true; | |
8034 } | |
7972 } | 8035 } |
7973 if (!library.explicitlyImportsCore && !identical(library, _coreLibrary)) { | 8036 if (!library.explicitlyImportsCore && !identical(library, _coreLibrary)) { |
7974 _addDependencyToMap(dependencyMap, library, _coreLibrary); | 8037 _addDependencyToMap(dependencyMap, library, _coreLibrary); |
7975 } | 8038 } |
8039 if (!asyncFound && !identical(library, _asyncLibrary)) { | |
8040 _addDependencyToMap(dependencyMap, library, _asyncLibrary); | |
8041 _addToDependencyMap(_asyncLibrary, dependencyMap, visitedLibraries); | |
8042 } | |
7976 } | 8043 } |
7977 } | 8044 } |
7978 | 8045 |
7979 /** | 8046 /** |
7980 * Build the element model representing the combinators declared by the given directive. | 8047 * Build the element model representing the combinators declared by the given directive. |
7981 * | 8048 * |
7982 * @param directive the directive that declares the combinators | 8049 * @param directive the directive that declares the combinators |
7983 * @return an array containing the import combinators that were built | 8050 * @return an array containing the import combinators that were built |
7984 */ | 8051 */ |
7985 List<NamespaceCombinator> _buildCombinators(NamespaceDirective directive) { | 8052 List<NamespaceCombinator> _buildCombinators(NamespaceDirective directive) { |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8332 * | 8399 * |
8333 * @param library the library to be processed to find libraries that have not yet been traversed | 8400 * @param library the library to be processed to find libraries that have not yet been traversed |
8334 * @param importedSources an array containing the sources that are imported in to the given library | 8401 * @param importedSources an array containing the sources that are imported in to the given library |
8335 * @param exportedSources an array containing the sources that are exported fr om the given library | 8402 * @param exportedSources an array containing the sources that are exported fr om the given library |
8336 * @throws AnalysisException if some portion of the library graph could not be traversed | 8403 * @throws AnalysisException if some portion of the library graph could not be traversed |
8337 */ | 8404 */ |
8338 void _computeLibraryDependenciesFromDirectives(Library library, | 8405 void _computeLibraryDependenciesFromDirectives(Library library, |
8339 List<Source> importedSources, List<Source> exportedSources) { | 8406 List<Source> importedSources, List<Source> exportedSources) { |
8340 List<Library> importedLibraries = new List<Library>(); | 8407 List<Library> importedLibraries = new List<Library>(); |
8341 bool explicitlyImportsCore = false; | 8408 bool explicitlyImportsCore = false; |
8409 bool importsAsync = false; | |
8342 for (Source importedSource in importedSources) { | 8410 for (Source importedSource in importedSources) { |
8343 if (importedSource == _coreLibrarySource) { | 8411 if (importedSource == _coreLibrarySource) { |
8344 explicitlyImportsCore = true; | 8412 explicitlyImportsCore = true; |
8345 } | 8413 } |
8414 if (importedSource == _asyncLibrarySource) { | |
8415 importsAsync = true; | |
8416 } | |
8346 Library importedLibrary = _libraryMap[importedSource]; | 8417 Library importedLibrary = _libraryMap[importedSource]; |
8347 if (importedLibrary == null) { | 8418 if (importedLibrary == null) { |
8348 importedLibrary = _createLibraryOrNull(importedSource); | 8419 importedLibrary = _createLibraryOrNull(importedSource); |
8349 if (importedLibrary != null) { | 8420 if (importedLibrary != null) { |
8350 _computeLibraryDependencies(importedLibrary); | 8421 _computeLibraryDependencies(importedLibrary); |
8351 } | 8422 } |
8352 } | 8423 } |
8353 if (importedLibrary != null) { | 8424 if (importedLibrary != null) { |
8354 importedLibraries.add(importedLibrary); | 8425 importedLibraries.add(importedLibrary); |
8355 } | 8426 } |
(...skipping 16 matching lines...) Expand all Loading... | |
8372 library.explicitlyImportsCore = explicitlyImportsCore; | 8443 library.explicitlyImportsCore = explicitlyImportsCore; |
8373 if (!explicitlyImportsCore && _coreLibrarySource != library.librarySource) { | 8444 if (!explicitlyImportsCore && _coreLibrarySource != library.librarySource) { |
8374 Library importedLibrary = _libraryMap[_coreLibrarySource]; | 8445 Library importedLibrary = _libraryMap[_coreLibrarySource]; |
8375 if (importedLibrary == null) { | 8446 if (importedLibrary == null) { |
8376 importedLibrary = _createLibraryOrNull(_coreLibrarySource); | 8447 importedLibrary = _createLibraryOrNull(_coreLibrarySource); |
8377 if (importedLibrary != null) { | 8448 if (importedLibrary != null) { |
8378 _computeLibraryDependencies(importedLibrary); | 8449 _computeLibraryDependencies(importedLibrary); |
8379 } | 8450 } |
8380 } | 8451 } |
8381 } | 8452 } |
8453 if (!importsAsync && _asyncLibrarySource != library.librarySource) { | |
8454 Library importedLibrary = _libraryMap[_asyncLibrarySource]; | |
8455 if (importedLibrary == null) { | |
8456 importedLibrary = _createLibraryOrNull(_asyncLibrarySource); | |
8457 if (importedLibrary != null) { | |
8458 _computeLibraryDependencies(importedLibrary); | |
8459 } | |
8460 } | |
8461 } | |
8382 } | 8462 } |
8383 | 8463 |
8384 /** | 8464 /** |
8385 * Create an object to represent the information about the library defined by the compilation unit | 8465 * Create an object to represent the information about the library defined by the compilation unit |
8386 * with the given source. Return the library object that was created, or `null ` if the | 8466 * with the given source. Return the library object that was created, or `null ` if the |
8387 * source is not valid. | 8467 * source is not valid. |
8388 * | 8468 * |
8389 * @param librarySource the source of the library's defining compilation unit | 8469 * @param librarySource the source of the library's defining compilation unit |
8390 * @return the library object that was created | 8470 * @return the library object that was created |
8391 */ | 8471 */ |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8553 * [AnalysisErrorListener] with the [recordingErrorListener]. | 8633 * [AnalysisErrorListener] with the [recordingErrorListener]. |
8554 */ | 8634 */ |
8555 RecordingErrorListener _errorListener; | 8635 RecordingErrorListener _errorListener; |
8556 | 8636 |
8557 /** | 8637 /** |
8558 * A source object representing the core library (dart:core). | 8638 * A source object representing the core library (dart:core). |
8559 */ | 8639 */ |
8560 Source _coreLibrarySource; | 8640 Source _coreLibrarySource; |
8561 | 8641 |
8562 /** | 8642 /** |
8643 * A source object representing the async library (dart:async). | |
8644 */ | |
8645 Source _asyncLibrarySource; | |
8646 | |
8647 /** | |
8563 * The object representing the core library. | 8648 * The object representing the core library. |
8564 */ | 8649 */ |
8565 ResolvableLibrary _coreLibrary; | 8650 ResolvableLibrary _coreLibrary; |
8566 | 8651 |
8567 /** | 8652 /** |
8653 * The object representing the async library. | |
8654 */ | |
8655 ResolvableLibrary _asyncLibrary; | |
8656 | |
8657 /** | |
8568 * The object used to access the types from the core library. | 8658 * The object used to access the types from the core library. |
8569 */ | 8659 */ |
8570 TypeProvider _typeProvider; | 8660 TypeProvider _typeProvider; |
8571 | 8661 |
8572 /** | 8662 /** |
8573 * A table mapping library sources to the information being maintained for tho se libraries. | 8663 * A table mapping library sources to the information being maintained for tho se libraries. |
8574 */ | 8664 */ |
8575 HashMap<Source, ResolvableLibrary> _libraryMap = | 8665 HashMap<Source, ResolvableLibrary> _libraryMap = |
8576 new HashMap<Source, ResolvableLibrary>(); | 8666 new HashMap<Source, ResolvableLibrary>(); |
8577 | 8667 |
8578 /** | 8668 /** |
8579 * A collection containing the libraries that are being resolved together. | 8669 * A collection containing the libraries that are being resolved together. |
8580 */ | 8670 */ |
8581 List<ResolvableLibrary> _librariesInCycle; | 8671 List<ResolvableLibrary> _librariesInCycle; |
8582 | 8672 |
8583 /** | 8673 /** |
8584 * Initialize a newly created library resolver to resolve libraries within the given context. | 8674 * Initialize a newly created library resolver to resolve libraries within the given context. |
8585 * | 8675 * |
8586 * @param analysisContext the analysis context in which the library is being a nalyzed | 8676 * @param analysisContext the analysis context in which the library is being a nalyzed |
8587 */ | 8677 */ |
8588 LibraryResolver2(this.analysisContext) { | 8678 LibraryResolver2(this.analysisContext) { |
8589 this._errorListener = new RecordingErrorListener(); | 8679 this._errorListener = new RecordingErrorListener(); |
8590 _coreLibrarySource = | 8680 _coreLibrarySource = |
8591 analysisContext.sourceFactory.forUri(DartSdk.DART_CORE); | 8681 analysisContext.sourceFactory.forUri(DartSdk.DART_CORE); |
8682 _asyncLibrarySource = | |
8683 analysisContext.sourceFactory.forUri(DartSdk.DART_ASYNC); | |
8592 } | 8684 } |
8593 | 8685 |
8594 /** | 8686 /** |
8595 * Return the listener to which analysis errors will be reported. | 8687 * Return the listener to which analysis errors will be reported. |
8596 * | 8688 * |
8597 * @return the listener to which analysis errors will be reported | 8689 * @return the listener to which analysis errors will be reported |
8598 */ | 8690 */ |
8599 RecordingErrorListener get errorListener => _errorListener; | 8691 RecordingErrorListener get errorListener => _errorListener; |
8600 | 8692 |
8601 /** | 8693 /** |
(...skipping 18 matching lines...) Expand all Loading... | |
8620 */ | 8712 */ |
8621 LibraryElement resolveLibrary(Source librarySource, | 8713 LibraryElement resolveLibrary(Source librarySource, |
8622 List<ResolvableLibrary> librariesInCycle) { | 8714 List<ResolvableLibrary> librariesInCycle) { |
8623 // | 8715 // |
8624 // Build the map of libraries that are known. | 8716 // Build the map of libraries that are known. |
8625 // | 8717 // |
8626 this._librariesInCycle = librariesInCycle; | 8718 this._librariesInCycle = librariesInCycle; |
8627 _libraryMap = _buildLibraryMap(); | 8719 _libraryMap = _buildLibraryMap(); |
8628 ResolvableLibrary targetLibrary = _libraryMap[librarySource]; | 8720 ResolvableLibrary targetLibrary = _libraryMap[librarySource]; |
8629 _coreLibrary = _libraryMap[_coreLibrarySource]; | 8721 _coreLibrary = _libraryMap[_coreLibrarySource]; |
8722 _asyncLibrary = _libraryMap[_asyncLibrarySource]; | |
8630 // | 8723 // |
8631 // Build the element models representing the libraries being resolved. | 8724 // Build the element models representing the libraries being resolved. |
8632 // This is done in three steps: | 8725 // This is done in three steps: |
8633 // | 8726 // |
8634 // 1. Build the basic element models without making any connections | 8727 // 1. Build the basic element models without making any connections |
8635 // between elements other than the basic parent/child relationships. | 8728 // between elements other than the basic parent/child relationships. |
8636 // This includes building the elements representing the libraries, but | 8729 // This includes building the elements representing the libraries, but |
8637 // excludes members defined in enums. | 8730 // excludes members defined in enums. |
8638 // 2. Build the elements for the import and export directives. This | 8731 // 2. Build the elements for the import and export directives. This |
8639 // requires that we have the elements built for the referenced | 8732 // requires that we have the elements built for the referenced |
8640 // libraries, but because of the possibility of circular references | 8733 // libraries, but because of the possibility of circular references |
8641 // needs to happen after all of the library elements have been created. | 8734 // needs to happen after all of the library elements have been created. |
8642 // 3. Build the members in enum declarations. | 8735 // 3. Build the members in enum declarations. |
8643 // 4. Build the rest of the type model by connecting superclasses, mixins, | 8736 // 4. Build the rest of the type model by connecting superclasses, mixins, |
8644 // and interfaces. This requires that we be able to compute the names | 8737 // and interfaces. This requires that we be able to compute the names |
8645 // visible in the libraries being resolved, which in turn requires that | 8738 // visible in the libraries being resolved, which in turn requires that |
8646 // we have resolved the import directives. | 8739 // we have resolved the import directives. |
8647 // | 8740 // |
8648 _buildElementModels(); | 8741 _buildElementModels(); |
8649 LibraryElement coreElement = _coreLibrary.libraryElement; | 8742 LibraryElement coreElement = _coreLibrary.libraryElement; |
8650 if (coreElement == null) { | 8743 if (coreElement == null) { |
8651 missingCoreLibrary(analysisContext, _coreLibrarySource); | 8744 missingCoreLibrary(analysisContext, _coreLibrarySource); |
8652 } | 8745 } |
8746 LibraryElement asyncElement = _asyncLibrary.libraryElement; | |
8747 if (asyncElement == null) { | |
8748 missingAsyncLibrary(analysisContext, _asyncLibrarySource); | |
8749 } | |
8653 _buildDirectiveModels(); | 8750 _buildDirectiveModels(); |
8654 _typeProvider = new TypeProviderImpl(coreElement); | 8751 _typeProvider = new TypeProviderImpl(coreElement, asyncElement); |
8655 _buildEnumMembers(); | 8752 _buildEnumMembers(); |
8656 _buildTypeAliases(); | 8753 _buildTypeAliases(); |
8657 _buildTypeHierarchies(); | 8754 _buildTypeHierarchies(); |
8658 _buildImplicitConstructors(); | 8755 _buildImplicitConstructors(); |
8659 // | 8756 // |
8660 // Perform resolution and type analysis. | 8757 // Perform resolution and type analysis. |
8661 // | 8758 // |
8662 // TODO(brianwilkerson) Decide whether we want to resolve all of the | 8759 // TODO(brianwilkerson) Decide whether we want to resolve all of the |
8663 // libraries or whether we want to only resolve the target library. The | 8760 // libraries or whether we want to only resolve the target library. The |
8664 // advantage to resolving everything is that we have already done part of | 8761 // advantage to resolving everything is that we have already done part of |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9061 ResolverVisitor visitor = | 9158 ResolverVisitor visitor = |
9062 new ResolverVisitor.con4(library, source, _typeProvider); | 9159 new ResolverVisitor.con4(library, source, _typeProvider); |
9063 ast.accept(visitor); | 9160 ast.accept(visitor); |
9064 } | 9161 } |
9065 } finally { | 9162 } finally { |
9066 timeCounter.stop(); | 9163 timeCounter.stop(); |
9067 } | 9164 } |
9068 } | 9165 } |
9069 | 9166 |
9070 /** | 9167 /** |
9168 * Report that the async library could not be resolved in the given | |
9169 * [analysisContext] and throw an exception. [asyncLibrarySource] is the sour ce | |
9170 * representing the async library. | |
9171 */ | |
9172 static void missingAsyncLibrary(AnalysisContext analysisContext, | |
9173 Source asyncLibrarySource) { | |
9174 throw new AnalysisException("Could not resolve dart:async"); | |
9175 } | |
9176 | |
9177 /** | |
9071 * Report that the core library could not be resolved in the given analysis co ntext and throw an | 9178 * Report that the core library could not be resolved in the given analysis co ntext and throw an |
9072 * exception. | 9179 * exception. |
9073 * | 9180 * |
9074 * @param analysisContext the analysis context in which the failure occurred | 9181 * @param analysisContext the analysis context in which the failure occurred |
9075 * @param coreLibrarySource the source representing the core library | 9182 * @param coreLibrarySource the source representing the core library |
9076 * @throws AnalysisException always | 9183 * @throws AnalysisException always |
9077 */ | 9184 */ |
9078 static void missingCoreLibrary(AnalysisContext analysisContext, | 9185 static void missingCoreLibrary(AnalysisContext analysisContext, |
9079 Source coreLibrarySource) { | 9186 Source coreLibrarySource) { |
9080 throw new AnalysisException("Could not resolve dart:core"); | 9187 throw new AnalysisException("Could not resolve dart:core"); |
(...skipping 4212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13293 DartType get dynamicType; | 13400 DartType get dynamicType; |
13294 | 13401 |
13295 /** | 13402 /** |
13296 * Return the type representing the built-in type 'Function'. | 13403 * Return the type representing the built-in type 'Function'. |
13297 * | 13404 * |
13298 * @return the type representing the built-in type 'Function' | 13405 * @return the type representing the built-in type 'Function' |
13299 */ | 13406 */ |
13300 InterfaceType get functionType; | 13407 InterfaceType get functionType; |
13301 | 13408 |
13302 /** | 13409 /** |
13410 * Return the type representing the built-in type 'Future'. | |
13411 */ | |
13412 InterfaceType get futureType; | |
13413 | |
13414 /** | |
13303 * Return the type representing the built-in type 'int'. | 13415 * Return the type representing the built-in type 'int'. |
13304 * | 13416 * |
13305 * @return the type representing the built-in type 'int' | 13417 * @return the type representing the built-in type 'int' |
13306 */ | 13418 */ |
13307 InterfaceType get intType; | 13419 InterfaceType get intType; |
13308 | 13420 |
13309 /** | 13421 /** |
13310 * Return the type representing the built-in type 'List'. | 13422 * Return the type representing the built-in type 'List'. |
13311 * | 13423 * |
13312 * @return the type representing the built-in type 'List' | 13424 * @return the type representing the built-in type 'List' |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13404 * The type representing the built-in type 'dynamic'. | 13516 * The type representing the built-in type 'dynamic'. |
13405 */ | 13517 */ |
13406 DartType _dynamicType; | 13518 DartType _dynamicType; |
13407 | 13519 |
13408 /** | 13520 /** |
13409 * The type representing the built-in type 'Function'. | 13521 * The type representing the built-in type 'Function'. |
13410 */ | 13522 */ |
13411 InterfaceType _functionType; | 13523 InterfaceType _functionType; |
13412 | 13524 |
13413 /** | 13525 /** |
13526 * The type representing the built-in type 'Future'. | |
13527 */ | |
13528 InterfaceType _futureType; | |
13529 | |
13530 /** | |
13414 * The type representing the built-in type 'int'. | 13531 * The type representing the built-in type 'int'. |
13415 */ | 13532 */ |
13416 InterfaceType _intType; | 13533 InterfaceType _intType; |
13417 | 13534 |
13418 /** | 13535 /** |
13419 * The type representing the built-in type 'List'. | 13536 * The type representing the built-in type 'List'. |
13420 */ | 13537 */ |
13421 InterfaceType _listType; | 13538 InterfaceType _listType; |
13422 | 13539 |
13423 /** | 13540 /** |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13463 /** | 13580 /** |
13464 * The type representing typenames that can't be resolved. | 13581 * The type representing typenames that can't be resolved. |
13465 */ | 13582 */ |
13466 DartType _undefinedType; | 13583 DartType _undefinedType; |
13467 | 13584 |
13468 /** | 13585 /** |
13469 * Initialize a newly created type provider to provide the types defined in th e given library. | 13586 * Initialize a newly created type provider to provide the types defined in th e given library. |
13470 * | 13587 * |
13471 * @param coreLibrary the element representing the core library (dart:core). | 13588 * @param coreLibrary the element representing the core library (dart:core). |
13472 */ | 13589 */ |
13473 TypeProviderImpl(LibraryElement coreLibrary) { | 13590 TypeProviderImpl(LibraryElement coreLibrary, LibraryElement asyncLibrary) { |
13474 _initializeFrom(coreLibrary); | 13591 _initializeFrom(coreLibrary, asyncLibrary); |
13475 } | 13592 } |
13476 | 13593 |
13477 @override | 13594 @override |
13478 InterfaceType get boolType => _boolType; | 13595 InterfaceType get boolType => _boolType; |
13479 | 13596 |
13480 @override | 13597 @override |
13481 DartType get bottomType => _bottomType; | 13598 DartType get bottomType => _bottomType; |
13482 | 13599 |
13483 @override | 13600 @override |
13484 InterfaceType get deprecatedType => _deprecatedType; | 13601 InterfaceType get deprecatedType => _deprecatedType; |
13485 | 13602 |
13486 @override | 13603 @override |
13487 InterfaceType get doubleType => _doubleType; | 13604 InterfaceType get doubleType => _doubleType; |
13488 | 13605 |
13489 @override | 13606 @override |
13490 DartType get dynamicType => _dynamicType; | 13607 DartType get dynamicType => _dynamicType; |
13491 | 13608 |
13492 @override | 13609 @override |
13493 InterfaceType get functionType => _functionType; | 13610 InterfaceType get functionType => _functionType; |
13494 | 13611 |
13495 @override | 13612 @override |
13613 InterfaceType get futureType => _futureType; | |
13614 | |
13615 @override | |
13496 InterfaceType get intType => _intType; | 13616 InterfaceType get intType => _intType; |
13497 | 13617 |
13498 @override | 13618 @override |
13499 InterfaceType get listType => _listType; | 13619 InterfaceType get listType => _listType; |
13500 | 13620 |
13501 @override | 13621 @override |
13502 InterfaceType get mapType => _mapType; | 13622 InterfaceType get mapType => _mapType; |
13503 | 13623 |
13504 @override | 13624 @override |
13505 InterfaceType get nullType => _nullType; | 13625 InterfaceType get nullType => _nullType; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13541 return null; | 13661 return null; |
13542 } | 13662 } |
13543 return (element as ClassElement).type; | 13663 return (element as ClassElement).type; |
13544 } | 13664 } |
13545 | 13665 |
13546 /** | 13666 /** |
13547 * Initialize the types provided by this type provider from the given library. | 13667 * Initialize the types provided by this type provider from the given library. |
13548 * | 13668 * |
13549 * @param library the library containing the definitions of the core types | 13669 * @param library the library containing the definitions of the core types |
13550 */ | 13670 */ |
13551 void _initializeFrom(LibraryElement library) { | 13671 void _initializeFrom(LibraryElement coreLibrary, |
13552 Namespace namespace = | 13672 LibraryElement asyncLibrary) { |
13553 new NamespaceBuilder().createPublicNamespaceForLibrary(library); | 13673 Namespace coreNamespace = |
13554 _boolType = _getType(namespace, "bool"); | 13674 new NamespaceBuilder().createPublicNamespaceForLibrary(coreLibrary); |
13675 Namespace asyncNamespace = | |
13676 new NamespaceBuilder().createPublicNamespaceForLibrary(asyncLibrary); | |
13677 _boolType = _getType(coreNamespace, "bool"); | |
13555 _bottomType = BottomTypeImpl.instance; | 13678 _bottomType = BottomTypeImpl.instance; |
13556 _deprecatedType = _getType(namespace, "Deprecated"); | 13679 _deprecatedType = _getType(coreNamespace, "Deprecated"); |
13557 _doubleType = _getType(namespace, "double"); | 13680 _doubleType = _getType(coreNamespace, "double"); |
13558 _dynamicType = DynamicTypeImpl.instance; | 13681 _dynamicType = DynamicTypeImpl.instance; |
13559 _functionType = _getType(namespace, "Function"); | 13682 _functionType = _getType(coreNamespace, "Function"); |
13560 _intType = _getType(namespace, "int"); | 13683 _futureType = _getType(asyncNamespace, "Future"); |
13561 _listType = _getType(namespace, "List"); | 13684 _intType = _getType(coreNamespace, "int"); |
13562 _mapType = _getType(namespace, "Map"); | 13685 _listType = _getType(coreNamespace, "List"); |
13563 _nullType = _getType(namespace, "Null"); | 13686 _mapType = _getType(coreNamespace, "Map"); |
13564 _numType = _getType(namespace, "num"); | 13687 _nullType = _getType(coreNamespace, "Null"); |
13565 _objectType = _getType(namespace, "Object"); | 13688 _numType = _getType(coreNamespace, "num"); |
13566 _stackTraceType = _getType(namespace, "StackTrace"); | 13689 _objectType = _getType(coreNamespace, "Object"); |
13567 _stringType = _getType(namespace, "String"); | 13690 _stackTraceType = _getType(coreNamespace, "StackTrace"); |
13568 _symbolType = _getType(namespace, "Symbol"); | 13691 _stringType = _getType(coreNamespace, "String"); |
13569 _typeType = _getType(namespace, "Type"); | 13692 _symbolType = _getType(coreNamespace, "Symbol"); |
13693 _typeType = _getType(coreNamespace, "Type"); | |
13570 _undefinedType = UndefinedTypeImpl.instance; | 13694 _undefinedType = UndefinedTypeImpl.instance; |
13571 } | 13695 } |
13572 } | 13696 } |
13573 | 13697 |
13574 /** | 13698 /** |
13575 * Instances of the class `TypeResolverVisitor` are used to resolve the types as sociated with | 13699 * Instances of the class `TypeResolverVisitor` are used to resolve the types as sociated with |
13576 * the elements in the element model. This includes the types of superclasses, m ixins, interfaces, | 13700 * the elements in the element model. This includes the types of superclasses, m ixins, interfaces, |
13577 * fields, methods, parameters, and local variables. As a side-effect, this also finishes building | 13701 * fields, methods, parameters, and local variables. As a side-effect, this also finishes building |
13578 * the type hierarchy. | 13702 * the type hierarchy. |
13579 */ | 13703 */ |
(...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15460 * library. | 15584 * library. |
15461 */ | 15585 */ |
15462 final HashSet<String> members = new HashSet<String>(); | 15586 final HashSet<String> members = new HashSet<String>(); |
15463 | 15587 |
15464 /** | 15588 /** |
15465 * Names of resolved or unresolved class members that are read in the | 15589 * Names of resolved or unresolved class members that are read in the |
15466 * library. | 15590 * library. |
15467 */ | 15591 */ |
15468 final HashSet<String> readMembers = new HashSet<String>(); | 15592 final HashSet<String> readMembers = new HashSet<String>(); |
15469 } | 15593 } |
OLD | NEW |