| 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:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'ast.dart'; | 9 import 'ast.dart'; |
| 10 import 'constant.dart'; | 10 import 'constant.dart'; |
| (...skipping 6586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6597 final InternalAnalysisContext _analysisContext; | 6597 final InternalAnalysisContext _analysisContext; |
| 6598 | 6598 |
| 6599 /** | 6599 /** |
| 6600 * The inheritance manager which is used for this member lookups in this libra
ry. | 6600 * The inheritance manager which is used for this member lookups in this libra
ry. |
| 6601 */ | 6601 */ |
| 6602 InheritanceManager _inheritanceManager; | 6602 InheritanceManager _inheritanceManager; |
| 6603 | 6603 |
| 6604 /** | 6604 /** |
| 6605 * The listener to which analysis errors will be reported. | 6605 * The listener to which analysis errors will be reported. |
| 6606 */ | 6606 */ |
| 6607 final AnalysisErrorListener _errorListener; | 6607 final AnalysisErrorListener errorListener; |
| 6608 | 6608 |
| 6609 /** | 6609 /** |
| 6610 * The source specifying the defining compilation unit of this library. | 6610 * The source specifying the defining compilation unit of this library. |
| 6611 */ | 6611 */ |
| 6612 final Source librarySource; | 6612 final Source librarySource; |
| 6613 | 6613 |
| 6614 /** | 6614 /** |
| 6615 * The library element representing this library. | 6615 * The library element representing this library. |
| 6616 */ | 6616 */ |
| 6617 LibraryElementImpl _libraryElement; | 6617 LibraryElementImpl _libraryElement; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6649 */ | 6649 */ |
| 6650 LibraryScope _libraryScope; | 6650 LibraryScope _libraryScope; |
| 6651 | 6651 |
| 6652 /** | 6652 /** |
| 6653 * Initialize a newly created data holder that can maintain the data associate
d with a library. | 6653 * Initialize a newly created data holder that can maintain the data associate
d with a library. |
| 6654 * | 6654 * |
| 6655 * @param analysisContext the analysis context in which this library is being
analyzed | 6655 * @param analysisContext the analysis context in which this library is being
analyzed |
| 6656 * @param errorListener the listener to which analysis errors will be reported | 6656 * @param errorListener the listener to which analysis errors will be reported |
| 6657 * @param librarySource the source specifying the defining compilation unit of
this library | 6657 * @param librarySource the source specifying the defining compilation unit of
this library |
| 6658 */ | 6658 */ |
| 6659 Library(this._analysisContext, this._errorListener, this.librarySource) { | 6659 Library(this._analysisContext, this.errorListener, this.librarySource) { |
| 6660 this._libraryElement = | 6660 this._libraryElement = |
| 6661 _analysisContext.getLibraryElement(librarySource) as LibraryElementImpl; | 6661 _analysisContext.getLibraryElement(librarySource) as LibraryElementImpl; |
| 6662 } | 6662 } |
| 6663 | 6663 |
| 6664 /** | 6664 /** |
| 6665 * Return an array of the [CompilationUnit]s that make up the library. The fir
st unit is | 6665 * Return an array of the [CompilationUnit]s that make up the library. The fir
st unit is |
| 6666 * always the defining unit. | 6666 * always the defining unit. |
| 6667 * | 6667 * |
| 6668 * @return an array of the [CompilationUnit]s that make up the library. The fi
rst unit is | 6668 * @return an array of the [CompilationUnit]s that make up the library. The fi
rst unit is |
| 6669 * always the defining unit | 6669 * always the defining unit |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6788 } | 6788 } |
| 6789 } | 6789 } |
| 6790 | 6790 |
| 6791 /** | 6791 /** |
| 6792 * Return the library scope used when resolving elements within this library's
compilation units. | 6792 * Return the library scope used when resolving elements within this library's
compilation units. |
| 6793 * | 6793 * |
| 6794 * @return the library scope used when resolving elements within this library'
s compilation units | 6794 * @return the library scope used when resolving elements within this library'
s compilation units |
| 6795 */ | 6795 */ |
| 6796 LibraryScope get libraryScope { | 6796 LibraryScope get libraryScope { |
| 6797 if (_libraryScope == null) { | 6797 if (_libraryScope == null) { |
| 6798 _libraryScope = new LibraryScope(_libraryElement, _errorListener); | 6798 _libraryScope = new LibraryScope(_libraryElement, errorListener); |
| 6799 } | 6799 } |
| 6800 return _libraryScope; | 6800 return _libraryScope; |
| 6801 } | 6801 } |
| 6802 | 6802 |
| 6803 /** | 6803 /** |
| 6804 * Return the AST structure associated with the given source. | 6804 * Return the AST structure associated with the given source. |
| 6805 * | 6805 * |
| 6806 * @param source the source representing the compilation unit whose AST is to
be returned | 6806 * @param source the source representing the compilation unit whose AST is to
be returned |
| 6807 * @return the AST structure associated with the given source | 6807 * @return the AST structure associated with the given source |
| 6808 * @throws AnalysisException if an AST structure could not be created for the
compilation unit | 6808 * @throws AnalysisException if an AST structure could not be created for the
compilation unit |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6819 /** | 6819 /** |
| 6820 * Return the result of resolving the URI of the given URI-based directive aga
inst the URI of the | 6820 * Return the result of resolving the URI of the given URI-based directive aga
inst the URI of the |
| 6821 * library, or `null` if the URI is not valid. If the URI is not valid, report
the error. | 6821 * library, or `null` if the URI is not valid. If the URI is not valid, report
the error. |
| 6822 * | 6822 * |
| 6823 * @param directive the directive which URI should be resolved | 6823 * @param directive the directive which URI should be resolved |
| 6824 * @return the result of resolving the URI against the URI of the library | 6824 * @return the result of resolving the URI against the URI of the library |
| 6825 */ | 6825 */ |
| 6826 Source getSource(UriBasedDirective directive) { | 6826 Source getSource(UriBasedDirective directive) { |
| 6827 StringLiteral uriLiteral = directive.uri; | 6827 StringLiteral uriLiteral = directive.uri; |
| 6828 if (uriLiteral is StringInterpolation) { | 6828 if (uriLiteral is StringInterpolation) { |
| 6829 _errorListener.onError(new AnalysisError(librarySource, uriLiteral.offset, | 6829 errorListener.onError(new AnalysisError(librarySource, uriLiteral.offset, |
| 6830 uriLiteral.length, CompileTimeErrorCode.URI_WITH_INTERPOLATION)); | 6830 uriLiteral.length, CompileTimeErrorCode.URI_WITH_INTERPOLATION)); |
| 6831 return null; | 6831 return null; |
| 6832 } | 6832 } |
| 6833 String uriContent = uriLiteral.stringValue.trim(); | 6833 String uriContent = uriLiteral.stringValue.trim(); |
| 6834 _directiveUris[directive] = uriContent; | 6834 _directiveUris[directive] = uriContent; |
| 6835 uriContent = Uri.encodeFull(uriContent); | 6835 uriContent = Uri.encodeFull(uriContent); |
| 6836 if (directive is ImportDirective && | 6836 if (directive is ImportDirective && |
| 6837 uriContent.startsWith(_DART_EXT_SCHEME)) { | 6837 uriContent.startsWith(_DART_EXT_SCHEME)) { |
| 6838 _libraryElement.hasExtUri = true; | 6838 _libraryElement.hasExtUri = true; |
| 6839 return null; | 6839 return null; |
| 6840 } | 6840 } |
| 6841 try { | 6841 try { |
| 6842 parseUriWithException(uriContent); | 6842 parseUriWithException(uriContent); |
| 6843 Source source = | 6843 Source source = |
| 6844 _analysisContext.sourceFactory.resolveUri(librarySource, uriContent); | 6844 _analysisContext.sourceFactory.resolveUri(librarySource, uriContent); |
| 6845 if (!_analysisContext.exists(source)) { | 6845 if (!_analysisContext.exists(source)) { |
| 6846 _errorListener.onError(new AnalysisError(librarySource, | 6846 errorListener.onError(new AnalysisError(librarySource, |
| 6847 uriLiteral.offset, uriLiteral.length, | 6847 uriLiteral.offset, uriLiteral.length, |
| 6848 CompileTimeErrorCode.URI_DOES_NOT_EXIST, [uriContent])); | 6848 CompileTimeErrorCode.URI_DOES_NOT_EXIST, [uriContent])); |
| 6849 } | 6849 } |
| 6850 return source; | 6850 return source; |
| 6851 } on URISyntaxException { | 6851 } on URISyntaxException { |
| 6852 _errorListener.onError(new AnalysisError(librarySource, uriLiteral.offset, | 6852 errorListener.onError(new AnalysisError(librarySource, uriLiteral.offset, |
| 6853 uriLiteral.length, CompileTimeErrorCode.INVALID_URI, [uriContent])); | 6853 uriLiteral.length, CompileTimeErrorCode.INVALID_URI, [uriContent])); |
| 6854 } | 6854 } |
| 6855 return null; | 6855 return null; |
| 6856 } | 6856 } |
| 6857 | 6857 |
| 6858 /** | 6858 /** |
| 6859 * Returns the URI value of the given directive. | 6859 * Returns the URI value of the given directive. |
| 6860 */ | 6860 */ |
| 6861 String getUri(UriBasedDirective directive) => _directiveUris[directive]; | 6861 String getUri(UriBasedDirective directive) => _directiveUris[directive]; |
| 6862 | 6862 |
| (...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7934 * | 7934 * |
| 7935 * @throws AnalysisException if any of the type hierarchies could not be resol
ved | 7935 * @throws AnalysisException if any of the type hierarchies could not be resol
ved |
| 7936 */ | 7936 */ |
| 7937 void _buildTypeHierarchies() { | 7937 void _buildTypeHierarchies() { |
| 7938 PerformanceStatistics.resolve.makeCurrentWhile(() { | 7938 PerformanceStatistics.resolve.makeCurrentWhile(() { |
| 7939 for (Library library in _librariesInCycles) { | 7939 for (Library library in _librariesInCycles) { |
| 7940 for (Source source in library.compilationUnitSources) { | 7940 for (Source source in library.compilationUnitSources) { |
| 7941 TypeResolverVisitorFactory typeResolverVisitorFactory = | 7941 TypeResolverVisitorFactory typeResolverVisitorFactory = |
| 7942 analysisContext.typeResolverVisitorFactory; | 7942 analysisContext.typeResolverVisitorFactory; |
| 7943 TypeResolverVisitor visitor = (typeResolverVisitorFactory == null) | 7943 TypeResolverVisitor visitor = (typeResolverVisitorFactory == null) |
| 7944 ? new TypeResolverVisitor.con1(library, source, _typeProvider) | 7944 ? new TypeResolverVisitor(library.libraryElement, source, |
| 7945 _typeProvider, library.errorListener, |
| 7946 nameScope: library.libraryScope) |
| 7945 : typeResolverVisitorFactory(library, source, _typeProvider); | 7947 : typeResolverVisitorFactory(library, source, _typeProvider); |
| 7946 library.getAST(source).accept(visitor); | 7948 library.getAST(source).accept(visitor); |
| 7947 } | 7949 } |
| 7948 } | 7950 } |
| 7949 }); | 7951 }); |
| 7950 } | 7952 } |
| 7951 | 7953 |
| 7952 /** | 7954 /** |
| 7953 * Compute a dependency map of libraries reachable from the given library. A d
ependency map is a | 7955 * Compute a dependency map of libraries reachable from the given library. A d
ependency map is a |
| 7954 * table that maps individual libraries to a list of the libraries that either
import or export | 7956 * table that maps individual libraries to a list of the libraries that either
import or export |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8193 * Resolve the identifiers and perform type analysis in the given library. | 8195 * Resolve the identifiers and perform type analysis in the given library. |
| 8194 * | 8196 * |
| 8195 * @param library the library to be resolved | 8197 * @param library the library to be resolved |
| 8196 * @throws AnalysisException if any of the identifiers could not be resolved o
r if the types in | 8198 * @throws AnalysisException if any of the identifiers could not be resolved o
r if the types in |
| 8197 * the library cannot be analyzed | 8199 * the library cannot be analyzed |
| 8198 */ | 8200 */ |
| 8199 void _resolveReferencesAndTypesInLibrary(Library library) { | 8201 void _resolveReferencesAndTypesInLibrary(Library library) { |
| 8200 PerformanceStatistics.resolve.makeCurrentWhile(() { | 8202 PerformanceStatistics.resolve.makeCurrentWhile(() { |
| 8201 for (Source source in library.compilationUnitSources) { | 8203 for (Source source in library.compilationUnitSources) { |
| 8202 CompilationUnit ast = library.getAST(source); | 8204 CompilationUnit ast = library.getAST(source); |
| 8203 ast.accept( | 8205 ast.accept(new VariableResolverVisitor(library.libraryElement, source, |
| 8204 new VariableResolverVisitor.con1(library, source, _typeProvider)); | 8206 _typeProvider, library.errorListener, |
| 8207 nameScope: library.libraryScope)); |
| 8205 ResolverVisitorFactory visitorFactory = | 8208 ResolverVisitorFactory visitorFactory = |
| 8206 analysisContext.resolverVisitorFactory; | 8209 analysisContext.resolverVisitorFactory; |
| 8207 ResolverVisitor visitor = visitorFactory != null | 8210 ResolverVisitor visitor = visitorFactory != null |
| 8208 ? visitorFactory(library, source, _typeProvider) | 8211 ? visitorFactory(library, source, _typeProvider) |
| 8209 : new ResolverVisitor.con1(library, source, _typeProvider); | 8212 : new ResolverVisitor(library.libraryElement, source, _typeProvider, |
| 8213 library.errorListener, |
| 8214 nameScope: library.libraryScope, |
| 8215 inheritanceManager: library.inheritanceManager); |
| 8210 ast.accept(visitor); | 8216 ast.accept(visitor); |
| 8211 } | 8217 } |
| 8212 }); | 8218 }); |
| 8213 } | 8219 } |
| 8214 | 8220 |
| 8215 /** | 8221 /** |
| 8216 * Return the result of resolving the URI of the given URI-based directive aga
inst the URI of the | 8222 * Return the result of resolving the URI of the given URI-based directive aga
inst the URI of the |
| 8217 * given library, or `null` if the URI is not valid. | 8223 * given library, or `null` if the URI is not valid. |
| 8218 * | 8224 * |
| 8219 * @param librarySource the source representing the library containing the dir
ective | 8225 * @param librarySource the source representing the library containing the dir
ective |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8594 * | 8600 * |
| 8595 * @throws AnalysisException if any of the type hierarchies could not be resol
ved | 8601 * @throws AnalysisException if any of the type hierarchies could not be resol
ved |
| 8596 */ | 8602 */ |
| 8597 void _buildTypeHierarchies() { | 8603 void _buildTypeHierarchies() { |
| 8598 PerformanceStatistics.resolve.makeCurrentWhile(() { | 8604 PerformanceStatistics.resolve.makeCurrentWhile(() { |
| 8599 for (ResolvableLibrary library in _librariesInCycle) { | 8605 for (ResolvableLibrary library in _librariesInCycle) { |
| 8600 for (ResolvableCompilationUnit unit | 8606 for (ResolvableCompilationUnit unit |
| 8601 in library.resolvableCompilationUnits) { | 8607 in library.resolvableCompilationUnits) { |
| 8602 Source source = unit.source; | 8608 Source source = unit.source; |
| 8603 CompilationUnit ast = unit.compilationUnit; | 8609 CompilationUnit ast = unit.compilationUnit; |
| 8604 TypeResolverVisitor visitor = | 8610 TypeResolverVisitor visitor = new TypeResolverVisitor( |
| 8605 new TypeResolverVisitor.con4(library, source, _typeProvider); | 8611 library.libraryElement, source, _typeProvider, |
| 8612 library.libraryScope.errorListener, |
| 8613 nameScope: library.libraryScope); |
| 8606 ast.accept(visitor); | 8614 ast.accept(visitor); |
| 8607 } | 8615 } |
| 8608 } | 8616 } |
| 8609 }); | 8617 }); |
| 8610 } | 8618 } |
| 8611 | 8619 |
| 8612 /** | 8620 /** |
| 8613 * Return an array containing the lexical identifiers associated with the node
s in the given list. | 8621 * Return an array containing the lexical identifiers associated with the node
s in the given list. |
| 8614 * | 8622 * |
| 8615 * @param names the AST nodes representing the identifiers | 8623 * @param names the AST nodes representing the identifiers |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8676 * @param library the library to be resolved | 8684 * @param library the library to be resolved |
| 8677 * @throws AnalysisException if any of the identifiers could not be resolved o
r if the types in | 8685 * @throws AnalysisException if any of the identifiers could not be resolved o
r if the types in |
| 8678 * the library cannot be analyzed | 8686 * the library cannot be analyzed |
| 8679 */ | 8687 */ |
| 8680 void _resolveReferencesAndTypesInLibrary(ResolvableLibrary library) { | 8688 void _resolveReferencesAndTypesInLibrary(ResolvableLibrary library) { |
| 8681 PerformanceStatistics.resolve.makeCurrentWhile(() { | 8689 PerformanceStatistics.resolve.makeCurrentWhile(() { |
| 8682 for (ResolvableCompilationUnit unit | 8690 for (ResolvableCompilationUnit unit |
| 8683 in library.resolvableCompilationUnits) { | 8691 in library.resolvableCompilationUnits) { |
| 8684 Source source = unit.source; | 8692 Source source = unit.source; |
| 8685 CompilationUnit ast = unit.compilationUnit; | 8693 CompilationUnit ast = unit.compilationUnit; |
| 8686 ast.accept( | 8694 ast.accept(new VariableResolverVisitor(library.libraryElement, source, |
| 8687 new VariableResolverVisitor.con3(library, source, _typeProvider)); | 8695 _typeProvider, library.libraryScope.errorListener, |
| 8688 ResolverVisitor visitor = | 8696 nameScope: library.libraryScope)); |
| 8689 new ResolverVisitor.con4(library, source, _typeProvider); | 8697 ResolverVisitor visitor = new ResolverVisitor(library.libraryElement, |
| 8698 source, _typeProvider, library._libraryScope.errorListener, |
| 8699 nameScope: library._libraryScope, |
| 8700 inheritanceManager: library.inheritanceManager); |
| 8690 ast.accept(visitor); | 8701 ast.accept(visitor); |
| 8691 } | 8702 } |
| 8692 }); | 8703 }); |
| 8693 } | 8704 } |
| 8694 | 8705 |
| 8695 /** | 8706 /** |
| 8696 * Report that the async library could not be resolved in the given | 8707 * Report that the async library could not be resolved in the given |
| 8697 * [analysisContext] and throw an exception. [asyncLibrarySource] is the sour
ce | 8708 * [analysisContext] and throw an exception. [asyncLibrarySource] is the sour
ce |
| 8698 * representing the async library. | 8709 * representing the async library. |
| 8699 */ | 8710 */ |
| (...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9964 * A comment before a function should be resolved in the context of the | 9975 * A comment before a function should be resolved in the context of the |
| 9965 * function. But when we incrementally resolve a comment, we don't want to | 9976 * function. But when we incrementally resolve a comment, we don't want to |
| 9966 * resolve the whole function. | 9977 * resolve the whole function. |
| 9967 * | 9978 * |
| 9968 * So, this flag is set to `true`, when just context of the function should | 9979 * So, this flag is set to `true`, when just context of the function should |
| 9969 * be built and the comment resolved. | 9980 * be built and the comment resolved. |
| 9970 */ | 9981 */ |
| 9971 bool resolveOnlyCommentInFunctionBody = false; | 9982 bool resolveOnlyCommentInFunctionBody = false; |
| 9972 | 9983 |
| 9973 /** | 9984 /** |
| 9974 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | |
| 9975 * | |
| 9976 * @param library the library containing the compilation unit being resolved | |
| 9977 * @param source the source representing the compilation unit being visited | |
| 9978 * @param typeProvider the object used to access the types from the core libra
ry | |
| 9979 */ | |
| 9980 ResolverVisitor.con1( | |
| 9981 Library library, Source source, TypeProvider typeProvider, | |
| 9982 {StaticTypeAnalyzer typeAnalyzer, | |
| 9983 StaticTypeAnalyzerFactory typeAnalyzerFactory}) | |
| 9984 : super.con1(library, source, typeProvider) { | |
| 9985 this._inheritanceManager = library.inheritanceManager; | |
| 9986 this.elementResolver = new ElementResolver(this); | |
| 9987 this.typeAnalyzer = typeAnalyzer != null | |
| 9988 ? typeAnalyzer | |
| 9989 : (typeAnalyzerFactory != null | |
| 9990 ? typeAnalyzerFactory(this) | |
| 9991 : new StaticTypeAnalyzer(this)); | |
| 9992 } | |
| 9993 | |
| 9994 /** | |
| 9995 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | |
| 9996 * | |
| 9997 * @param definingLibrary the element for the library containing the compilati
on unit being | |
| 9998 * visited | |
| 9999 * @param source the source representing the compilation unit being visited | |
| 10000 * @param typeProvider the object used to access the types from the core libra
ry | |
| 10001 * @param errorListener the error listener that will be informed of any errors
that are found | |
| 10002 * during resolution | |
| 10003 */ | |
| 10004 ResolverVisitor.con2(LibraryElement definingLibrary, Source source, | |
| 10005 TypeProvider typeProvider, InheritanceManager inheritanceManager, | |
| 10006 AnalysisErrorListener errorListener) | |
| 10007 : super.con2(definingLibrary, source, typeProvider, errorListener) { | |
| 10008 this._inheritanceManager = inheritanceManager; | |
| 10009 this.elementResolver = new ElementResolver(this); | |
| 10010 this.typeAnalyzer = new StaticTypeAnalyzer(this); | |
| 10011 } | |
| 10012 | |
| 10013 /** | |
| 10014 * Initialize a newly created visitor to resolve the nodes in an AST node. | 9985 * Initialize a newly created visitor to resolve the nodes in an AST node. |
| 10015 * | 9986 * |
| 10016 * @param definingLibrary the element for the library containing the node bein
g visited | 9987 * [definingLibrary] is the element for the library containing the node being |
| 10017 * @param source the source representing the compilation unit containing the n
ode being visited | 9988 * visited. |
| 10018 * @param typeProvider the object used to access the types from the core libra
ry | 9989 * [source] is the source representing the compilation unit containing the |
| 10019 * @param nameScope the scope used to resolve identifiers in the node that wil
l first be visited | 9990 * node being visited. |
| 10020 * @param errorListener the error listener that will be informed of any errors
that are found | 9991 * [typeProvider] the object used to access the types from the core library. |
| 10021 * during resolution | 9992 * [errorListener] the error listener that will be informed of any errors |
| 9993 * that are found during resolution. |
| 9994 * [nameScope] is the scope used to resolve identifiers in the node that will |
| 9995 * first be visited. If `null` or unspecified, a new [LibraryScope] will be |
| 9996 * created based on [definingLibrary] and [typeProvider]. |
| 9997 * [inheritanceManager] is used to perform inheritance lookups. If `null` or |
| 9998 * unspecified, a new [InheritanceManager] will be created based on |
| 9999 * [definingLibrary]. |
| 10000 * [typeAnalyzerFactory] is used to create the type analyzer. If `null` or |
| 10001 * unspecified, a type analyzer of type [StaticTypeAnalyzer] will be created. |
| 10022 */ | 10002 */ |
| 10023 ResolverVisitor.con3(LibraryElement definingLibrary, Source source, | 10003 ResolverVisitor(LibraryElement definingLibrary, Source source, |
| 10024 TypeProvider typeProvider, Scope nameScope, | 10004 TypeProvider typeProvider, AnalysisErrorListener errorListener, |
| 10025 AnalysisErrorListener errorListener) | 10005 {Scope nameScope, InheritanceManager inheritanceManager, |
| 10026 : super.con3( | 10006 StaticTypeAnalyzerFactory typeAnalyzerFactory}) |
| 10027 definingLibrary, source, typeProvider, nameScope, errorListener) { | 10007 : super(definingLibrary, source, typeProvider, errorListener, |
| 10028 this._inheritanceManager = new InheritanceManager(definingLibrary); | 10008 nameScope: nameScope) { |
| 10009 if (inheritanceManager == null) { |
| 10010 this._inheritanceManager = new InheritanceManager(definingLibrary); |
| 10011 } else { |
| 10012 this._inheritanceManager = inheritanceManager; |
| 10013 } |
| 10029 this.elementResolver = new ElementResolver(this); | 10014 this.elementResolver = new ElementResolver(this); |
| 10030 this.typeAnalyzer = new StaticTypeAnalyzer(this); | 10015 if (typeAnalyzerFactory == null) { |
| 10016 this.typeAnalyzer = new StaticTypeAnalyzer(this); |
| 10017 } else { |
| 10018 this.typeAnalyzer = typeAnalyzerFactory(this); |
| 10019 } |
| 10031 } | 10020 } |
| 10032 | 10021 |
| 10033 /** | 10022 /** |
| 10034 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | 10023 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. |
| 10035 * | 10024 * |
| 10036 * @param library the library containing the compilation unit being resolved | 10025 * @param library the library containing the compilation unit being resolved |
| 10037 * @param source the source representing the compilation unit being visited | 10026 * @param source the source representing the compilation unit being visited |
| 10038 * @param typeProvider the object used to access the types from the core libra
ry | 10027 * @param typeProvider the object used to access the types from the core libra
ry |
| 10028 * |
| 10029 * Deprecated. Please use unnamed constructor instead. |
| 10039 */ | 10030 */ |
| 10040 ResolverVisitor.con4( | 10031 @deprecated |
| 10041 ResolvableLibrary library, Source source, TypeProvider typeProvider) | 10032 ResolverVisitor.con1( |
| 10042 : super.con4(library, source, typeProvider) { | 10033 Library library, Source source, TypeProvider typeProvider, |
| 10043 this._inheritanceManager = library.inheritanceManager; | 10034 {StaticTypeAnalyzerFactory typeAnalyzerFactory}) |
| 10044 this.elementResolver = new ElementResolver(this); | 10035 : this( |
| 10045 this.typeAnalyzer = new StaticTypeAnalyzer(this); | 10036 library.libraryElement, source, typeProvider, library.errorListener, |
| 10046 } | 10037 nameScope: library.libraryScope, |
| 10038 inheritanceManager: library.inheritanceManager, |
| 10039 typeAnalyzerFactory: typeAnalyzerFactory); |
| 10047 | 10040 |
| 10048 /** | 10041 /** |
| 10049 * Return the element representing the function containing the current node, o
r `null` if | 10042 * Return the element representing the function containing the current node, o
r `null` if |
| 10050 * the current node is not contained in a function. | 10043 * the current node is not contained in a function. |
| 10051 * | 10044 * |
| 10052 * @return the element representing the function containing the current node | 10045 * @return the element representing the function containing the current node |
| 10053 */ | 10046 */ |
| 10054 ExecutableElement get enclosingFunction => _enclosingFunction; | 10047 ExecutableElement get enclosingFunction => _enclosingFunction; |
| 10055 | 10048 |
| 10056 /** | 10049 /** |
| (...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11657 */ | 11650 */ |
| 11658 LabelScope labelScope; | 11651 LabelScope labelScope; |
| 11659 | 11652 |
| 11660 /** | 11653 /** |
| 11661 * The class containing the AST nodes being visited, | 11654 * The class containing the AST nodes being visited, |
| 11662 * or `null` if we are not in the scope of a class. | 11655 * or `null` if we are not in the scope of a class. |
| 11663 */ | 11656 */ |
| 11664 ClassElement enclosingClass; | 11657 ClassElement enclosingClass; |
| 11665 | 11658 |
| 11666 /** | 11659 /** |
| 11667 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | 11660 * Initialize a newly created visitor to resolve the nodes in a compilation |
| 11661 * unit. |
| 11668 * | 11662 * |
| 11669 * @param library the library containing the compilation unit being resolved | 11663 * [definingLibrary] is the element for the library containing the |
| 11670 * @param source the source representing the compilation unit being visited | 11664 * compilation unit being visited. |
| 11671 * @param typeProvider the object used to access the types from the core libra
ry | 11665 * [source] is the source representing the compilation unit being visited. |
| 11666 * [typeProvider] is the object used to access the types from the core |
| 11667 * library. |
| 11668 * [errorListener] is the error listener that will be informed of any errors |
| 11669 * that are found during resolution. |
| 11670 * [nameScope] is the scope used to resolve identifiers in the node that will |
| 11671 * first be visited. If `null` or unspecified, a new [LibraryScope] will be |
| 11672 * created based on [definingLibrary] and [typeProvider]. |
| 11672 */ | 11673 */ |
| 11673 ScopedVisitor.con1(Library library, this.source, this.typeProvider) { | 11674 ScopedVisitor(LibraryElement definingLibrary, this.source, this.typeProvider, |
| 11674 this._definingLibrary = library.libraryElement; | 11675 AnalysisErrorListener errorListener, {Scope nameScope}) { |
| 11675 LibraryScope libraryScope = library.libraryScope; | 11676 this._definingLibrary = definingLibrary; |
| 11676 this._errorListener = libraryScope.errorListener; | 11677 this._errorListener = errorListener; |
| 11677 this.nameScope = libraryScope; | 11678 if (nameScope == null) { |
| 11679 this.nameScope = new LibraryScope(definingLibrary, errorListener); |
| 11680 } else { |
| 11681 this.nameScope = nameScope; |
| 11682 } |
| 11678 } | 11683 } |
| 11679 | 11684 |
| 11680 /** | 11685 /** |
| 11681 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | |
| 11682 * | |
| 11683 * @param definingLibrary the element for the library containing the compilati
on unit being | |
| 11684 * visited | |
| 11685 * @param source the source representing the compilation unit being visited | |
| 11686 * @param typeProvider the object used to access the types from the core libra
ry | |
| 11687 * @param errorListener the error listener that will be informed of any errors
that are found | |
| 11688 * during resolution | |
| 11689 */ | |
| 11690 ScopedVisitor.con2(LibraryElement definingLibrary, this.source, | |
| 11691 this.typeProvider, AnalysisErrorListener errorListener) { | |
| 11692 this._definingLibrary = definingLibrary; | |
| 11693 this._errorListener = errorListener; | |
| 11694 this.nameScope = new LibraryScope(definingLibrary, errorListener); | |
| 11695 } | |
| 11696 | |
| 11697 /** | |
| 11698 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | |
| 11699 * | |
| 11700 * @param definingLibrary the element for the library containing the compilati
on unit being | |
| 11701 * visited | |
| 11702 * @param source the source representing the compilation unit being visited | |
| 11703 * @param typeProvider the object used to access the types from the core libra
ry | |
| 11704 * @param nameScope the scope used to resolve identifiers in the node that wil
l first be visited | |
| 11705 * @param errorListener the error listener that will be informed of any errors
that are found | |
| 11706 * during resolution | |
| 11707 */ | |
| 11708 ScopedVisitor.con3(LibraryElement definingLibrary, this.source, | |
| 11709 this.typeProvider, Scope nameScope, AnalysisErrorListener errorListener) { | |
| 11710 this._definingLibrary = definingLibrary; | |
| 11711 this._errorListener = errorListener; | |
| 11712 this.nameScope = nameScope; | |
| 11713 } | |
| 11714 | |
| 11715 /** | |
| 11716 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | |
| 11717 * | |
| 11718 * @param library the library containing the compilation unit being resolved | |
| 11719 * @param source the source representing the compilation unit being visited | |
| 11720 * @param typeProvider the object used to access the types from the core libra
ry | |
| 11721 */ | |
| 11722 ScopedVisitor.con4( | |
| 11723 ResolvableLibrary library, this.source, this.typeProvider) { | |
| 11724 this._definingLibrary = library.libraryElement; | |
| 11725 LibraryScope libraryScope = library.libraryScope; | |
| 11726 this._errorListener = libraryScope.errorListener; | |
| 11727 this.nameScope = libraryScope; | |
| 11728 } | |
| 11729 | |
| 11730 /** | |
| 11731 * Return the library element for the library containing the compilation unit
being resolved. | 11686 * Return the library element for the library containing the compilation unit
being resolved. |
| 11732 * | 11687 * |
| 11733 * @return the library element for the library containing the compilation unit
being resolved | 11688 * @return the library element for the library containing the compilation unit
being resolved |
| 11734 */ | 11689 */ |
| 11735 LibraryElement get definingLibrary => _definingLibrary; | 11690 LibraryElement get definingLibrary => _definingLibrary; |
| 11736 | 11691 |
| 11737 /** | 11692 /** |
| 11738 * Return the implicit label scope in which the current node is being | 11693 * Return the implicit label scope in which the current node is being |
| 11739 * resolved. | 11694 * resolved. |
| 11740 */ | 11695 */ |
| (...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13354 * The type representing typenames that can't be resolved. | 13309 * The type representing typenames that can't be resolved. |
| 13355 */ | 13310 */ |
| 13356 DartType _undefinedType; | 13311 DartType _undefinedType; |
| 13357 | 13312 |
| 13358 /** | 13313 /** |
| 13359 * The flag specifying if currently visited class references 'super' expressio
n. | 13314 * The flag specifying if currently visited class references 'super' expressio
n. |
| 13360 */ | 13315 */ |
| 13361 bool _hasReferenceToSuper = false; | 13316 bool _hasReferenceToSuper = false; |
| 13362 | 13317 |
| 13363 /** | 13318 /** |
| 13364 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | |
| 13365 * | |
| 13366 * @param library the library containing the compilation unit being resolved | |
| 13367 * @param source the source representing the compilation unit being visited | |
| 13368 * @param typeProvider the object used to access the types from the core libra
ry | |
| 13369 */ | |
| 13370 TypeResolverVisitor.con1( | |
| 13371 Library library, Source source, TypeProvider typeProvider) | |
| 13372 : super.con1(library, source, typeProvider) { | |
| 13373 _dynamicType = typeProvider.dynamicType; | |
| 13374 _undefinedType = typeProvider.undefinedType; | |
| 13375 } | |
| 13376 | |
| 13377 /** | |
| 13378 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | |
| 13379 * | |
| 13380 * @param definingLibrary the element for the library containing the compilati
on unit being | |
| 13381 * visited | |
| 13382 * @param source the source representing the compilation unit being visited | |
| 13383 * @param typeProvider the object used to access the types from the core libra
ry | |
| 13384 * @param errorListener the error listener that will be informed of any errors
that are found | |
| 13385 * during resolution | |
| 13386 */ | |
| 13387 TypeResolverVisitor.con2(LibraryElement definingLibrary, Source source, | |
| 13388 TypeProvider typeProvider, AnalysisErrorListener errorListener) | |
| 13389 : super.con2(definingLibrary, source, typeProvider, errorListener) { | |
| 13390 _dynamicType = typeProvider.dynamicType; | |
| 13391 _undefinedType = typeProvider.undefinedType; | |
| 13392 } | |
| 13393 | |
| 13394 /** | |
| 13395 * Initialize a newly created visitor to resolve the nodes in an AST node. | 13319 * Initialize a newly created visitor to resolve the nodes in an AST node. |
| 13396 * | 13320 * |
| 13397 * @param definingLibrary the element for the library containing the node bein
g visited | 13321 * [definingLibrary] is the element for the library containing the node being |
| 13398 * @param source the source representing the compilation unit containing the n
ode being visited | 13322 * visited. |
| 13399 * @param typeProvider the object used to access the types from the core libra
ry | 13323 * [source] is the source representing the compilation unit containing the |
| 13400 * @param nameScope the scope used to resolve identifiers in the node that wil
l first be visited | 13324 * node being visited. |
| 13401 * @param errorListener the error listener that will be informed of any errors
that are found | 13325 * [typeProvider] is the object used to access the types from the core |
| 13402 * during resolution | 13326 * library. |
| 13327 * [errorListener] is the error listener that will be informed of any errors |
| 13328 * that are found during resolution. |
| 13329 * [nameScope] is the scope used to resolve identifiers in the node that will |
| 13330 * first be visited. If `null` or unspecified, a new [LibraryScope] will be |
| 13331 * created based on [definingLibrary] and [typeProvider]. |
| 13403 */ | 13332 */ |
| 13404 TypeResolverVisitor.con3(LibraryElement definingLibrary, Source source, | 13333 TypeResolverVisitor(LibraryElement definingLibrary, Source source, |
| 13405 TypeProvider typeProvider, Scope nameScope, | 13334 TypeProvider typeProvider, AnalysisErrorListener errorListener, |
| 13406 AnalysisErrorListener errorListener) | 13335 {Scope nameScope}) |
| 13407 : super.con3( | 13336 : super(definingLibrary, source, typeProvider, errorListener, |
| 13408 definingLibrary, source, typeProvider, nameScope, errorListener) { | 13337 nameScope: nameScope) { |
| 13409 _dynamicType = typeProvider.dynamicType; | 13338 _dynamicType = typeProvider.dynamicType; |
| 13410 _undefinedType = typeProvider.undefinedType; | 13339 _undefinedType = typeProvider.undefinedType; |
| 13411 } | 13340 } |
| 13412 | |
| 13413 /** | |
| 13414 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | |
| 13415 * | |
| 13416 * @param library the library containing the compilation unit being resolved | |
| 13417 * @param source the source representing the compilation unit being visited | |
| 13418 * @param typeProvider the object used to access the types from the core libra
ry | |
| 13419 */ | |
| 13420 TypeResolverVisitor.con4( | |
| 13421 ResolvableLibrary library, Source source, TypeProvider typeProvider) | |
| 13422 : super.con4(library, source, typeProvider) { | |
| 13423 _dynamicType = typeProvider.dynamicType; | |
| 13424 _undefinedType = typeProvider.undefinedType; | |
| 13425 } | |
| 13426 | 13341 |
| 13427 @override | 13342 @override |
| 13428 Object visitAnnotation(Annotation node) { | 13343 Object visitAnnotation(Annotation node) { |
| 13429 // | 13344 // |
| 13430 // Visit annotations, if the annotation is @proxy, on a class, and "proxy" | 13345 // Visit annotations, if the annotation is @proxy, on a class, and "proxy" |
| 13431 // resolves to the proxy annotation in dart.core, then create create the | 13346 // resolves to the proxy annotation in dart.core, then create create the |
| 13432 // ElementAnnotationImpl and set it as the metadata on the enclosing class. | 13347 // ElementAnnotationImpl and set it as the metadata on the enclosing class. |
| 13433 // | 13348 // |
| 13434 // Element resolution is done in the ElementResolver, and this work will be | 13349 // Element resolution is done in the ElementResolver, and this work will be |
| 13435 // done in the general case for all annotations in the ElementResolver. | 13350 // done in the general case for all annotations in the ElementResolver. |
| (...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14922 * [SimpleIdentifier]s to local variables and formal parameters. | 14837 * [SimpleIdentifier]s to local variables and formal parameters. |
| 14923 */ | 14838 */ |
| 14924 class VariableResolverVisitor extends ScopedVisitor { | 14839 class VariableResolverVisitor extends ScopedVisitor { |
| 14925 /** | 14840 /** |
| 14926 * The method or function that we are currently visiting, or `null` if we are
not inside a | 14841 * The method or function that we are currently visiting, or `null` if we are
not inside a |
| 14927 * method or function. | 14842 * method or function. |
| 14928 */ | 14843 */ |
| 14929 ExecutableElement _enclosingFunction; | 14844 ExecutableElement _enclosingFunction; |
| 14930 | 14845 |
| 14931 /** | 14846 /** |
| 14932 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | |
| 14933 * | |
| 14934 * @param library the library containing the compilation unit being resolved | |
| 14935 * @param source the source representing the compilation unit being visited | |
| 14936 * @param typeProvider the object used to access the types from the core libra
ry | |
| 14937 */ | |
| 14938 VariableResolverVisitor.con1( | |
| 14939 Library library, Source source, TypeProvider typeProvider) | |
| 14940 : super.con1(library, source, typeProvider); | |
| 14941 | |
| 14942 /** | |
| 14943 * Initialize a newly created visitor to resolve the nodes in an AST node. | 14847 * Initialize a newly created visitor to resolve the nodes in an AST node. |
| 14944 * | 14848 * |
| 14945 * @param definingLibrary the element for the library containing the node bein
g visited | 14849 * [definingLibrary] is the element for the library containing the node being |
| 14946 * @param source the source representing the compilation unit containing the n
ode being visited | 14850 * visited. |
| 14947 * @param typeProvider the object used to access the types from the core libra
ry | 14851 * [source] is the source representing the compilation unit containing the |
| 14948 * @param nameScope the scope used to resolve identifiers in the node that wil
l first be visited | 14852 * node being visited |
| 14949 * @param errorListener the error listener that will be informed of any errors
that are found | 14853 * [typeProvider] is the object used to access the types from the core |
| 14950 * during resolution | 14854 * library. |
| 14855 * [errorListener] is the error listener that will be informed of any errors |
| 14856 * that are found during resolution. |
| 14857 * [nameScope] is the scope used to resolve identifiers in the node that will |
| 14858 * first be visited. If `null` or unspecified, a new [LibraryScope] will be |
| 14859 * created based on [definingLibrary] and [typeProvider]. |
| 14951 */ | 14860 */ |
| 14952 VariableResolverVisitor.con2(LibraryElement definingLibrary, Source source, | 14861 VariableResolverVisitor(LibraryElement definingLibrary, Source source, |
| 14953 TypeProvider typeProvider, Scope nameScope, | 14862 TypeProvider typeProvider, AnalysisErrorListener errorListener, |
| 14954 AnalysisErrorListener errorListener) | 14863 {Scope nameScope}) |
| 14955 : super.con3( | 14864 : super(definingLibrary, source, typeProvider, errorListener, |
| 14956 definingLibrary, source, typeProvider, nameScope, errorListener); | 14865 nameScope: nameScope); |
| 14957 | 14866 |
| 14958 /** | 14867 /** |
| 14959 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. | 14868 * Initialize a newly created visitor to resolve the nodes in a compilation un
it. |
| 14960 * | 14869 * |
| 14961 * @param library the library containing the compilation unit being resolved | 14870 * @param library the library containing the compilation unit being resolved |
| 14962 * @param source the source representing the compilation unit being visited | 14871 * @param source the source representing the compilation unit being visited |
| 14963 * @param typeProvider the object used to access the types from the core libra
ry | 14872 * @param typeProvider the object used to access the types from the core libra
ry |
| 14873 * |
| 14874 * Deprecated. Please use unnamed constructor instead. |
| 14964 */ | 14875 */ |
| 14965 VariableResolverVisitor.con3( | 14876 @deprecated |
| 14966 ResolvableLibrary library, Source source, TypeProvider typeProvider) | 14877 VariableResolverVisitor.con1( |
| 14967 : super.con4(library, source, typeProvider); | 14878 Library library, Source source, TypeProvider typeProvider) |
| 14879 : this( |
| 14880 library.libraryElement, source, typeProvider, library.errorListener, |
| 14881 nameScope: library.libraryScope); |
| 14968 | 14882 |
| 14969 @override | 14883 @override |
| 14970 Object visitExportDirective(ExportDirective node) => null; | 14884 Object visitExportDirective(ExportDirective node) => null; |
| 14971 | 14885 |
| 14972 @override | 14886 @override |
| 14973 Object visitFunctionDeclaration(FunctionDeclaration node) { | 14887 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 14974 ExecutableElement outerFunction = _enclosingFunction; | 14888 ExecutableElement outerFunction = _enclosingFunction; |
| 14975 try { | 14889 try { |
| 14976 _enclosingFunction = node.element; | 14890 _enclosingFunction = node.element; |
| 14977 return super.visitFunctionDeclaration(node); | 14891 return super.visitFunctionDeclaration(node); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15227 nonFields.add(node); | 15141 nonFields.add(node); |
| 15228 return null; | 15142 return null; |
| 15229 } | 15143 } |
| 15230 | 15144 |
| 15231 @override | 15145 @override |
| 15232 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); | 15146 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); |
| 15233 | 15147 |
| 15234 @override | 15148 @override |
| 15235 Object visitWithClause(WithClause node) => null; | 15149 Object visitWithClause(WithClause node) => null; |
| 15236 } | 15150 } |
| OLD | NEW |