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

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

Issue 1012403002: Task: Build Type Aliases. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library engine.resolver; 5 library engine.resolver;
6 6
7 import "dart:math" as math; 7 import "dart:math" as math;
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/src/generated/utilities_collection.dart'; 10 import 'package:analyzer/src/generated/utilities_collection.dart';
(...skipping 4870 matching lines...) Expand 10 before | Expand all | Expand 10 after
4881 4881
4882 /** 4882 /**
4883 * Initialize a newly created visitor to build implicit constructors for file 4883 * Initialize a newly created visitor to build implicit constructors for file
4884 * [source], in library [libraryElement], which has scope [libraryScope]. Use 4884 * [source], in library [libraryElement], which has scope [libraryScope]. Use
4885 * [typeProvider] to access types from the core library. 4885 * [typeProvider] to access types from the core library.
4886 * 4886 *
4887 * The visit methods will pass closures to [_callback] to indicate what 4887 * The visit methods will pass closures to [_callback] to indicate what
4888 * computation needs to be performed, and its dependency order. 4888 * computation needs to be performed, and its dependency order.
4889 */ 4889 */
4890 ImplicitConstructorBuilder(Source source, LibraryElement libraryElement, 4890 ImplicitConstructorBuilder(Source source, LibraryElement libraryElement,
4891 LibraryScope libraryScope, TypeProvider typeProvider, this._callback) 4891 Scope libraryScope, TypeProvider typeProvider, this._callback)
4892 : super.con3(libraryElement, source, typeProvider, libraryScope, 4892 : super.con3(libraryElement, source, typeProvider, libraryScope,
4893 libraryScope.errorListener); 4893 libraryScope.errorListener);
4894 4894
4895 @override 4895 @override
4896 Object visitClassDeclaration(ClassDeclaration node) { 4896 Object visitClassDeclaration(ClassDeclaration node) {
4897 ClassElementImpl classElement = node.element; 4897 ClassElementImpl classElement = node.element;
4898 classElement.mixinErrorsReported = false; 4898 classElement.mixinErrorsReported = false;
4899 if (node.extendsClause != null && node.withClause != null) { 4899 if (node.extendsClause != null && node.withClause != null) {
4900 // We don't need to build any implicitly constructors for the mixin 4900 // We don't need to build any implicitly constructors for the mixin
4901 // application (since there isn't an explicit element for it), but we 4901 // application (since there isn't an explicit element for it), but we
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
5118 */ 5118 */
5119 ImplicitConstructorComputer(this.typeProvider); 5119 ImplicitConstructorComputer(this.typeProvider);
5120 5120
5121 /** 5121 /**
5122 * Add the given [unit] to the list of units which need to have implicit 5122 * Add the given [unit] to the list of units which need to have implicit
5123 * constructors built for them. [source] is the source file corresponding to 5123 * constructors built for them. [source] is the source file corresponding to
5124 * the compilation unit, [libraryElement] is the library element containing 5124 * the compilation unit, [libraryElement] is the library element containing
5125 * that source, and [libraryScope] is the scope for the library element. 5125 * that source, and [libraryScope] is the scope for the library element.
5126 */ 5126 */
5127 void add(CompilationUnit unit, Source source, LibraryElement libraryElement, 5127 void add(CompilationUnit unit, Source source, LibraryElement libraryElement,
5128 LibraryScope libraryScope) { 5128 Scope libraryScope) {
5129 unit.accept(new ImplicitConstructorBuilder( 5129 unit.accept(new ImplicitConstructorBuilder(
5130 source, libraryElement, libraryScope, typeProvider, _defer)); 5130 source, libraryElement, libraryScope, typeProvider, _defer));
5131 } 5131 }
5132 5132
5133 /** 5133 /**
5134 * Compute the implicit constructors for all compilation units that have been 5134 * Compute the implicit constructors for all compilation units that have been
5135 * passed to [add]. 5135 * passed to [add].
5136 */ 5136 */
5137 void compute() { 5137 void compute() {
5138 List<List<ClassElement>> topologicalSort = 5138 List<List<ClassElement>> topologicalSort =
(...skipping 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after
6920 } 6920 }
6921 } 6921 }
6922 6922
6923 /** 6923 /**
6924 * Return the library scope used when resolving elements within this library's compilation units. 6924 * Return the library scope used when resolving elements within this library's compilation units.
6925 * 6925 *
6926 * @return the library scope used when resolving elements within this library' s compilation units 6926 * @return the library scope used when resolving elements within this library' s compilation units
6927 */ 6927 */
6928 LibraryScope get libraryScope { 6928 LibraryScope get libraryScope {
6929 if (_libraryScope == null) { 6929 if (_libraryScope == null) {
6930 _libraryScope = new LibraryScope(_libraryElement, _errorListener); 6930 _libraryScope = new LibraryScope(_libraryElement,
6931 new LibraryImportScope(_libraryElement, _errorListener),
6932 _errorListener);
6931 } 6933 }
6932 return _libraryScope; 6934 return _libraryScope;
6933 } 6935 }
6934 6936
6935 /** 6937 /**
6936 * Return the AST structure associated with the given source. 6938 * Return the AST structure associated with the given source.
6937 * 6939 *
6938 * @param source the source representing the compilation unit whose AST is to be returned 6940 * @param source the source representing the compilation unit whose AST is to be returned
6939 * @return the AST structure associated with the given source 6941 * @return the AST structure associated with the given source
6940 * @throws AnalysisException if an AST structure could not be created for the compilation unit 6942 * @throws AnalysisException if an AST structure could not be created for the compilation unit
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
7326 } 7328 }
7327 7329
7328 /** 7330 /**
7329 * Instances of the class `LibraryImportScope` represent the scope containing al l of the names 7331 * Instances of the class `LibraryImportScope` represent the scope containing al l of the names
7330 * available from imported libraries. 7332 * available from imported libraries.
7331 */ 7333 */
7332 class LibraryImportScope extends Scope { 7334 class LibraryImportScope extends Scope {
7333 /** 7335 /**
7334 * The element representing the library in which this scope is enclosed. 7336 * The element representing the library in which this scope is enclosed.
7335 */ 7337 */
7336 final LibraryElement _definingLibrary; 7338 final LibraryElement definingLibrary;
7337 7339
7338 /** 7340 /**
7339 * The listener that is to be informed when an error is encountered. 7341 * The listener that is to be informed when an error is encountered.
7340 */ 7342 */
7341 final AnalysisErrorListener errorListener; 7343 final AnalysisErrorListener errorListener;
7342 7344
7343 /** 7345 /**
7344 * A list of the namespaces representing the names that are available in this scope from imported 7346 * A list of the namespaces representing the names that are available in this scope from imported
7345 * libraries. 7347 * libraries.
7346 */ 7348 */
7347 List<Namespace> _importedNamespaces; 7349 final List<Namespace> importedNamespaces = <Namespace>[];
7348 7350
7349 /** 7351 /**
7350 * Initialize a newly created scope representing the names imported into the g iven library. 7352 * Initialize a newly created scope representing the names imported into the g iven library.
7351 * 7353 *
7352 * @param definingLibrary the element representing the library that imports th e names defined in 7354 * @param definingLibrary the element representing the library that imports th e names defined in
7353 * this scope 7355 * this scope
7354 * @param errorListener the listener that is to be informed when an error is e ncountered 7356 * @param errorListener the listener that is to be informed when an error is e ncountered
7355 */ 7357 */
7356 LibraryImportScope(this._definingLibrary, this.errorListener) { 7358 LibraryImportScope(this.definingLibrary, this.errorListener) {
7357 _createImportedNamespaces(); 7359 createImportedNamespaces();
7360 }
7361
7362 /**
7363 * Create all of the namespaces associated with the libraries imported into th is library. The
7364 * names are not added to this scope, but are stored for later reference.
7365 *
7366 * @param definingLibrary the element representing the library that imports th e libraries for
7367 * which namespaces will be created
7368 */
7369 void createImportedNamespaces() {
7370 NamespaceBuilder builder = new NamespaceBuilder();
7371 for (ImportElement import in definingLibrary.imports) {
7372 Namespace namespace = builder.createImportNamespaceForDirective(import);
7373 importedNamespaces.add(namespace);
7374 }
7358 } 7375 }
7359 7376
7360 @override 7377 @override
7361 void define(Element element) { 7378 void define(Element element) {
7362 if (!Scope.isPrivateName(element.displayName)) { 7379 if (!Scope.isPrivateName(element.displayName)) {
7363 super.define(element); 7380 super.define(element);
7364 } 7381 }
7365 } 7382 }
7366 7383
7367 @override 7384 @override
7368 Source getSource(AstNode node) { 7385 Source getSource(AstNode node) {
7369 Source source = super.getSource(node); 7386 Source source = super.getSource(node);
7370 if (source == null) { 7387 if (source == null) {
7371 source = _definingLibrary.definingCompilationUnit.source; 7388 source = definingLibrary.definingCompilationUnit.source;
7372 } 7389 }
7373 return source; 7390 return source;
7374 } 7391 }
7375 7392
7376 @override 7393 @override
7377 Element internalLookup( 7394 Element internalLookup(
7378 Identifier identifier, String name, LibraryElement referencingLibrary) { 7395 Identifier identifier, String name, LibraryElement referencingLibrary) {
7379 Element foundElement = localLookup(name, referencingLibrary); 7396 Element foundElement = localLookup(name, referencingLibrary);
7380 if (foundElement != null) { 7397 if (foundElement != null) {
7381 return foundElement; 7398 return foundElement;
7382 } 7399 }
7383 for (int i = 0; i < _importedNamespaces.length; i++) { 7400 for (int i = 0; i < importedNamespaces.length; i++) {
7384 Namespace nameSpace = _importedNamespaces[i]; 7401 Namespace nameSpace = importedNamespaces[i];
7385 Element element = nameSpace.get(name); 7402 Element element = nameSpace.get(name);
7386 if (element != null) { 7403 if (element != null) {
7387 if (foundElement == null) { 7404 if (foundElement == null) {
7388 foundElement = element; 7405 foundElement = element;
7389 } else if (!identical(foundElement, element)) { 7406 } else if (!identical(foundElement, element)) {
7390 foundElement = MultiplyDefinedElementImpl.fromElements( 7407 foundElement = MultiplyDefinedElementImpl.fromElements(
7391 _definingLibrary.context, foundElement, element); 7408 definingLibrary.context, foundElement, element);
7392 } 7409 }
7393 } 7410 }
7394 } 7411 }
7395 if (foundElement is MultiplyDefinedElementImpl) { 7412 if (foundElement is MultiplyDefinedElementImpl) {
7396 foundElement = _removeSdkElements( 7413 foundElement = _removeSdkElements(
7397 identifier, name, foundElement as MultiplyDefinedElementImpl); 7414 identifier, name, foundElement as MultiplyDefinedElementImpl);
7398 } 7415 }
7399 if (foundElement is MultiplyDefinedElementImpl) { 7416 if (foundElement is MultiplyDefinedElementImpl) {
7400 String foundEltName = foundElement.displayName; 7417 String foundEltName = foundElement.displayName;
7401 List<Element> conflictingMembers = foundElement.conflictingElements; 7418 List<Element> conflictingMembers = foundElement.conflictingElements;
(...skipping 11 matching lines...) Expand all
7413 ])); 7430 ]));
7414 return foundElement; 7431 return foundElement;
7415 } 7432 }
7416 if (foundElement != null) { 7433 if (foundElement != null) {
7417 defineNameWithoutChecking(name, foundElement); 7434 defineNameWithoutChecking(name, foundElement);
7418 } 7435 }
7419 return foundElement; 7436 return foundElement;
7420 } 7437 }
7421 7438
7422 /** 7439 /**
7423 * Create all of the namespaces associated with the libraries imported into th is library. The
7424 * names are not added to this scope, but are stored for later reference.
7425 *
7426 * @param definingLibrary the element representing the library that imports th e libraries for
7427 * which namespaces will be created
7428 */
7429 void _createImportedNamespaces() {
7430 NamespaceBuilder builder = new NamespaceBuilder();
7431 List<ImportElement> imports = _definingLibrary.imports;
7432 int count = imports.length;
7433 _importedNamespaces = new List<Namespace>(count);
7434 for (int i = 0; i < count; i++) {
7435 _importedNamespaces[i] =
7436 builder.createImportNamespaceForDirective(imports[i]);
7437 }
7438 }
7439
7440 /**
7441 * Returns the name of the library that defines given element. 7440 * Returns the name of the library that defines given element.
7442 * 7441 *
7443 * @param element the element to get library name 7442 * @param element the element to get library name
7444 * @return the name of the library that defines given element 7443 * @return the name of the library that defines given element
7445 */ 7444 */
7446 String _getLibraryName(Element element) { 7445 String _getLibraryName(Element element) {
7447 if (element == null) { 7446 if (element == null) {
7448 return StringUtilities.EMPTY; 7447 return StringUtilities.EMPTY;
7449 } 7448 }
7450 LibraryElement library = element.library; 7449 LibraryElement library = element.library;
7451 if (library == null) { 7450 if (library == null) {
7452 return StringUtilities.EMPTY; 7451 return StringUtilities.EMPTY;
7453 } 7452 }
7454 List<ImportElement> imports = _definingLibrary.imports; 7453 List<ImportElement> imports = definingLibrary.imports;
7455 int count = imports.length; 7454 int count = imports.length;
7456 for (int i = 0; i < count; i++) { 7455 for (int i = 0; i < count; i++) {
7457 if (identical(imports[i].importedLibrary, library)) { 7456 if (identical(imports[i].importedLibrary, library)) {
7458 return library.definingCompilationUnit.displayName; 7457 return library.definingCompilationUnit.displayName;
7459 } 7458 }
7460 } 7459 }
7461 List<String> indirectSources = new List<String>(); 7460 List<String> indirectSources = new List<String>();
7462 for (int i = 0; i < count; i++) { 7461 for (int i = 0; i < count; i++) {
7463 LibraryElement importedLibrary = imports[i].importedLibrary; 7462 LibraryElement importedLibrary = imports[i].importedLibrary;
7464 if (importedLibrary != null) { 7463 if (importedLibrary != null) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
7521 } else if (nonSdkElements.length == 1) { 7520 } else if (nonSdkElements.length == 1) {
7522 // All but one member was removed 7521 // All but one member was removed
7523 return nonSdkElements[0]; 7522 return nonSdkElements[0];
7524 } else if (nonSdkElements.length == 0) { 7523 } else if (nonSdkElements.length == 0) {
7525 // All members were removed 7524 // All members were removed
7526 AnalysisEngine.instance.logger 7525 AnalysisEngine.instance.logger
7527 .logInformation("Multiply defined SDK element: $foundElement"); 7526 .logInformation("Multiply defined SDK element: $foundElement");
7528 return foundElement; 7527 return foundElement;
7529 } 7528 }
7530 return new MultiplyDefinedElementImpl( 7529 return new MultiplyDefinedElementImpl(
7531 _definingLibrary.context, nonSdkElements); 7530 definingLibrary.context, nonSdkElements);
7532 } 7531 }
7533 } 7532 }
7534 7533
7535 /** 7534 /**
7536 * Instances of the class `LibraryResolver` are used to resolve one or more mutu ally dependent 7535 * Instances of the class `LibraryResolver` are used to resolve one or more mutu ally dependent
7537 * libraries within a single context. 7536 * libraries within a single context.
7538 */ 7537 */
7539 class LibraryResolver { 7538 class LibraryResolver {
7540 /** 7539 /**
7541 * The analysis context in which the libraries are being analyzed. 7540 * The analysis context in which the libraries are being analyzed.
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after
8996 * Instances of the class `LibraryScope` implement a scope containing all of the names defined 8995 * Instances of the class `LibraryScope` implement a scope containing all of the names defined
8997 * in a given library. 8996 * in a given library.
8998 */ 8997 */
8999 class LibraryScope extends EnclosedScope { 8998 class LibraryScope extends EnclosedScope {
9000 /** 8999 /**
9001 * Initialize a newly created scope representing the names defined in the give n library. 9000 * Initialize a newly created scope representing the names defined in the give n library.
9002 * 9001 *
9003 * @param definingLibrary the element representing the library represented by this scope 9002 * @param definingLibrary the element representing the library represented by this scope
9004 * @param errorListener the listener that is to be informed when an error is e ncountered 9003 * @param errorListener the listener that is to be informed when an error is e ncountered
9005 */ 9004 */
9006 LibraryScope( 9005 LibraryScope(LibraryElement definingLibrary, Scope importScope,
Brian Wilkerson 2015/03/18 14:34:05 This is a breaking change for other clients and ma
9007 LibraryElement definingLibrary, AnalysisErrorListener errorListener) 9006 AnalysisErrorListener errorListener)
9008 : super(new LibraryImportScope(definingLibrary, errorListener)) { 9007 : super(importScope) {
9009 _defineTopLevelNames(definingLibrary); 9008 _defineTopLevelNames(definingLibrary);
9010 } 9009 }
9011 9010
9012 @override 9011 @override
9013 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { 9012 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) {
9014 if (existing is PrefixElement) { 9013 if (existing is PrefixElement) {
9015 // TODO(scheglov) consider providing actual 'nameOffset' from the 9014 // TODO(scheglov) consider providing actual 'nameOffset' from the
9016 // synthetic accessor 9015 // synthetic accessor
9017 int offset = duplicate.nameOffset; 9016 int offset = duplicate.nameOffset;
9018 if (duplicate is PropertyAccessorElement) { 9017 if (duplicate is PropertyAccessorElement) {
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
10015 } 10014 }
10016 } 10015 }
10017 10016
10018 /** 10017 /**
10019 * Return the library scope used when resolving elements within this library's compilation units. 10018 * Return the library scope used when resolving elements within this library's compilation units.
10020 * 10019 *
10021 * @return the library scope used when resolving elements within this library' s compilation units 10020 * @return the library scope used when resolving elements within this library' s compilation units
10022 */ 10021 */
10023 LibraryScope get libraryScope { 10022 LibraryScope get libraryScope {
10024 if (_libraryScope == null) { 10023 if (_libraryScope == null) {
10025 _libraryScope = new LibraryScope(_libraryElement, _errorListener); 10024 _libraryScope = new LibraryScope(_libraryElement,
10025 new LibraryImportScope(_libraryElement, _errorListener),
10026 _errorListener);
10026 } 10027 }
10027 return _libraryScope; 10028 return _libraryScope;
10028 } 10029 }
10029 10030
10030 /** 10031 /**
10031 * Return an array containing the compilation units that comprise this library . The defining 10032 * Return an array containing the compilation units that comprise this library . The defining
10032 * compilation unit is always first. 10033 * compilation unit is always first.
10033 * 10034 *
10034 * @return the compilation units that comprise this library 10035 * @return the compilation units that comprise this library
10035 */ 10036 */
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
10204 /** 10205 /**
10205 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 10206 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
10206 * 10207 *
10207 * @param definingLibrary the element for the library containing the compilati on unit being 10208 * @param definingLibrary the element for the library containing the compilati on unit being
10208 * visited 10209 * visited
10209 * @param source the source representing the compilation unit being visited 10210 * @param source the source representing the compilation unit being visited
10210 * @param typeProvider the object used to access the types from the core libra ry 10211 * @param typeProvider the object used to access the types from the core libra ry
10211 * @param errorListener the error listener that will be informed of any errors that are found 10212 * @param errorListener the error listener that will be informed of any errors that are found
10212 * during resolution 10213 * during resolution
10213 */ 10214 */
10214 ResolverVisitor.con2(LibraryElement definingLibrary, Source source, 10215 ResolverVisitor.con2(LibraryElement definingLibrary, Scope libraryScope,
Brian Wilkerson 2015/03/18 14:34:05 Should this be "LibraryScope libraryScope"? If not
10215 TypeProvider typeProvider, InheritanceManager inheritanceManager, 10216 Source source, TypeProvider typeProvider,
10217 InheritanceManager inheritanceManager,
10216 AnalysisErrorListener errorListener) 10218 AnalysisErrorListener errorListener)
10217 : super.con2(definingLibrary, source, typeProvider, errorListener) { 10219 : super.con2(
10220 definingLibrary, libraryScope, source, typeProvider, errorListener) {
10218 this._inheritanceManager = inheritanceManager; 10221 this._inheritanceManager = inheritanceManager;
10219 this._elementResolver = new ElementResolver(this); 10222 this._elementResolver = new ElementResolver(this);
10220 this._typeAnalyzer = new StaticTypeAnalyzer(this); 10223 this._typeAnalyzer = new StaticTypeAnalyzer(this);
10221 } 10224 }
10222 10225
10223 /** 10226 /**
10224 * Initialize a newly created visitor to resolve the nodes in an AST node. 10227 * Initialize a newly created visitor to resolve the nodes in an AST node.
10225 * 10228 *
10226 * @param definingLibrary the element for the library containing the node bein g visited 10229 * @param definingLibrary the element for the library containing the node bein g visited
10227 * @param source the source representing the compilation unit containing the n ode being visited 10230 * @param source the source representing the compilation unit containing the n ode being visited
(...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after
11825 /** 11828 /**
11826 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 11829 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
11827 * 11830 *
11828 * @param definingLibrary the element for the library containing the compilati on unit being 11831 * @param definingLibrary the element for the library containing the compilati on unit being
11829 * visited 11832 * visited
11830 * @param source the source representing the compilation unit being visited 11833 * @param source the source representing the compilation unit being visited
11831 * @param typeProvider the object used to access the types from the core libra ry 11834 * @param typeProvider the object used to access the types from the core libra ry
11832 * @param errorListener the error listener that will be informed of any errors that are found 11835 * @param errorListener the error listener that will be informed of any errors that are found
11833 * during resolution 11836 * during resolution
11834 */ 11837 */
11835 ScopedVisitor.con2(LibraryElement definingLibrary, this.source, 11838 ScopedVisitor.con2(LibraryElement definingLibrary, Scope libraryScope,
11836 this.typeProvider, AnalysisErrorListener errorListener) { 11839 this.source, this.typeProvider, AnalysisErrorListener errorListener) {
11837 this._definingLibrary = definingLibrary; 11840 this._definingLibrary = definingLibrary;
11838 this._errorListener = errorListener; 11841 this._errorListener = errorListener;
11839 this._nameScope = new LibraryScope(definingLibrary, errorListener); 11842 this._nameScope = libraryScope;
11840 } 11843 }
11841 11844
11842 /** 11845 /**
11843 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 11846 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
11844 * 11847 *
11845 * @param definingLibrary the element for the library containing the compilati on unit being 11848 * @param definingLibrary the element for the library containing the compilati on unit being
11846 * visited 11849 * visited
11847 * @param source the source representing the compilation unit being visited 11850 * @param source the source representing the compilation unit being visited
11848 * @param typeProvider the object used to access the types from the core libra ry 11851 * @param typeProvider the object used to access the types from the core libra ry
11849 * @param nameScope the scope used to resolve identifiers in the node that wil l first be visited 11852 * @param nameScope the scope used to resolve identifiers in the node that wil l first be visited
(...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after
13579 /** 13582 /**
13580 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 13583 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
13581 * 13584 *
13582 * @param definingLibrary the element for the library containing the compilati on unit being 13585 * @param definingLibrary the element for the library containing the compilati on unit being
13583 * visited 13586 * visited
13584 * @param source the source representing the compilation unit being visited 13587 * @param source the source representing the compilation unit being visited
13585 * @param typeProvider the object used to access the types from the core libra ry 13588 * @param typeProvider the object used to access the types from the core libra ry
13586 * @param errorListener the error listener that will be informed of any errors that are found 13589 * @param errorListener the error listener that will be informed of any errors that are found
13587 * during resolution 13590 * during resolution
13588 */ 13591 */
13589 TypeResolverVisitor.con2(LibraryElement definingLibrary, Source source, 13592 TypeResolverVisitor.con2(LibraryElement definingLibrary, Scope libraryScope,
13590 TypeProvider typeProvider, AnalysisErrorListener errorListener) 13593 Source source, TypeProvider typeProvider,
13591 : super.con2(definingLibrary, source, typeProvider, errorListener) { 13594 AnalysisErrorListener errorListener)
13595 : super.con2(
13596 definingLibrary, libraryScope, source, typeProvider, errorListener) {
13592 _dynamicType = typeProvider.dynamicType; 13597 _dynamicType = typeProvider.dynamicType;
13593 _undefinedType = typeProvider.undefinedType; 13598 _undefinedType = typeProvider.undefinedType;
13594 } 13599 }
13595 13600
13596 /** 13601 /**
13597 * Initialize a newly created visitor to resolve the nodes in an AST node. 13602 * Initialize a newly created visitor to resolve the nodes in an AST node.
13598 * 13603 *
13599 * @param definingLibrary the element for the library containing the node bein g visited 13604 * @param definingLibrary the element for the library containing the node bein g visited
13600 * @param source the source representing the compilation unit containing the n ode being visited 13605 * @param source the source representing the compilation unit containing the n ode being visited
13601 * @param typeProvider the object used to access the types from the core libra ry 13606 * @param typeProvider the object used to access the types from the core libra ry
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
14809 ExecutableElement outerFunction = _enclosingFunction; 14814 ExecutableElement outerFunction = _enclosingFunction;
14810 try { 14815 try {
14811 _enclosingFunction = node.element; 14816 _enclosingFunction = node.element;
14812 return super.visitFunctionDeclaration(node); 14817 return super.visitFunctionDeclaration(node);
14813 } finally { 14818 } finally {
14814 _enclosingFunction = outerFunction; 14819 _enclosingFunction = outerFunction;
14815 } 14820 }
14816 } 14821 }
14817 14822
14818 @override 14823 @override
14819 Object visitMethodDeclaration(MethodDeclaration node) {
14820 ExecutableElement outerFunction = _enclosingFunction;
14821 try {
14822 _enclosingFunction = node.element;
14823 return super.visitMethodDeclaration(node);
14824 } finally {
14825 _enclosingFunction = outerFunction;
14826 }
14827 }
14828
14829 @override
14830 Object visitFunctionExpression(FunctionExpression node) { 14824 Object visitFunctionExpression(FunctionExpression node) {
14831 if (node.parent is! FunctionDeclaration) { 14825 if (node.parent is! FunctionDeclaration) {
14832 ExecutableElement outerFunction = _enclosingFunction; 14826 ExecutableElement outerFunction = _enclosingFunction;
14833 try { 14827 try {
14834 _enclosingFunction = node.element; 14828 _enclosingFunction = node.element;
14835 return super.visitFunctionExpression(node); 14829 return super.visitFunctionExpression(node);
14836 } finally { 14830 } finally {
14837 _enclosingFunction = outerFunction; 14831 _enclosingFunction = outerFunction;
14838 } 14832 }
14839 } else { 14833 } else {
14840 return super.visitFunctionExpression(node); 14834 return super.visitFunctionExpression(node);
14841 } 14835 }
14842 } 14836 }
14843 14837
14844 @override 14838 @override
14845 Object visitImportDirective(ImportDirective node) => null; 14839 Object visitImportDirective(ImportDirective node) => null;
14846 14840
14847 @override 14841 @override
14842 Object visitMethodDeclaration(MethodDeclaration node) {
14843 ExecutableElement outerFunction = _enclosingFunction;
14844 try {
14845 _enclosingFunction = node.element;
14846 return super.visitMethodDeclaration(node);
14847 } finally {
14848 _enclosingFunction = outerFunction;
14849 }
14850 }
14851
14852 @override
14848 Object visitSimpleIdentifier(SimpleIdentifier node) { 14853 Object visitSimpleIdentifier(SimpleIdentifier node) {
14849 // Ignore if already resolved - declaration or type. 14854 // Ignore if already resolved - declaration or type.
14850 if (node.staticElement != null) { 14855 if (node.staticElement != null) {
14851 return null; 14856 return null;
14852 } 14857 }
14853 // Ignore if qualified. 14858 // Ignore if qualified.
14854 AstNode parent = node.parent; 14859 AstNode parent = node.parent;
14855 if (parent is PrefixedIdentifier && identical(parent.identifier, node)) { 14860 if (parent is PrefixedIdentifier && identical(parent.identifier, node)) {
14856 return null; 14861 return null;
14857 } 14862 }
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
15378 * library. 15383 * library.
15379 */ 15384 */
15380 final HashSet<String> members = new HashSet<String>(); 15385 final HashSet<String> members = new HashSet<String>();
15381 15386
15382 /** 15387 /**
15383 * Names of resolved or unresolved class members that are read in the 15388 * Names of resolved or unresolved class members that are read in the
15384 * library. 15389 * library.
15385 */ 15390 */
15386 final HashSet<String> readMembers = new HashSet<String>(); 15391 final HashSet<String> readMembers = new HashSet<String>();
15387 } 15392 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | pkg/analyzer/lib/src/task/dart.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698