Chromium Code Reviews| Index: pkg/analyzer/lib/src/generated/resolver.dart |
| diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart |
| index 7a6952e790e3a761b1db1b16abd61aa0f19d5050..801ea47d51523cfe0b4a3370b1ee08ae55dd4378 100644 |
| --- a/pkg/analyzer/lib/src/generated/resolver.dart |
| +++ b/pkg/analyzer/lib/src/generated/resolver.dart |
| @@ -4888,7 +4888,7 @@ class ImplicitConstructorBuilder extends ScopedVisitor { |
| * computation needs to be performed, and its dependency order. |
| */ |
| ImplicitConstructorBuilder(Source source, LibraryElement libraryElement, |
| - LibraryScope libraryScope, TypeProvider typeProvider, this._callback) |
| + Scope libraryScope, TypeProvider typeProvider, this._callback) |
| : super.con3(libraryElement, source, typeProvider, libraryScope, |
| libraryScope.errorListener); |
| @@ -5125,7 +5125,7 @@ class ImplicitConstructorComputer { |
| * that source, and [libraryScope] is the scope for the library element. |
| */ |
| void add(CompilationUnit unit, Source source, LibraryElement libraryElement, |
| - LibraryScope libraryScope) { |
| + Scope libraryScope) { |
| unit.accept(new ImplicitConstructorBuilder( |
| source, libraryElement, libraryScope, typeProvider, _defer)); |
| } |
| @@ -6927,7 +6927,9 @@ class Library { |
| */ |
| LibraryScope get libraryScope { |
| if (_libraryScope == null) { |
| - _libraryScope = new LibraryScope(_libraryElement, _errorListener); |
| + _libraryScope = new LibraryScope(_libraryElement, |
| + new LibraryImportScope(_libraryElement, _errorListener), |
| + _errorListener); |
| } |
| return _libraryScope; |
| } |
| @@ -7333,7 +7335,7 @@ class LibraryImportScope extends Scope { |
| /** |
| * The element representing the library in which this scope is enclosed. |
| */ |
| - final LibraryElement _definingLibrary; |
| + final LibraryElement definingLibrary; |
| /** |
| * The listener that is to be informed when an error is encountered. |
| @@ -7344,7 +7346,7 @@ class LibraryImportScope extends Scope { |
| * A list of the namespaces representing the names that are available in this scope from imported |
| * libraries. |
| */ |
| - List<Namespace> _importedNamespaces; |
| + final List<Namespace> importedNamespaces = <Namespace>[]; |
| /** |
| * Initialize a newly created scope representing the names imported into the given library. |
| @@ -7353,8 +7355,23 @@ class LibraryImportScope extends Scope { |
| * this scope |
| * @param errorListener the listener that is to be informed when an error is encountered |
| */ |
| - LibraryImportScope(this._definingLibrary, this.errorListener) { |
| - _createImportedNamespaces(); |
| + LibraryImportScope(this.definingLibrary, this.errorListener) { |
| + createImportedNamespaces(); |
| + } |
| + |
| + /** |
| + * Create all of the namespaces associated with the libraries imported into this library. The |
| + * names are not added to this scope, but are stored for later reference. |
| + * |
| + * @param definingLibrary the element representing the library that imports the libraries for |
| + * which namespaces will be created |
| + */ |
| + void createImportedNamespaces() { |
| + NamespaceBuilder builder = new NamespaceBuilder(); |
| + for (ImportElement import in definingLibrary.imports) { |
| + Namespace namespace = builder.createImportNamespaceForDirective(import); |
| + importedNamespaces.add(namespace); |
| + } |
| } |
| @override |
| @@ -7368,7 +7385,7 @@ class LibraryImportScope extends Scope { |
| Source getSource(AstNode node) { |
| Source source = super.getSource(node); |
| if (source == null) { |
| - source = _definingLibrary.definingCompilationUnit.source; |
| + source = definingLibrary.definingCompilationUnit.source; |
| } |
| return source; |
| } |
| @@ -7380,15 +7397,15 @@ class LibraryImportScope extends Scope { |
| if (foundElement != null) { |
| return foundElement; |
| } |
| - for (int i = 0; i < _importedNamespaces.length; i++) { |
| - Namespace nameSpace = _importedNamespaces[i]; |
| + for (int i = 0; i < importedNamespaces.length; i++) { |
| + Namespace nameSpace = importedNamespaces[i]; |
| Element element = nameSpace.get(name); |
| if (element != null) { |
| if (foundElement == null) { |
| foundElement = element; |
| } else if (!identical(foundElement, element)) { |
| foundElement = MultiplyDefinedElementImpl.fromElements( |
| - _definingLibrary.context, foundElement, element); |
| + definingLibrary.context, foundElement, element); |
| } |
| } |
| } |
| @@ -7420,24 +7437,6 @@ class LibraryImportScope extends Scope { |
| } |
| /** |
| - * Create all of the namespaces associated with the libraries imported into this library. The |
| - * names are not added to this scope, but are stored for later reference. |
| - * |
| - * @param definingLibrary the element representing the library that imports the libraries for |
| - * which namespaces will be created |
| - */ |
| - void _createImportedNamespaces() { |
| - NamespaceBuilder builder = new NamespaceBuilder(); |
| - List<ImportElement> imports = _definingLibrary.imports; |
| - int count = imports.length; |
| - _importedNamespaces = new List<Namespace>(count); |
| - for (int i = 0; i < count; i++) { |
| - _importedNamespaces[i] = |
| - builder.createImportNamespaceForDirective(imports[i]); |
| - } |
| - } |
| - |
| - /** |
| * Returns the name of the library that defines given element. |
| * |
| * @param element the element to get library name |
| @@ -7451,7 +7450,7 @@ class LibraryImportScope extends Scope { |
| if (library == null) { |
| return StringUtilities.EMPTY; |
| } |
| - List<ImportElement> imports = _definingLibrary.imports; |
| + List<ImportElement> imports = definingLibrary.imports; |
| int count = imports.length; |
| for (int i = 0; i < count; i++) { |
| if (identical(imports[i].importedLibrary, library)) { |
| @@ -7528,7 +7527,7 @@ class LibraryImportScope extends Scope { |
| return foundElement; |
| } |
| return new MultiplyDefinedElementImpl( |
| - _definingLibrary.context, nonSdkElements); |
| + definingLibrary.context, nonSdkElements); |
| } |
| } |
| @@ -9003,9 +9002,9 @@ class LibraryScope extends EnclosedScope { |
| * @param definingLibrary the element representing the library represented by this scope |
| * @param errorListener the listener that is to be informed when an error is encountered |
| */ |
| - LibraryScope( |
| - LibraryElement definingLibrary, AnalysisErrorListener errorListener) |
| - : super(new LibraryImportScope(definingLibrary, errorListener)) { |
| + LibraryScope(LibraryElement definingLibrary, Scope importScope, |
|
Brian Wilkerson
2015/03/18 14:34:05
This is a breaking change for other clients and ma
|
| + AnalysisErrorListener errorListener) |
| + : super(importScope) { |
| _defineTopLevelNames(definingLibrary); |
| } |
| @@ -10022,7 +10021,9 @@ class ResolvableLibrary { |
| */ |
| LibraryScope get libraryScope { |
| if (_libraryScope == null) { |
| - _libraryScope = new LibraryScope(_libraryElement, _errorListener); |
| + _libraryScope = new LibraryScope(_libraryElement, |
| + new LibraryImportScope(_libraryElement, _errorListener), |
| + _errorListener); |
| } |
| return _libraryScope; |
| } |
| @@ -10211,10 +10212,12 @@ class ResolverVisitor extends ScopedVisitor { |
| * @param errorListener the error listener that will be informed of any errors that are found |
| * during resolution |
| */ |
| - ResolverVisitor.con2(LibraryElement definingLibrary, Source source, |
| - TypeProvider typeProvider, InheritanceManager inheritanceManager, |
| + ResolverVisitor.con2(LibraryElement definingLibrary, Scope libraryScope, |
|
Brian Wilkerson
2015/03/18 14:34:05
Should this be "LibraryScope libraryScope"? If not
|
| + Source source, TypeProvider typeProvider, |
| + InheritanceManager inheritanceManager, |
| AnalysisErrorListener errorListener) |
| - : super.con2(definingLibrary, source, typeProvider, errorListener) { |
| + : super.con2( |
| + definingLibrary, libraryScope, source, typeProvider, errorListener) { |
| this._inheritanceManager = inheritanceManager; |
| this._elementResolver = new ElementResolver(this); |
| this._typeAnalyzer = new StaticTypeAnalyzer(this); |
| @@ -11832,11 +11835,11 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<Object> { |
| * @param errorListener the error listener that will be informed of any errors that are found |
| * during resolution |
| */ |
| - ScopedVisitor.con2(LibraryElement definingLibrary, this.source, |
| - this.typeProvider, AnalysisErrorListener errorListener) { |
| + ScopedVisitor.con2(LibraryElement definingLibrary, Scope libraryScope, |
| + this.source, this.typeProvider, AnalysisErrorListener errorListener) { |
| this._definingLibrary = definingLibrary; |
| this._errorListener = errorListener; |
| - this._nameScope = new LibraryScope(definingLibrary, errorListener); |
| + this._nameScope = libraryScope; |
| } |
| /** |
| @@ -13586,9 +13589,11 @@ class TypeResolverVisitor extends ScopedVisitor { |
| * @param errorListener the error listener that will be informed of any errors that are found |
| * during resolution |
| */ |
| - TypeResolverVisitor.con2(LibraryElement definingLibrary, Source source, |
| - TypeProvider typeProvider, AnalysisErrorListener errorListener) |
| - : super.con2(definingLibrary, source, typeProvider, errorListener) { |
| + TypeResolverVisitor.con2(LibraryElement definingLibrary, Scope libraryScope, |
| + Source source, TypeProvider typeProvider, |
| + AnalysisErrorListener errorListener) |
| + : super.con2( |
| + definingLibrary, libraryScope, source, typeProvider, errorListener) { |
| _dynamicType = typeProvider.dynamicType; |
| _undefinedType = typeProvider.undefinedType; |
| } |
| @@ -14816,17 +14821,6 @@ class VariableResolverVisitor extends ScopedVisitor { |
| } |
| @override |
| - Object visitMethodDeclaration(MethodDeclaration node) { |
| - ExecutableElement outerFunction = _enclosingFunction; |
| - try { |
| - _enclosingFunction = node.element; |
| - return super.visitMethodDeclaration(node); |
| - } finally { |
| - _enclosingFunction = outerFunction; |
| - } |
| - } |
| - |
| - @override |
| Object visitFunctionExpression(FunctionExpression node) { |
| if (node.parent is! FunctionDeclaration) { |
| ExecutableElement outerFunction = _enclosingFunction; |
| @@ -14845,6 +14839,17 @@ class VariableResolverVisitor extends ScopedVisitor { |
| Object visitImportDirective(ImportDirective node) => null; |
| @override |
| + Object visitMethodDeclaration(MethodDeclaration node) { |
| + ExecutableElement outerFunction = _enclosingFunction; |
| + try { |
| + _enclosingFunction = node.element; |
| + return super.visitMethodDeclaration(node); |
| + } finally { |
| + _enclosingFunction = outerFunction; |
| + } |
| + } |
| + |
| + @override |
| Object visitSimpleIdentifier(SimpleIdentifier node) { |
| // Ignore if already resolved - declaration or type. |
| if (node.staticElement != null) { |