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

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

Issue 1211523003: Remove BuildFunctionTypeAliasesTask. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
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:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/src/generated/utilities_collection.dart'; 10 import 'package:analyzer/src/generated/utilities_collection.dart';
(...skipping 7819 matching lines...) Expand 10 before | Expand all | Expand 10 after
7830 LibraryElement coreElement = _coreLibrary.libraryElement; 7830 LibraryElement coreElement = _coreLibrary.libraryElement;
7831 if (coreElement == null) { 7831 if (coreElement == null) {
7832 throw new AnalysisException("Could not resolve dart:core"); 7832 throw new AnalysisException("Could not resolve dart:core");
7833 } 7833 }
7834 LibraryElement asyncElement = _asyncLibrary.libraryElement; 7834 LibraryElement asyncElement = _asyncLibrary.libraryElement;
7835 if (asyncElement == null) { 7835 if (asyncElement == null) {
7836 throw new AnalysisException("Could not resolve dart:async"); 7836 throw new AnalysisException("Could not resolve dart:async");
7837 } 7837 }
7838 _buildDirectiveModels(); 7838 _buildDirectiveModels();
7839 _typeProvider = new TypeProviderImpl(coreElement, asyncElement); 7839 _typeProvider = new TypeProviderImpl(coreElement, asyncElement);
7840 _buildTypeAliases();
7841 _buildTypeHierarchies(); 7840 _buildTypeHierarchies();
7842 // 7841 //
7843 // Perform resolution and type analysis. 7842 // Perform resolution and type analysis.
7844 // 7843 //
7845 // TODO(brianwilkerson) Decide whether we want to resolve all of the 7844 // TODO(brianwilkerson) Decide whether we want to resolve all of the
7846 // libraries or whether we want to only resolve the target library. 7845 // libraries or whether we want to only resolve the target library.
7847 // The advantage to resolving everything is that we have already done part 7846 // The advantage to resolving everything is that we have already done part
7848 // of the work so we'll avoid duplicated effort. The disadvantage of 7847 // of the work so we'll avoid duplicated effort. The disadvantage of
7849 // resolving everything is that we might do extra work that we don't 7848 // resolving everything is that we might do extra work that we don't
7850 // really care about. Another possibility is to add a parameter to this 7849 // really care about. Another possibility is to add a parameter to this
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
7910 if (coreElement == null) { 7909 if (coreElement == null) {
7911 throw new AnalysisException("Could not resolve dart:core"); 7910 throw new AnalysisException("Could not resolve dart:core");
7912 } 7911 }
7913 LibraryElement asyncElement = _asyncLibrary.libraryElement; 7912 LibraryElement asyncElement = _asyncLibrary.libraryElement;
7914 if (asyncElement == null) { 7913 if (asyncElement == null) {
7915 throw new AnalysisException("Could not resolve dart:async"); 7914 throw new AnalysisException("Could not resolve dart:async");
7916 } 7915 }
7917 _buildDirectiveModels(); 7916 _buildDirectiveModels();
7918 _typeProvider = new TypeProviderImpl(coreElement, asyncElement); 7917 _typeProvider = new TypeProviderImpl(coreElement, asyncElement);
7919 _buildEnumMembers(); 7918 _buildEnumMembers();
7920 _buildTypeAliases();
7921 _buildTypeHierarchies(); 7919 _buildTypeHierarchies();
7922 _buildImplicitConstructors(); 7920 _buildImplicitConstructors();
7923 // 7921 //
7924 // Perform resolution and type analysis. 7922 // Perform resolution and type analysis.
7925 // 7923 //
7926 // TODO(brianwilkerson) Decide whether we want to resolve all of the 7924 // TODO(brianwilkerson) Decide whether we want to resolve all of the
7927 // libraries or whether we want to only resolve the target library. The 7925 // libraries or whether we want to only resolve the target library. The
7928 // advantage to resolving everything is that we have already done part of 7926 // advantage to resolving everything is that we have already done part of
7929 // the work so we'll avoid duplicated effort. The disadvantage of 7927 // the work so we'll avoid duplicated effort. The disadvantage of
7930 // resolving everything is that we might do extra work that we don't 7928 // resolving everything is that we might do extra work that we don't
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
8209 PerformanceStatistics.resolve.makeCurrentWhile(() { 8207 PerformanceStatistics.resolve.makeCurrentWhile(() {
8210 ImplicitConstructorComputer computer = new ImplicitConstructorComputer(); 8208 ImplicitConstructorComputer computer = new ImplicitConstructorComputer();
8211 for (Library library in _librariesInCycles) { 8209 for (Library library in _librariesInCycles) {
8212 computer.add(_errorListener, library.libraryElement); 8210 computer.add(_errorListener, library.libraryElement);
8213 } 8211 }
8214 computer.compute(); 8212 computer.compute();
8215 }); 8213 });
8216 } 8214 }
8217 8215
8218 /** 8216 /**
8219 * Resolve the types referenced by function type aliases across all of the fun ction type aliases
8220 * defined in the current cycle.
8221 *
8222 * @throws AnalysisException if any of the function type aliases could not be resolved
8223 */
8224 void _buildTypeAliases() {
8225 PerformanceStatistics.resolve.makeCurrentWhile(() {
8226 List<LibraryResolver_TypeAliasInfo> typeAliases =
8227 new List<LibraryResolver_TypeAliasInfo>();
8228 for (Library library in _librariesInCycles) {
8229 for (Source source in library.compilationUnitSources) {
8230 CompilationUnit ast = library.getAST(source);
8231 for (CompilationUnitMember member in ast.declarations) {
8232 if (member is FunctionTypeAlias) {
8233 typeAliases.add(
8234 new LibraryResolver_TypeAliasInfo(library, source, member));
8235 }
8236 }
8237 }
8238 }
8239 // TODO(brianwilkerson) We need to sort the type aliases such that all
8240 // aliases referenced by an alias T are resolved before we resolve T.
8241 for (LibraryResolver_TypeAliasInfo info in typeAliases) {
8242 TypeResolverVisitor visitor = new TypeResolverVisitor.con1(
8243 info._library, info._source, _typeProvider);
8244 info._typeAlias.accept(visitor);
8245 }
8246 });
8247 }
8248
8249 /**
8250 * Resolve the type hierarchy across all of the types declared in the librarie s in the current 8217 * Resolve the type hierarchy across all of the types declared in the librarie s in the current
8251 * cycle. 8218 * cycle.
8252 * 8219 *
8253 * @throws AnalysisException if any of the type hierarchies could not be resol ved 8220 * @throws AnalysisException if any of the type hierarchies could not be resol ved
8254 */ 8221 */
8255 void _buildTypeHierarchies() { 8222 void _buildTypeHierarchies() {
8256 PerformanceStatistics.resolve.makeCurrentWhile(() { 8223 PerformanceStatistics.resolve.makeCurrentWhile(() {
8257 for (Library library in _librariesInCycles) { 8224 for (Library library in _librariesInCycles) {
8258 for (Source source in library.compilationUnitSources) { 8225 for (Source source in library.compilationUnitSources) {
8259 TypeResolverVisitorFactory typeResolverVisitorFactory = 8226 TypeResolverVisitorFactory typeResolverVisitorFactory =
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
8678 if (coreElement == null) { 8645 if (coreElement == null) {
8679 missingCoreLibrary(analysisContext, _coreLibrarySource); 8646 missingCoreLibrary(analysisContext, _coreLibrarySource);
8680 } 8647 }
8681 LibraryElement asyncElement = _asyncLibrary.libraryElement; 8648 LibraryElement asyncElement = _asyncLibrary.libraryElement;
8682 if (asyncElement == null) { 8649 if (asyncElement == null) {
8683 missingAsyncLibrary(analysisContext, _asyncLibrarySource); 8650 missingAsyncLibrary(analysisContext, _asyncLibrarySource);
8684 } 8651 }
8685 _buildDirectiveModels(); 8652 _buildDirectiveModels();
8686 _typeProvider = new TypeProviderImpl(coreElement, asyncElement); 8653 _typeProvider = new TypeProviderImpl(coreElement, asyncElement);
8687 _buildEnumMembers(); 8654 _buildEnumMembers();
8688 _buildTypeAliases();
8689 _buildTypeHierarchies(); 8655 _buildTypeHierarchies();
8690 _buildImplicitConstructors(); 8656 _buildImplicitConstructors();
8691 // 8657 //
8692 // Perform resolution and type analysis. 8658 // Perform resolution and type analysis.
8693 // 8659 //
8694 // TODO(brianwilkerson) Decide whether we want to resolve all of the 8660 // TODO(brianwilkerson) Decide whether we want to resolve all of the
8695 // libraries or whether we want to only resolve the target library. The 8661 // libraries or whether we want to only resolve the target library. The
8696 // advantage to resolving everything is that we have already done part of 8662 // advantage to resolving everything is that we have already done part of
8697 // the work so we'll avoid duplicated effort. The disadvantage of 8663 // the work so we'll avoid duplicated effort. The disadvantage of
8698 // resolving everything is that we might do extra work that we don't 8664 // resolving everything is that we might do extra work that we don't
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
8918 for (int j = 0; j < dependencyCount; j++) { 8884 for (int j = 0; j < dependencyCount; j++) {
8919 ResolvableLibrary dependency = dependencies[j]; 8885 ResolvableLibrary dependency = dependencies[j];
8920 //dependency.setErrorListener(errorListener); 8886 //dependency.setErrorListener(errorListener);
8921 libraryMap[dependency.librarySource] = dependency; 8887 libraryMap[dependency.librarySource] = dependency;
8922 } 8888 }
8923 } 8889 }
8924 return libraryMap; 8890 return libraryMap;
8925 } 8891 }
8926 8892
8927 /** 8893 /**
8928 * Resolve the types referenced by function type aliases across all of the fun ction type aliases
8929 * defined in the current cycle.
8930 *
8931 * @throws AnalysisException if any of the function type aliases could not be resolved
8932 */
8933 void _buildTypeAliases() {
8934 PerformanceStatistics.resolve.makeCurrentWhile(() {
8935 List<LibraryResolver2_TypeAliasInfo> typeAliases =
8936 new List<LibraryResolver2_TypeAliasInfo>();
8937 for (ResolvableLibrary library in _librariesInCycle) {
8938 for (ResolvableCompilationUnit unit
8939 in library.resolvableCompilationUnits) {
8940 for (CompilationUnitMember member
8941 in unit.compilationUnit.declarations) {
8942 if (member is FunctionTypeAlias) {
8943 typeAliases.add(new LibraryResolver2_TypeAliasInfo(
8944 library, unit.source, member));
8945 }
8946 }
8947 }
8948 }
8949 // TODO(brianwilkerson) We need to sort the type aliases such that all
8950 // aliases referenced by an alias T are resolved before we resolve T.
8951 for (LibraryResolver2_TypeAliasInfo info in typeAliases) {
8952 TypeResolverVisitor visitor = new TypeResolverVisitor.con4(
8953 info._library, info._source, _typeProvider);
8954 info._typeAlias.accept(visitor);
8955 }
8956 });
8957 }
8958
8959 /**
8960 * Resolve the type hierarchy across all of the types declared in the librarie s in the current 8894 * Resolve the type hierarchy across all of the types declared in the librarie s in the current
8961 * cycle. 8895 * cycle.
8962 * 8896 *
8963 * @throws AnalysisException if any of the type hierarchies could not be resol ved 8897 * @throws AnalysisException if any of the type hierarchies could not be resol ved
8964 */ 8898 */
8965 void _buildTypeHierarchies() { 8899 void _buildTypeHierarchies() {
8966 PerformanceStatistics.resolve.makeCurrentWhile(() { 8900 PerformanceStatistics.resolve.makeCurrentWhile(() {
8967 for (ResolvableLibrary library in _librariesInCycle) { 8901 for (ResolvableLibrary library in _librariesInCycle) {
8968 for (ResolvableCompilationUnit unit 8902 for (ResolvableCompilationUnit unit
8969 in library.resolvableCompilationUnits) { 8903 in library.resolvableCompilationUnits) {
(...skipping 5065 matching lines...) Expand 10 before | Expand all | Expand 10 after
14035 type.typeArguments = definingClass.type.typeArguments; 13969 type.typeArguments = definingClass.type.typeArguments;
14036 } 13970 }
14037 element.type = type; 13971 element.type = type;
14038 return null; 13972 return null;
14039 } 13973 }
14040 13974
14041 @override 13975 @override
14042 Object visitFunctionTypeAlias(FunctionTypeAlias node) { 13976 Object visitFunctionTypeAlias(FunctionTypeAlias node) {
14043 FunctionTypeAliasElementImpl element = 13977 FunctionTypeAliasElementImpl element =
14044 node.element as FunctionTypeAliasElementImpl; 13978 node.element as FunctionTypeAliasElementImpl;
14045 if (element.returnType == null) { 13979 super.visitFunctionTypeAlias(node);
14046 // Only visit function type aliases once. 13980 element.returnType = _computeReturnType(node.returnType);
14047 super.visitFunctionTypeAlias(node);
14048 element.returnType = _computeReturnType(node.returnType);
14049 }
14050 return null; 13981 return null;
14051 } 13982 }
14052 13983
14053 @override 13984 @override
14054 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { 13985 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
14055 super.visitFunctionTypedFormalParameter(node); 13986 super.visitFunctionTypedFormalParameter(node);
14056 Element element = node.identifier.staticElement; 13987 Element element = node.identifier.staticElement;
14057 if (element is ParameterElementImpl) { 13988 if (element is ParameterElementImpl) {
14058 _setFunctionTypedParameterType(element, node.returnType, node.parameters); 13989 _setFunctionTypedParameterType(element, node.returnType, node.parameters);
14059 } else { 13990 } else {
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
15598 nonFields.add(node); 15529 nonFields.add(node);
15599 return null; 15530 return null;
15600 } 15531 }
15601 15532
15602 @override 15533 @override
15603 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); 15534 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this);
15604 15535
15605 @override 15536 @override
15606 Object visitWithClause(WithClause node) => null; 15537 Object visitWithClause(WithClause node) => null;
15607 } 15538 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/context/context.dart ('k') | pkg/analyzer/lib/src/plugin/engine_plugin.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698