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

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

Issue 26307005: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 library engine.resolver; 3 library engine.resolver;
4 import 'dart:collection'; 4 import 'dart:collection';
5 import 'java_core.dart'; 5 import 'java_core.dart';
6 import 'java_engine.dart'; 6 import 'java_engine.dart';
7 import 'instrumentation.dart'; 7 import 'instrumentation.dart';
8 import 'source.dart'; 8 import 'source.dart';
9 import 'error.dart'; 9 import 'error.dart';
10 import 'scanner.dart' as sc; 10 import 'scanner.dart' as sc;
(...skipping 17 matching lines...) Expand all
28 /** 28 /**
29 * Build the compilation unit element for the given source. 29 * Build the compilation unit element for the given source.
30 * 30 *
31 * @param source the source describing the compilation unit 31 * @param source the source describing the compilation unit
32 * @param unit the AST structure representing the compilation unit 32 * @param unit the AST structure representing the compilation unit
33 * @return the compilation unit element that was built 33 * @return the compilation unit element that was built
34 * @throws AnalysisException if the analysis could not be performed 34 * @throws AnalysisException if the analysis could not be performed
35 */ 35 */
36 CompilationUnitElementImpl buildCompilationUnit(Source source, CompilationUnit unit) { 36 CompilationUnitElementImpl buildCompilationUnit(Source source, CompilationUnit unit) {
37 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art(); 37 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art();
38 if (unit == null) { 38 try {
39 return null; 39 if (unit == null) {
40 return null;
41 }
42 ElementHolder holder = new ElementHolder();
43 ElementBuilder builder = new ElementBuilder(holder);
44 unit.accept(builder);
45 CompilationUnitElementImpl element = new CompilationUnitElementImpl(source .shortName);
46 element.accessors = holder.accessors;
47 element.functions = holder.functions;
48 element.source = source;
49 element.typeAliases = holder.typeAliases;
50 element.types = holder.types;
51 element.topLevelVariables = holder.topLevelVariables;
52 unit.element = element;
53 return element;
54 } finally {
55 timeCounter.stop();
40 } 56 }
41 ElementHolder holder = new ElementHolder();
42 ElementBuilder builder = new ElementBuilder(holder);
43 unit.accept(builder);
44 CompilationUnitElementImpl element = new CompilationUnitElementImpl(source.s hortName);
45 element.accessors = holder.accessors;
46 element.functions = holder.functions;
47 element.source = source;
48 element.typeAliases = holder.typeAliases;
49 element.types = holder.types;
50 element.topLevelVariables = holder.topLevelVariables;
51 unit.element = element;
52 timeCounter.stop();
53 return element;
54 } 57 }
55 } 58 }
56 /** 59 /**
57 * Instances of the class `ElementBuilder` traverse an AST structure and build t he element 60 * Instances of the class `ElementBuilder` traverse an AST structure and build t he element
58 * model representing the AST structure. 61 * model representing the AST structure.
59 * 62 *
60 * @coverage dart.engine.resolver 63 * @coverage dart.engine.resolver
61 */ 64 */
62 class ElementBuilder extends RecursiveASTVisitor<Object> { 65 class ElementBuilder extends RecursiveASTVisitor<Object> {
63 66
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 * 1538 *
1536 * @param node the as expression to check 1539 * @param node the as expression to check
1537 * @return `true` if and only if a hint code is generated on the passed node 1540 * @return `true` if and only if a hint code is generated on the passed node
1538 * @see HintCode#UNNECESSARY_CAST 1541 * @see HintCode#UNNECESSARY_CAST
1539 */ 1542 */
1540 bool checkForUnnecessaryCast(AsExpression node) { 1543 bool checkForUnnecessaryCast(AsExpression node) {
1541 Expression expression = node.expression; 1544 Expression expression = node.expression;
1542 TypeName typeName = node.type; 1545 TypeName typeName = node.type;
1543 Type2 lhsType = expression.staticType; 1546 Type2 lhsType = expression.staticType;
1544 Type2 rhsType = typeName.type; 1547 Type2 rhsType = typeName.type;
1545 if (lhsType != null && rhsType != null && !lhsType.isDynamic && !rhsType.isD ynamic && lhsType.isSubtypeOf(rhsType)) { 1548 if (lhsType != null && rhsType != null && !lhsType.isDynamic && !rhsType.isD ynamic && lhsType is! TypeParameterType && rhsType is! TypeParameterType && lhsT ype.isSubtypeOf(rhsType)) {
1546 _errorReporter.reportError2(HintCode.UNNECESSARY_CAST, node, []); 1549 _errorReporter.reportError2(HintCode.UNNECESSARY_CAST, node, []);
1547 return true; 1550 return true;
1548 } 1551 }
1549 return false; 1552 return false;
1550 } 1553 }
1551 } 1554 }
1552 /** 1555 /**
1553 * Instances of the class `Dart2JSVerifier` traverse an AST structure looking fo r hints for 1556 * Instances of the class `Dart2JSVerifier` traverse an AST structure looking fo r hints for
1554 * code that will be compiled to JS, such as [HintCode#IS_DOUBLE]. 1557 * code that will be compiled to JS, such as [HintCode#IS_DOUBLE].
1555 * 1558 *
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 HintGenerator(List<CompilationUnit> compilationUnits, AnalysisContext context, AnalysisErrorListener errorListener) { 1858 HintGenerator(List<CompilationUnit> compilationUnits, AnalysisContext context, AnalysisErrorListener errorListener) {
1856 this._compilationUnits = compilationUnits; 1859 this._compilationUnits = compilationUnits;
1857 this._context = context; 1860 this._context = context;
1858 this._errorListener = errorListener; 1861 this._errorListener = errorListener;
1859 LibraryElement library = compilationUnits[0].element.library; 1862 LibraryElement library = compilationUnits[0].element.library;
1860 _importsVerifier = new ImportsVerifier(library); 1863 _importsVerifier = new ImportsVerifier(library);
1861 _enableDart2JSHints = context.analysisOptions.dart2jsHint; 1864 _enableDart2JSHints = context.analysisOptions.dart2jsHint;
1862 } 1865 }
1863 void generateForLibrary() { 1866 void generateForLibrary() {
1864 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.hints.star t(); 1867 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.hints.star t();
1865 for (int i = 0; i < _compilationUnits.length; i++) { 1868 try {
1866 CompilationUnitElement element = _compilationUnits[i].element; 1869 for (int i = 0; i < _compilationUnits.length; i++) {
1867 if (element != null) { 1870 CompilationUnitElement element = _compilationUnits[i].element;
1868 if (i == 0) { 1871 if (element != null) {
1869 _importsVerifier.inDefiningCompilationUnit = true; 1872 if (i == 0) {
1870 generateForCompilationUnit(_compilationUnits[i], element.source); 1873 _importsVerifier.inDefiningCompilationUnit = true;
1871 _importsVerifier.inDefiningCompilationUnit = false; 1874 generateForCompilationUnit(_compilationUnits[i], element.source);
1872 } else { 1875 _importsVerifier.inDefiningCompilationUnit = false;
1873 generateForCompilationUnit(_compilationUnits[i], element.source); 1876 } else {
1877 generateForCompilationUnit(_compilationUnits[i], element.source);
1878 }
1874 } 1879 }
1875 } 1880 }
1881 ErrorReporter definingCompilationUnitErrorReporter = new ErrorReporter(_er rorListener, _compilationUnits[0].element.source);
1882 _importsVerifier.generateDuplicateImportHints(definingCompilationUnitError Reporter);
1883 _importsVerifier.generateUnusedImportHints(definingCompilationUnitErrorRep orter);
1884 } finally {
1885 timeCounter.stop();
1876 } 1886 }
1877 ErrorReporter definingCompilationUnitErrorReporter = new ErrorReporter(_erro rListener, _compilationUnits[0].element.source);
1878 _importsVerifier.generateDuplicateImportHints(definingCompilationUnitErrorRe porter);
1879 _importsVerifier.generateUnusedImportHints(definingCompilationUnitErrorRepor ter);
1880 timeCounter.stop();
1881 } 1887 }
1882 void generateForCompilationUnit(CompilationUnit unit, Source source) { 1888 void generateForCompilationUnit(CompilationUnit unit, Source source) {
1883 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source); 1889 ErrorReporter errorReporter = new ErrorReporter(_errorListener, source);
1884 _importsVerifier.visitCompilationUnit(unit); 1890 _importsVerifier.visitCompilationUnit(unit);
1885 new DeadCodeVerifier(errorReporter).visitCompilationUnit(unit); 1891 new DeadCodeVerifier(errorReporter).visitCompilationUnit(unit);
1886 if (_enableDart2JSHints) { 1892 if (_enableDart2JSHints) {
1887 new Dart2JSVerifier(errorReporter).visitCompilationUnit(unit); 1893 new Dart2JSVerifier(errorReporter).visitCompilationUnit(unit);
1888 } 1894 }
1889 new BestPracticesVerifier(errorReporter).visitCompilationUnit(unit); 1895 new BestPracticesVerifier(errorReporter).visitCompilationUnit(unit);
1890 } 1896 }
(...skipping 3075 matching lines...) Expand 10 before | Expand all | Expand 10 after
4966 return resultMap; 4972 return resultMap;
4967 } 4973 }
4968 if (superclassElt != null) { 4974 if (superclassElt != null) {
4969 if (!visitedClasses.contains(superclassElt)) { 4975 if (!visitedClasses.contains(superclassElt)) {
4970 javaSetAdd(visitedClasses, classElt); 4976 javaSetAdd(visitedClasses, classElt);
4971 resultMap = new MemberMap.con2(computeClassChainLookupMap(superclassElt, visitedClasses)); 4977 resultMap = new MemberMap.con2(computeClassChainLookupMap(superclassElt, visitedClasses));
4972 } else { 4978 } else {
4973 _classLookup[superclassElt] = resultMap; 4979 _classLookup[superclassElt] = resultMap;
4974 return resultMap; 4980 return resultMap;
4975 } 4981 }
4982 substituteTypeParametersDownHierarchy(supertype, resultMap);
4976 recordMapWithClassMembers(resultMap, supertype); 4983 recordMapWithClassMembers(resultMap, supertype);
4977 } 4984 }
4978 List<InterfaceType> mixins = classElt.mixins; 4985 List<InterfaceType> mixins = classElt.mixins;
4979 for (int i = mixins.length - 1; i >= 0; i--) { 4986 for (int i = mixins.length - 1; i >= 0; i--) {
4980 recordMapWithClassMembers(resultMap, mixins[i]); 4987 recordMapWithClassMembers(resultMap, mixins[i]);
4981 } 4988 }
4982 _classLookup[classElt] = resultMap; 4989 _classLookup[classElt] = resultMap;
4983 return resultMap; 4990 return resultMap;
4984 } 4991 }
4985 4992
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
5052 ClassElement superclassElement = supertype != null ? supertype.element : nul l; 5059 ClassElement superclassElement = supertype != null ? supertype.element : nul l;
5053 List<InterfaceType> mixins = classElt.mixins; 5060 List<InterfaceType> mixins = classElt.mixins;
5054 List<InterfaceType> interfaces = classElt.interfaces; 5061 List<InterfaceType> interfaces = classElt.interfaces;
5055 List<MemberMap> lookupMaps = new List<MemberMap>(); 5062 List<MemberMap> lookupMaps = new List<MemberMap>();
5056 if (superclassElement != null) { 5063 if (superclassElement != null) {
5057 if (!visitedInterfaces.contains(superclassElement)) { 5064 if (!visitedInterfaces.contains(superclassElement)) {
5058 try { 5065 try {
5059 javaSetAdd(visitedInterfaces, superclassElement); 5066 javaSetAdd(visitedInterfaces, superclassElement);
5060 MemberMap map = computeInterfaceLookupMap(superclassElement, visitedIn terfaces); 5067 MemberMap map = computeInterfaceLookupMap(superclassElement, visitedIn terfaces);
5061 map = new MemberMap.con2(map); 5068 map = new MemberMap.con2(map);
5062 List<MethodElement> methods = supertype.methods; 5069 substituteTypeParametersDownHierarchy(supertype, map);
5063 for (MethodElement method in methods) { 5070 recordMapWithClassMembers(map, supertype);
5064 if (method.isAccessibleIn(_library) && !method.isStatic) {
5065 map.put(method.name, method);
5066 }
5067 }
5068 List<PropertyAccessorElement> accessors = supertype.accessors;
5069 for (PropertyAccessorElement accessor in accessors) {
5070 if (accessor.isAccessibleIn(_library) && !accessor.isStatic) {
5071 map.put(accessor.name, accessor);
5072 }
5073 }
5074 lookupMaps.add(map); 5071 lookupMaps.add(map);
5075 } finally { 5072 } finally {
5076 visitedInterfaces.remove(superclassElement); 5073 visitedInterfaces.remove(superclassElement);
5077 } 5074 }
5078 } else { 5075 } else {
5079 MemberMap map = _interfaceLookup[classElt]; 5076 MemberMap map = _interfaceLookup[classElt];
5080 if (map != null) { 5077 if (map != null) {
5081 lookupMaps.add(map); 5078 lookupMaps.add(map);
5082 } else { 5079 } else {
5083 _interfaceLookup[superclassElement] = resultMap; 5080 _interfaceLookup[superclassElement] = resultMap;
5084 return resultMap; 5081 return resultMap;
5085 } 5082 }
5086 } 5083 }
5087 } 5084 }
5088 for (InterfaceType mixinType in mixins) { 5085 for (InterfaceType mixinType in mixins) {
5089 MemberMap mapWithMixinMembers = new MemberMap(); 5086 MemberMap mapWithMixinMembers = new MemberMap();
5090 recordMapWithClassMembers(mapWithMixinMembers, mixinType); 5087 recordMapWithClassMembers(mapWithMixinMembers, mixinType);
5091 lookupMaps.add(mapWithMixinMembers); 5088 lookupMaps.add(mapWithMixinMembers);
5092 } 5089 }
5093 for (InterfaceType interfaceType in interfaces) { 5090 for (InterfaceType interfaceType in interfaces) {
5094 ClassElement interfaceElement = interfaceType.element; 5091 ClassElement interfaceElement = interfaceType.element;
5095 if (interfaceElement != null) { 5092 if (interfaceElement != null) {
5096 if (!visitedInterfaces.contains(interfaceElement)) { 5093 if (!visitedInterfaces.contains(interfaceElement)) {
5097 try { 5094 try {
5098 javaSetAdd(visitedInterfaces, interfaceElement); 5095 javaSetAdd(visitedInterfaces, interfaceElement);
5099 MemberMap map = computeInterfaceLookupMap(interfaceElement, visitedI nterfaces); 5096 MemberMap map = computeInterfaceLookupMap(interfaceElement, visitedI nterfaces);
5100 map = new MemberMap.con2(map); 5097 map = new MemberMap.con2(map);
5101 List<MethodElement> methods = interfaceType.methods; 5098 substituteTypeParametersDownHierarchy(interfaceType, map);
5102 for (MethodElement method in methods) { 5099 recordMapWithClassMembers(map, interfaceType);
5103 if (method.isAccessibleIn(_library) && !method.isStatic) {
5104 map.put(method.name, method);
5105 }
5106 }
5107 List<PropertyAccessorElement> accessors = interfaceType.accessors;
5108 for (PropertyAccessorElement accessor in accessors) {
5109 if (accessor.isAccessibleIn(_library) && !accessor.isStatic) {
5110 map.put(accessor.name, accessor);
5111 }
5112 }
5113 lookupMaps.add(map); 5100 lookupMaps.add(map);
5114 } finally { 5101 } finally {
5115 visitedInterfaces.remove(interfaceElement); 5102 visitedInterfaces.remove(interfaceElement);
5116 } 5103 }
5117 } else { 5104 } else {
5118 MemberMap map = _interfaceLookup[classElt]; 5105 MemberMap map = _interfaceLookup[classElt];
5119 if (map != null) { 5106 if (map != null) {
5120 lookupMaps.add(map); 5107 lookupMaps.add(map);
5121 } else { 5108 } else {
5122 _interfaceLookup[interfaceElement] = resultMap; 5109 _interfaceLookup[interfaceElement] = resultMap;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
5269 * @param arguments the arguments used to build the error message 5256 * @param arguments the arguments used to build the error message
5270 */ 5257 */
5271 void reportError(ClassElement classElt, int offset, int length, ErrorCode erro rCode, List<Object> arguments) { 5258 void reportError(ClassElement classElt, int offset, int length, ErrorCode erro rCode, List<Object> arguments) {
5272 Set<AnalysisError> errorSet = _errorsInClassElement[classElt]; 5259 Set<AnalysisError> errorSet = _errorsInClassElement[classElt];
5273 if (errorSet == null) { 5260 if (errorSet == null) {
5274 errorSet = new Set<AnalysisError>(); 5261 errorSet = new Set<AnalysisError>();
5275 _errorsInClassElement[classElt] = errorSet; 5262 _errorsInClassElement[classElt] = errorSet;
5276 } 5263 }
5277 javaSetAdd(errorSet, new AnalysisError.con2(classElt.source, offset, length, errorCode, arguments)); 5264 javaSetAdd(errorSet, new AnalysisError.con2(classElt.source, offset, length, errorCode, arguments));
5278 } 5265 }
5266
5267 /**
5268 * Loop through all of the members in some [MemberMap], performing type parame ter
5269 * substitutions using a passed supertype.
5270 *
5271 * @param superType the supertype to substitute into the members of the [Membe rMap]
5272 * @param map the MemberMap to perform the substitutions on
5273 */
5274 void substituteTypeParametersDownHierarchy(InterfaceType superType, MemberMap map) {
5275 for (int i = 0; i < map.size; i++) {
5276 String key = map.getKey(i);
5277 ExecutableElement executableElement = map.getValue(i);
5278 if (executableElement is MethodMember) {
5279 executableElement = MethodMember.from(executableElement as MethodMember, superType);
5280 map.put(key, executableElement);
5281 } else if (executableElement is PropertyAccessorMember) {
5282 executableElement = PropertyAccessorMember.from(executableElement as Pro pertyAccessorMember, superType);
5283 map.put(key, executableElement);
5284 }
5285 }
5286 }
5279 } 5287 }
5280 /** 5288 /**
5281 * Instances of the class `Library` represent the data about a single library du ring the 5289 * Instances of the class `Library` represent the data about a single library du ring the
5282 * resolution of some (possibly different) library. They are not intended to be used except during 5290 * resolution of some (possibly different) library. They are not intended to be used except during
5283 * the resolution process. 5291 * the resolution process.
5284 * 5292 *
5285 * @coverage dart.engine.resolver 5293 * @coverage dart.engine.resolver
5286 */ 5294 */
5287 class Library { 5295 class Library {
5288 5296
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
5998 List<ImportElement> imports = new List<ImportElement>(); 6006 List<ImportElement> imports = new List<ImportElement>();
5999 List<ExportElement> exports = new List<ExportElement>(); 6007 List<ExportElement> exports = new List<ExportElement>();
6000 for (Directive directive in library.definingCompilationUnit.directives) { 6008 for (Directive directive in library.definingCompilationUnit.directives) {
6001 if (directive is ImportDirective) { 6009 if (directive is ImportDirective) {
6002 ImportDirective importDirective = directive as ImportDirective; 6010 ImportDirective importDirective = directive as ImportDirective;
6003 Source importedSource = library.getSource(importDirective); 6011 Source importedSource = library.getSource(importDirective);
6004 if (importedSource != null) { 6012 if (importedSource != null) {
6005 Library importedLibrary = _libraryMap[importedSource]; 6013 Library importedLibrary = _libraryMap[importedSource];
6006 if (importedLibrary != null) { 6014 if (importedLibrary != null) {
6007 ImportElementImpl importElement = new ImportElementImpl(); 6015 ImportElementImpl importElement = new ImportElementImpl();
6016 importElement.offset = directive.offset;
6017 StringLiteral uriLiteral = importDirective.uri;
6018 if (uriLiteral != null) {
6019 importElement.uriEnd = uriLiteral.end;
6020 }
6008 importElement.uri = library.getUri(importDirective); 6021 importElement.uri = library.getUri(importDirective);
6009 importElement.combinators = buildCombinators(importDirective); 6022 importElement.combinators = buildCombinators(importDirective);
6010 LibraryElement importedLibraryElement = importedLibrary.libraryEle ment; 6023 LibraryElement importedLibraryElement = importedLibrary.libraryEle ment;
6011 if (importedLibraryElement != null) { 6024 if (importedLibraryElement != null) {
6012 importElement.importedLibrary = importedLibraryElement; 6025 importElement.importedLibrary = importedLibraryElement;
6013 } 6026 }
6014 SimpleIdentifier prefixNode = ((directive as ImportDirective)).pre fix; 6027 SimpleIdentifier prefixNode = ((directive as ImportDirective)).pre fix;
6015 if (prefixNode != null) { 6028 if (prefixNode != null) {
6029 importElement.prefixOffset = prefixNode.offset;
6016 String prefixName = prefixNode.name; 6030 String prefixName = prefixNode.name;
6017 PrefixElementImpl prefix = nameToPrefixMap[prefixName]; 6031 PrefixElementImpl prefix = nameToPrefixMap[prefixName];
6018 if (prefix == null) { 6032 if (prefix == null) {
6019 prefix = new PrefixElementImpl(prefixNode); 6033 prefix = new PrefixElementImpl(prefixNode);
6020 nameToPrefixMap[prefixName] = prefix; 6034 nameToPrefixMap[prefixName] = prefix;
6021 } 6035 }
6022 importElement.prefix = prefix; 6036 importElement.prefix = prefix;
6023 prefixNode.staticElement = prefix; 6037 prefixNode.staticElement = prefix;
6024 } 6038 }
6025 directive.element = importElement; 6039 directive.element = importElement;
6026 imports.add(importElement); 6040 imports.add(importElement);
6027 if (doesCompilationUnitHavePartOfDirective(importedLibrary.getAST( importedSource))) { 6041 if (doesCompilationUnitHavePartOfDirective(importedLibrary.getAST( importedSource))) {
6028 StringLiteral uriLiteral = importDirective.uri;
6029 errorListener.onError(new AnalysisError.con2(library.librarySour ce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.IMPORT_OF_NON_LIB RARY, [uriLiteral.toSource()])); 6042 errorListener.onError(new AnalysisError.con2(library.librarySour ce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.IMPORT_OF_NON_LIB RARY, [uriLiteral.toSource()]));
6030 } 6043 }
6031 } 6044 }
6032 } 6045 }
6033 } else if (directive is ExportDirective) { 6046 } else if (directive is ExportDirective) {
6034 ExportDirective exportDirective = directive as ExportDirective; 6047 ExportDirective exportDirective = directive as ExportDirective;
6035 Source exportedSource = library.getSource(exportDirective); 6048 Source exportedSource = library.getSource(exportDirective);
6036 if (exportedSource != null) { 6049 if (exportedSource != null) {
6037 Library exportedLibrary = _libraryMap[exportedSource]; 6050 Library exportedLibrary = _libraryMap[exportedSource];
6038 if (exportedLibrary != null) { 6051 if (exportedLibrary != null) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
6080 } 6093 }
6081 6094
6082 /** 6095 /**
6083 * Resolve the type hierarchy across all of the types declared in the librarie s in the current 6096 * Resolve the type hierarchy across all of the types declared in the librarie s in the current
6084 * cycle. 6097 * cycle.
6085 * 6098 *
6086 * @throws AnalysisException if any of the type hierarchies could not be resol ved 6099 * @throws AnalysisException if any of the type hierarchies could not be resol ved
6087 */ 6100 */
6088 void buildTypeHierarchies() { 6101 void buildTypeHierarchies() {
6089 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art(); 6102 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art();
6090 for (Library library in resolvedLibraries) { 6103 try {
6091 for (Source source in library.compilationUnitSources) { 6104 for (Library library in resolvedLibraries) {
6092 TypeResolverVisitor visitor = new TypeResolverVisitor.con1(library, sour ce, _typeProvider); 6105 for (Source source in library.compilationUnitSources) {
6093 library.getAST(source).accept(visitor); 6106 TypeResolverVisitor visitor = new TypeResolverVisitor.con1(library, so urce, _typeProvider);
6107 library.getAST(source).accept(visitor);
6108 }
6094 } 6109 }
6110 } finally {
6111 timeCounter.stop();
6095 } 6112 }
6096 timeCounter.stop();
6097 } 6113 }
6098 6114
6099 /** 6115 /**
6100 * Compute a dependency map of libraries reachable from the given library. A d ependency map is a 6116 * Compute a dependency map of libraries reachable from the given library. A d ependency map is a
6101 * table that maps individual libraries to a list of the libraries that either import or export 6117 * table that maps individual libraries to a list of the libraries that either import or export
6102 * those libraries. 6118 * those libraries.
6103 * 6119 *
6104 * This map is used to compute all of the libraries involved in a cycle that i nclude the root 6120 * This map is used to compute all of the libraries involved in a cycle that i nclude the root
6105 * library. Given that we only add libraries that are reachable from the root library, when we 6121 * library. Given that we only add libraries that are reachable from the root library, when we
6106 * work backward we are guaranteed to only get libraries in the cycle. 6122 * work backward we are guaranteed to only get libraries in the cycle.
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
6300 identifiers[i] = names[i].name; 6316 identifiers[i] = names[i].name;
6301 } 6317 }
6302 return identifiers; 6318 return identifiers;
6303 } 6319 }
6304 6320
6305 /** 6321 /**
6306 * Compute a value for all of the constants in the libraries being analyzed. 6322 * Compute a value for all of the constants in the libraries being analyzed.
6307 */ 6323 */
6308 void performConstantEvaluation() { 6324 void performConstantEvaluation() {
6309 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art(); 6325 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art();
6310 ConstantValueComputer computer = new ConstantValueComputer(); 6326 try {
6311 for (Library library in resolvedLibraries) { 6327 ConstantValueComputer computer = new ConstantValueComputer();
6312 for (Source source in library.compilationUnitSources) { 6328 for (Library library in resolvedLibraries) {
6313 try { 6329 for (Source source in library.compilationUnitSources) {
6314 CompilationUnit unit = library.getAST(source); 6330 try {
6315 if (unit != null) { 6331 CompilationUnit unit = library.getAST(source);
6316 computer.add(unit); 6332 if (unit != null) {
6333 computer.add(unit);
6334 }
6335 } on AnalysisException catch (exception) {
6336 AnalysisEngine.instance.logger.logError2("Internal Error: Could not access AST for ${source.fullName} during constant evaluation", exception);
6317 } 6337 }
6318 } on AnalysisException catch (exception) {
6319 AnalysisEngine.instance.logger.logError2("Internal Error: Could not ac cess AST for ${source.fullName} during constant evaluation", exception);
6320 } 6338 }
6321 } 6339 }
6340 computer.computeValues();
6341 } finally {
6342 timeCounter.stop();
6322 } 6343 }
6323 computer.computeValues();
6324 timeCounter.stop();
6325 } 6344 }
6326 6345
6327 /** 6346 /**
6328 * Resolve the identifiers and perform type analysis in the libraries in the c urrent cycle. 6347 * Resolve the identifiers and perform type analysis in the libraries in the c urrent cycle.
6329 * 6348 *
6330 * @throws AnalysisException if any of the identifiers could not be resolved o r if any of the 6349 * @throws AnalysisException if any of the identifiers could not be resolved o r if any of the
6331 * libraries could not have their types analyzed 6350 * libraries could not have their types analyzed
6332 */ 6351 */
6333 void resolveReferencesAndTypes() { 6352 void resolveReferencesAndTypes() {
6334 for (Library library in resolvedLibraries) { 6353 for (Library library in resolvedLibraries) {
6335 resolveReferencesAndTypes2(library); 6354 resolveReferencesAndTypes2(library);
6336 } 6355 }
6337 } 6356 }
6338 6357
6339 /** 6358 /**
6340 * Resolve the identifiers and perform type analysis in the given library. 6359 * Resolve the identifiers and perform type analysis in the given library.
6341 * 6360 *
6342 * @param library the library to be resolved 6361 * @param library the library to be resolved
6343 * @throws AnalysisException if any of the identifiers could not be resolved o r if the types in 6362 * @throws AnalysisException if any of the identifiers could not be resolved o r if the types in
6344 * the library cannot be analyzed 6363 * the library cannot be analyzed
6345 */ 6364 */
6346 void resolveReferencesAndTypes2(Library library) { 6365 void resolveReferencesAndTypes2(Library library) {
6347 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art(); 6366 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art();
6348 for (Source source in library.compilationUnitSources) { 6367 try {
6349 ResolverVisitor visitor = new ResolverVisitor.con1(library, source, _typeP rovider); 6368 for (Source source in library.compilationUnitSources) {
6350 library.getAST(source).accept(visitor); 6369 ResolverVisitor visitor = new ResolverVisitor.con1(library, source, _typ eProvider);
6351 for (ProxyConditionalAnalysisError conditionalCode in visitor.proxyConditi onalAnalysisErrors) { 6370 library.getAST(source).accept(visitor);
6352 if (conditionalCode.shouldIncludeErrorCode()) { 6371 for (ProxyConditionalAnalysisError conditionalCode in visitor.proxyCondi tionalAnalysisErrors) {
6353 visitor.reportError(conditionalCode.analysisError); 6372 if (conditionalCode.shouldIncludeErrorCode()) {
6373 visitor.reportError(conditionalCode.analysisError);
6374 }
6354 } 6375 }
6355 } 6376 }
6377 } finally {
6378 timeCounter.stop();
6356 } 6379 }
6357 timeCounter.stop();
6358 } 6380 }
6359 6381
6360 /** 6382 /**
6361 * Return the result of resolving the URI of the given URI-based directive aga inst the URI of the 6383 * Return the result of resolving the URI of the given URI-based directive aga inst the URI of the
6362 * given library, or `null` if the URI is not valid. 6384 * given library, or `null` if the URI is not valid.
6363 * 6385 *
6364 * @param librarySource the source representing the library containing the dir ective 6386 * @param librarySource the source representing the library containing the dir ective
6365 * @param directive the directive which URI should be resolved 6387 * @param directive the directive which URI should be resolved
6366 * @return the result of resolving the URI against the URI of the library 6388 * @return the result of resolving the URI against the URI of the library
6367 */ 6389 */
(...skipping 6611 matching lines...) Expand 10 before | Expand all | Expand 10 after
12979 ParameterElement parameter = parameters[i]; 13001 ParameterElement parameter = parameters[i];
12980 if (parameter.parameterKind.isOptional) { 13002 if (parameter.parameterKind.isOptional) {
12981 formalParameters.add(parameterLocations[i]); 13003 formalParameters.add(parameterLocations[i]);
12982 parameterElts.add(parameter as ParameterElementImpl); 13004 parameterElts.add(parameter as ParameterElementImpl);
12983 } 13005 }
12984 } 13006 }
12985 for (ParameterElement parameterElt in overriddenPEs) { 13007 for (ParameterElement parameterElt in overriddenPEs) {
12986 if (parameterElt.parameterKind.isOptional) { 13008 if (parameterElt.parameterKind.isOptional) {
12987 if (parameterElt is ParameterElementImpl) { 13009 if (parameterElt is ParameterElementImpl) {
12988 overriddenParameterElts.add(parameterElt as ParameterElementImpl); 13010 overriddenParameterElts.add(parameterElt as ParameterElementImpl);
12989 } else if (parameterElt is ParameterMember) {
12990 overriddenParameterElts.add(((parameterElt as ParameterMember)).baseEl ement as ParameterElementImpl);
12991 } 13011 }
12992 } 13012 }
12993 } 13013 }
12994 if (parameterElts.length > 0) { 13014 if (parameterElts.length > 0) {
12995 if (identical(parameterElts[0].parameterKind, ParameterKind.NAMED)) { 13015 if (identical(parameterElts[0].parameterKind, ParameterKind.NAMED)) {
12996 for (int i = 0; i < parameterElts.length; i++) { 13016 for (int i = 0; i < parameterElts.length; i++) {
12997 ParameterElementImpl parameterElt = parameterElts[i]; 13017 ParameterElementImpl parameterElt = parameterElts[i];
12998 EvaluationResultImpl result = parameterElt.evaluationResult; 13018 EvaluationResultImpl result = parameterElt.evaluationResult;
12999 if (result == null || identical(result, ValidResult.RESULT_OBJECT)) { 13019 if (result == null || identical(result, ValidResult.RESULT_OBJECT)) {
13000 continue; 13020 continue;
(...skipping 3214 matching lines...) Expand 10 before | Expand all | Expand 10 after
16215 ResolverErrorCode.con2(String name, int ordinal, ErrorType type, String messag e, String correction) : super(name, ordinal) { 16235 ResolverErrorCode.con2(String name, int ordinal, ErrorType type, String messag e, String correction) : super(name, ordinal) {
16216 this._type = type; 16236 this._type = type;
16217 this._message = message; 16237 this._message = message;
16218 this.correction9 = correction; 16238 this.correction9 = correction;
16219 } 16239 }
16220 String get correction => correction9; 16240 String get correction => correction9;
16221 ErrorSeverity get errorSeverity => _type.severity; 16241 ErrorSeverity get errorSeverity => _type.severity;
16222 String get message => _message; 16242 String get message => _message;
16223 ErrorType get type => _type; 16243 ErrorType get type => _type;
16224 } 16244 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/lib/src/generated/parser.dart ('k') | pkg/analyzer_experimental/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698