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

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

Issue 229653004: New analyzer snapshot with MapIterator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/lib/src/generated/error.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine; 8 library engine;
9 9
10 import 'java_core.dart'; 10 import 'java_core.dart';
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 bool get analyzeAngular; 820 bool get analyzeAngular;
821 821
822 /** 822 /**
823 * Return `true` if analysis is to parse and analyze function bodies. 823 * Return `true` if analysis is to parse and analyze function bodies.
824 * 824 *
825 * @return `true` if analysis is to parse and analyzer function bodies 825 * @return `true` if analysis is to parse and analyzer function bodies
826 */ 826 */
827 bool get analyzeFunctionBodies; 827 bool get analyzeFunctionBodies;
828 828
829 /** 829 /**
830 * Return `true` if analysis is to analyze Polymer.
831 *
832 * @return `true` if analysis is to analyze Polymer
833 */
834 bool get analyzePolymer;
835
836 /**
830 * Return the maximum number of sources for which AST structures should be kep t in the cache. 837 * Return the maximum number of sources for which AST structures should be kep t in the cache.
831 * 838 *
832 * @return the maximum number of sources for which AST structures should be ke pt in the cache 839 * @return the maximum number of sources for which AST structures should be ke pt in the cache
833 */ 840 */
834 int get cacheSize; 841 int get cacheSize;
835 842
836 /** 843 /**
837 * Return `true` if analysis is to generate dart2js related hint results. 844 * Return `true` if analysis is to generate dart2js related hint results.
838 * 845 *
839 * @return `true` if analysis is to generate dart2js related hint results 846 * @return `true` if analysis is to generate dart2js related hint results
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 } 1186 }
1180 while (_recentlyUsed.length >= _maxCacheSize) { 1187 while (_recentlyUsed.length >= _maxCacheSize) {
1181 if (!_flushAstFromCache()) { 1188 if (!_flushAstFromCache()) {
1182 break; 1189 break;
1183 } 1190 }
1184 } 1191 }
1185 _recentlyUsed.add(source); 1192 _recentlyUsed.add(source);
1186 } 1193 }
1187 1194
1188 /** 1195 /**
1189 * Return a collection containing all of the map entries mapping sources to ca che entries. Clients
1190 * should not modify the returned collection.
1191 *
1192 * @return a collection containing all of the map entries mapping sources to c ache entries
1193 */
1194 Iterable<MapEntry<Source, SourceEntry>> entrySet() => getMapEntrySet(_sourceMa p);
1195
1196 /**
1197 * Return the entry associated with the given source. 1196 * Return the entry associated with the given source.
1198 * 1197 *
1199 * @param source the source whose entry is to be returned 1198 * @param source the source whose entry is to be returned
1200 * @return the entry associated with the given source 1199 * @return the entry associated with the given source
1201 */ 1200 */
1202 SourceEntry get(Source source) => _sourceMap[source]; 1201 SourceEntry get(Source source) => _sourceMap[source];
1203 1202
1204 /** 1203 /**
1204 * Return an iterator returning all of the map entries mapping sources to cach e entries.
1205 *
1206 * @return an iterator returning all of the map entries mapping sources to cac he entries
1207 */
1208 MapIterator<Source, SourceEntry> iterator() => new SingleMapIterator<Source, S ourceEntry>(_sourceMap);
1209
1210 /**
1205 * Associate the given entry with the given source. 1211 * Associate the given entry with the given source.
1206 * 1212 *
1207 * @param source the source with which the entry is to be associated 1213 * @param source the source with which the entry is to be associated
1208 * @param entry the entry to be associated with the source 1214 * @param entry the entry to be associated with the source
1209 */ 1215 */
1210 void put(Source source, SourceEntry entry) { 1216 void put(Source source, SourceEntry entry) {
1211 (entry as SourceEntryImpl).fixExceptionState(); 1217 (entry as SourceEntryImpl).fixExceptionState();
1212 _sourceMap[source] = entry; 1218 _sourceMap[source] = entry;
1213 } 1219 }
1214 1220
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 * The interface `DartEntry` defines the behavior of objects that maintain the i nformation 1401 * The interface `DartEntry` defines the behavior of objects that maintain the i nformation
1396 * cached by an analysis context about an individual Dart file. 1402 * cached by an analysis context about an individual Dart file.
1397 */ 1403 */
1398 abstract class DartEntry implements SourceEntry { 1404 abstract class DartEntry implements SourceEntry {
1399 /** 1405 /**
1400 * The data descriptor representing the errors reported during Angular resolut ion. 1406 * The data descriptor representing the errors reported during Angular resolut ion.
1401 */ 1407 */
1402 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS = new DataDesc riptor<List<AnalysisError>>("DartEntry.ANGULAR_ERRORS"); 1408 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS = new DataDesc riptor<List<AnalysisError>>("DartEntry.ANGULAR_ERRORS");
1403 1409
1404 /** 1410 /**
1411 * The data descriptor representing the errors reported while building an elem ent model.
1412 */
1413 static final DataDescriptor<List<AnalysisError>> BUILD_ELEMENT_ERRORS = new Da taDescriptor<List<AnalysisError>>("DartEntry.BUILD_ELEMENT_ERRORS");
1414
1415 /**
1405 * The data descriptor representing the list of libraries that contain this co mpilation unit. 1416 * The data descriptor representing the list of libraries that contain this co mpilation unit.
1406 */ 1417 */
1407 static final DataDescriptor<List<Source>> CONTAINING_LIBRARIES = new DataDescr iptor<List<Source>>("DartEntry.CONTAINING_LIBRARIES"); 1418 static final DataDescriptor<List<Source>> CONTAINING_LIBRARIES = new DataDescr iptor<List<Source>>("DartEntry.CONTAINING_LIBRARIES");
1408 1419
1409 /** 1420 /**
1410 * The data descriptor representing the library element for the library. This data is only 1421 * The data descriptor representing the library element for the library. This data is only
1411 * available for Dart files that are the defining compilation unit of a librar y. 1422 * available for Dart files that are the defining compilation unit of a librar y.
1412 */ 1423 */
1413 static final DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<Libra ryElement>("DartEntry.ELEMENT"); 1424 static final DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<Libra ryElement>("DartEntry.ELEMENT");
1414 1425
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 _resolutionState.flushAstStructures(); 1761 _resolutionState.flushAstStructures();
1751 } 1762 }
1752 1763
1753 @override 1764 @override
1754 List<AnalysisError> get allErrors { 1765 List<AnalysisError> get allErrors {
1755 List<AnalysisError> errors = new List<AnalysisError>(); 1766 List<AnalysisError> errors = new List<AnalysisError>();
1756 ListUtilities.addAll(errors, _scanErrors); 1767 ListUtilities.addAll(errors, _scanErrors);
1757 ListUtilities.addAll(errors, _parseErrors); 1768 ListUtilities.addAll(errors, _parseErrors);
1758 DartEntryImpl_ResolutionState state = _resolutionState; 1769 DartEntryImpl_ResolutionState state = _resolutionState;
1759 while (state != null) { 1770 while (state != null) {
1771 ListUtilities.addAll(errors, state._buildElementErrors);
1760 ListUtilities.addAll(errors, state._resolutionErrors); 1772 ListUtilities.addAll(errors, state._resolutionErrors);
1761 ListUtilities.addAll(errors, state._verificationErrors); 1773 ListUtilities.addAll(errors, state._verificationErrors);
1762 ListUtilities.addAll(errors, state._hints); 1774 ListUtilities.addAll(errors, state._hints);
1763 state = state._nextState; 1775 state = state._nextState;
1764 } 1776 }
1765 ListUtilities.addAll(errors, _angularErrors); 1777 ListUtilities.addAll(errors, _angularErrors);
1766 if (errors.length == 0) { 1778 if (errors.length == 0) {
1767 return AnalysisError.NO_ERRORS; 1779 return AnalysisError.NO_ERRORS;
1768 } 1780 }
1769 return new List.from(errors); 1781 return new List.from(errors);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 } else { 1885 } else {
1874 return super.getState(descriptor); 1886 return super.getState(descriptor);
1875 } 1887 }
1876 } 1888 }
1877 1889
1878 @override 1890 @override
1879 CacheState getStateInLibrary(DataDescriptor descriptor, Source librarySource) { 1891 CacheState getStateInLibrary(DataDescriptor descriptor, Source librarySource) {
1880 DartEntryImpl_ResolutionState state = _resolutionState; 1892 DartEntryImpl_ResolutionState state = _resolutionState;
1881 while (state != null) { 1893 while (state != null) {
1882 if (librarySource == state._librarySource) { 1894 if (librarySource == state._librarySource) {
1883 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { 1895 if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS)) {
1896 return state._buildElementErrorsState;
1897 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
1884 return state._resolutionErrorsState; 1898 return state._resolutionErrorsState;
1885 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 1899 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
1886 return state._resolvedUnitState; 1900 return state._resolvedUnitState;
1887 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 1901 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
1888 return state._verificationErrorsState; 1902 return state._verificationErrorsState;
1889 } else if (identical(descriptor, DartEntry.HINTS)) { 1903 } else if (identical(descriptor, DartEntry.HINTS)) {
1890 return state._hintsState; 1904 return state._hintsState;
1891 } else { 1905 } else {
1892 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" ); 1906 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" );
1893 } 1907 }
1894 } 1908 }
1895 state = state._nextState; 1909 state = state._nextState;
1896 } 1910 }
1897 ; 1911 ;
1898 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript or, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICATION_ERR ORS) || identical(descriptor, DartEntry.HINTS)) { 1912 if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS) || identical(descr iptor, DartEntry.RESOLUTION_ERRORS) || identical(descriptor, DartEntry.RESOLVED_ UNIT) || identical(descriptor, DartEntry.VERIFICATION_ERRORS) || identical(descr iptor, DartEntry.HINTS)) {
1899 return CacheState.INVALID; 1913 return CacheState.INVALID;
1900 } else { 1914 } else {
1901 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 1915 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
1902 } 1916 }
1903 } 1917 }
1904 1918
1905 @override 1919 @override
1906 Object getValue(DataDescriptor descriptor) { 1920 Object getValue(DataDescriptor descriptor) {
1907 if (identical(descriptor, DartEntry.ANGULAR_ERRORS)) { 1921 if (identical(descriptor, DartEntry.ANGULAR_ERRORS)) {
1908 return _angularErrors; 1922 return _angularErrors;
(...skipping 26 matching lines...) Expand all
1935 return _tokenStream; 1949 return _tokenStream;
1936 } 1950 }
1937 return super.getValue(descriptor); 1951 return super.getValue(descriptor);
1938 } 1952 }
1939 1953
1940 @override 1954 @override
1941 Object getValueInLibrary(DataDescriptor descriptor, Source librarySource) { 1955 Object getValueInLibrary(DataDescriptor descriptor, Source librarySource) {
1942 DartEntryImpl_ResolutionState state = _resolutionState; 1956 DartEntryImpl_ResolutionState state = _resolutionState;
1943 while (state != null) { 1957 while (state != null) {
1944 if (librarySource == state._librarySource) { 1958 if (librarySource == state._librarySource) {
1945 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { 1959 if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS)) {
1960 return state._buildElementErrors;
1961 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
1946 return state._resolutionErrors; 1962 return state._resolutionErrors;
1947 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 1963 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
1948 return state._resolvedUnit; 1964 return state._resolvedUnit;
1949 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 1965 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
1950 return state._verificationErrors; 1966 return state._verificationErrors;
1951 } else if (identical(descriptor, DartEntry.HINTS)) { 1967 } else if (identical(descriptor, DartEntry.HINTS)) {
1952 return state._hints; 1968 return state._hints;
1953 } else { 1969 } else {
1954 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" ); 1970 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" );
1955 } 1971 }
1956 } 1972 }
1957 state = state._nextState; 1973 state = state._nextState;
1958 } 1974 }
1959 ; 1975 ;
1960 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript or, DartEntry.VERIFICATION_ERRORS) || identical(descriptor, DartEntry.HINTS)) { 1976 if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS) || identical(descr iptor, DartEntry.RESOLUTION_ERRORS) || identical(descriptor, DartEntry.VERIFICAT ION_ERRORS) || identical(descriptor, DartEntry.HINTS)) {
1961 return AnalysisError.NO_ERRORS; 1977 return AnalysisError.NO_ERRORS;
1962 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 1978 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
1963 return null; 1979 return null;
1964 } else { 1980 } else {
1965 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 1981 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
1966 } 1982 }
1967 } 1983 }
1968 1984
1969 @override 1985 @override
1970 DartEntryImpl get writableCopy { 1986 DartEntryImpl get writableCopy {
(...skipping 21 matching lines...) Expand all
1992 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { 2008 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) {
1993 return _parsedUnitState == CacheState.INVALID; 2009 return _parsedUnitState == CacheState.INVALID;
1994 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { 2010 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) {
1995 return _publicNamespaceState == CacheState.INVALID; 2011 return _publicNamespaceState == CacheState.INVALID;
1996 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) { 2012 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) {
1997 return _scanErrorsState == CacheState.INVALID; 2013 return _scanErrorsState == CacheState.INVALID;
1998 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { 2014 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
1999 return _sourceKindState == CacheState.INVALID; 2015 return _sourceKindState == CacheState.INVALID;
2000 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) { 2016 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) {
2001 return _tokenStreamState == CacheState.INVALID; 2017 return _tokenStreamState == CacheState.INVALID;
2002 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(d escriptor, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICAT ION_ERRORS) || identical(descriptor, DartEntry.HINTS)) { 2018 } else if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS) || identica l(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descriptor, DartEntry.RE SOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICATION_ERRORS) || identica l(descriptor, DartEntry.HINTS)) {
2003 DartEntryImpl_ResolutionState state = _resolutionState; 2019 DartEntryImpl_ResolutionState state = _resolutionState;
2004 while (state != null) { 2020 while (state != null) {
2005 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { 2021 if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS)) {
2022 return state._buildElementErrorsState == CacheState.INVALID;
2023 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
2006 return state._resolutionErrorsState == CacheState.INVALID; 2024 return state._resolutionErrorsState == CacheState.INVALID;
2007 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 2025 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
2008 return state._resolvedUnitState == CacheState.INVALID; 2026 return state._resolvedUnitState == CacheState.INVALID;
2009 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 2027 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
2010 return state._verificationErrorsState == CacheState.INVALID; 2028 return state._verificationErrorsState == CacheState.INVALID;
2011 } else if (identical(descriptor, DartEntry.HINTS)) { 2029 } else if (identical(descriptor, DartEntry.HINTS)) {
2012 return state._hintsState == CacheState.INVALID; 2030 return state._hintsState == CacheState.INVALID;
2013 } 2031 }
2014 } 2032 }
2015 return false; 2033 return false;
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 * Set the state of the data represented by the given descriptor in the contex t of the given 2372 * Set the state of the data represented by the given descriptor in the contex t of the given
2355 * library to the given state. 2373 * library to the given state.
2356 * 2374 *
2357 * @param descriptor the descriptor representing the data whose state is to be set 2375 * @param descriptor the descriptor representing the data whose state is to be set
2358 * @param librarySource the source of the defining compilation unit of the lib rary that is the 2376 * @param librarySource the source of the defining compilation unit of the lib rary that is the
2359 * context for the data 2377 * context for the data
2360 * @param cacheState the new state of the data represented by the given descri ptor 2378 * @param cacheState the new state of the data represented by the given descri ptor
2361 */ 2379 */
2362 void setStateInLibrary(DataDescriptor descriptor, Source librarySource, CacheS tate cacheState) { 2380 void setStateInLibrary(DataDescriptor descriptor, Source librarySource, CacheS tate cacheState) {
2363 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou rce); 2381 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou rce);
2364 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { 2382 if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS)) {
2383 state._buildElementErrors = updatedValue(cacheState, state._buildElementEr rors, AnalysisError.NO_ERRORS);
2384 state._buildElementErrorsState = cacheState;
2385 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
2365 state._resolutionErrors = updatedValue(cacheState, state._resolutionErrors , AnalysisError.NO_ERRORS); 2386 state._resolutionErrors = updatedValue(cacheState, state._resolutionErrors , AnalysisError.NO_ERRORS);
2366 state._resolutionErrorsState = cacheState; 2387 state._resolutionErrorsState = cacheState;
2367 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 2388 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
2368 state._resolvedUnit = updatedValue(cacheState, state._resolvedUnit, null); 2389 state._resolvedUnit = updatedValue(cacheState, state._resolvedUnit, null);
2369 state._resolvedUnitState = cacheState; 2390 state._resolvedUnitState = cacheState;
2370 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 2391 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
2371 state._verificationErrors = updatedValue(cacheState, state._verificationEr rors, AnalysisError.NO_ERRORS); 2392 state._verificationErrors = updatedValue(cacheState, state._verificationEr rors, AnalysisError.NO_ERRORS);
2372 state._verificationErrorsState = cacheState; 2393 state._verificationErrorsState = cacheState;
2373 } else if (identical(descriptor, DartEntry.HINTS)) { 2394 } else if (identical(descriptor, DartEntry.HINTS)) {
2374 state._hints = updatedValue(cacheState, state._hints, AnalysisError.NO_ERR ORS); 2395 state._hints = updatedValue(cacheState, state._hints, AnalysisError.NO_ERR ORS);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2428 * Set the value of the data represented by the given descriptor in the contex t of the given 2449 * Set the value of the data represented by the given descriptor in the contex t of the given
2429 * library to the given value, and set the state of that data to [CacheState#V ALID]. 2450 * library to the given value, and set the state of that data to [CacheState#V ALID].
2430 * 2451 *
2431 * @param descriptor the descriptor representing which data is to have its val ue set 2452 * @param descriptor the descriptor representing which data is to have its val ue set
2432 * @param librarySource the source of the defining compilation unit of the lib rary that is the 2453 * @param librarySource the source of the defining compilation unit of the lib rary that is the
2433 * context for the data 2454 * context for the data
2434 * @param value the new value of the data represented by the given descriptor and library 2455 * @param value the new value of the data represented by the given descriptor and library
2435 */ 2456 */
2436 void setValueInLibrary(DataDescriptor descriptor, Source librarySource, Object value) { 2457 void setValueInLibrary(DataDescriptor descriptor, Source librarySource, Object value) {
2437 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou rce); 2458 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou rce);
2438 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { 2459 if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS)) {
2460 state._buildElementErrors = value == null ? AnalysisError.NO_ERRORS : (val ue as List<AnalysisError>);
2461 state._buildElementErrorsState = CacheState.VALID;
2462 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
2439 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<AnalysisError>); 2463 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<AnalysisError>);
2440 state._resolutionErrorsState = CacheState.VALID; 2464 state._resolutionErrorsState = CacheState.VALID;
2441 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 2465 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
2442 state._resolvedUnit = value as CompilationUnit; 2466 state._resolvedUnit = value as CompilationUnit;
2443 state._resolvedUnitState = CacheState.VALID; 2467 state._resolvedUnitState = CacheState.VALID;
2444 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 2468 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
2445 state._verificationErrors = value == null ? AnalysisError.NO_ERRORS : (val ue as List<AnalysisError>); 2469 state._verificationErrors = value == null ? AnalysisError.NO_ERRORS : (val ue as List<AnalysisError>);
2446 state._verificationErrorsState = CacheState.VALID; 2470 state._verificationErrorsState = CacheState.VALID;
2447 } else if (identical(descriptor, DartEntry.HINTS)) { 2471 } else if (identical(descriptor, DartEntry.HINTS)) {
2448 state._hints = value == null ? AnalysisError.NO_ERRORS : (value as List<An alysisError>); 2472 state._hints = value == null ? AnalysisError.NO_ERRORS : (value as List<An alysisError>);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
2588 DartEntryImpl_ResolutionState _nextState; 2612 DartEntryImpl_ResolutionState _nextState;
2589 2613
2590 /** 2614 /**
2591 * The source for the defining compilation unit of the library that contains t his unit. If this 2615 * The source for the defining compilation unit of the library that contains t his unit. If this
2592 * unit is the defining compilation unit for it's library, then this will be t he source for this 2616 * unit is the defining compilation unit for it's library, then this will be t he source for this
2593 * unit. 2617 * unit.
2594 */ 2618 */
2595 Source _librarySource; 2619 Source _librarySource;
2596 2620
2597 /** 2621 /**
2622 * The state of the cached errors reported while building an element model.
2623 */
2624 CacheState _buildElementErrorsState = CacheState.INVALID;
2625
2626 /**
2627 * The errors produced while building an element model, or an empty array if t he errors are not
2628 * currently cached.
2629 */
2630 List<AnalysisError> _buildElementErrors = AnalysisError.NO_ERRORS;
2631
2632 /**
2598 * The state of the cached resolved compilation unit. 2633 * The state of the cached resolved compilation unit.
2599 */ 2634 */
2600 CacheState _resolvedUnitState = CacheState.INVALID; 2635 CacheState _resolvedUnitState = CacheState.INVALID;
2601 2636
2602 /** 2637 /**
2603 * The resolved compilation unit, or `null` if the resolved compilation unit i s not 2638 * The resolved compilation unit, or `null` if the resolved compilation unit i s not
2604 * currently cached. 2639 * currently cached.
2605 */ 2640 */
2606 CompilationUnit _resolvedUnit; 2641 CompilationUnit _resolvedUnit;
2607 2642
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2639 List<AnalysisError> _hints = AnalysisError.NO_ERRORS; 2674 List<AnalysisError> _hints = AnalysisError.NO_ERRORS;
2640 2675
2641 /** 2676 /**
2642 * Set this state to be exactly like the given state, recursively copying the next state as 2677 * Set this state to be exactly like the given state, recursively copying the next state as
2643 * necessary. 2678 * necessary.
2644 * 2679 *
2645 * @param other the state to be copied 2680 * @param other the state to be copied
2646 */ 2681 */
2647 void copyFrom(DartEntryImpl_ResolutionState other) { 2682 void copyFrom(DartEntryImpl_ResolutionState other) {
2648 _librarySource = other._librarySource; 2683 _librarySource = other._librarySource;
2684 _buildElementErrorsState = other._buildElementErrorsState;
2685 _buildElementErrors = other._buildElementErrors;
2649 _resolvedUnitState = other._resolvedUnitState; 2686 _resolvedUnitState = other._resolvedUnitState;
2650 _resolvedUnit = other._resolvedUnit; 2687 _resolvedUnit = other._resolvedUnit;
2651 _resolutionErrorsState = other._resolutionErrorsState; 2688 _resolutionErrorsState = other._resolutionErrorsState;
2652 _resolutionErrors = other._resolutionErrors; 2689 _resolutionErrors = other._resolutionErrors;
2653 _verificationErrorsState = other._verificationErrorsState; 2690 _verificationErrorsState = other._verificationErrorsState;
2654 _verificationErrors = other._verificationErrors; 2691 _verificationErrors = other._verificationErrors;
2655 _hintsState = other._hintsState; 2692 _hintsState = other._hintsState;
2656 _hints = other._hints; 2693 _hints = other._hints;
2657 if (other._nextState != null) { 2694 if (other._nextState != null) {
2658 _nextState = new DartEntryImpl_ResolutionState(); 2695 _nextState = new DartEntryImpl_ResolutionState();
2659 _nextState.copyFrom(other._nextState); 2696 _nextState.copyFrom(other._nextState);
2660 } 2697 }
2661 } 2698 }
2662 2699
2663 /** 2700 /**
2664 * Flush any AST structures being maintained by this state. 2701 * Flush any AST structures being maintained by this state.
2665 */ 2702 */
2666 void flushAstStructures() { 2703 void flushAstStructures() {
2667 if (_resolvedUnitState == CacheState.VALID) { 2704 if (_resolvedUnitState == CacheState.VALID) {
2668 _resolvedUnitState = CacheState.FLUSHED; 2705 _resolvedUnitState = CacheState.FLUSHED;
2669 _resolvedUnit = null; 2706 _resolvedUnit = null;
2670 } 2707 }
2671 if (_nextState != null) { 2708 if (_nextState != null) {
2672 _nextState.flushAstStructures(); 2709 _nextState.flushAstStructures();
2673 } 2710 }
2674 } 2711 }
2675 2712
2676 bool get hasErrorState => _resolvedUnitState == CacheState.ERROR || _resolutio nErrorsState == CacheState.ERROR || _verificationErrorsState == CacheState.ERROR || _hintsState == CacheState.ERROR || (_nextState != null && _nextState.hasErro rState); 2713 bool get hasErrorState => _buildElementErrorsState == CacheState.ERROR || _res olvedUnitState == CacheState.ERROR || _resolutionErrorsState == CacheState.ERROR || _verificationErrorsState == CacheState.ERROR || _hintsState == CacheState.ER ROR || (_nextState != null && _nextState.hasErrorState);
2677 2714
2678 /** 2715 /**
2679 * Invalidate all of the resolution information associated with the compilatio n unit. 2716 * Invalidate all of the resolution information associated with the compilatio n unit.
2680 */ 2717 */
2681 void invalidateAllResolutionInformation() { 2718 void invalidateAllResolutionInformation() {
2682 _nextState = null; 2719 _nextState = null;
2683 _librarySource = null; 2720 _librarySource = null;
2721 _buildElementErrorsState = CacheState.INVALID;
2722 _buildElementErrors = AnalysisError.NO_ERRORS;
2684 _resolvedUnitState = CacheState.INVALID; 2723 _resolvedUnitState = CacheState.INVALID;
2685 _resolvedUnit = null; 2724 _resolvedUnit = null;
2686 _resolutionErrorsState = CacheState.INVALID; 2725 _resolutionErrorsState = CacheState.INVALID;
2687 _resolutionErrors = AnalysisError.NO_ERRORS; 2726 _resolutionErrors = AnalysisError.NO_ERRORS;
2688 _verificationErrorsState = CacheState.INVALID; 2727 _verificationErrorsState = CacheState.INVALID;
2689 _verificationErrors = AnalysisError.NO_ERRORS; 2728 _verificationErrors = AnalysisError.NO_ERRORS;
2690 _hintsState = CacheState.INVALID; 2729 _hintsState = CacheState.INVALID;
2691 _hints = AnalysisError.NO_ERRORS; 2730 _hints = AnalysisError.NO_ERRORS;
2692 } 2731 }
2693 2732
2694 /** 2733 /**
2695 * Record that an error occurred while attempting to scan or parse the entry r epresented by this 2734 * Record that an error occurred while attempting to scan or parse the entry r epresented by this
2696 * entry. This will set the state of all resolution-based information as being in error, but 2735 * entry. This will set the state of all resolution-based information as being in error, but
2697 * will not change the state of any parse results. 2736 * will not change the state of any parse results.
2698 */ 2737 */
2699 void recordResolutionError() { 2738 void recordResolutionError() {
2739 _buildElementErrorsState = CacheState.ERROR;
2740 _buildElementErrors = AnalysisError.NO_ERRORS;
2700 _resolvedUnitState = CacheState.ERROR; 2741 _resolvedUnitState = CacheState.ERROR;
2701 _resolvedUnit = null; 2742 _resolvedUnit = null;
2702 _resolutionErrorsState = CacheState.ERROR; 2743 _resolutionErrorsState = CacheState.ERROR;
2703 _resolutionErrors = AnalysisError.NO_ERRORS; 2744 _resolutionErrors = AnalysisError.NO_ERRORS;
2704 _verificationErrorsState = CacheState.ERROR; 2745 _verificationErrorsState = CacheState.ERROR;
2705 _verificationErrors = AnalysisError.NO_ERRORS; 2746 _verificationErrors = AnalysisError.NO_ERRORS;
2706 _hintsState = CacheState.ERROR; 2747 _hintsState = CacheState.ERROR;
2707 _hints = AnalysisError.NO_ERRORS; 2748 _hints = AnalysisError.NO_ERRORS;
2708 if (_nextState != null) { 2749 if (_nextState != null) {
2709 _nextState.recordResolutionError(); 2750 _nextState.recordResolutionError();
2710 } 2751 }
2711 } 2752 }
2712 2753
2713 /** 2754 /**
2714 * Record that an in-process parse has stopped without recording results becau se the results 2755 * Record that an in-process parse has stopped without recording results becau se the results
2715 * were invalidated before they could be recorded. 2756 * were invalidated before they could be recorded.
2716 */ 2757 */
2717 void recordResolutionNotInProcess() { 2758 void recordResolutionNotInProcess() {
2759 if (_buildElementErrorsState == CacheState.IN_PROCESS) {
2760 _buildElementErrorsState = CacheState.INVALID;
2761 }
2718 if (_resolvedUnitState == CacheState.IN_PROCESS) { 2762 if (_resolvedUnitState == CacheState.IN_PROCESS) {
2719 _resolvedUnitState = CacheState.INVALID; 2763 _resolvedUnitState = CacheState.INVALID;
2720 } 2764 }
2721 if (_resolutionErrorsState == CacheState.IN_PROCESS) { 2765 if (_resolutionErrorsState == CacheState.IN_PROCESS) {
2722 _resolutionErrorsState = CacheState.INVALID; 2766 _resolutionErrorsState = CacheState.INVALID;
2723 } 2767 }
2724 if (_verificationErrorsState == CacheState.IN_PROCESS) { 2768 if (_verificationErrorsState == CacheState.IN_PROCESS) {
2725 _verificationErrorsState = CacheState.INVALID; 2769 _verificationErrorsState = CacheState.INVALID;
2726 } 2770 }
2727 if (_hintsState == CacheState.IN_PROCESS) { 2771 if (_hintsState == CacheState.IN_PROCESS) {
2728 _hintsState = CacheState.INVALID; 2772 _hintsState = CacheState.INVALID;
2729 } 2773 }
2730 if (_nextState != null) { 2774 if (_nextState != null) {
2731 _nextState.recordResolutionNotInProcess(); 2775 _nextState.recordResolutionNotInProcess();
2732 } 2776 }
2733 } 2777 }
2734 2778
2735 /** 2779 /**
2736 * Write a textual representation of this state to the given builder. The resu lt will only be 2780 * Write a textual representation of this state to the given builder. The resu lt will only be
2737 * used for debugging purposes. 2781 * used for debugging purposes.
2738 * 2782 *
2739 * @param builder the builder to which the text should be written 2783 * @param builder the builder to which the text should be written
2740 */ 2784 */
2741 void writeOn(JavaStringBuilder builder) { 2785 void writeOn(JavaStringBuilder builder) {
2742 if (_librarySource != null) { 2786 if (_librarySource != null) {
2787 builder.append("; buildElementErrors = ");
2788 builder.append(_buildElementErrorsState);
2743 builder.append("; resolvedUnit = "); 2789 builder.append("; resolvedUnit = ");
2744 builder.append(_resolvedUnitState); 2790 builder.append(_resolvedUnitState);
2745 builder.append("; resolutionErrors = "); 2791 builder.append("; resolutionErrors = ");
2746 builder.append(_resolutionErrorsState); 2792 builder.append(_resolutionErrorsState);
2747 builder.append("; verificationErrors = "); 2793 builder.append("; verificationErrors = ");
2748 builder.append(_verificationErrorsState); 2794 builder.append(_verificationErrorsState);
2749 builder.append("; hints = "); 2795 builder.append("; hints = ");
2750 builder.append(_hintsState); 2796 builder.append(_hintsState);
2751 if (_nextState != null) { 2797 if (_nextState != null) {
2752 _nextState.writeOn(builder); 2798 _nextState.writeOn(builder);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2833 * The data descriptor representing the list of referenced libraries. 2879 * The data descriptor representing the list of referenced libraries.
2834 */ 2880 */
2835 static final DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescr iptor<List<Source>>("HtmlEntry.REFERENCED_LIBRARIES"); 2881 static final DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescr iptor<List<Source>>("HtmlEntry.REFERENCED_LIBRARIES");
2836 2882
2837 /** 2883 /**
2838 * The data descriptor representing the errors resulting from resolving the so urce. 2884 * The data descriptor representing the errors resulting from resolving the so urce.
2839 */ 2885 */
2840 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataD escriptor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS"); 2886 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataD escriptor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS");
2841 2887
2842 /** 2888 /**
2889 * The data descriptor representing the status of Polymer elements in the sour ce.
2890 */
2891 static final DataDescriptor<List<AnalysisError>> POLYMER_BUILD_ERRORS = new Da taDescriptor<List<AnalysisError>>("HtmlEntry.POLYMER_BUILD_ERRORS");
2892
2893 /**
2894 * The data descriptor representing the errors reported during Polymer resolut ion.
2895 */
2896 static final DataDescriptor<List<AnalysisError>> POLYMER_RESOLUTION_ERRORS = n ew DataDescriptor<List<AnalysisError>>("HtmlEntry.POLYMER_RESOLUTION_ERRORS");
2897
2898 /**
2843 * Return all of the errors associated with the compilation unit that are curr ently cached. 2899 * Return all of the errors associated with the compilation unit that are curr ently cached.
2844 * 2900 *
2845 * @return all of the errors associated with the compilation unit 2901 * @return all of the errors associated with the compilation unit
2846 */ 2902 */
2847 List<AnalysisError> get allErrors; 2903 List<AnalysisError> get allErrors;
2848 2904
2849 /** 2905 /**
2850 * Return a valid parsed unit, either an unresolved AST structure or the resul t of resolving the 2906 * Return a valid parsed unit, either an unresolved AST structure or the resul t of resolving the
2851 * AST structure, or `null` if there is no parsed unit available. 2907 * AST structure, or `null` if there is no parsed unit available.
2852 * 2908 *
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2971 */ 3027 */
2972 CacheState _hintsState = CacheState.INVALID; 3028 CacheState _hintsState = CacheState.INVALID;
2973 3029
2974 /** 3030 /**
2975 * The hints produced while auditing the compilation unit, or an empty array i f the hints are not 3031 * The hints produced while auditing the compilation unit, or an empty array i f the hints are not
2976 * currently cached. 3032 * currently cached.
2977 */ 3033 */
2978 List<AnalysisError> _hints = AnalysisError.NO_ERRORS; 3034 List<AnalysisError> _hints = AnalysisError.NO_ERRORS;
2979 3035
2980 /** 3036 /**
3037 * The state of the Polymer elements.
3038 */
3039 CacheState _polymerBuildErrorsState = CacheState.INVALID;
3040
3041 /**
3042 * The hints produced while performing Polymer HTML elements building, or an e mpty array if the
3043 * error are not currently cached.
3044 */
3045 List<AnalysisError> _polymerBuildErrors = AnalysisError.NO_ERRORS;
3046
3047 /**
3048 * The state of the Polymer resolution errors.
3049 */
3050 CacheState _polymerResolutionErrorsState = CacheState.INVALID;
3051
3052 /**
3053 * The hints produced while performing Polymer resolution, or an empty array i f the error are not
3054 * currently cached.
3055 */
3056 List<AnalysisError> _polymerResolutionErrors = AnalysisError.NO_ERRORS;
3057
3058 /**
2981 * Flush any AST structures being maintained by this entry. 3059 * Flush any AST structures being maintained by this entry.
2982 */ 3060 */
2983 void flushAstStructures() { 3061 void flushAstStructures() {
2984 if (_parsedUnitState == CacheState.VALID) { 3062 if (_parsedUnitState == CacheState.VALID) {
2985 _parsedUnitState = CacheState.FLUSHED; 3063 _parsedUnitState = CacheState.FLUSHED;
2986 _parsedUnit = null; 3064 _parsedUnit = null;
2987 } 3065 }
2988 if (_resolvedUnitState == CacheState.VALID) { 3066 if (_resolvedUnitState == CacheState.VALID) {
2989 _resolvedUnitState = CacheState.FLUSHED; 3067 _resolvedUnitState = CacheState.FLUSHED;
2990 _resolvedUnit = null; 3068 _resolvedUnit = null;
(...skipping 22 matching lines...) Expand all
3013 if (_angularErrors != null) { 3091 if (_angularErrors != null) {
3014 for (AnalysisError error in _angularErrors) { 3092 for (AnalysisError error in _angularErrors) {
3015 errors.add(error); 3093 errors.add(error);
3016 } 3094 }
3017 } 3095 }
3018 if (_hints != null) { 3096 if (_hints != null) {
3019 for (AnalysisError error in _hints) { 3097 for (AnalysisError error in _hints) {
3020 errors.add(error); 3098 errors.add(error);
3021 } 3099 }
3022 } 3100 }
3101 if (_polymerBuildErrors != null) {
3102 for (AnalysisError error in _polymerBuildErrors) {
3103 errors.add(error);
3104 }
3105 }
3106 if (_polymerResolutionErrors != null) {
3107 for (AnalysisError error in _polymerResolutionErrors) {
3108 errors.add(error);
3109 }
3110 }
3023 if (errors.length == 0) { 3111 if (errors.length == 0) {
3024 return AnalysisError.NO_ERRORS; 3112 return AnalysisError.NO_ERRORS;
3025 } 3113 }
3026 return new List.from(errors); 3114 return new List.from(errors);
3027 } 3115 }
3028 3116
3029 @override 3117 @override
3030 ht.HtmlUnit get anyParsedUnit { 3118 ht.HtmlUnit get anyParsedUnit {
3031 if (_parsedUnitState == CacheState.VALID) { 3119 if (_parsedUnitState == CacheState.VALID) {
3032 // parsedUnitAccessed = true; 3120 // parsedUnitAccessed = true;
(...skipping 26 matching lines...) Expand all
3059 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { 3147 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) {
3060 return _parsedUnitState; 3148 return _parsedUnitState;
3061 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { 3149 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) {
3062 return _resolvedUnitState; 3150 return _resolvedUnitState;
3063 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { 3151 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) {
3064 return _referencedLibrariesState; 3152 return _referencedLibrariesState;
3065 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { 3153 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) {
3066 return _resolutionErrorsState; 3154 return _resolutionErrorsState;
3067 } else if (identical(descriptor, HtmlEntry.HINTS)) { 3155 } else if (identical(descriptor, HtmlEntry.HINTS)) {
3068 return _hintsState; 3156 return _hintsState;
3157 } else if (identical(descriptor, HtmlEntry.POLYMER_BUILD_ERRORS)) {
3158 return _polymerBuildErrorsState;
3159 } else if (identical(descriptor, HtmlEntry.POLYMER_RESOLUTION_ERRORS)) {
3160 return _polymerResolutionErrorsState;
3069 } 3161 }
3070 return super.getState(descriptor); 3162 return super.getState(descriptor);
3071 } 3163 }
3072 3164
3073 @override 3165 @override
3074 Object getValue(DataDescriptor descriptor) { 3166 Object getValue(DataDescriptor descriptor) {
3075 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) { 3167 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) {
3076 return _angularApplication; 3168 return _angularApplication;
3077 } else if (identical(descriptor, HtmlEntry.ANGULAR_COMPONENT)) { 3169 } else if (identical(descriptor, HtmlEntry.ANGULAR_COMPONENT)) {
3078 return _angularComponent; 3170 return _angularComponent;
3079 } else if (identical(descriptor, HtmlEntry.ANGULAR_ENTRY)) { 3171 } else if (identical(descriptor, HtmlEntry.ANGULAR_ENTRY)) {
3080 return _angularEntry; 3172 return _angularEntry;
3081 } else if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) { 3173 } else if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) {
3082 return _angularErrors; 3174 return _angularErrors;
3083 } else if (identical(descriptor, HtmlEntry.ELEMENT)) { 3175 } else if (identical(descriptor, HtmlEntry.ELEMENT)) {
3084 return _element; 3176 return _element;
3085 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) { 3177 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) {
3086 return _parseErrors; 3178 return _parseErrors;
3087 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { 3179 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) {
3088 return _parsedUnit; 3180 return _parsedUnit;
3089 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { 3181 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) {
3090 return _resolvedUnit; 3182 return _resolvedUnit;
3091 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { 3183 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) {
3092 return _referencedLibraries; 3184 return _referencedLibraries;
3093 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { 3185 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) {
3094 return _resolutionErrors; 3186 return _resolutionErrors;
3095 } else if (identical(descriptor, HtmlEntry.HINTS)) { 3187 } else if (identical(descriptor, HtmlEntry.HINTS)) {
3096 return _hints; 3188 return _hints;
3189 } else if (identical(descriptor, HtmlEntry.POLYMER_BUILD_ERRORS)) {
3190 return _polymerBuildErrors;
3191 } else if (identical(descriptor, HtmlEntry.POLYMER_RESOLUTION_ERRORS)) {
3192 return _polymerResolutionErrors;
3097 } 3193 }
3098 return super.getValue(descriptor); 3194 return super.getValue(descriptor);
3099 } 3195 }
3100 3196
3101 @override 3197 @override
3102 HtmlEntryImpl get writableCopy { 3198 HtmlEntryImpl get writableCopy {
3103 HtmlEntryImpl copy = new HtmlEntryImpl(); 3199 HtmlEntryImpl copy = new HtmlEntryImpl();
3104 copy.copyFrom(this); 3200 copy.copyFrom(this);
3105 return copy; 3201 return copy;
3106 } 3202 }
(...skipping 13 matching lines...) Expand all
3120 } 3216 }
3121 3217
3122 /** 3218 /**
3123 * Invalidate all of the resolution information associated with the HTML file. 3219 * Invalidate all of the resolution information associated with the HTML file.
3124 */ 3220 */
3125 void invalidateAllResolutionInformation() { 3221 void invalidateAllResolutionInformation() {
3126 _angularEntry = null; 3222 _angularEntry = null;
3127 _angularEntryState = CacheState.INVALID; 3223 _angularEntryState = CacheState.INVALID;
3128 _angularErrors = AnalysisError.NO_ERRORS; 3224 _angularErrors = AnalysisError.NO_ERRORS;
3129 _angularErrorsState = CacheState.INVALID; 3225 _angularErrorsState = CacheState.INVALID;
3226 _polymerBuildErrors = AnalysisError.NO_ERRORS;
3227 _polymerBuildErrorsState = CacheState.INVALID;
3228 _polymerResolutionErrors = AnalysisError.NO_ERRORS;
3229 _polymerResolutionErrorsState = CacheState.INVALID;
3130 _element = null; 3230 _element = null;
3131 _elementState = CacheState.INVALID; 3231 _elementState = CacheState.INVALID;
3132 _resolutionErrors = AnalysisError.NO_ERRORS; 3232 _resolutionErrors = AnalysisError.NO_ERRORS;
3133 _resolutionErrorsState = CacheState.INVALID; 3233 _resolutionErrorsState = CacheState.INVALID;
3134 _hints = AnalysisError.NO_ERRORS; 3234 _hints = AnalysisError.NO_ERRORS;
3135 _hintsState = CacheState.INVALID; 3235 _hintsState = CacheState.INVALID;
3136 } 3236 }
3137 3237
3138 @override 3238 @override
3139 void recordContentError() { 3239 void recordContentError() {
(...skipping 16 matching lines...) Expand all
3156 /** 3256 /**
3157 * Record that an error was encountered while attempting to resolve the source associated with 3257 * Record that an error was encountered while attempting to resolve the source associated with
3158 * this entry. 3258 * this entry.
3159 */ 3259 */
3160 void recordResolutionError() { 3260 void recordResolutionError() {
3161 setState(HtmlEntry.ANGULAR_ERRORS, CacheState.ERROR); 3261 setState(HtmlEntry.ANGULAR_ERRORS, CacheState.ERROR);
3162 setState(HtmlEntry.RESOLVED_UNIT, CacheState.ERROR); 3262 setState(HtmlEntry.RESOLVED_UNIT, CacheState.ERROR);
3163 setState(HtmlEntry.ELEMENT, CacheState.ERROR); 3263 setState(HtmlEntry.ELEMENT, CacheState.ERROR);
3164 setState(HtmlEntry.RESOLUTION_ERRORS, CacheState.ERROR); 3264 setState(HtmlEntry.RESOLUTION_ERRORS, CacheState.ERROR);
3165 setState(HtmlEntry.HINTS, CacheState.ERROR); 3265 setState(HtmlEntry.HINTS, CacheState.ERROR);
3266 setState(HtmlEntry.POLYMER_BUILD_ERRORS, CacheState.ERROR);
3267 setState(HtmlEntry.POLYMER_RESOLUTION_ERRORS, CacheState.ERROR);
3166 } 3268 }
3167 3269
3168 @override 3270 @override
3169 void setState(DataDescriptor descriptor, CacheState state) { 3271 void setState(DataDescriptor descriptor, CacheState state) {
3170 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) { 3272 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) {
3171 _angularApplication = updatedValue(state, _angularApplication, null); 3273 _angularApplication = updatedValue(state, _angularApplication, null);
3172 _angularApplicationState = state; 3274 _angularApplicationState = state;
3173 } else if (identical(descriptor, HtmlEntry.ANGULAR_COMPONENT)) { 3275 } else if (identical(descriptor, HtmlEntry.ANGULAR_COMPONENT)) {
3174 _angularComponent = updatedValue(state, _angularComponent, null); 3276 _angularComponent = updatedValue(state, _angularComponent, null);
3175 _angularComponentState = state; 3277 _angularComponentState = state;
(...skipping 17 matching lines...) Expand all
3193 _resolvedUnitState = state; 3295 _resolvedUnitState = state;
3194 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { 3296 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) {
3195 _referencedLibraries = updatedValue(state, _referencedLibraries, Source.EM PTY_ARRAY); 3297 _referencedLibraries = updatedValue(state, _referencedLibraries, Source.EM PTY_ARRAY);
3196 _referencedLibrariesState = state; 3298 _referencedLibrariesState = state;
3197 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { 3299 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) {
3198 _resolutionErrors = updatedValue(state, _resolutionErrors, AnalysisError.N O_ERRORS); 3300 _resolutionErrors = updatedValue(state, _resolutionErrors, AnalysisError.N O_ERRORS);
3199 _resolutionErrorsState = state; 3301 _resolutionErrorsState = state;
3200 } else if (identical(descriptor, HtmlEntry.HINTS)) { 3302 } else if (identical(descriptor, HtmlEntry.HINTS)) {
3201 _hints = updatedValue(state, _hints, AnalysisError.NO_ERRORS); 3303 _hints = updatedValue(state, _hints, AnalysisError.NO_ERRORS);
3202 _hintsState = state; 3304 _hintsState = state;
3305 } else if (identical(descriptor, HtmlEntry.POLYMER_BUILD_ERRORS)) {
3306 _polymerBuildErrors = updatedValue(state, _polymerBuildErrors, null);
3307 _polymerBuildErrorsState = state;
3308 } else if (identical(descriptor, HtmlEntry.POLYMER_RESOLUTION_ERRORS)) {
3309 _polymerResolutionErrors = updatedValue(state, _polymerResolutionErrors, n ull);
3310 _polymerResolutionErrorsState = state;
3203 } else { 3311 } else {
3204 super.setState(descriptor, state); 3312 super.setState(descriptor, state);
3205 } 3313 }
3206 } 3314 }
3207 3315
3208 @override 3316 @override
3209 void setValue(DataDescriptor descriptor, Object value) { 3317 void setValue(DataDescriptor descriptor, Object value) {
3210 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) { 3318 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) {
3211 _angularApplication = value as AngularApplication; 3319 _angularApplication = value as AngularApplication;
3212 _angularApplicationState = CacheState.VALID; 3320 _angularApplicationState = CacheState.VALID;
(...skipping 20 matching lines...) Expand all
3233 _resolvedUnitState = CacheState.VALID; 3341 _resolvedUnitState = CacheState.VALID;
3234 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { 3342 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) {
3235 _referencedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List <Source>); 3343 _referencedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List <Source>);
3236 _referencedLibrariesState = CacheState.VALID; 3344 _referencedLibrariesState = CacheState.VALID;
3237 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { 3345 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) {
3238 _resolutionErrors = value as List<AnalysisError>; 3346 _resolutionErrors = value as List<AnalysisError>;
3239 _resolutionErrorsState = CacheState.VALID; 3347 _resolutionErrorsState = CacheState.VALID;
3240 } else if (identical(descriptor, HtmlEntry.HINTS)) { 3348 } else if (identical(descriptor, HtmlEntry.HINTS)) {
3241 _hints = value as List<AnalysisError>; 3349 _hints = value as List<AnalysisError>;
3242 _hintsState = CacheState.VALID; 3350 _hintsState = CacheState.VALID;
3351 } else if (identical(descriptor, HtmlEntry.POLYMER_BUILD_ERRORS)) {
3352 _polymerBuildErrors = value as List<AnalysisError>;
3353 _polymerBuildErrorsState = CacheState.VALID;
3354 } else if (identical(descriptor, HtmlEntry.POLYMER_RESOLUTION_ERRORS)) {
3355 _polymerResolutionErrors = value as List<AnalysisError>;
3356 _polymerResolutionErrorsState = CacheState.VALID;
3243 } else { 3357 } else {
3244 super.setValue(descriptor, value); 3358 super.setValue(descriptor, value);
3245 } 3359 }
3246 } 3360 }
3247 3361
3248 @override 3362 @override
3249 void copyFrom(SourceEntryImpl entry) { 3363 void copyFrom(SourceEntryImpl entry) {
3250 super.copyFrom(entry); 3364 super.copyFrom(entry);
3251 HtmlEntryImpl other = entry as HtmlEntryImpl; 3365 HtmlEntryImpl other = entry as HtmlEntryImpl;
3252 _angularApplicationState = other._angularApplicationState; 3366 _angularApplicationState = other._angularApplicationState;
3253 _angularApplication = other._angularApplication; 3367 _angularApplication = other._angularApplication;
3254 _angularComponentState = other._angularComponentState; 3368 _angularComponentState = other._angularComponentState;
3255 _angularComponent = other._angularComponent; 3369 _angularComponent = other._angularComponent;
3256 _angularEntryState = other._angularEntryState; 3370 _angularEntryState = other._angularEntryState;
3257 _angularEntry = other._angularEntry; 3371 _angularEntry = other._angularEntry;
3258 _angularErrorsState = other._angularErrorsState; 3372 _angularErrorsState = other._angularErrorsState;
3259 _angularErrors = other._angularErrors; 3373 _angularErrors = other._angularErrors;
3260 _parseErrorsState = other._parseErrorsState; 3374 _parseErrorsState = other._parseErrorsState;
3261 _parseErrors = other._parseErrors; 3375 _parseErrors = other._parseErrors;
3262 _parsedUnitState = other._parsedUnitState; 3376 _parsedUnitState = other._parsedUnitState;
3263 _parsedUnit = other._parsedUnit; 3377 _parsedUnit = other._parsedUnit;
3264 _resolvedUnitState = other._resolvedUnitState; 3378 _resolvedUnitState = other._resolvedUnitState;
3265 _resolvedUnit = other._resolvedUnit; 3379 _resolvedUnit = other._resolvedUnit;
3266 _referencedLibrariesState = other._referencedLibrariesState; 3380 _referencedLibrariesState = other._referencedLibrariesState;
3267 _referencedLibraries = other._referencedLibraries; 3381 _referencedLibraries = other._referencedLibraries;
3382 _resolutionErrorsState = other._resolutionErrorsState;
3268 _resolutionErrors = other._resolutionErrors; 3383 _resolutionErrors = other._resolutionErrors;
3269 _resolutionErrorsState = other._resolutionErrorsState;
3270 _elementState = other._elementState; 3384 _elementState = other._elementState;
3271 _element = other._element; 3385 _element = other._element;
3386 _hintsState = other._hintsState;
3272 _hints = other._hints; 3387 _hints = other._hints;
3273 _hintsState = other._hintsState; 3388 _polymerBuildErrorsState = other._polymerBuildErrorsState;
3389 _polymerBuildErrors = other._polymerBuildErrors;
3390 _polymerResolutionErrorsState = other._polymerResolutionErrorsState;
3391 _polymerResolutionErrors = other._polymerResolutionErrors;
3274 } 3392 }
3275 3393
3276 @override 3394 @override
3277 bool get hasErrorState => super.hasErrorState || _parsedUnitState == CacheStat e.ERROR || _resolvedUnitState == CacheState.ERROR || _parseErrorsState == CacheS tate.ERROR || _resolutionErrorsState == CacheState.ERROR || _referencedLibraries State == CacheState.ERROR || _elementState == CacheState.ERROR || _angularErrors State == CacheState.ERROR || _hintsState == CacheState.ERROR; 3395 bool get hasErrorState => super.hasErrorState || _parsedUnitState == CacheStat e.ERROR || _resolvedUnitState == CacheState.ERROR || _parseErrorsState == CacheS tate.ERROR || _resolutionErrorsState == CacheState.ERROR || _referencedLibraries State == CacheState.ERROR || _elementState == CacheState.ERROR || _angularErrors State == CacheState.ERROR || _hintsState == CacheState.ERROR || _polymerBuildErr orsState == CacheState.ERROR || _polymerResolutionErrorsState == CacheState.ERRO R;
3278 3396
3279 @override 3397 @override
3280 void writeOn(JavaStringBuilder builder) { 3398 void writeOn(JavaStringBuilder builder) {
3281 builder.append("Html: "); 3399 builder.append("Html: ");
3282 super.writeOn(builder); 3400 super.writeOn(builder);
3283 builder.append("; parseErrors = "); 3401 builder.append("; parseErrors = ");
3284 builder.append(_parseErrorsState); 3402 builder.append(_parseErrorsState);
3285 builder.append("; parsedUnit = "); 3403 builder.append("; parsedUnit = ");
3286 builder.append(_parsedUnitState); 3404 builder.append(_parsedUnitState);
3287 builder.append("; resolvedUnit = "); 3405 builder.append("; resolvedUnit = ");
3288 builder.append(_resolvedUnitState); 3406 builder.append(_resolvedUnitState);
3289 builder.append("; resolutionErrors = "); 3407 builder.append("; resolutionErrors = ");
3290 builder.append(_resolutionErrorsState); 3408 builder.append(_resolutionErrorsState);
3291 builder.append("; referencedLibraries = "); 3409 builder.append("; referencedLibraries = ");
3292 builder.append(_referencedLibrariesState); 3410 builder.append(_referencedLibrariesState);
3293 builder.append("; element = "); 3411 builder.append("; element = ");
3294 builder.append(_elementState); 3412 builder.append(_elementState);
3295 builder.append("; angularApplication = "); 3413 builder.append("; angularApplication = ");
3296 builder.append(_angularApplicationState); 3414 builder.append(_angularApplicationState);
3297 builder.append("; angularComponent = "); 3415 builder.append("; angularComponent = ");
3298 builder.append(_angularComponentState); 3416 builder.append(_angularComponentState);
3299 builder.append("; angularEntry = "); 3417 builder.append("; angularEntry = ");
3300 builder.append(_angularEntryState); 3418 builder.append(_angularEntryState);
3301 builder.append("; angularErrors = "); 3419 builder.append("; angularErrors = ");
3302 builder.append(_angularErrorsState); 3420 builder.append(_angularErrorsState);
3421 builder.append("; polymerBuildErrors = ");
3422 builder.append(_polymerBuildErrorsState);
3423 builder.append("; polymerResolutionErrors = ");
3424 builder.append(_polymerResolutionErrorsState);
3303 } 3425 }
3304 } 3426 }
3305 3427
3306 /** 3428 /**
3307 * The enumerated type `RetentionPriority` represents the priority of data in th e cache in 3429 * The enumerated type `RetentionPriority` represents the priority of data in th e cache in
3308 * terms of the desirability of retaining some specified data about a specified source. 3430 * terms of the desirability of retaining some specified data about a specified source.
3309 */ 3431 */
3310 class RetentionPriority extends Enum<RetentionPriority> { 3432 class RetentionPriority extends Enum<RetentionPriority> {
3311 /** 3433 /**
3312 * A priority indicating that a given piece of data can be removed from the ca che without 3434 * A priority indicating that a given piece of data can be removed from the ca che without
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
3933 for (Source source in removedSources) { 4055 for (Source source in removedSources) {
3934 _sourceRemoved(source); 4056 _sourceRemoved(source);
3935 } 4057 }
3936 if (addedDartSource) { 4058 if (addedDartSource) {
3937 // TODO(brianwilkerson) This is hugely inefficient, but we need to re-anal yze any libraries 4059 // TODO(brianwilkerson) This is hugely inefficient, but we need to re-anal yze any libraries
3938 // that might have been referencing the not-yet-existing source that was j ust added. Longer 4060 // that might have been referencing the not-yet-existing source that was j ust added. Longer
3939 // term we need to keep track of which libraries are referencing non-exist ing sources and 4061 // term we need to keep track of which libraries are referencing non-exist ing sources and
3940 // only re-analyze those libraries. 4062 // only re-analyze those libraries.
3941 // logInformation("Added Dart sources, invalidating all resolution information"); 4063 // logInformation("Added Dart sources, invalidating all resolution information");
3942 List<Source> sourcesToInvalidate = new List<Source>(); 4064 List<Source> sourcesToInvalidate = new List<Source>();
3943 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { 4065 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
3944 Source source = mapEntry.getKey(); 4066 while (iterator.moveNext()) {
3945 SourceEntry sourceEntry = mapEntry.getValue(); 4067 Source source = iterator.key;
4068 SourceEntry sourceEntry = iterator.value;
3946 if (!source.isInSystemLibrary && sourceEntry is DartEntry) { 4069 if (!source.isInSystemLibrary && sourceEntry is DartEntry) {
3947 sourcesToInvalidate.add(source); 4070 sourcesToInvalidate.add(source);
3948 } 4071 }
3949 } 4072 }
3950 int count = sourcesToInvalidate.length; 4073 int count = sourcesToInvalidate.length;
3951 for (int i = 0; i < count; i++) { 4074 for (int i = 0; i < count; i++) {
3952 Source source = sourcesToInvalidate[i]; 4075 Source source = sourcesToInvalidate[i];
3953 DartEntry dartEntry = _getReadableDartEntry(source); 4076 DartEntry dartEntry = _getReadableDartEntry(source);
3954 _removeFromParts(source, dartEntry); 4077 _removeFromParts(source, dartEntry);
3955 DartEntryImpl dartCopy = dartEntry.writableCopy; 4078 DartEntryImpl dartCopy = dartEntry.writableCopy;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
4127 return source.exists(); 4250 return source.exists();
4128 } 4251 }
4129 4252
4130 @override 4253 @override
4131 AnalysisContext extractContext(SourceContainer container) => extractContextInt o(container, AnalysisEngine.instance.createAnalysisContext() as InternalAnalysis Context); 4254 AnalysisContext extractContext(SourceContainer container) => extractContextInt o(container, AnalysisEngine.instance.createAnalysisContext() as InternalAnalysis Context);
4132 4255
4133 @override 4256 @override
4134 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) { 4257 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) {
4135 List<Source> sourcesToRemove = new List<Source>(); 4258 List<Source> sourcesToRemove = new List<Source>();
4136 // Move sources in the specified directory to the new context 4259 // Move sources in the specified directory to the new context
4137 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 4260 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
4138 Source source = entry.getKey(); 4261 while (iterator.moveNext()) {
4262 Source source = iterator.key;
4263 SourceEntry sourceEntry = iterator.value;
4139 if (container.contains(source)) { 4264 if (container.contains(source)) {
4140 sourcesToRemove.add(source); 4265 sourcesToRemove.add(source);
4141 newContext.addSourceInfo(source, entry.getValue().writableCopy); 4266 newContext.addSourceInfo(source, sourceEntry.writableCopy);
4142 } 4267 }
4143 } 4268 }
4144 return newContext; 4269 return newContext;
4145 } 4270 }
4146 4271
4147 @override 4272 @override
4148 AnalysisOptions get analysisOptions => _options; 4273 AnalysisOptions get analysisOptions => _options;
4149 4274
4150 @override 4275 @override
4151 AngularApplication getAngularApplicationWithHtml(Source htmlSource) { 4276 AngularApplication getAngularApplicationWithHtml(Source htmlSource) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
4234 List<Source> getHtmlFilesReferencing(Source source) { 4359 List<Source> getHtmlFilesReferencing(Source source) {
4235 SourceKind sourceKind = getKindOf(source); 4360 SourceKind sourceKind = getKindOf(source);
4236 if (sourceKind == null) { 4361 if (sourceKind == null) {
4237 return Source.EMPTY_ARRAY; 4362 return Source.EMPTY_ARRAY;
4238 } 4363 }
4239 List<Source> htmlSources = new List<Source>(); 4364 List<Source> htmlSources = new List<Source>();
4240 while (true) { 4365 while (true) {
4241 if (sourceKind == SourceKind.LIBRARY) { 4366 if (sourceKind == SourceKind.LIBRARY) {
4242 } else if (sourceKind == SourceKind.PART) { 4367 } else if (sourceKind == SourceKind.PART) {
4243 List<Source> librarySources = getLibrariesContaining(source); 4368 List<Source> librarySources = getLibrariesContaining(source);
4244 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 4369 MapIterator<Source, SourceEntry> partIterator = _cache.iterator();
4245 SourceEntry sourceEntry = entry.getValue(); 4370 while (partIterator.moveNext()) {
4371 SourceEntry sourceEntry = partIterator.value;
4246 if (sourceEntry.kind == SourceKind.HTML) { 4372 if (sourceEntry.kind == SourceKind.HTML) {
4247 List<Source> referencedLibraries = (sourceEntry as HtmlEntry).getVal ue(HtmlEntry.REFERENCED_LIBRARIES); 4373 List<Source> referencedLibraries = (sourceEntry as HtmlEntry).getVal ue(HtmlEntry.REFERENCED_LIBRARIES);
4248 if (_containsAny(referencedLibraries, librarySources)) { 4374 if (_containsAny(referencedLibraries, librarySources)) {
4249 htmlSources.add(entry.getKey()); 4375 htmlSources.add(partIterator.key);
4250 } 4376 }
4251 } 4377 }
4252 } 4378 }
4253 } 4379 }
4254 break; 4380 break;
4255 } 4381 }
4256 if (htmlSources.isEmpty) { 4382 if (htmlSources.isEmpty) {
4257 return Source.EMPTY_ARRAY; 4383 return Source.EMPTY_ARRAY;
4258 } 4384 }
4259 return new List.from(htmlSources); 4385 return new List.from(htmlSources);
4260 } 4386 }
4261 4387
4262 @override 4388 @override
4263 List<Source> get htmlSources => _getSources(SourceKind.HTML); 4389 List<Source> get htmlSources => _getSources(SourceKind.HTML);
4264 4390
4265 @override 4391 @override
4266 SourceKind getKindOf(Source source) { 4392 SourceKind getKindOf(Source source) {
4267 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source); 4393 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source);
4268 if (sourceEntry == null) { 4394 if (sourceEntry == null) {
4269 return SourceKind.UNKNOWN; 4395 return SourceKind.UNKNOWN;
4270 } 4396 }
4271 return sourceEntry.kind; 4397 return sourceEntry.kind;
4272 } 4398 }
4273 4399
4274 @override 4400 @override
4275 List<Source> get launchableClientLibrarySources { 4401 List<Source> get launchableClientLibrarySources {
4276 // TODO(brianwilkerson) This needs to filter out libraries that do not refer ence dart:html, 4402 // TODO(brianwilkerson) This needs to filter out libraries that do not refer ence dart:html,
4277 // either directly or indirectly. 4403 // either directly or indirectly.
4278 List<Source> sources = new List<Source>(); 4404 List<Source> sources = new List<Source>();
4279 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 4405 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
4280 Source source = entry.getKey(); 4406 while (iterator.moveNext()) {
4281 SourceEntry sourceEntry = entry.getValue(); 4407 Source source = iterator.key;
4408 SourceEntry sourceEntry = iterator.value;
4282 if (sourceEntry.kind == SourceKind.LIBRARY && !source.isInSystemLibrary) { 4409 if (sourceEntry.kind == SourceKind.LIBRARY && !source.isInSystemLibrary) {
4283 // DartEntry dartEntry = (DartEntry) sourceEntry; 4410 // DartEntry dartEntry = (DartEntry) sourceEntry;
4284 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && dartEntry .getValue(DartEntry.IS_CLIENT)) { 4411 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && dartEntry .getValue(DartEntry.IS_CLIENT)) {
4285 sources.add(source); 4412 sources.add(source);
4286 } 4413 }
4287 } 4414 }
4288 return new List.from(sources); 4415 return new List.from(sources);
4289 } 4416 }
4290 4417
4291 @override 4418 @override
4292 List<Source> get launchableServerLibrarySources { 4419 List<Source> get launchableServerLibrarySources {
4293 // TODO(brianwilkerson) This needs to filter out libraries that reference da rt:html, either 4420 // TODO(brianwilkerson) This needs to filter out libraries that reference da rt:html, either
4294 // directly or indirectly. 4421 // directly or indirectly.
4295 List<Source> sources = new List<Source>(); 4422 List<Source> sources = new List<Source>();
4296 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 4423 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
4297 Source source = entry.getKey(); 4424 while (iterator.moveNext()) {
4298 SourceEntry sourceEntry = entry.getValue(); 4425 Source source = iterator.key;
4426 SourceEntry sourceEntry = iterator.value;
4299 if (sourceEntry.kind == SourceKind.LIBRARY && !source.isInSystemLibrary) { 4427 if (sourceEntry.kind == SourceKind.LIBRARY && !source.isInSystemLibrary) {
4300 // DartEntry dartEntry = (DartEntry) sourceEntry; 4428 // DartEntry dartEntry = (DartEntry) sourceEntry;
4301 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && !dartEntr y.getValue(DartEntry.IS_CLIENT)) { 4429 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && !dartEntr y.getValue(DartEntry.IS_CLIENT)) {
4302 sources.add(source); 4430 sources.add(source);
4303 } 4431 }
4304 } 4432 }
4305 return new List.from(sources); 4433 return new List.from(sources);
4306 } 4434 }
4307 4435
4308 @override 4436 @override
4309 List<Source> getLibrariesContaining(Source source) { 4437 List<Source> getLibrariesContaining(Source source) {
4310 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source); 4438 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source);
4311 if (sourceEntry is DartEntry) { 4439 if (sourceEntry is DartEntry) {
4312 return sourceEntry.getValue(DartEntry.CONTAINING_LIBRARIES); 4440 return sourceEntry.getValue(DartEntry.CONTAINING_LIBRARIES);
4313 } 4441 }
4314 return Source.EMPTY_ARRAY; 4442 return Source.EMPTY_ARRAY;
4315 } 4443 }
4316 4444
4317 @override 4445 @override
4318 List<Source> getLibrariesDependingOn(Source librarySource) { 4446 List<Source> getLibrariesDependingOn(Source librarySource) {
4319 List<Source> dependentLibraries = new List<Source>(); 4447 List<Source> dependentLibraries = new List<Source>();
4320 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 4448 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
4321 SourceEntry sourceEntry = entry.getValue(); 4449 while (iterator.moveNext()) {
4450 SourceEntry sourceEntry = iterator.value;
4322 if (sourceEntry.kind == SourceKind.LIBRARY) { 4451 if (sourceEntry.kind == SourceKind.LIBRARY) {
4323 if (_contains((sourceEntry as DartEntry).getValue(DartEntry.EXPORTED_LIB RARIES), librarySource)) { 4452 if (_contains((sourceEntry as DartEntry).getValue(DartEntry.EXPORTED_LIB RARIES), librarySource)) {
4324 dependentLibraries.add(entry.getKey()); 4453 dependentLibraries.add(iterator.key);
4325 } 4454 }
4326 if (_contains((sourceEntry as DartEntry).getValue(DartEntry.IMPORTED_LIB RARIES), librarySource)) { 4455 if (_contains((sourceEntry as DartEntry).getValue(DartEntry.IMPORTED_LIB RARIES), librarySource)) {
4327 dependentLibraries.add(entry.getKey()); 4456 dependentLibraries.add(iterator.key);
4328 } 4457 }
4329 } 4458 }
4330 } 4459 }
4331 if (dependentLibraries.isEmpty) { 4460 if (dependentLibraries.isEmpty) {
4332 return Source.EMPTY_ARRAY; 4461 return Source.EMPTY_ARRAY;
4333 } 4462 }
4334 return new List.from(dependentLibraries); 4463 return new List.from(dependentLibraries);
4335 } 4464 }
4336 4465
4337 @override 4466 @override
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
4400 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); 4529 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace);
4401 _cache.put(source, dartCopy); 4530 _cache.put(source, dartCopy);
4402 } 4531 }
4403 } 4532 }
4404 return namespace; 4533 return namespace;
4405 } 4534 }
4406 4535
4407 @override 4536 @override
4408 List<Source> get refactoringUnsafeSources { 4537 List<Source> get refactoringUnsafeSources {
4409 List<Source> sources = new List<Source>(); 4538 List<Source> sources = new List<Source>();
4410 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 4539 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
4411 SourceEntry sourceEntry = entry.getValue(); 4540 while (iterator.moveNext()) {
4541 SourceEntry sourceEntry = iterator.value;
4412 if (sourceEntry is DartEntry) { 4542 if (sourceEntry is DartEntry) {
4413 if (!sourceEntry.isRefactoringSafe) { 4543 if (!sourceEntry.isRefactoringSafe) {
4414 sources.add(entry.getKey()); 4544 sources.add(iterator.key);
4415 } 4545 }
4416 } 4546 }
4417 } 4547 }
4418 return new List.from(sources); 4548 return new List.from(sources);
4419 } 4549 }
4420 4550
4421 @override 4551 @override
4422 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l ibrary) { 4552 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l ibrary) {
4423 if (library == null) { 4553 if (library == null) {
4424 return null; 4554 return null;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4460 bool hintsEnabled = _options.hint; 4590 bool hintsEnabled = _options.hint;
4461 // 4591 //
4462 // Look for priority sources that need to be analyzed. 4592 // Look for priority sources that need to be analyzed.
4463 // 4593 //
4464 for (Source source in _priorityOrder) { 4594 for (Source source in _priorityOrder) {
4465 _getSourcesNeedingProcessing(source, _cache.get(source), true, hintsEnable d, sources); 4595 _getSourcesNeedingProcessing(source, _cache.get(source), true, hintsEnable d, sources);
4466 } 4596 }
4467 // 4597 //
4468 // Look for non-priority sources that need to be analyzed. 4598 // Look for non-priority sources that need to be analyzed.
4469 // 4599 //
4470 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 4600 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
4471 _getSourcesNeedingProcessing(entry.getKey(), entry.getValue(), false, hint sEnabled, sources); 4601 while (iterator.moveNext()) {
4602 _getSourcesNeedingProcessing(iterator.key, iterator.value, false, hintsEna bled, sources);
4472 } 4603 }
4473 return new List<Source>.from(sources); 4604 return new List<Source>.from(sources);
4474 } 4605 }
4475 4606
4476 @override 4607 @override
4477 AnalysisContentStatistics get statistics { 4608 AnalysisContentStatistics get statistics {
4478 bool hintsEnabled = _options.hint; 4609 bool hintsEnabled = _options.hint;
4479 AnalysisContentStatisticsImpl statistics = new AnalysisContentStatisticsImpl (); 4610 AnalysisContentStatisticsImpl statistics = new AnalysisContentStatisticsImpl ();
4480 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { 4611 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
4481 statistics.addSource(mapEntry.getKey()); 4612 while (iterator.moveNext()) {
4482 SourceEntry entry = mapEntry.getValue(); 4613 SourceEntry sourceEntry = iterator.value;
4483 if (entry is DartEntry) { 4614 if (sourceEntry is DartEntry) {
4484 Source source = mapEntry.getKey(); 4615 Source source = iterator.key;
4485 DartEntry dartEntry = entry; 4616 DartEntry dartEntry = sourceEntry;
4486 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); 4617 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND);
4487 // get library independent values 4618 // get library independent values
4488 statistics.putCacheItem(dartEntry, SourceEntry.LINE_INFO); 4619 statistics.putCacheItem(dartEntry, SourceEntry.LINE_INFO);
4489 statistics.putCacheItem(dartEntry, DartEntry.PARSE_ERRORS); 4620 statistics.putCacheItem(dartEntry, DartEntry.PARSE_ERRORS);
4490 statistics.putCacheItem(dartEntry, DartEntry.PARSED_UNIT); 4621 statistics.putCacheItem(dartEntry, DartEntry.PARSED_UNIT);
4491 statistics.putCacheItem(dartEntry, DartEntry.SOURCE_KIND); 4622 statistics.putCacheItem(dartEntry, DartEntry.SOURCE_KIND);
4492 if (kind == SourceKind.LIBRARY) { 4623 if (kind == SourceKind.LIBRARY) {
4493 statistics.putCacheItem(dartEntry, DartEntry.ELEMENT); 4624 statistics.putCacheItem(dartEntry, DartEntry.ELEMENT);
4494 statistics.putCacheItem(dartEntry, DartEntry.EXPORTED_LIBRARIES); 4625 statistics.putCacheItem(dartEntry, DartEntry.EXPORTED_LIBRARIES);
4495 statistics.putCacheItem(dartEntry, DartEntry.IMPORTED_LIBRARIES); 4626 statistics.putCacheItem(dartEntry, DartEntry.IMPORTED_LIBRARIES);
4496 statistics.putCacheItem(dartEntry, DartEntry.INCLUDED_PARTS); 4627 statistics.putCacheItem(dartEntry, DartEntry.INCLUDED_PARTS);
4497 statistics.putCacheItem(dartEntry, DartEntry.IS_CLIENT); 4628 statistics.putCacheItem(dartEntry, DartEntry.IS_CLIENT);
4498 statistics.putCacheItem(dartEntry, DartEntry.IS_LAUNCHABLE); 4629 statistics.putCacheItem(dartEntry, DartEntry.IS_LAUNCHABLE);
4499 } 4630 }
4500 // get library-specific values 4631 // get library-specific values
4501 List<Source> librarySources = getLibrariesContaining(source); 4632 List<Source> librarySources = getLibrariesContaining(source);
4502 for (Source librarySource in librarySources) { 4633 for (Source librarySource in librarySources) {
4503 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry.R ESOLUTION_ERRORS); 4634 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry.R ESOLUTION_ERRORS);
4504 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry.R ESOLVED_UNIT); 4635 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry.R ESOLVED_UNIT);
4505 if (_generateSdkErrors || !source.isInSystemLibrary) { 4636 if (_generateSdkErrors || !source.isInSystemLibrary) {
4506 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry .VERIFICATION_ERRORS); 4637 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry .VERIFICATION_ERRORS);
4507 if (hintsEnabled) { 4638 if (hintsEnabled) {
4508 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEnt ry.HINTS); 4639 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEnt ry.HINTS);
4509 } 4640 }
4510 } 4641 }
4511 } 4642 }
4512 } else if (entry is HtmlEntry) { 4643 } else if (sourceEntry is HtmlEntry) {
4513 HtmlEntry htmlEntry = entry; 4644 HtmlEntry htmlEntry = sourceEntry;
4514 statistics.putCacheItem(htmlEntry, SourceEntry.LINE_INFO); 4645 statistics.putCacheItem(htmlEntry, SourceEntry.LINE_INFO);
4515 statistics.putCacheItem(htmlEntry, HtmlEntry.PARSE_ERRORS); 4646 statistics.putCacheItem(htmlEntry, HtmlEntry.PARSE_ERRORS);
4516 statistics.putCacheItem(htmlEntry, HtmlEntry.PARSED_UNIT); 4647 statistics.putCacheItem(htmlEntry, HtmlEntry.PARSED_UNIT);
4517 statistics.putCacheItem(htmlEntry, HtmlEntry.RESOLUTION_ERRORS); 4648 statistics.putCacheItem(htmlEntry, HtmlEntry.RESOLUTION_ERRORS);
4518 statistics.putCacheItem(htmlEntry, HtmlEntry.RESOLVED_UNIT); 4649 statistics.putCacheItem(htmlEntry, HtmlEntry.RESOLVED_UNIT);
4519 } 4650 }
4520 } 4651 }
4521 return statistics; 4652 return statistics;
4522 } 4653 }
4523 4654
(...skipping 28 matching lines...) Expand all
4552 4683
4553 @override 4684 @override
4554 void mergeContext(AnalysisContext context) { 4685 void mergeContext(AnalysisContext context) {
4555 if (context is InstrumentedAnalysisContextImpl) { 4686 if (context is InstrumentedAnalysisContextImpl) {
4556 context = (context as InstrumentedAnalysisContextImpl).basis; 4687 context = (context as InstrumentedAnalysisContextImpl).basis;
4557 } 4688 }
4558 if (context is! AnalysisContextImpl) { 4689 if (context is! AnalysisContextImpl) {
4559 return; 4690 return;
4560 } 4691 }
4561 // TODO(brianwilkerson) This does not lock against the other context's cache Lock. 4692 // TODO(brianwilkerson) This does not lock against the other context's cache Lock.
4562 for (MapEntry<Source, SourceEntry> entry in (context as AnalysisContextImpl) ._cache.entrySet()) { 4693 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
4563 Source newSource = entry.getKey(); 4694 while (iterator.moveNext()) {
4695 Source newSource = iterator.key;
4564 SourceEntry existingEntry = _getReadableSourceEntry(newSource); 4696 SourceEntry existingEntry = _getReadableSourceEntry(newSource);
4565 if (existingEntry == null) { 4697 if (existingEntry == null) {
4566 // TODO(brianwilkerson) Decide whether we really need to copy the info. 4698 // TODO(brianwilkerson) Decide whether we really need to copy the info.
4567 _cache.put(newSource, entry.getValue().writableCopy); 4699 _cache.put(newSource, iterator.value.writableCopy);
4568 } else { 4700 } else {
4569 } 4701 }
4570 } 4702 }
4571 } 4703 }
4572 4704
4573 @override 4705 @override
4574 CompilationUnit parseCompilationUnit(Source source) => _getDartParseData2(sour ce, DartEntry.PARSED_UNIT, null); 4706 CompilationUnit parseCompilationUnit(Source source) => _getDartParseData2(sour ce, DartEntry.PARSED_UNIT, null);
4575 4707
4576 @override 4708 @override
4577 ht.HtmlUnit parseHtmlUnit(Source source) => _getHtmlParseData(source, HtmlEntr y.PARSED_UNIT, null); 4709 ht.HtmlUnit parseHtmlUnit(Source source) => _getHtmlParseData(source, HtmlEntr y.PARSED_UNIT, null);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
4612 AnalysisEngine.instance.logger.logError2("Internal error while performin g the task: ${task}", exception); 4744 AnalysisEngine.instance.logger.logError2("Internal error while performin g the task: ${task}", exception);
4613 } 4745 }
4614 } 4746 }
4615 int performEnd = JavaSystem.currentTimeMillis(); 4747 int performEnd = JavaSystem.currentTimeMillis();
4616 return new AnalysisResult(_getChangeNotices(false), getEnd - getStart, task. runtimeType.toString(), performEnd - performStart); 4748 return new AnalysisResult(_getChangeNotices(false), getEnd - getStart, task. runtimeType.toString(), performEnd - performStart);
4617 } 4749 }
4618 4750
4619 @override 4751 @override
4620 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { 4752 void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
4621 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); 4753 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML);
4622 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap)) { 4754 for (MapIterator<Source, LibraryElement> iter = SingleMapIterator.forMap(ele mentMap); iter.moveNext();) {
4623 Source librarySource = entry.getKey(); 4755 Source librarySource = iter.key;
4624 LibraryElement library = entry.getValue(); 4756 LibraryElement library = iter.value;
4625 // 4757 //
4626 // Cache the element in the library's info. 4758 // Cache the element in the library's info.
4627 // 4759 //
4628 DartEntry dartEntry = _getReadableDartEntry(librarySource); 4760 DartEntry dartEntry = _getReadableDartEntry(librarySource);
4629 if (dartEntry != null) { 4761 if (dartEntry != null) {
4630 DartEntryImpl dartCopy = dartEntry.writableCopy; 4762 DartEntryImpl dartCopy = dartEntry.writableCopy;
4631 _recordElementData(dartEntry, dartCopy, library, library.source, htmlSou rce); 4763 _recordElementData(dartCopy, library, library.source, htmlSource);
4632 _cache.put(librarySource, dartCopy); 4764 _cache.put(librarySource, dartCopy);
4633 } 4765 }
4634 } 4766 }
4635 } 4767 }
4636 4768
4637 @override 4769 @override
4638 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra ry) { 4770 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra ry) {
4639 if (library == null) { 4771 if (library == null) {
4640 return null; 4772 return null;
4641 } 4773 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
4806 } 4938 }
4807 if (_allModificationTimesMatch(resolvedLibraries)) { 4939 if (_allModificationTimesMatch(resolvedLibraries)) {
4808 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); 4940 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
4809 RecordingErrorListener errorListener = resolver.errorListener; 4941 RecordingErrorListener errorListener = resolver.errorListener;
4810 for (ResolvableLibrary library in resolvedLibraries) { 4942 for (ResolvableLibrary library in resolvedLibraries) {
4811 Source librarySource = library.librarySource; 4943 Source librarySource = library.librarySource;
4812 for (Source source in library.compilationUnitSources) { 4944 for (Source source in library.compilationUnitSources) {
4813 CompilationUnit unit = library.getAST(source); 4945 CompilationUnit unit = library.getAST(source);
4814 List<AnalysisError> errors = errorListener.getErrorsForSource(source ); 4946 List<AnalysisError> errors = errorListener.getErrorsForSource(source );
4815 LineInfo lineInfo = getLineInfo(source); 4947 LineInfo lineInfo = getLineInfo(source);
4816 DartEntry dartEntry = _cache.get(source) as DartEntry; 4948 DartEntryImpl dartCopy = _cache.get(source).writableCopy as DartEntr yImpl;
4817 int sourceTime = getModificationStamp(source);
4818 if (dartEntry.modificationTime != sourceTime) {
4819 // The source has changed without the context being notified. Simu late notification.
4820 _sourceChanged(source);
4821 dartEntry = _getReadableDartEntry(source);
4822 if (dartEntry == null) {
4823 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${source.fullName}");
4824 }
4825 }
4826 DartEntryImpl dartCopy = dartEntry.writableCopy;
4827 if (thrownException == null) { 4949 if (thrownException == null) {
4828 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); 4950 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo);
4829 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); 4951 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
4830 dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, unit); 4952 dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, unit);
4831 dartCopy.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySou rce, errors); 4953 dartCopy.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySou rce, errors);
4832 if (source == librarySource) { 4954 if (source == librarySource) {
4833 _recordElementData(dartEntry, dartCopy, library.libraryElement, librarySource, htmlSource); 4955 _recordElementData(dartCopy, library.libraryElement, librarySour ce, htmlSource);
4834 } 4956 }
4835 _cache.storedAst(source); 4957 _cache.storedAst(source);
4836 } else { 4958 } else {
4837 dartCopy.recordResolutionError(); 4959 dartCopy.recordResolutionError();
4838 _cache.remove(source); 4960 _cache.remove(source);
4839 } 4961 }
4840 dartCopy.exception = thrownException; 4962 dartCopy.exception = thrownException;
4841 _cache.put(source, dartCopy); 4963 _cache.put(source, dartCopy);
4842 if (source != librarySource) { 4964 if (source != librarySource) {
4843 _workManager.add(source, SourcePriority.PRIORITY_PART); 4965 _workManager.add(source, SourcePriority.PRIORITY_PART);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
4948 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${source.fullName}"); 5070 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${source.fullName}");
4949 } 5071 }
4950 } 5072 }
4951 DartEntryImpl dartCopy = dartEntry.writableCopy; 5073 DartEntryImpl dartCopy = dartEntry.writableCopy;
4952 if (thrownException == null) { 5074 if (thrownException == null) {
4953 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); 5075 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo);
4954 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); 5076 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
4955 dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, unit); 5077 dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, unit);
4956 dartCopy.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySou rce, errors); 5078 dartCopy.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySou rce, errors);
4957 if (source == librarySource) { 5079 if (source == librarySource) {
4958 _recordElementData(dartEntry, dartCopy, library.libraryElement, librarySource, htmlSource); 5080 _recordElementData(dartCopy, library.libraryElement, librarySour ce, htmlSource);
4959 } 5081 }
4960 _cache.storedAst(source); 5082 _cache.storedAst(source);
4961 } else { 5083 } else {
4962 dartCopy.recordResolutionError(); 5084 dartCopy.recordResolutionError();
4963 _cache.remove(source); 5085 _cache.remove(source);
4964 } 5086 }
4965 dartCopy.exception = thrownException; 5087 dartCopy.exception = thrownException;
4966 _cache.put(source, dartCopy); 5088 _cache.put(source, dartCopy);
4967 if (source != librarySource) { 5089 if (source != librarySource) {
4968 _workManager.add(source, SourcePriority.PRIORITY_PART); 5090 _workManager.add(source, SourcePriority.PRIORITY_PART);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
5037 5159
5038 /** 5160 /**
5039 * Add all of the sources contained in the given source container to the given list of sources. 5161 * Add all of the sources contained in the given source container to the given list of sources.
5040 * 5162 *
5041 * Note: This method must only be invoked while we are synchronized on [cacheL ock]. 5163 * Note: This method must only be invoked while we are synchronized on [cacheL ock].
5042 * 5164 *
5043 * @param sources the list to which sources are to be added 5165 * @param sources the list to which sources are to be added
5044 * @param container the source container containing the sources to be added to the list 5166 * @param container the source container containing the sources to be added to the list
5045 */ 5167 */
5046 void _addSourcesInContainer(List<Source> sources, SourceContainer container) { 5168 void _addSourcesInContainer(List<Source> sources, SourceContainer container) {
5047 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 5169 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
5048 Source source = entry.getKey(); 5170 while (iterator.moveNext()) {
5171 Source source = iterator.key;
5049 if (container.contains(source)) { 5172 if (container.contains(source)) {
5050 sources.add(source); 5173 sources.add(source);
5051 } 5174 }
5052 } 5175 }
5053 } 5176 }
5054 5177
5055 /** 5178 /**
5056 * Return `true` if the modification times of the sources used by the given li brary resolver 5179 * Return `true` if the modification times of the sources used by the given li brary resolver
5057 * to resolve one or more libraries are consistent with the modification times in the cache. 5180 * to resolve one or more libraries are consistent with the modification times in the cache.
5058 * 5181 *
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
5529 } 5652 }
5530 String content = htmlEntry.getValue(SourceEntry.CONTENT); 5653 String content = htmlEntry.getValue(SourceEntry.CONTENT);
5531 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 5654 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
5532 htmlCopy.setState(SourceEntry.CONTENT, CacheState.FLUSHED); 5655 htmlCopy.setState(SourceEntry.CONTENT, CacheState.FLUSHED);
5533 htmlCopy.setState(HtmlEntry.PARSE_ERRORS, CacheState.IN_PROCESS); 5656 htmlCopy.setState(HtmlEntry.PARSE_ERRORS, CacheState.IN_PROCESS);
5534 _cache.put(source, htmlCopy); 5657 _cache.put(source, htmlCopy);
5535 return new AnalysisContextImpl_TaskData(new ParseHtmlTask(this, source, html Copy.modificationTime, content), false); 5658 return new AnalysisContextImpl_TaskData(new ParseHtmlTask(this, source, html Copy.modificationTime, content), false);
5536 } 5659 }
5537 5660
5538 /** 5661 /**
5662 * Create a [PolymerBuildHtmlTask] for the given source, marking the Polymer e lements as
5663 * being in-process.
5664 *
5665 * @param source the source whose content is to be processed
5666 * @param htmlEntry the entry for the source
5667 * @return task data representing the created task
5668 */
5669 AnalysisContextImpl_TaskData _createPolymerBuildHtmlTask(Source source, HtmlEn try htmlEntry) {
5670 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) {
5671 return _createResolveHtmlTask(source, htmlEntry);
5672 }
5673 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
5674 htmlCopy.setState(HtmlEntry.POLYMER_BUILD_ERRORS, CacheState.IN_PROCESS);
5675 _cache.put(source, htmlCopy);
5676 return new AnalysisContextImpl_TaskData(new PolymerBuildHtmlTask(this, sourc e, htmlCopy.modificationTime, htmlEntry.getValue(SourceEntry.LINE_INFO), htmlCop y.getValue(HtmlEntry.RESOLVED_UNIT)), false);
5677 }
5678
5679 /**
5680 * Create a [PolymerResolveHtmlTask] for the given source, marking the Polymer errors as
5681 * being in-process.
5682 *
5683 * @param source the source whose content is to be resolved
5684 * @param htmlEntry the entry for the source
5685 * @return task data representing the created task
5686 */
5687 AnalysisContextImpl_TaskData _createPolymerResolveHtmlTask(Source source, Html Entry htmlEntry) {
5688 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) {
5689 return _createResolveHtmlTask(source, htmlEntry);
5690 }
5691 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
5692 htmlCopy.setState(HtmlEntry.POLYMER_RESOLUTION_ERRORS, CacheState.IN_PROCESS );
5693 _cache.put(source, htmlCopy);
5694 return new AnalysisContextImpl_TaskData(new PolymerResolveHtmlTask(this, sou rce, htmlCopy.modificationTime, htmlEntry.getValue(SourceEntry.LINE_INFO), htmlC opy.getValue(HtmlEntry.RESOLVED_UNIT)), false);
5695 }
5696
5697 /**
5539 * Create a [ResolveAngularComponentTemplateTask] for the given source, markin g the angular 5698 * Create a [ResolveAngularComponentTemplateTask] for the given source, markin g the angular
5540 * errors as being in-process. 5699 * errors as being in-process.
5541 * 5700 *
5542 * @param source the source whose content is to be resolved 5701 * @param source the source whose content is to be resolved
5543 * @param htmlEntry the entry for the source 5702 * @param htmlEntry the entry for the source
5544 * @return task data representing the created task 5703 * @return task data representing the created task
5545 */ 5704 */
5546 AnalysisContextImpl_TaskData _createResolveAngularComponentTemplateTask(Source source, HtmlEntry htmlEntry) { 5705 AnalysisContextImpl_TaskData _createResolveAngularComponentTemplateTask(Source source, HtmlEntry htmlEntry) {
5547 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) { 5706 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) {
5548 return _createResolveHtmlTask(source, htmlEntry); 5707 return _createResolveHtmlTask(source, htmlEntry);
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
6175 CacheState angularEntryState = htmlEntry.getState(HtmlEntry.ANGULAR_ENTR Y); 6334 CacheState angularEntryState = htmlEntry.getState(HtmlEntry.ANGULAR_ENTR Y);
6176 if (angularEntryState == CacheState.INVALID || (isPriority && angularEnt ryState == CacheState.FLUSHED)) { 6335 if (angularEntryState == CacheState.INVALID || (isPriority && angularEnt ryState == CacheState.FLUSHED)) {
6177 return _createResolveAngularEntryHtmlTask(source, htmlEntry); 6336 return _createResolveAngularEntryHtmlTask(source, htmlEntry);
6178 } 6337 }
6179 // Try to resolve the HTML as an Angular application part. 6338 // Try to resolve the HTML as an Angular application part.
6180 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR ORS); 6339 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR ORS);
6181 if (angularErrorsState == CacheState.INVALID || (isPriority && angularEr rorsState == CacheState.FLUSHED)) { 6340 if (angularErrorsState == CacheState.INVALID || (isPriority && angularEr rorsState == CacheState.FLUSHED)) {
6182 return _createResolveAngularComponentTemplateTask(source, htmlEntry); 6341 return _createResolveAngularComponentTemplateTask(source, htmlEntry);
6183 } 6342 }
6184 } 6343 }
6344 //
6345 // Polymer support
6346 //
6347 if (_options.analyzePolymer) {
6348 // Build elements.
6349 CacheState polymerBuildErrorsState = htmlEntry.getState(HtmlEntry.POLYME R_BUILD_ERRORS);
6350 if (polymerBuildErrorsState == CacheState.INVALID || (isPriority && poly merBuildErrorsState == CacheState.FLUSHED)) {
6351 return _createPolymerBuildHtmlTask(source, htmlEntry);
6352 }
6353 // Resolve references.
6354 CacheState polymerResolutionErrorsState = htmlEntry.getState(HtmlEntry.P OLYMER_RESOLUTION_ERRORS);
6355 if (polymerResolutionErrorsState == CacheState.INVALID || (isPriority && polymerResolutionErrorsState == CacheState.FLUSHED)) {
6356 return _createPolymerResolveHtmlTask(source, htmlEntry);
6357 }
6358 }
6185 } 6359 }
6186 return new AnalysisContextImpl_TaskData(null, false); 6360 return new AnalysisContextImpl_TaskData(null, false);
6187 } 6361 }
6188 6362
6189 /** 6363 /**
6190 * Return a change notice for the given source, creating one if one does not a lready exist. 6364 * Return a change notice for the given source, creating one if one does not a lready exist.
6191 * 6365 *
6192 * @param source the source for which changes are being reported 6366 * @param source the source for which changes are being reported
6193 * @return a change notice for the given source 6367 * @return a change notice for the given source
6194 */ 6368 */
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
6280 } 6454 }
6281 6455
6282 /** 6456 /**
6283 * Return an array containing all of the sources known to this context that ha ve the given kind. 6457 * Return an array containing all of the sources known to this context that ha ve the given kind.
6284 * 6458 *
6285 * @param kind the kind of sources to be returned 6459 * @param kind the kind of sources to be returned
6286 * @return all of the sources known to this context that have the given kind 6460 * @return all of the sources known to this context that have the given kind
6287 */ 6461 */
6288 List<Source> _getSources(SourceKind kind) { 6462 List<Source> _getSources(SourceKind kind) {
6289 List<Source> sources = new List<Source>(); 6463 List<Source> sources = new List<Source>();
6290 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 6464 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
6291 if (entry.getValue().kind == kind) { 6465 while (iterator.moveNext()) {
6292 sources.add(entry.getKey()); 6466 if (iterator.value.kind == kind) {
6467 sources.add(iterator.key);
6293 } 6468 }
6294 } 6469 }
6295 return new List.from(sources); 6470 return new List.from(sources);
6296 } 6471 }
6297 6472
6298 /** 6473 /**
6299 * Look at the given source to see whether a task needs to be performed relate d to it. If so, add 6474 * Look at the given source to see whether a task needs to be performed relate d to it. If so, add
6300 * the source to the set of sources that need to be processed. This method dup licates, and must 6475 * the source to the set of sources that need to be processed. This method dup licates, and must
6301 * therefore be kept in sync with, 6476 * therefore be kept in sync with,
6302 * [getNextAnalysisTask]. This method is intended to 6477 * [getNextAnalysisTask]. This method is intended to
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
6389 AngularApplication applicationInfo = htmlEntry.getValue(HtmlEntry.ANGU LAR_APPLICATION); 6564 AngularApplication applicationInfo = htmlEntry.getValue(HtmlEntry.ANGU LAR_APPLICATION);
6390 if (applicationInfo != null) { 6565 if (applicationInfo != null) {
6391 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANG ULAR_COMPONENT); 6566 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANG ULAR_COMPONENT);
6392 if (component != null) { 6567 if (component != null) {
6393 sources.add(source); 6568 sources.add(source);
6394 return; 6569 return;
6395 } 6570 }
6396 } 6571 }
6397 } 6572 }
6398 } 6573 }
6574 // Polymer
6575 if (_options.analyzePolymer) {
6576 // Elements building.
6577 CacheState polymerBuildErrorsState = htmlEntry.getState(HtmlEntry.POLYME R_BUILD_ERRORS);
6578 if (polymerBuildErrorsState == CacheState.INVALID || (isPriority && poly merBuildErrorsState == CacheState.FLUSHED)) {
6579 sources.add(source);
6580 }
6581 // Resolution.
6582 CacheState polymerResolutionErrorsState = htmlEntry.getState(HtmlEntry.P OLYMER_RESOLUTION_ERRORS);
6583 if (polymerResolutionErrorsState == CacheState.INVALID || (isPriority && polymerResolutionErrorsState == CacheState.FLUSHED)) {
6584 sources.add(source);
6585 }
6586 }
6399 } 6587 }
6400 } 6588 }
6401 6589
6402 /** 6590 /**
6403 * Invalidate all of the resolution results computed by this context. 6591 * Invalidate all of the resolution results computed by this context.
6404 * 6592 *
6405 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 6593 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
6406 */ 6594 */
6407 void _invalidateAllResolutionInformation() { 6595 void _invalidateAllResolutionInformation() {
6408 Map<Source, List<Source>> oldPartMap = new Map<Source, List<Source>>(); 6596 Map<Source, List<Source>> oldPartMap = new Map<Source, List<Source>>();
6409 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { 6597 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
6410 Source source = mapEntry.getKey(); 6598 while (iterator.moveNext()) {
6411 SourceEntry sourceEntry = mapEntry.getValue(); 6599 Source source = iterator.key;
6600 SourceEntry sourceEntry = iterator.value;
6412 if (sourceEntry is HtmlEntry) { 6601 if (sourceEntry is HtmlEntry) {
6413 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; 6602 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy;
6414 htmlCopy.invalidateAllResolutionInformation(); 6603 htmlCopy.invalidateAllResolutionInformation();
6415 mapEntry.setValue(htmlCopy); 6604 iterator.value = htmlCopy;
6416 } else if (sourceEntry is DartEntry) { 6605 } else if (sourceEntry is DartEntry) {
6417 DartEntry dartEntry = sourceEntry; 6606 DartEntry dartEntry = sourceEntry;
6418 oldPartMap[source] = dartEntry.getValue(DartEntry.INCLUDED_PARTS); 6607 oldPartMap[source] = dartEntry.getValue(DartEntry.INCLUDED_PARTS);
6419 DartEntryImpl dartCopy = dartEntry.writableCopy; 6608 DartEntryImpl dartCopy = dartEntry.writableCopy;
6420 dartCopy.invalidateAllResolutionInformation(); 6609 dartCopy.invalidateAllResolutionInformation();
6421 mapEntry.setValue(dartCopy); 6610 iterator.value = dartCopy;
6422 _workManager.add(source, SourcePriority.UNKNOWN); 6611 _workManager.add(source, SourcePriority.UNKNOWN);
6423 } 6612 }
6424 } 6613 }
6425 _removeFromPartsUsingMap(oldPartMap); 6614 _removeFromPartsUsingMap(oldPartMap);
6426 } 6615 }
6427 6616
6428 /** 6617 /**
6429 * In response to a change to Angular entry point [HtmlElement], invalidate an y results that 6618 * In response to a change to Angular entry point [HtmlElement], invalidate an y results that
6430 * depend on it. 6619 * depend on it.
6431 * 6620 *
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
6611 // notify about Dart errors 6800 // notify about Dart errors
6612 ChangeNoticeImpl notice = _getNotice(elementSource); 6801 ChangeNoticeImpl notice = _getNotice(elementSource);
6613 notice.setErrors(dartCopy.allErrors, computeLineInfo(elementSource)); 6802 notice.setErrors(dartCopy.allErrors, computeLineInfo(elementSource));
6614 } 6803 }
6615 } 6804 }
6616 // remember Angular entry point 6805 // remember Angular entry point
6617 entry.setValue(HtmlEntry.ANGULAR_ENTRY, application); 6806 entry.setValue(HtmlEntry.ANGULAR_ENTRY, application);
6618 } 6807 }
6619 6808
6620 /** 6809 /**
6810 * Record the results produced by performing a [BuildDartElementModelTask]. If the results
6811 * were computed from data that is now out-of-date, then the results will not be recorded.
6812 *
6813 * @param task the task that was performed
6814 * @return an entry containing the recorded results
6815 * @throws AnalysisException if the results could not be recorded
6816 */
6817 DartEntry _recordBuildDartElementModelTask(BuildDartElementModelTask task) {
6818 Source targetLibrary = task.targetLibrary;
6819 List<ResolvableLibrary> builtLibraries = task.librariesInCycle;
6820 AnalysisException thrownException = task.exception;
6821 DartEntry targetEntry = null;
6822 if (_allModificationTimesMatch(builtLibraries)) {
6823 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
6824 RecordingErrorListener errorListener = task.errorListener;
6825 for (ResolvableLibrary library in builtLibraries) {
6826 Source librarySource = library.librarySource;
6827 for (Source source in library.compilationUnitSources) {
6828 CompilationUnit unit = library.getAST(source);
6829 List<AnalysisError> errors = errorListener.getErrorsForSource(source);
6830 LineInfo lineInfo = getLineInfo(source);
6831 DartEntryImpl dartCopy = _cache.get(source).writableCopy as DartEntryI mpl;
6832 if (thrownException == null) {
6833 dartCopy.setValueInLibrary(DartEntry.BUILD_ELEMENT_ERRORS, librarySo urce, errors);
6834 if (source == librarySource) {
6835 LibraryElementImpl libraryElement = library.libraryElement;
6836 dartCopy.setValue(DartEntry.ELEMENT, libraryElement);
6837 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, libraryElement.entryPoi nt != null);
6838 dartCopy.setValue(DartEntry.IS_CLIENT, _isClient(libraryElement, h tmlSource, new Set<LibraryElement>()));
6839 }
6840 } else {
6841 dartCopy.recordResolutionError();
6842 _cache.remove(source);
6843 }
6844 dartCopy.exception = thrownException;
6845 _cache.put(source, dartCopy);
6846 if (source != librarySource) {
6847 _workManager.add(librarySource, SourcePriority.PRIORITY_PART);
6848 }
6849 if (source == targetLibrary) {
6850 targetEntry = dartCopy;
6851 }
6852 ChangeNoticeImpl notice = _getNotice(source);
6853 notice.compilationUnit = unit;
6854 notice.setErrors(dartCopy.allErrors, lineInfo);
6855 }
6856 }
6857 } else {
6858 PrintStringWriter writer = new PrintStringWriter();
6859 writer.println("Build element model results discarded for");
6860 for (ResolvableLibrary library in builtLibraries) {
6861 for (Source source in library.compilationUnitSources) {
6862 DartEntry dartEntry = _getReadableDartEntry(source);
6863 if (dartEntry != null) {
6864 int resultTime = library.getModificationTime(source);
6865 writer.println(" ${_debuggingString(source)}; sourceTime = ${getMod ificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.mod ificationTime}");
6866 DartEntryImpl dartCopy = dartEntry.writableCopy;
6867 if (thrownException == null || resultTime >= 0) {
6868 //
6869 // The analysis was performed on out-of-date sources. Mark the cac he so that the
6870 // sources will be re-analyzed using the up-to-date sources.
6871 //
6872 dartCopy.recordResolutionNotInProcess();
6873 } else {
6874 //
6875 // We could not determine whether the sources were up-to-date or o ut-of-date. Mark
6876 // the cache so that we won't attempt to re-analyze the sources un til there's a
6877 // good chance that we'll be able to do so without error.
6878 //
6879 dartCopy.recordResolutionError();
6880 _cache.remove(source);
6881 }
6882 dartCopy.exception = thrownException;
6883 _cache.put(source, dartCopy);
6884 if (source == targetLibrary) {
6885 targetEntry = dartCopy;
6886 }
6887 } else {
6888 writer.println(" ${_debuggingString(source)}; sourceTime = ${getMod ificationStamp(source)}, no entry");
6889 }
6890 }
6891 }
6892 _logInformation(writer.toString());
6893 }
6894 if (thrownException != null) {
6895 throw thrownException;
6896 }
6897 if (targetEntry == null) {
6898 targetEntry = _getReadableDartEntry(targetLibrary);
6899 if (targetEntry == null) {
6900 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${ targetLibrary.fullName}");
6901 }
6902 }
6903 return targetEntry;
6904 }
6905
6906 /**
6621 * Given a cache entry and a library element, record the library element and o ther information 6907 * Given a cache entry and a library element, record the library element and o ther information
6622 * gleaned from the element in the cache entry. 6908 * gleaned from the element in the cache entry.
6623 * 6909 *
6624 * @param dartEntry the original cache entry from which the copy was made
6625 * @param dartCopy the cache entry in which data is to be recorded 6910 * @param dartCopy the cache entry in which data is to be recorded
6626 * @param library the library element used to record information 6911 * @param library the library element used to record information
6627 * @param librarySource the source for the library used to record information 6912 * @param librarySource the source for the library used to record information
6628 * @param htmlSource the source for the HTML library 6913 * @param htmlSource the source for the HTML library
6629 */ 6914 */
6630 void _recordElementData(DartEntry dartEntry, DartEntryImpl dartCopy, LibraryEl ement library, Source librarySource, Source htmlSource) { 6915 void _recordElementData(DartEntryImpl dartCopy, LibraryElement library, Source librarySource, Source htmlSource) {
6631 dartCopy.setValue(DartEntry.ELEMENT, library); 6916 dartCopy.setValue(DartEntry.ELEMENT, library);
6632 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); 6917 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null);
6633 dartCopy.setValue(DartEntry.IS_CLIENT, _isClient(library, htmlSource, new Se t<LibraryElement>())); 6918 dartCopy.setValue(DartEntry.IS_CLIENT, _isClient(library, htmlSource, new Se t<LibraryElement>()));
6634 } 6919 }
6635 6920
6636 /** 6921 /**
6637 * Record the results produced by performing a [GenerateDartErrorsTask]. If th e results were 6922 * Record the results produced by performing a [GenerateDartErrorsTask]. If th e results were
6638 * computed from data that is now out-of-date, then the results will not be re corded. 6923 * computed from data that is now out-of-date, then the results will not be re corded.
6639 * 6924 *
6640 * @param task the task that was performed 6925 * @param task the task that was performed
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
6735 } 7020 }
6736 if (thrownException == null) { 7021 if (thrownException == null) {
6737 thrownException = new AnalysisException.con1("GenerateDartHintsTask retu rned a null hint map without throwing an exception: ${librarySource.fullName}"); 7022 thrownException = new AnalysisException.con1("GenerateDartHintsTask retu rned a null hint map without throwing an exception: ${librarySource.fullName}");
6738 } 7023 }
6739 DartEntryImpl dartCopy = (sourceEntry as DartEntry).writableCopy; 7024 DartEntryImpl dartCopy = (sourceEntry as DartEntry).writableCopy;
6740 dartCopy.setStateInLibrary(DartEntry.HINTS, librarySource, CacheState.ERRO R); 7025 dartCopy.setStateInLibrary(DartEntry.HINTS, librarySource, CacheState.ERRO R);
6741 dartCopy.exception = thrownException; 7026 dartCopy.exception = thrownException;
6742 _cache.put(librarySource, dartCopy); 7027 _cache.put(librarySource, dartCopy);
6743 throw thrownException; 7028 throw thrownException;
6744 } 7029 }
6745 for (MapEntry<Source, TimestampedData<List<AnalysisError>>> entry in getMapE ntrySet(hintMap)) { 7030 for (MapIterator<Source, TimestampedData<List<AnalysisError>>> iter = Single MapIterator.forMap(hintMap); iter.moveNext();) {
6746 Source unitSource = entry.getKey(); 7031 Source unitSource = iter.key;
6747 TimestampedData<List<AnalysisError>> results = entry.getValue(); 7032 TimestampedData<List<AnalysisError>> results = iter.value;
6748 SourceEntry sourceEntry = _cache.get(unitSource); 7033 SourceEntry sourceEntry = _cache.get(unitSource);
6749 if (sourceEntry is! DartEntry) { 7034 if (sourceEntry is! DartEntry) {
6750 // This shouldn't be possible because we should never have performed the task if the source 7035 // This shouldn't be possible because we should never have performed the task if the source
6751 // didn't represent a Dart file, but check to be safe. 7036 // didn't represent a Dart file, but check to be safe.
6752 throw new AnalysisException.con1("Internal error: attempting to parse no n-Dart file as a Dart file: ${unitSource.fullName}"); 7037 throw new AnalysisException.con1("Internal error: attempting to parse no n-Dart file as a Dart file: ${unitSource.fullName}");
6753 } 7038 }
6754 DartEntry dartEntry = sourceEntry as DartEntry; 7039 DartEntry dartEntry = sourceEntry as DartEntry;
6755 if (unitSource == librarySource) { 7040 if (unitSource == librarySource) {
6756 libraryEntry = dartEntry; 7041 libraryEntry = dartEntry;
6757 } 7042 }
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
7068 _cache.put(source, htmlCopy); 7353 _cache.put(source, htmlCopy);
7069 htmlEntry = htmlCopy; 7354 htmlEntry = htmlCopy;
7070 } 7355 }
7071 if (thrownException != null) { 7356 if (thrownException != null) {
7072 throw thrownException; 7357 throw thrownException;
7073 } 7358 }
7074 return htmlEntry; 7359 return htmlEntry;
7075 } 7360 }
7076 7361
7077 /** 7362 /**
7078 * Record the results produced by performing a [ResolveAngularComponentTemplat eTask]. If the 7363 * Record the results produced by performing a [PolymerBuildHtmlTask]. If the results were
7079 * results were computed from data that is now out-of-date, then the results w ill not be recorded. 7364 * computed from data that is now out-of-date, then the results will not be re corded.
7080 * 7365 *
7081 * @param task the task that was performed 7366 * @param task the task that was performed
7082 * @throws AnalysisException if the results could not be recorded 7367 * @throws AnalysisException if the results could not be recorded
7083 */ 7368 */
7084 HtmlEntry _recordResolveAngularComponentTemplateTaskResults(ResolveAngularComp onentTemplateTask task) { 7369 HtmlEntry _recordPolymerBuildHtmlTaskResults(PolymerBuildHtmlTask task) {
7085 Source source = task.source; 7370 Source source = task.source;
7086 AnalysisException thrownException = task.exception; 7371 AnalysisException thrownException = task.exception;
7087 HtmlEntry htmlEntry = null; 7372 HtmlEntry htmlEntry = null;
7088 SourceEntry sourceEntry = _cache.get(source); 7373 SourceEntry sourceEntry = _cache.get(source);
7089 if (sourceEntry == null) { 7374 if (sourceEntry == null) {
7090 throw new ObsoleteSourceAnalysisException(source); 7375 throw new ObsoleteSourceAnalysisException(source);
7091 } else if (sourceEntry is! HtmlEntry) { 7376 } else if (sourceEntry is! HtmlEntry) {
7092 // This shouldn't be possible because we should never have performed the t ask if the source 7377 // This shouldn't be possible because we should never have performed the t ask if the source
7093 // didn't represent an HTML file, but check to be safe. 7378 // didn't represent an HTML file, but check to be safe.
7094 throw new AnalysisException.con1("Internal error: attempting to resolve no n-HTML file as an HTML file: ${source.fullName}"); 7379 throw new AnalysisException.con1("Internal error: attempting to resolve no n-HTML file as an HTML file: ${source.fullName}");
7095 } 7380 }
7096 htmlEntry = sourceEntry as HtmlEntry; 7381 htmlEntry = sourceEntry as HtmlEntry;
7097 int sourceTime = getModificationStamp(source); 7382 int sourceTime = getModificationStamp(source);
7098 int resultTime = task.modificationTime; 7383 int resultTime = task.modificationTime;
7099 if (sourceTime == resultTime) { 7384 if (sourceTime == resultTime) {
7100 if (htmlEntry.modificationTime != sourceTime) { 7385 if (htmlEntry.modificationTime != sourceTime) {
7101 // The source has changed without the context being notified. Simulate n otification. 7386 // The source has changed without the context being notified. Simulate n otification.
7102 _sourceChanged(source); 7387 _sourceChanged(source);
7103 htmlEntry = _getReadableHtmlEntry(source); 7388 htmlEntry = _getReadableHtmlEntry(source);
7104 if (htmlEntry == null) { 7389 if (htmlEntry == null) {
7105 throw new AnalysisException.con1("An HTML file became a non-HTML file: ${source.fullName}"); 7390 throw new AnalysisException.con1("An HTML file became a non-HTML file: ${source.fullName}");
7106 } 7391 }
7107 } 7392 }
7108 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 7393 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
7109 if (thrownException == null) { 7394 if (thrownException == null) {
7110 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors); 7395 htmlCopy.setValue(HtmlEntry.POLYMER_BUILD_ERRORS, task.errors);
7111 // notify about errors 7396 // notify about errors
7112 ChangeNoticeImpl notice = _getNotice(source); 7397 ChangeNoticeImpl notice = _getNotice(source);
7113 notice.htmlUnit = task.resolvedUnit;
7114 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_ INFO)); 7398 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_ INFO));
7115 } else { 7399 } else {
7116 htmlCopy.recordResolutionError(); 7400 htmlCopy.recordResolutionError();
7117 } 7401 }
7118 htmlCopy.exception = thrownException; 7402 htmlCopy.exception = thrownException;
7119 _cache.put(source, htmlCopy); 7403 _cache.put(source, htmlCopy);
7120 htmlEntry = htmlCopy; 7404 htmlEntry = htmlCopy;
7121 } else { 7405 } else {
7122 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 7406 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
7123 if (thrownException == null || resultTime >= 0) { 7407 if (thrownException == null || resultTime >= 0) {
7124 // 7408 //
7125 // The analysis was performed on out-of-date sources. Mark the cache so that the sources 7409 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
7126 // will be re-analyzed using the up-to-date sources. 7410 // will be re-analyzed using the up-to-date sources.
7127 // 7411 //
7128 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheStat e.IN_PROCESS) {
7129 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INV ALID);
7130 // }
7131 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) {
7132 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
7133 // }
7134 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) {
7135 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID);
7136 // }
7137 htmlCopy.invalidateAllInformation(); 7412 htmlCopy.invalidateAllInformation();
7138 htmlCopy.modificationTime = sourceTime; 7413 htmlCopy.modificationTime = sourceTime;
7139 _cache.removedAst(source); 7414 _cache.removedAst(source);
7140 } else { 7415 } else {
7141 // 7416 //
7142 // We could not determine whether the sources were up-to-date or out-of- date. Mark the 7417 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
7143 // cache so that we won't attempt to re-analyze the sources until there' s a good chance 7418 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
7144 // that we'll be able to do so without error. 7419 // that we'll be able to do so without error.
7145 // 7420 //
7146 htmlCopy.recordResolutionError(); 7421 htmlCopy.recordResolutionError();
7147 } 7422 }
7148 htmlCopy.exception = thrownException; 7423 htmlCopy.exception = thrownException;
7149 _cache.put(source, htmlCopy); 7424 _cache.put(source, htmlCopy);
7150 htmlEntry = htmlCopy; 7425 htmlEntry = htmlCopy;
7151 } 7426 }
7152 if (thrownException != null) { 7427 if (thrownException != null) {
7153 throw thrownException; 7428 throw thrownException;
7154 } 7429 }
7155 return htmlEntry; 7430 return htmlEntry;
7156 } 7431 }
7157 7432
7158 /** 7433 /**
7159 * Record the results produced by performing a [ResolveAngularEntryHtmlTask]. If the results 7434 * Record the results produced by performing a [PolymerResolveHtmlTask]. If th e results were
7160 * were computed from data that is now out-of-date, then the results will not be recorded. 7435 * computed from data that is now out-of-date, then the results will not be re corded.
7161 * 7436 *
7162 * @param task the task that was performed 7437 * @param task the task that was performed
7163 * @throws AnalysisException if the results could not be recorded 7438 * @throws AnalysisException if the results could not be recorded
7164 */ 7439 */
7165 HtmlEntry _recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTas k task) { 7440 HtmlEntry _recordPolymerResolveHtmlTaskResults(PolymerResolveHtmlTask task) {
7166 Source source = task.source; 7441 Source source = task.source;
7167 AnalysisException thrownException = task.exception; 7442 AnalysisException thrownException = task.exception;
7168 HtmlEntry htmlEntry = null; 7443 HtmlEntry htmlEntry = null;
7169 SourceEntry sourceEntry = _cache.get(source); 7444 SourceEntry sourceEntry = _cache.get(source);
7170 if (sourceEntry == null) { 7445 if (sourceEntry == null) {
7171 throw new ObsoleteSourceAnalysisException(source); 7446 throw new ObsoleteSourceAnalysisException(source);
7172 } else if (sourceEntry is! HtmlEntry) { 7447 } else if (sourceEntry is! HtmlEntry) {
7173 // This shouldn't be possible because we should never have performed the t ask if the source 7448 // This shouldn't be possible because we should never have performed the t ask if the source
7174 // didn't represent an HTML file, but check to be safe. 7449 // didn't represent an HTML file, but check to be safe.
7175 throw new AnalysisException.con1("Internal error: attempting to resolve no n-HTML file as an HTML file: ${source.fullName}"); 7450 throw new AnalysisException.con1("Internal error: attempting to resolve no n-HTML file as an HTML file: ${source.fullName}");
7176 } 7451 }
7177 htmlEntry = sourceEntry as HtmlEntry; 7452 htmlEntry = sourceEntry as HtmlEntry;
7178 int sourceTime = getModificationStamp(source); 7453 int sourceTime = getModificationStamp(source);
7179 int resultTime = task.modificationTime; 7454 int resultTime = task.modificationTime;
7180 if (sourceTime == resultTime) { 7455 if (sourceTime == resultTime) {
7181 if (htmlEntry.modificationTime != sourceTime) { 7456 if (htmlEntry.modificationTime != sourceTime) {
7182 // The source has changed without the context being notified. Simulate n otification. 7457 // The source has changed without the context being notified. Simulate n otification.
7183 _sourceChanged(source); 7458 _sourceChanged(source);
7184 htmlEntry = _getReadableHtmlEntry(source); 7459 htmlEntry = _getReadableHtmlEntry(source);
7185 if (htmlEntry == null) { 7460 if (htmlEntry == null) {
7186 throw new AnalysisException.con1("An HTML file became a non-HTML file: ${source.fullName}"); 7461 throw new AnalysisException.con1("An HTML file became a non-HTML file: ${source.fullName}");
7187 } 7462 }
7188 } 7463 }
7189 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 7464 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
7190 if (thrownException == null) { 7465 if (thrownException == null) {
7191 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); 7466 htmlCopy.setValue(HtmlEntry.POLYMER_RESOLUTION_ERRORS, task.errors);
7192 _recordAngularEntryPoint(htmlCopy, task); 7467 // notify about errors
7193 _cache.storedAst(source);
7194 ChangeNoticeImpl notice = _getNotice(source); 7468 ChangeNoticeImpl notice = _getNotice(source);
7195 notice.htmlUnit = task.resolvedUnit;
7196 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_ INFO)); 7469 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_ INFO));
7197 } else { 7470 } else {
7198 htmlCopy.recordResolutionError(); 7471 htmlCopy.recordResolutionError();
7199 } 7472 }
7200 htmlCopy.exception = thrownException; 7473 htmlCopy.exception = thrownException;
7201 _cache.put(source, htmlCopy); 7474 _cache.put(source, htmlCopy);
7202 htmlEntry = htmlCopy; 7475 htmlEntry = htmlCopy;
7203 } else { 7476 } else {
7204 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 7477 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
7205 if (thrownException == null || resultTime >= 0) { 7478 if (thrownException == null || resultTime >= 0) {
7206 // 7479 //
7207 // The analysis was performed on out-of-date sources. Mark the cache so that the sources 7480 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
7208 // will be re-analyzed using the up-to-date sources. 7481 // will be re-analyzed using the up-to-date sources.
7209 // 7482 //
7210 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheStat e.IN_PROCESS) {
7211 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INV ALID);
7212 // }
7213 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) {
7214 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
7215 // }
7216 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) {
7217 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID);
7218 // }
7219 htmlCopy.invalidateAllInformation(); 7483 htmlCopy.invalidateAllInformation();
7220 htmlCopy.modificationTime = sourceTime; 7484 htmlCopy.modificationTime = sourceTime;
7221 _cache.removedAst(source); 7485 _cache.removedAst(source);
7222 } else { 7486 } else {
7223 // 7487 //
7224 // We could not determine whether the sources were up-to-date or out-of- date. Mark the 7488 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
7225 // cache so that we won't attempt to re-analyze the sources until there' s a good chance 7489 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
7226 // that we'll be able to do so without error. 7490 // that we'll be able to do so without error.
7227 // 7491 //
7228 htmlCopy.recordResolutionError(); 7492 htmlCopy.recordResolutionError();
7229 } 7493 }
7230 htmlCopy.exception = thrownException; 7494 htmlCopy.exception = thrownException;
7231 _cache.put(source, htmlCopy); 7495 _cache.put(source, htmlCopy);
7232 htmlEntry = htmlCopy; 7496 htmlEntry = htmlCopy;
7233 } 7497 }
7234 if (thrownException != null) { 7498 if (thrownException != null) {
7235 throw thrownException; 7499 throw thrownException;
7236 } 7500 }
7237 return htmlEntry; 7501 return htmlEntry;
7238 } 7502 }
7239 7503
7240 /** 7504 /**
7505 * Record the results produced by performing a [ResolveAngularComponentTemplat eTask]. If the
7506 * results were computed from data that is now out-of-date, then the results w ill not be recorded.
7507 *
7508 * @param task the task that was performed
7509 * @throws AnalysisException if the results could not be recorded
7510 */
7511 HtmlEntry _recordResolveAngularComponentTemplateTaskResults(ResolveAngularComp onentTemplateTask task) {
7512 Source source = task.source;
7513 AnalysisException thrownException = task.exception;
7514 HtmlEntry htmlEntry = null;
7515 SourceEntry sourceEntry = _cache.get(source);
7516 if (sourceEntry == null) {
7517 throw new ObsoleteSourceAnalysisException(source);
7518 } else if (sourceEntry is! HtmlEntry) {
7519 // This shouldn't be possible because we should never have performed the t ask if the source
7520 // didn't represent an HTML file, but check to be safe.
7521 throw new AnalysisException.con1("Internal error: attempting to resolve no n-HTML file as an HTML file: ${source.fullName}");
7522 }
7523 htmlEntry = sourceEntry as HtmlEntry;
7524 int sourceTime = getModificationStamp(source);
7525 int resultTime = task.modificationTime;
7526 if (sourceTime == resultTime) {
7527 if (htmlEntry.modificationTime != sourceTime) {
7528 // The source has changed without the context being notified. Simulate n otification.
7529 _sourceChanged(source);
7530 htmlEntry = _getReadableHtmlEntry(source);
7531 if (htmlEntry == null) {
7532 throw new AnalysisException.con1("An HTML file became a non-HTML file: ${source.fullName}");
7533 }
7534 }
7535 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
7536 if (thrownException == null) {
7537 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors);
7538 // notify about errors
7539 ChangeNoticeImpl notice = _getNotice(source);
7540 notice.htmlUnit = task.resolvedUnit;
7541 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_ INFO));
7542 } else {
7543 htmlCopy.recordResolutionError();
7544 }
7545 htmlCopy.exception = thrownException;
7546 _cache.put(source, htmlCopy);
7547 htmlEntry = htmlCopy;
7548 } else {
7549 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
7550 if (thrownException == null || resultTime >= 0) {
7551 //
7552 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
7553 // will be re-analyzed using the up-to-date sources.
7554 //
7555 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheStat e.IN_PROCESS) {
7556 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INV ALID);
7557 // }
7558 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) {
7559 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
7560 // }
7561 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) {
7562 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID);
7563 // }
7564 htmlCopy.invalidateAllInformation();
7565 htmlCopy.modificationTime = sourceTime;
7566 _cache.removedAst(source);
7567 } else {
7568 //
7569 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
7570 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
7571 // that we'll be able to do so without error.
7572 //
7573 htmlCopy.recordResolutionError();
7574 }
7575 htmlCopy.exception = thrownException;
7576 _cache.put(source, htmlCopy);
7577 htmlEntry = htmlCopy;
7578 }
7579 if (thrownException != null) {
7580 throw thrownException;
7581 }
7582 return htmlEntry;
7583 }
7584
7585 /**
7586 * Record the results produced by performing a [ResolveAngularEntryHtmlTask]. If the results
7587 * were computed from data that is now out-of-date, then the results will not be recorded.
7588 *
7589 * @param task the task that was performed
7590 * @throws AnalysisException if the results could not be recorded
7591 */
7592 HtmlEntry _recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTas k task) {
7593 Source source = task.source;
7594 AnalysisException thrownException = task.exception;
7595 HtmlEntry htmlEntry = null;
7596 SourceEntry sourceEntry = _cache.get(source);
7597 if (sourceEntry == null) {
7598 throw new ObsoleteSourceAnalysisException(source);
7599 } else if (sourceEntry is! HtmlEntry) {
7600 // This shouldn't be possible because we should never have performed the t ask if the source
7601 // didn't represent an HTML file, but check to be safe.
7602 throw new AnalysisException.con1("Internal error: attempting to resolve no n-HTML file as an HTML file: ${source.fullName}");
7603 }
7604 htmlEntry = sourceEntry as HtmlEntry;
7605 int sourceTime = getModificationStamp(source);
7606 int resultTime = task.modificationTime;
7607 if (sourceTime == resultTime) {
7608 if (htmlEntry.modificationTime != sourceTime) {
7609 // The source has changed without the context being notified. Simulate n otification.
7610 _sourceChanged(source);
7611 htmlEntry = _getReadableHtmlEntry(source);
7612 if (htmlEntry == null) {
7613 throw new AnalysisException.con1("An HTML file became a non-HTML file: ${source.fullName}");
7614 }
7615 }
7616 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
7617 if (thrownException == null) {
7618 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit);
7619 _recordAngularEntryPoint(htmlCopy, task);
7620 _cache.storedAst(source);
7621 ChangeNoticeImpl notice = _getNotice(source);
7622 notice.htmlUnit = task.resolvedUnit;
7623 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_ INFO));
7624 } else {
7625 htmlCopy.recordResolutionError();
7626 }
7627 htmlCopy.exception = thrownException;
7628 _cache.put(source, htmlCopy);
7629 htmlEntry = htmlCopy;
7630 } else {
7631 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
7632 if (thrownException == null || resultTime >= 0) {
7633 //
7634 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
7635 // will be re-analyzed using the up-to-date sources.
7636 //
7637 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheStat e.IN_PROCESS) {
7638 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INV ALID);
7639 // }
7640 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) {
7641 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
7642 // }
7643 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) {
7644 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID);
7645 // }
7646 htmlCopy.invalidateAllInformation();
7647 htmlCopy.modificationTime = sourceTime;
7648 _cache.removedAst(source);
7649 } else {
7650 //
7651 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
7652 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
7653 // that we'll be able to do so without error.
7654 //
7655 htmlCopy.recordResolutionError();
7656 }
7657 htmlCopy.exception = thrownException;
7658 _cache.put(source, htmlCopy);
7659 htmlEntry = htmlCopy;
7660 }
7661 if (thrownException != null) {
7662 throw thrownException;
7663 }
7664 return htmlEntry;
7665 }
7666
7667 /**
7241 * Record the results produced by performing a [ResolveDartUnitTask]. If the r esults were 7668 * Record the results produced by performing a [ResolveDartUnitTask]. If the r esults were
7242 * computed from data that is now out-of-date, then the results will not be re corded. 7669 * computed from data that is now out-of-date, then the results will not be re corded.
7243 * 7670 *
7244 * @param task the task that was performed 7671 * @param task the task that was performed
7245 * @return an entry containing the computed results 7672 * @return an entry containing the computed results
7246 * @throws AnalysisException if the results could not be recorded 7673 * @throws AnalysisException if the results could not be recorded
7247 */ 7674 */
7248 DartEntry _recordResolveDartUnitTaskResults(ResolveDartUnitTask task) { 7675 DartEntry _recordResolveDartUnitTaskResults(ResolveDartUnitTask task) {
7249 Source unitSource = task.source; 7676 Source unitSource = task.source;
7250 Source librarySource = task.librarySource; 7677 Source librarySource = task.librarySource;
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
7509 7936
7510 /** 7937 /**
7511 * Remove the given libraries that are keys in the given map from the list of containing libraries 7938 * Remove the given libraries that are keys in the given map from the list of containing libraries
7512 * for each of the parts in the corresponding value. 7939 * for each of the parts in the corresponding value.
7513 * 7940 *
7514 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 7941 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
7515 * 7942 *
7516 * @param oldPartMap the table containing the parts associated with each libra ry 7943 * @param oldPartMap the table containing the parts associated with each libra ry
7517 */ 7944 */
7518 void _removeFromPartsUsingMap(Map<Source, List<Source>> oldPartMap) { 7945 void _removeFromPartsUsingMap(Map<Source, List<Source>> oldPartMap) {
7519 for (MapEntry<Source, List<Source>> entry in getMapEntrySet(oldPartMap)) { 7946 for (MapIterator<Source, List<Source>> iter = SingleMapIterator.forMap(oldPa rtMap); iter.moveNext();) {
7520 Source librarySource = entry.getKey(); 7947 Source librarySource = iter.key;
7521 List<Source> oldParts = entry.getValue(); 7948 List<Source> oldParts = iter.value;
7522 for (int i = 0; i < oldParts.length; i++) { 7949 for (int i = 0; i < oldParts.length; i++) {
7523 Source partSource = oldParts[i]; 7950 Source partSource = oldParts[i];
7524 if (partSource != librarySource) { 7951 if (partSource != librarySource) {
7525 DartEntry partEntry = _getReadableDartEntry(partSource); 7952 DartEntry partEntry = _getReadableDartEntry(partSource);
7526 if (partEntry != null) { 7953 if (partEntry != null) {
7527 DartEntryImpl partCopy = partEntry.writableCopy; 7954 DartEntryImpl partCopy = partEntry.writableCopy;
7528 partCopy.removeContainingLibrary(librarySource); 7955 partCopy.removeContainingLibrary(librarySource);
7529 if (partCopy.containingLibraries.length == 0 && !exists(partSource)) { 7956 if (partCopy.containingLibraries.length == 0 && !exists(partSource)) {
7530 _cache.remove(partSource); 7957 _cache.remove(partSource);
7531 } else { 7958 } else {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
7660 * invalid so that the source will be re-analyzed. 8087 * invalid so that the source will be re-analyzed.
7661 * 8088 *
7662 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 8089 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
7663 * 8090 *
7664 * @return `true` if at least one entry was invalid 8091 * @return `true` if at least one entry was invalid
7665 */ 8092 */
7666 bool _validateCacheConsistency() { 8093 bool _validateCacheConsistency() {
7667 int consistencyCheckStart = JavaSystem.nanoTime(); 8094 int consistencyCheckStart = JavaSystem.nanoTime();
7668 List<Source> changedSources = new List<Source>(); 8095 List<Source> changedSources = new List<Source>();
7669 List<Source> missingSources = new List<Source>(); 8096 List<Source> missingSources = new List<Source>();
7670 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 8097 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
7671 Source source = entry.getKey(); 8098 while (iterator.moveNext()) {
7672 SourceEntry sourceEntry = entry.getValue(); 8099 Source source = iterator.key;
8100 SourceEntry sourceEntry = iterator.value;
7673 int sourceTime = getModificationStamp(source); 8101 int sourceTime = getModificationStamp(source);
7674 if (sourceTime != sourceEntry.modificationTime) { 8102 if (sourceTime != sourceEntry.modificationTime) {
7675 changedSources.add(source); 8103 changedSources.add(source);
7676 } 8104 }
7677 if (sourceEntry.exception != null) { 8105 if (sourceEntry.exception != null) {
7678 if (!exists(source)) { 8106 if (!exists(source)) {
7679 missingSources.add(source); 8107 missingSources.add(source);
7680 } 8108 }
7681 } 8109 }
7682 } 8110 }
(...skipping 26 matching lines...) Expand all
7709 /** 8137 /**
7710 * Instances of the class `AnalysisTaskResultRecorder` are used by an analysis c ontext to 8138 * Instances of the class `AnalysisTaskResultRecorder` are used by an analysis c ontext to
7711 * record the results of a task. 8139 * record the results of a task.
7712 */ 8140 */
7713 class AnalysisContextImpl_AnalysisTaskResultRecorder implements AnalysisTaskVisi tor<SourceEntry> { 8141 class AnalysisContextImpl_AnalysisTaskResultRecorder implements AnalysisTaskVisi tor<SourceEntry> {
7714 final AnalysisContextImpl AnalysisContextImpl_this; 8142 final AnalysisContextImpl AnalysisContextImpl_this;
7715 8143
7716 AnalysisContextImpl_AnalysisTaskResultRecorder(this.AnalysisContextImpl_this); 8144 AnalysisContextImpl_AnalysisTaskResultRecorder(this.AnalysisContextImpl_this);
7717 8145
7718 @override 8146 @override
8147 DartEntry visitBuildDartElementModelTask(BuildDartElementModelTask task) => An alysisContextImpl_this._recordBuildDartElementModelTask(task);
8148
8149 @override
7719 DartEntry visitGenerateDartErrorsTask(GenerateDartErrorsTask task) => Analysis ContextImpl_this._recordGenerateDartErrorsTask(task); 8150 DartEntry visitGenerateDartErrorsTask(GenerateDartErrorsTask task) => Analysis ContextImpl_this._recordGenerateDartErrorsTask(task);
7720 8151
7721 @override 8152 @override
7722 DartEntry visitGenerateDartHintsTask(GenerateDartHintsTask task) => AnalysisCo ntextImpl_this._recordGenerateDartHintsTask(task); 8153 DartEntry visitGenerateDartHintsTask(GenerateDartHintsTask task) => AnalysisCo ntextImpl_this._recordGenerateDartHintsTask(task);
7723 8154
7724 @override 8155 @override
7725 SourceEntry visitGetContentTask(GetContentTask task) => AnalysisContextImpl_th is._recordGetContentsTask(task); 8156 SourceEntry visitGetContentTask(GetContentTask task) => AnalysisContextImpl_th is._recordGetContentsTask(task);
7726 8157
7727 @override 8158 @override
7728 DartEntry visitIncrementalAnalysisTask(IncrementalAnalysisTask task) => Analys isContextImpl_this._recordIncrementalAnalysisTaskResults(task); 8159 DartEntry visitIncrementalAnalysisTask(IncrementalAnalysisTask task) => Analys isContextImpl_this._recordIncrementalAnalysisTaskResults(task);
7729 8160
7730 @override 8161 @override
7731 DartEntry visitParseDartTask(ParseDartTask task) => AnalysisContextImpl_this._ recordParseDartTaskResults(task); 8162 DartEntry visitParseDartTask(ParseDartTask task) => AnalysisContextImpl_this._ recordParseDartTaskResults(task);
7732 8163
7733 @override 8164 @override
7734 HtmlEntry visitParseHtmlTask(ParseHtmlTask task) => AnalysisContextImpl_this._ recordParseHtmlTaskResults(task); 8165 HtmlEntry visitParseHtmlTask(ParseHtmlTask task) => AnalysisContextImpl_this._ recordParseHtmlTaskResults(task);
7735 8166
7736 @override 8167 @override
8168 HtmlEntry visitPolymerBuildHtmlTask(PolymerBuildHtmlTask task) => AnalysisCont extImpl_this._recordPolymerBuildHtmlTaskResults(task);
8169
8170 @override
8171 HtmlEntry visitPolymerResolveHtmlTask(PolymerResolveHtmlTask task) => Analysis ContextImpl_this._recordPolymerResolveHtmlTaskResults(task);
8172
8173 @override
7737 HtmlEntry visitResolveAngularComponentTemplateTask(ResolveAngularComponentTemp lateTask task) => AnalysisContextImpl_this._recordResolveAngularComponentTemplat eTaskResults(task); 8174 HtmlEntry visitResolveAngularComponentTemplateTask(ResolveAngularComponentTemp lateTask task) => AnalysisContextImpl_this._recordResolveAngularComponentTemplat eTaskResults(task);
7738 8175
7739 @override 8176 @override
7740 HtmlEntry visitResolveAngularEntryHtmlTask(ResolveAngularEntryHtmlTask task) = > AnalysisContextImpl_this._recordResolveAngularEntryHtmlTaskResults(task); 8177 HtmlEntry visitResolveAngularEntryHtmlTask(ResolveAngularEntryHtmlTask task) = > AnalysisContextImpl_this._recordResolveAngularEntryHtmlTaskResults(task);
7741 8178
7742 @override 8179 @override
7743 DartEntry visitResolveDartLibraryCycleTask(ResolveDartLibraryCycleTask task) = > AnalysisContextImpl_this.recordResolveDartLibraryCycleTaskResults(task); 8180 DartEntry visitResolveDartLibraryCycleTask(ResolveDartLibraryCycleTask task) = > AnalysisContextImpl_this.recordResolveDartLibraryCycleTaskResults(task);
7744 8181
7745 @override 8182 @override
7746 DartEntry visitResolveDartLibraryTask(ResolveDartLibraryTask task) => Analysis ContextImpl_this.recordResolveDartLibraryTaskResults(task); 8183 DartEntry visitResolveDartLibraryTask(ResolveDartLibraryTask task) => Analysis ContextImpl_this.recordResolveDartLibraryTaskResults(task);
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
8412 * A flag indicating whether analysis is to parse comments. 8849 * A flag indicating whether analysis is to parse comments.
8413 */ 8850 */
8414 bool preserveComments = true; 8851 bool preserveComments = true;
8415 8852
8416 /** 8853 /**
8417 * A flag indicating whether analysis is to analyze Angular. 8854 * A flag indicating whether analysis is to analyze Angular.
8418 */ 8855 */
8419 bool analyzeAngular = true; 8856 bool analyzeAngular = true;
8420 8857
8421 /** 8858 /**
8859 * A flag indicating whether analysis is to analyze Polymer.
8860 */
8861 bool analyzePolymer = true;
8862
8863 /**
8422 * Initialize a newly created set of analysis options to have their default va lues. 8864 * Initialize a newly created set of analysis options to have their default va lues.
8423 */ 8865 */
8424 AnalysisOptionsImpl(); 8866 AnalysisOptionsImpl();
8425 8867
8426 /** 8868 /**
8427 * Initialize a newly created set of analysis options to have the same values as those in the 8869 * Initialize a newly created set of analysis options to have the same values as those in the
8428 * given set of analysis options. 8870 * given set of analysis options.
8429 * 8871 *
8430 * @param options the analysis options whose values are being copied 8872 * @param options the analysis options whose values are being copied
8431 */ 8873 */
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after
9829 * the elements representing the libraries 10271 * the elements representing the libraries
9830 */ 10272 */
9831 void recordLibraryElements(Map<Source, LibraryElement> elementMap); 10273 void recordLibraryElements(Map<Source, LibraryElement> elementMap);
9832 } 10274 }
9833 10275
9834 /** 10276 /**
9835 * Container with global [AnalysisContext] performance statistics. 10277 * Container with global [AnalysisContext] performance statistics.
9836 */ 10278 */
9837 class PerformanceStatistics { 10279 class PerformanceStatistics {
9838 /** 10280 /**
9839 * The [TimeCounter] for time spent in Angular analysis.
9840 */
9841 static TimeCounter angular = new TimeCounter();
9842
9843 /**
9844 * The [TimeCounter] for time spent in reading files. 10281 * The [TimeCounter] for time spent in reading files.
9845 */ 10282 */
9846 static TimeCounter io = new TimeCounter(); 10283 static TimeCounter io = new TimeCounter();
9847 10284
9848 /** 10285 /**
9849 * The [TimeCounter] for time spent in scanning. 10286 * The [TimeCounter] for time spent in scanning.
9850 */ 10287 */
9851 static TimeCounter scan = new TimeCounter(); 10288 static TimeCounter scan = new TimeCounter();
9852 10289
9853 /** 10290 /**
9854 * The [TimeCounter] for time spent in parsing. 10291 * The [TimeCounter] for time spent in parsing.
9855 */ 10292 */
9856 static TimeCounter parse = new TimeCounter(); 10293 static TimeCounter parse = new TimeCounter();
9857 10294
9858 /** 10295 /**
9859 * The [TimeCounter] for time spent in resolving. 10296 * The [TimeCounter] for time spent in resolving.
9860 */ 10297 */
9861 static TimeCounter resolve = new TimeCounter(); 10298 static TimeCounter resolve = new TimeCounter();
9862 10299
9863 /** 10300 /**
10301 * The [TimeCounter] for time spent in Angular analysis.
10302 */
10303 static TimeCounter angular = new TimeCounter();
10304
10305 /**
10306 * The [TimeCounter] for time spent in Polymer analysis.
10307 */
10308 static TimeCounter polymer = new TimeCounter();
10309
10310 /**
9864 * The [TimeCounter] for time spent in error verifier. 10311 * The [TimeCounter] for time spent in error verifier.
9865 */ 10312 */
9866 static TimeCounter errors = new TimeCounter(); 10313 static TimeCounter errors = new TimeCounter();
9867 10314
9868 /** 10315 /**
9869 * The [TimeCounter] for time spent in hints generator. 10316 * The [TimeCounter] for time spent in hints generator.
9870 */ 10317 */
9871 static TimeCounter hints = new TimeCounter(); 10318 static TimeCounter hints = new TimeCounter();
9872 10319
9873 /** 10320 /**
9874 * Reset all of the time counters to zero. 10321 * Reset all of the time counters to zero.
9875 */ 10322 */
9876 static void reset() { 10323 static void reset() {
9877 io = new TimeCounter(); 10324 io = new TimeCounter();
9878 scan = new TimeCounter(); 10325 scan = new TimeCounter();
9879 parse = new TimeCounter(); 10326 parse = new TimeCounter();
9880 resolve = new TimeCounter(); 10327 resolve = new TimeCounter();
9881 angular = new TimeCounter(); 10328 angular = new TimeCounter();
10329 polymer = new TimeCounter();
9882 errors = new TimeCounter(); 10330 errors = new TimeCounter();
9883 hints = new TimeCounter(); 10331 hints = new TimeCounter();
9884 } 10332 }
9885 } 10333 }
9886 10334
9887 /** 10335 /**
9888 * Instances of the class `RecordingErrorListener` implement an error listener t hat will 10336 * Instances of the class `RecordingErrorListener` implement an error listener t hat will
9889 * record the errors that are reported to it in a way that is appropriate for ca ching those errors 10337 * record the errors that are reported to it in a way that is appropriate for ca ching those errors
9890 * within an analysis context. 10338 * within an analysis context.
9891 */ 10339 */
(...skipping 13 matching lines...) Expand all
9905 onError(error); 10353 onError(error);
9906 } 10354 }
9907 } 10355 }
9908 10356
9909 /** 10357 /**
9910 * Answer the errors collected by the listener. 10358 * Answer the errors collected by the listener.
9911 * 10359 *
9912 * @return an array of errors (not `null`, contains no `null`s) 10360 * @return an array of errors (not `null`, contains no `null`s)
9913 */ 10361 */
9914 List<AnalysisError> get errors { 10362 List<AnalysisError> get errors {
9915 Iterable<MapEntry<Source, Set<AnalysisError>>> entrySet = getMapEntrySet(_er rors); 10363 Iterable<Set<AnalysisError>> errorsSets = _errors.values;
9916 int numEntries = entrySet.length; 10364 int numEntries = errorsSets.length;
9917 if (numEntries == 0) { 10365 if (numEntries == 0) {
9918 return AnalysisError.NO_ERRORS; 10366 return AnalysisError.NO_ERRORS;
9919 } 10367 }
9920 List<AnalysisError> resultList = new List<AnalysisError>(); 10368 List<AnalysisError> resultList = new List<AnalysisError>();
9921 for (MapEntry<Source, Set<AnalysisError>> entry in entrySet) { 10369 for (Set<AnalysisError> errorsSet in errorsSets) {
9922 resultList.addAll(entry.getValue()); 10370 resultList.addAll(errorsSet);
9923 } 10371 }
9924 return new List.from(resultList); 10372 return new List.from(resultList);
9925 } 10373 }
9926 10374
9927 /** 10375 /**
9928 * Answer the errors collected by the listener for some passed [Source]. 10376 * Answer the errors collected by the listener for some passed [Source].
9929 * 10377 *
9930 * @param source some [Source] for which the caller wants the set of [Analysis Error]s 10378 * @param source some [Source] for which the caller wants the set of [Analysis Error]s
9931 * collected by this listener 10379 * collected by this listener
9932 * @return the errors collected by the listener for the passed [Source] 10380 * @return the errors collected by the listener for the passed [Source]
(...skipping 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after
11588 /** 12036 /**
11589 * Checks if this processor can be applied to the given [XmlTagNode]. 12037 * Checks if this processor can be applied to the given [XmlTagNode].
11590 * 12038 *
11591 * @param node the [XmlTagNode] to check 12039 * @param node the [XmlTagNode] to check
11592 * @return `true` if this processor can be applied, or `false` otherwise 12040 * @return `true` if this processor can be applied, or `false` otherwise
11593 */ 12041 */
11594 bool canApply(ht.XmlTagNode node); 12042 bool canApply(ht.XmlTagNode node);
11595 } 12043 }
11596 12044
11597 /** 12045 /**
12046 * Instances of the class [PolymerHtmlUnitBuilder] build Polymer specific elemen ts.
12047 */
12048 class PolymerHtmlUnitBuilder extends ht.RecursiveXmlVisitor<Object> {
12049 /**
12050 * These names are forbidden to use as a custom tag name.
12051 *
12052 * http://w3c.github.io/webcomponents/spec/custom/#concepts
12053 */
12054 static Set<String> _FORBIDDEN_TAG_NAMES = new Set();
12055
12056 static bool isValidAttributeName(String name) {
12057 // cannot be empty
12058 if (name.isEmpty) {
12059 return false;
12060 }
12061 // check characters
12062 int length = name.length;
12063 for (int i = 0; i < length; i++) {
12064 int c = name.codeUnitAt(i);
12065 if (i == 0) {
12066 if (!Character.isLetter(c)) {
12067 return false;
12068 }
12069 } else {
12070 if (!(Character.isLetterOrDigit(c) || c == 0x5F)) {
12071 return false;
12072 }
12073 }
12074 }
12075 return true;
12076 }
12077
12078 static bool isValidTagName(String name) {
12079 // cannot be empty
12080 if (name.isEmpty) {
12081 return false;
12082 }
12083 // check for forbidden name
12084 if (_FORBIDDEN_TAG_NAMES.contains(name)) {
12085 return false;
12086 }
12087 // check characters
12088 int length = name.length;
12089 bool hasDash = false;
12090 for (int i = 0; i < length; i++) {
12091 int c = name.codeUnitAt(i);
12092 // check for '-'
12093 if (c == 0x2D) {
12094 hasDash = true;
12095 }
12096 // check character
12097 if (i == 0) {
12098 if (hasDash) {
12099 return false;
12100 }
12101 if (!Character.isLetter(c)) {
12102 return false;
12103 }
12104 } else {
12105 if (!(Character.isLetterOrDigit(c) || c == 0x2D || c == 0x5F)) {
12106 return false;
12107 }
12108 }
12109 }
12110 if (!hasDash) {
12111 return false;
12112 }
12113 return true;
12114 }
12115
12116 final InternalAnalysisContext _context;
12117
12118 TypeProvider _typeProvider;
12119
12120 final AnalysisErrorListener _errorListener;
12121
12122 final Source _source;
12123
12124 final LineInfo _lineInfo;
12125
12126 final ht.HtmlUnit _unit;
12127
12128 List<PolymerTagHtmlElement> _tagHtmlElements = [];
12129
12130 ht.XmlTagNode _elementNode;
12131
12132 String _elementName;
12133
12134 PolymerTagHtmlElementImpl _htmlElement;
12135
12136 PolymerTagDartElementImpl _dartElement;
12137
12138 PolymerHtmlUnitBuilder(this._context, this._errorListener, this._source, this. _lineInfo, this._unit) {
12139 this._typeProvider = _context.typeProvider;
12140 }
12141
12142 /**
12143 * Builds Polymer specific HTML elements.
12144 */
12145 void build() {
12146 _unit.accept(this);
12147 // set Polymer tags
12148 HtmlElementImpl unitElement = _unit.element as HtmlElementImpl;
12149 unitElement.polymerTags = new List.from(_tagHtmlElements);
12150 }
12151
12152 @override
12153 Object visitXmlTagNode(ht.XmlTagNode node) {
12154 if (node.tag == "polymer-element") {
12155 _createTagHtmlElement(node);
12156 }
12157 // visit children
12158 return super.visitXmlTagNode(node);
12159 }
12160
12161 void _createAttributeElements() {
12162 // prepare "attributes" attribute
12163 ht.XmlAttributeNode attributesAttribute = _elementNode.getAttribute("attribu tes");
12164 if (attributesAttribute == null) {
12165 return;
12166 }
12167 // check if there is a Dart part to resolve against it
12168 if (_dartElement == null) {
12169 // TODO(scheglov) maybe report error (if it is allowed at all to have elem ent without Dart part)
12170 return;
12171 }
12172 // prepare value of the "attributes" attribute
12173 String attributesText = attributesAttribute.text;
12174 if (attributesText.trim().isEmpty) {
12175 _reportErrorForAttribute(attributesAttribute, PolymerCode.EMPTY_ATTRIBUTES , []);
12176 return;
12177 }
12178 // prepare attribute name tokens
12179 List<PolymerHtmlUnitBuilder_NameToken> nameTokens = [];
12180 {
12181 int index = 0;
12182 int textOffset = attributesAttribute.textOffset;
12183 int nameOffset = -1;
12184 JavaStringBuilder nameBuilder = new JavaStringBuilder();
12185 while (index < attributesText.length) {
12186 int c = attributesText.codeUnitAt(index++);
12187 if (Character.isWhitespace(c)) {
12188 if (nameOffset != -1) {
12189 nameTokens.add(new PolymerHtmlUnitBuilder_NameToken(nameOffset, name Builder.toString()));
12190 nameBuilder = new JavaStringBuilder();
12191 nameOffset = -1;
12192 }
12193 continue;
12194 }
12195 if (nameOffset == -1) {
12196 nameOffset = textOffset + index - 1;
12197 }
12198 nameBuilder.appendChar(c);
12199 }
12200 if (nameOffset != -1) {
12201 nameTokens.add(new PolymerHtmlUnitBuilder_NameToken(nameOffset, nameBuil der.toString()));
12202 nameBuilder = new JavaStringBuilder();
12203 }
12204 }
12205 // create attributes for name tokens
12206 List<PolymerAttributeElement> attributes = [];
12207 Set<String> definedNames = new Set();
12208 ClassElement classElement = _dartElement.classElement;
12209 for (PolymerHtmlUnitBuilder_NameToken nameToken in nameTokens) {
12210 int offset = nameToken._offset;
12211 // prepare name
12212 String name = nameToken._value;
12213 if (!isValidAttributeName(name)) {
12214 _reportErrorForNameToken(nameToken, PolymerCode.INVALID_ATTRIBUTE_NAME, [name]);
12215 continue;
12216 }
12217 if (!definedNames.add(name)) {
12218 _reportErrorForNameToken(nameToken, PolymerCode.DUPLICATE_ATTRIBUTE_DEFI NITION, [name]);
12219 continue;
12220 }
12221 // create attribute
12222 PolymerAttributeElementImpl attribute = new PolymerAttributeElementImpl(na me, offset);
12223 attributes.add(attribute);
12224 // resolve field
12225 FieldElement field = classElement.getField(name);
12226 if (field == null) {
12227 _reportErrorForNameToken(nameToken, PolymerCode.UNDEFINED_ATTRIBUTE_FIEL D, [name, classElement.displayName]);
12228 continue;
12229 }
12230 if (!_isPublishedField(field)) {
12231 _reportErrorForNameToken(nameToken, PolymerCode.ATTRIBUTE_FIELD_NOT_PUBL ISHED, [name, classElement.displayName]);
12232 }
12233 attribute.field = field;
12234 }
12235 _htmlElement.attributes = new List.from(attributes);
12236 }
12237
12238 void _createTagHtmlElement(ht.XmlTagNode node) {
12239 this._elementNode = node;
12240 this._elementName = null;
12241 this._htmlElement = null;
12242 this._dartElement = null;
12243 // prepare 'name' attribute
12244 ht.XmlAttributeNode nameAttribute = node.getAttribute("name");
12245 if (nameAttribute == null) {
12246 _reportErrorForToken(node.tagToken, PolymerCode.MISSING_TAG_NAME, []);
12247 return;
12248 }
12249 // prepare name
12250 _elementName = nameAttribute.text;
12251 if (!isValidTagName(_elementName)) {
12252 _reportErrorForAttributeValue(nameAttribute, PolymerCode.INVALID_TAG_NAME, [_elementName]);
12253 return;
12254 }
12255 // TODO(scheglov) Maybe check that at least one of "template" or "script" ch ildren.
12256 // TODO(scheglov) Maybe check if more than one top-level "template".
12257 // create HTML element
12258 int nameOffset = nameAttribute.textOffset;
12259 _htmlElement = new PolymerTagHtmlElementImpl(_elementName, nameOffset);
12260 // bind to the corresponding Dart element
12261 _dartElement = _findTagDartElement();
12262 if (_dartElement != null) {
12263 _htmlElement.dartElement = _dartElement;
12264 _dartElement.htmlElement = _htmlElement;
12265 }
12266 // TODO(scheglov) create attributes
12267 _createAttributeElements();
12268 // done
12269 _tagHtmlElements.add(_htmlElement);
12270 }
12271
12272 /**
12273 * Returns the [PolymerTagDartElement] that corresponds to the Polymer custom tag declared
12274 * by the given [XmlTagNode].
12275 */
12276 PolymerTagDartElementImpl _findTagDartElement() {
12277 LibraryElement dartLibraryElement = dartUnitElement;
12278 if (dartLibraryElement == null) {
12279 return null;
12280 }
12281 return _findTagDartElement_inLibrary(dartLibraryElement);
12282 }
12283
12284 /**
12285 * Returns the [PolymerTagDartElementImpl] declared in the given [LibraryEleme nt] with
12286 * the [elementName]. Maybe `null`.
12287 */
12288 PolymerTagDartElementImpl _findTagDartElement_inLibrary(LibraryElement library ) {
12289 try {
12290 library.accept(new RecursiveElementVisitor_PolymerHtmlUnitBuilder_findTagD artElement_inLibrary(this));
12291 } on PolymerHtmlUnitBuilder_FoundTagDartElementError catch (e) {
12292 return e._result;
12293 }
12294 return null;
12295 }
12296
12297 /**
12298 * Returns the only [LibraryElement] referenced by a direct `script` child. Ma ybe
12299 * `null` if none.
12300 */
12301 LibraryElement get dartUnitElement {
12302 // TODO(scheglov) Maybe check if more than one "script".
12303 for (ht.XmlTagNode child in _elementNode.tagNodes) {
12304 if (child is ht.HtmlScriptTagNode) {
12305 HtmlScriptElement scriptElement = child.scriptElement;
12306 if (scriptElement is ExternalHtmlScriptElement) {
12307 Source scriptSource = scriptElement.scriptSource;
12308 if (scriptSource != null) {
12309 return _context.getLibraryElement(scriptSource);
12310 }
12311 }
12312 }
12313 }
12314 return null;
12315 }
12316
12317 bool _isPublishedAnnotation(ElementAnnotation annotation) {
12318 Element element = annotation.element;
12319 if (element != null && element.name == "published") {
12320 return true;
12321 }
12322 return false;
12323 }
12324
12325 bool _isPublishedField(FieldElement field) {
12326 List<ElementAnnotation> annotations = field.metadata;
12327 for (ElementAnnotation annotation in annotations) {
12328 if (_isPublishedAnnotation(annotation)) {
12329 return true;
12330 }
12331 }
12332 return false;
12333 }
12334
12335 /**
12336 * Reports an error on the attribute's value, or (if absent) on the attribute' s name.
12337 */
12338 void _reportErrorForAttribute(ht.XmlAttributeNode node, ErrorCode errorCode, L ist<Object> arguments) {
12339 _reportErrorForOffset(node.offset, node.length, errorCode, arguments);
12340 }
12341
12342 /**
12343 * Reports an error on the attribute's value, or (if absent) on the attribute' s name.
12344 */
12345 void _reportErrorForAttributeValue(ht.XmlAttributeNode node, ErrorCode errorCo de, List<Object> arguments) {
12346 ht.Token valueToken = node.valueToken;
12347 if (valueToken == null || valueToken.isSynthetic) {
12348 _reportErrorForAttribute(node, errorCode, arguments);
12349 } else {
12350 _reportErrorForToken(valueToken, errorCode, arguments);
12351 }
12352 }
12353
12354 void _reportErrorForNameToken(PolymerHtmlUnitBuilder_NameToken token, ErrorCod e errorCode, List<Object> arguments) {
12355 int offset = token._offset;
12356 int length = token._value.length;
12357 _reportErrorForOffset(offset, length, errorCode, arguments);
12358 }
12359
12360 void _reportErrorForOffset(int offset, int length, ErrorCode errorCode, List<O bject> arguments) {
12361 _errorListener.onError(new AnalysisError.con2(_source, offset, length, error Code, arguments));
12362 }
12363
12364 void _reportErrorForToken(ht.Token token, ErrorCode errorCode, List<Object> ar guments) {
12365 int offset = token.offset;
12366 int length = token.length;
12367 _reportErrorForOffset(offset, length, errorCode, arguments);
12368 }
12369 }
12370
12371 class PolymerHtmlUnitBuilder_FoundTagDartElementError extends Error {
12372 final PolymerTagDartElementImpl _result;
12373
12374 PolymerHtmlUnitBuilder_FoundTagDartElementError(this._result);
12375 }
12376
12377 class PolymerHtmlUnitBuilder_NameToken {
12378 final int _offset;
12379
12380 final String _value;
12381
12382 PolymerHtmlUnitBuilder_NameToken(this._offset, this._value);
12383 }
12384
12385 class RecursiveElementVisitor_PolymerHtmlUnitBuilder_findTagDartElement_inLibrar y extends RecursiveElementVisitor<Object> {
12386 final PolymerHtmlUnitBuilder PolymerHtmlUnitBuilder_this;
12387
12388 RecursiveElementVisitor_PolymerHtmlUnitBuilder_findTagDartElement_inLibrary(th is.PolymerHtmlUnitBuilder_this) : super();
12389
12390 @override
12391 Object visitPolymerTagDartElement(PolymerTagDartElement element) {
12392 if (element.name == PolymerHtmlUnitBuilder_this._elementName) {
12393 throw new PolymerHtmlUnitBuilder_FoundTagDartElementError(element as Polym erTagDartElementImpl);
12394 }
12395 return null;
12396 }
12397 }
12398
12399 /**
12400 * Instances of the class [PolymerHtmlUnitResolver] resolve Polymer specific
12401 * [XmlTagNode]s and expressions.
12402 *
12403 * TODO(scheglov) implement it
12404 */
12405 class PolymerHtmlUnitResolver extends ht.RecursiveXmlVisitor<Object> {
12406 final InternalAnalysisContext _context;
12407
12408 TypeProvider _typeProvider;
12409
12410 final AnalysisErrorListener _errorListener;
12411
12412 final Source _source;
12413
12414 final LineInfo _lineInfo;
12415
12416 final ht.HtmlUnit _unit;
12417
12418 PolymerHtmlUnitResolver(this._context, this._errorListener, this._source, this ._lineInfo, this._unit) {
12419 this._typeProvider = _context.typeProvider;
12420 }
12421
12422 /**
12423 * Resolves Polymer specific features.
12424 */
12425 void resolveUnit() {
12426 }
12427
12428 @override
12429 Object visitXmlAttributeNode(ht.XmlAttributeNode node) => super.visitXmlAttrib uteNode(node);
12430
12431 @override
12432 Object visitXmlTagNode(ht.XmlTagNode node) => super.visitXmlTagNode(node);
12433 }
12434
12435 /**
11598 * The abstract class `AnalysisTask` defines the behavior of objects used to per form an 12436 * The abstract class `AnalysisTask` defines the behavior of objects used to per form an
11599 * analysis task. 12437 * analysis task.
11600 */ 12438 */
11601 abstract class AnalysisTask { 12439 abstract class AnalysisTask {
11602 /** 12440 /**
11603 * The context in which the task is to be performed. 12441 * The context in which the task is to be performed.
11604 */ 12442 */
11605 final InternalAnalysisContext context; 12443 final InternalAnalysisContext context;
11606 12444
11607 /** 12445 /**
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
11685 } 12523 }
11686 } 12524 }
11687 12525
11688 /** 12526 /**
11689 * The interface `AnalysisTaskVisitor` defines the behavior of objects that can visit tasks. 12527 * The interface `AnalysisTaskVisitor` defines the behavior of objects that can visit tasks.
11690 * While tasks are not structured in any interesting way, this class provides th e ability to 12528 * While tasks are not structured in any interesting way, this class provides th e ability to
11691 * dispatch to an appropriate method. 12529 * dispatch to an appropriate method.
11692 */ 12530 */
11693 abstract class AnalysisTaskVisitor<E> { 12531 abstract class AnalysisTaskVisitor<E> {
11694 /** 12532 /**
12533 * Visit a [BuildDartElementModelTask].
12534 *
12535 * @param task the task to be visited
12536 * @return the result of visiting the task
12537 * @throws AnalysisException if the visitor throws an exception for some reaso n
12538 */
12539 E visitBuildDartElementModelTask(BuildDartElementModelTask task);
12540
12541 /**
11695 * Visit a [GenerateDartErrorsTask]. 12542 * Visit a [GenerateDartErrorsTask].
11696 * 12543 *
11697 * @param task the task to be visited 12544 * @param task the task to be visited
11698 * @return the result of visiting the task 12545 * @return the result of visiting the task
11699 * @throws AnalysisException if the visitor throws an exception for some reaso n 12546 * @throws AnalysisException if the visitor throws an exception for some reaso n
11700 */ 12547 */
11701 E visitGenerateDartErrorsTask(GenerateDartErrorsTask task); 12548 E visitGenerateDartErrorsTask(GenerateDartErrorsTask task);
11702 12549
11703 /** 12550 /**
11704 * Visit a [GenerateDartHintsTask]. 12551 * Visit a [GenerateDartHintsTask].
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
11739 /** 12586 /**
11740 * Visit a [ParseHtmlTask]. 12587 * Visit a [ParseHtmlTask].
11741 * 12588 *
11742 * @param task the task to be visited 12589 * @param task the task to be visited
11743 * @return the result of visiting the task 12590 * @return the result of visiting the task
11744 * @throws AnalysisException if the visitor throws an exception for some reaso n 12591 * @throws AnalysisException if the visitor throws an exception for some reaso n
11745 */ 12592 */
11746 E visitParseHtmlTask(ParseHtmlTask task); 12593 E visitParseHtmlTask(ParseHtmlTask task);
11747 12594
11748 /** 12595 /**
12596 * Visit a [PolymerBuildHtmlTask].
12597 *
12598 * @param task the task to be visited
12599 * @return the result of visiting the task
12600 * @throws AnalysisException if the visitor throws an exception for some reaso n
12601 */
12602 E visitPolymerBuildHtmlTask(PolymerBuildHtmlTask task);
12603
12604 /**
12605 * Visit a [PolymerResolveHtmlTask].
12606 *
12607 * @param task the task to be visited
12608 * @return the result of visiting the task
12609 * @throws AnalysisException if the visitor throws an exception for some reaso n
12610 */
12611 E visitPolymerResolveHtmlTask(PolymerResolveHtmlTask task);
12612
12613 /**
11749 * Visit a [ResolveAngularComponentTemplateTask]. 12614 * Visit a [ResolveAngularComponentTemplateTask].
11750 * 12615 *
11751 * @param task the task to be visited 12616 * @param task the task to be visited
11752 * @return the result of visiting the task 12617 * @return the result of visiting the task
11753 * @throws AnalysisException if the visitor throws an exception for some reaso n 12618 * @throws AnalysisException if the visitor throws an exception for some reaso n
11754 */ 12619 */
11755 E visitResolveAngularComponentTemplateTask(ResolveAngularComponentTemplateTask task); 12620 E visitResolveAngularComponentTemplateTask(ResolveAngularComponentTemplateTask task);
11756 12621
11757 /** 12622 /**
11758 * Visit a [ResolveAngularEntryHtmlTask]. 12623 * Visit a [ResolveAngularEntryHtmlTask].
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
11803 * Visit a [ScanDartTask]. 12668 * Visit a [ScanDartTask].
11804 * 12669 *
11805 * @param task the task to be visited 12670 * @param task the task to be visited
11806 * @return the result of visiting the task 12671 * @return the result of visiting the task
11807 * @throws AnalysisException if the visitor throws an exception for some reaso n 12672 * @throws AnalysisException if the visitor throws an exception for some reaso n
11808 */ 12673 */
11809 E visitScanDartTask(ScanDartTask task); 12674 E visitScanDartTask(ScanDartTask task);
11810 } 12675 }
11811 12676
11812 /** 12677 /**
12678 * Instances of the class `BuildDartElementModelTask` build the element models f or all of the
12679 * libraries in a cycle.
12680 */
12681 class BuildDartElementModelTask extends AnalysisTask {
12682 /**
12683 * The library for which an element model was originally requested.
12684 */
12685 Source _targetLibrary;
12686
12687 /**
12688 * The libraries that are part of the cycle to be resolved.
12689 */
12690 final List<ResolvableLibrary> librariesInCycle;
12691
12692 /**
12693 * The listener to which analysis errors will be reported.
12694 */
12695 RecordingErrorListener _errorListener;
12696
12697 /**
12698 * A source object representing the core library (dart:core).
12699 */
12700 Source _coreLibrarySource;
12701
12702 /**
12703 * The object representing the core library.
12704 */
12705 ResolvableLibrary _coreLibrary;
12706
12707 /**
12708 * A table mapping library sources to the information being maintained for tho se libraries.
12709 */
12710 Map<Source, ResolvableLibrary> _libraryMap = new Map<Source, ResolvableLibrary >();
12711
12712 /**
12713 * Initialize a newly created task to perform analysis within the given contex t.
12714 *
12715 * @param context the context in which the task is to be performed
12716 * @param targetLibrary the library for which an element model was originally requested
12717 * @param librariesInCycle the libraries that are part of the cycle to be reso lved
12718 */
12719 BuildDartElementModelTask(InternalAnalysisContext context, Source targetLibrar y, this.librariesInCycle) : super(context) {
12720 this._errorListener = new RecordingErrorListener();
12721 _coreLibrarySource = context.sourceFactory.forUri(DartSdk.DART_CORE);
12722 }
12723
12724 @override
12725 accept(AnalysisTaskVisitor visitor) => visitor.visitBuildDartElementModelTask( this);
12726
12727 /**
12728 * Return the listener to which analysis errors were (or will be) reported.
12729 *
12730 * @return the listener to which analysis errors were reported
12731 */
12732 RecordingErrorListener get errorListener => _errorListener;
12733
12734 /**
12735 * Return the library for which an element model was originally requested.
12736 *
12737 * @return the library for which an element model was originally requested
12738 */
12739 Source get targetLibrary => _targetLibrary;
12740
12741 @override
12742 String get taskDescription {
12743 Source librarySource = librariesInCycle[0].librarySource;
12744 if (librarySource == null) {
12745 return "build an element model for unknown library";
12746 }
12747 return "build an element model for ${librarySource.fullName}";
12748 }
12749
12750 @override
12751 void internalPerform() {
12752 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.LibraryResolver.resolveLibrary");
12753 try {
12754 //
12755 // Build the map of libraries that are known.
12756 //
12757 _libraryMap = _buildLibraryMap();
12758 _coreLibrary = _libraryMap[_coreLibrarySource];
12759 LibraryElement coreElement = _coreLibrary.libraryElement;
12760 if (coreElement == null) {
12761 throw new AnalysisException.con1("Could not resolve dart:core");
12762 }
12763 instrumentation.metric3("buildLibraryMap", "complete");
12764 //
12765 // Build the element models representing the libraries being resolved. Thi s is done in three
12766 // steps.
12767 //
12768 // 1. Build the basic element models without making any connections betwee n elements other than
12769 // the basic parent/child relationships. This includes building the ele ments representing the
12770 // libraries.
12771 //
12772 _buildElementModels();
12773 instrumentation.metric3("buildElementModels", "complete");
12774 //
12775 // 2. Build the elements for the import and export directives. This requir es that we have the
12776 // elements built for the referenced libraries, but because of the poss ibility of circular
12777 // references needs to happen after all of the library elements have be en created.
12778 //
12779 _buildDirectiveModels();
12780 instrumentation.metric3("buildDirectiveModels", "complete");
12781 //
12782 // 3. Build the rest of the type model by connecting superclasses, mixins, and interfaces. This
12783 // requires that we be able to compute the names visible in the librari es being resolved,
12784 // which in turn requires that we have resolved the import directives.
12785 //
12786 _buildTypeHierarchies(new TypeProviderImpl(coreElement));
12787 instrumentation.metric3("buildTypeHierarchies", "complete");
12788 } finally {
12789 instrumentation.log();
12790 }
12791 }
12792
12793 /**
12794 * Build the element model representing the combinators declared by the given directive.
12795 *
12796 * @param directive the directive that declares the combinators
12797 * @return an array containing the import combinators that were built
12798 */
12799 List<NamespaceCombinator> _buildCombinators(NamespaceDirective directive) {
12800 List<NamespaceCombinator> combinators = new List<NamespaceCombinator>();
12801 for (Combinator combinator in directive.combinators) {
12802 if (combinator is HideCombinator) {
12803 HideElementCombinatorImpl hide = new HideElementCombinatorImpl();
12804 hide.hiddenNames = _getIdentifiers(combinator.hiddenNames);
12805 combinators.add(hide);
12806 } else {
12807 ShowElementCombinatorImpl show = new ShowElementCombinatorImpl();
12808 show.offset = combinator.offset;
12809 show.end = combinator.end;
12810 show.shownNames = _getIdentifiers((combinator as ShowCombinator).shownNa mes);
12811 combinators.add(show);
12812 }
12813 }
12814 return new List.from(combinators);
12815 }
12816
12817 /**
12818 * Every library now has a corresponding [LibraryElement], so it is now possib le to resolve
12819 * the import and export directives.
12820 *
12821 * @throws AnalysisException if the defining compilation unit for any of the l ibraries could not
12822 * be accessed
12823 */
12824 void _buildDirectiveModels() {
12825 AnalysisContext analysisContext = context;
12826 for (ResolvableLibrary library in librariesInCycle) {
12827 Map<String, PrefixElementImpl> nameToPrefixMap = new Map<String, PrefixEle mentImpl>();
12828 List<ImportElement> imports = new List<ImportElement>();
12829 List<ExportElement> exports = new List<ExportElement>();
12830 for (Directive directive in library.definingCompilationUnit.directives) {
12831 if (directive is ImportDirective) {
12832 ImportDirective importDirective = directive;
12833 String uriContent = importDirective.uriContent;
12834 if (DartUriResolver.isDartExtUri(uriContent)) {
12835 library.libraryElement.hasExtUri = true;
12836 }
12837 Source importedSource = importDirective.source;
12838 if (importedSource != null && analysisContext.exists(importedSource)) {
12839 // The imported source will be null if the URI in the import directi ve was invalid.
12840 ResolvableLibrary importedLibrary = _libraryMap[importedSource];
12841 if (importedLibrary != null) {
12842 ImportElementImpl importElement = new ImportElementImpl(directive. offset);
12843 StringLiteral uriLiteral = importDirective.uri;
12844 if (uriLiteral != null) {
12845 importElement.uriOffset = uriLiteral.offset;
12846 importElement.uriEnd = uriLiteral.end;
12847 }
12848 importElement.uri = uriContent;
12849 importElement.combinators = _buildCombinators(importDirective);
12850 LibraryElement importedLibraryElement = importedLibrary.libraryEle ment;
12851 if (importedLibraryElement != null) {
12852 importElement.importedLibrary = importedLibraryElement;
12853 }
12854 SimpleIdentifier prefixNode = directive.prefix;
12855 if (prefixNode != null) {
12856 importElement.prefixOffset = prefixNode.offset;
12857 String prefixName = prefixNode.name;
12858 PrefixElementImpl prefix = nameToPrefixMap[prefixName];
12859 if (prefix == null) {
12860 prefix = new PrefixElementImpl(prefixNode);
12861 nameToPrefixMap[prefixName] = prefix;
12862 }
12863 importElement.prefix = prefix;
12864 prefixNode.staticElement = prefix;
12865 }
12866 directive.element = importElement;
12867 imports.add(importElement);
12868 if (analysisContext.computeKindOf(importedSource) != SourceKind.LI BRARY) {
12869 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.IMPORT_OF_NON_LI BRARY, [uriLiteral.toSource()]));
12870 }
12871 }
12872 }
12873 } else if (directive is ExportDirective) {
12874 ExportDirective exportDirective = directive;
12875 Source exportedSource = exportDirective.source;
12876 if (exportedSource != null && analysisContext.exists(exportedSource)) {
12877 // The exported source will be null if the URI in the export directi ve was invalid.
12878 ResolvableLibrary exportedLibrary = _libraryMap[exportedSource];
12879 if (exportedLibrary != null) {
12880 ExportElementImpl exportElement = new ExportElementImpl();
12881 StringLiteral uriLiteral = exportDirective.uri;
12882 if (uriLiteral != null) {
12883 exportElement.uriOffset = uriLiteral.offset;
12884 exportElement.uriEnd = uriLiteral.end;
12885 }
12886 exportElement.uri = exportDirective.uriContent;
12887 exportElement.combinators = _buildCombinators(exportDirective);
12888 LibraryElement exportedLibraryElement = exportedLibrary.libraryEle ment;
12889 if (exportedLibraryElement != null) {
12890 exportElement.exportedLibrary = exportedLibraryElement;
12891 }
12892 directive.element = exportElement;
12893 exports.add(exportElement);
12894 if (analysisContext.computeKindOf(exportedSource) != SourceKind.LI BRARY) {
12895 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.EXPORT_OF_NON_LI BRARY, [uriLiteral.toSource()]));
12896 }
12897 }
12898 }
12899 }
12900 }
12901 Source librarySource = library.librarySource;
12902 if (!library.explicitlyImportsCore && _coreLibrarySource != librarySource) {
12903 ImportElementImpl importElement = new ImportElementImpl(-1);
12904 importElement.importedLibrary = _coreLibrary.libraryElement;
12905 importElement.synthetic = true;
12906 imports.add(importElement);
12907 }
12908 LibraryElementImpl libraryElement = library.libraryElement;
12909 libraryElement.imports = new List.from(imports);
12910 libraryElement.exports = new List.from(exports);
12911 if (libraryElement.entryPoint == null) {
12912 Namespace namespace = new NamespaceBuilder().createExportNamespaceForLib rary(libraryElement);
12913 Element element = namespace.get(LibraryElementBuilder.ENTRY_POINT_NAME);
12914 if (element is FunctionElement) {
12915 libraryElement.entryPoint = element;
12916 }
12917 }
12918 }
12919 }
12920
12921 /**
12922 * Build element models for all of the libraries in the current cycle.
12923 *
12924 * @throws AnalysisException if any of the element models cannot be built
12925 */
12926 void _buildElementModels() {
12927 for (ResolvableLibrary library in librariesInCycle) {
12928 LibraryElementBuilder builder = new LibraryElementBuilder(context, _errorL istener);
12929 LibraryElementImpl libraryElement = builder.buildLibrary2(library);
12930 library.libraryElement = libraryElement;
12931 }
12932 }
12933
12934 /**
12935 * Build a table mapping library sources to the resolvable libraries represent ing those libraries.
12936 *
12937 * @return the map that was built
12938 */
12939 Map<Source, ResolvableLibrary> _buildLibraryMap() {
12940 Map<Source, ResolvableLibrary> libraryMap = new Map<Source, ResolvableLibrar y>();
12941 int libraryCount = librariesInCycle.length;
12942 for (int i = 0; i < libraryCount; i++) {
12943 ResolvableLibrary library = librariesInCycle[i];
12944 library.errorListener = _errorListener;
12945 libraryMap[library.librarySource] = library;
12946 List<ResolvableLibrary> dependencies = library.importsAndExports;
12947 int dependencyCount = dependencies.length;
12948 for (int j = 0; j < dependencyCount; j++) {
12949 ResolvableLibrary dependency = dependencies[j];
12950 //dependency.setErrorListener(errorListener);
12951 libraryMap[dependency.librarySource] = dependency;
12952 }
12953 }
12954 return libraryMap;
12955 }
12956
12957 /**
12958 * Resolve the type hierarchy across all of the types declared in the librarie s in the current
12959 * cycle.
12960 *
12961 * @throws AnalysisException if any of the type hierarchies could not be resol ved
12962 */
12963 void _buildTypeHierarchies(TypeProvider typeProvider) {
12964 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art();
12965 try {
12966 for (ResolvableLibrary library in librariesInCycle) {
12967 for (ResolvableCompilationUnit unit in library.resolvableCompilationUnit s) {
12968 Source source = unit.source;
12969 CompilationUnit ast = unit.compilationUnit;
12970 TypeResolverVisitor visitor = new TypeResolverVisitor.con4(library, so urce, typeProvider);
12971 ast.accept(visitor);
12972 }
12973 }
12974 } finally {
12975 timeCounter.stop();
12976 }
12977 }
12978
12979 /**
12980 * Return an array containing the lexical identifiers associated with the node s in the given list.
12981 *
12982 * @param names the AST nodes representing the identifiers
12983 * @return the lexical identifiers associated with the nodes in the list
12984 */
12985 List<String> _getIdentifiers(NodeList<SimpleIdentifier> names) {
12986 int count = names.length;
12987 List<String> identifiers = new List<String>(count);
12988 for (int i = 0; i < count; i++) {
12989 identifiers[i] = names[i].name;
12990 }
12991 return identifiers;
12992 }
12993 }
12994
12995 /**
11813 * Instances of the class `GenerateDartErrorsTask` generate errors and warnings for a single 12996 * Instances of the class `GenerateDartErrorsTask` generate errors and warnings for a single
11814 * Dart source. 12997 * Dart source.
11815 */ 12998 */
11816 class GenerateDartErrorsTask extends AnalysisTask { 12999 class GenerateDartErrorsTask extends AnalysisTask {
11817 /** 13000 /**
11818 * The source for which errors and warnings are to be produced. 13001 * The source for which errors and warnings are to be produced.
11819 */ 13002 */
11820 final Source source; 13003 final Source source;
11821 13004
11822 /** 13005 /**
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
12569 libraries.add(librarySource); 13752 libraries.add(librarySource);
12570 } 13753 }
12571 } on URISyntaxException catch (e) { 13754 } on URISyntaxException catch (e) {
12572 } 13755 }
12573 } 13756 }
12574 return super.visitHtmlScriptTagNode(node); 13757 return super.visitHtmlScriptTagNode(node);
12575 } 13758 }
12576 } 13759 }
12577 13760
12578 /** 13761 /**
13762 * Instances of the class `PolymerBuildHtmlTask` build Polymer specific elements .
13763 */
13764 class PolymerBuildHtmlTask extends AnalysisTask {
13765 /**
13766 * The source to build which Polymer HTML elements for.
13767 */
13768 final Source source;
13769
13770 /**
13771 * The time at which the contents of the source were last modified.
13772 */
13773 final int modificationTime;
13774
13775 /**
13776 * The line information associated with the source.
13777 */
13778 final LineInfo _lineInfo;
13779
13780 /**
13781 * The HTML unit to be resolved.
13782 */
13783 final ht.HtmlUnit _unit;
13784
13785 /**
13786 * The resolution errors that were discovered while building elements.
13787 */
13788 List<AnalysisError> _errors = AnalysisError.NO_ERRORS;
13789
13790 /**
13791 * Initialize a newly created task to perform analysis within the given contex t.
13792 *
13793 * @param context the context in which the task is to be performed
13794 * @param source the source to be resolved
13795 * @param modificationTime the time at which the contents of the source were l ast modified
13796 * @param lineInfo the line information associated with the source
13797 * @param unit the HTML unit to build Polymer elements for
13798 */
13799 PolymerBuildHtmlTask(InternalAnalysisContext context, this.source, this.modifi cationTime, this._lineInfo, this._unit) : super(context);
13800
13801 @override
13802 accept(AnalysisTaskVisitor visitor) => visitor.visitPolymerBuildHtmlTask(this) ;
13803
13804 List<AnalysisError> get errors => _errors;
13805
13806 @override
13807 String get taskDescription => "build Polymer elements ${source.fullName}";
13808
13809 @override
13810 void internalPerform() {
13811 RecordingErrorListener errorListener = new RecordingErrorListener();
13812 PolymerHtmlUnitBuilder resolver = new PolymerHtmlUnitBuilder(context, errorL istener, source, _lineInfo, _unit);
13813 resolver.build();
13814 _errors = errorListener.getErrorsForSource(source);
13815 }
13816 }
13817
13818 /**
13819 * Instances of the class `PolymerResolveHtmlTask` performs Polymer specific HTM L file
13820 * resolution.
13821 *
13822 * TODO(scheglov) implement it
13823 */
13824 class PolymerResolveHtmlTask extends AnalysisTask {
13825 /**
13826 * The source to be resolved.
13827 */
13828 final Source source;
13829
13830 /**
13831 * The time at which the contents of the source were last modified.
13832 */
13833 final int modificationTime;
13834
13835 /**
13836 * The line information associated with the source.
13837 */
13838 final LineInfo _lineInfo;
13839
13840 /**
13841 * The HTML unit to be resolved.
13842 */
13843 final ht.HtmlUnit _unit;
13844
13845 /**
13846 * The resolution errors that were discovered while resolving the source.
13847 */
13848 List<AnalysisError> _errors = AnalysisError.NO_ERRORS;
13849
13850 /**
13851 * Initialize a newly created task to perform analysis within the given contex t.
13852 *
13853 * @param context the context in which the task is to be performed
13854 * @param source the source to be resolved
13855 * @param modificationTime the time at which the contents of the source were l ast modified
13856 * @param unit the HTML unit to be resolved
13857 */
13858 PolymerResolveHtmlTask(InternalAnalysisContext context, this.source, this.modi ficationTime, this._lineInfo, this._unit) : super(context);
13859
13860 @override
13861 accept(AnalysisTaskVisitor visitor) => visitor.visitPolymerResolveHtmlTask(thi s);
13862
13863 List<AnalysisError> get errors => _errors;
13864
13865 @override
13866 String get taskDescription => "resolve as Polymer ${source.fullName}";
13867
13868 @override
13869 void internalPerform() {
13870 RecordingErrorListener errorListener = new RecordingErrorListener();
13871 PolymerHtmlUnitResolver resolver = new PolymerHtmlUnitResolver(context, erro rListener, source, _lineInfo, _unit);
13872 resolver.resolveUnit();
13873 _errors = errorListener.getErrorsForSource(source);
13874 }
13875 }
13876
13877 /**
12579 * Instances of the class `ResolveAngularComponentTemplateTask` resolve HTML tem plate 13878 * Instances of the class `ResolveAngularComponentTemplateTask` resolve HTML tem plate
12580 * referenced by [AngularComponentElement]. 13879 * referenced by [AngularComponentElement].
12581 */ 13880 */
12582 class ResolveAngularComponentTemplateTask extends AnalysisTask { 13881 class ResolveAngularComponentTemplateTask extends AnalysisTask {
12583 /** 13882 /**
12584 * The source to be resolved. 13883 * The source to be resolved.
12585 */ 13884 */
12586 final Source source; 13885 final Source source;
12587 13886
12588 /** 13887 /**
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
12633 List<AnalysisError> get resolutionErrors => _resolutionErrors; 13932 List<AnalysisError> get resolutionErrors => _resolutionErrors;
12634 13933
12635 /** 13934 /**
12636 * Return the [HtmlUnit] that was resolved by this task. 13935 * Return the [HtmlUnit] that was resolved by this task.
12637 * 13936 *
12638 * @return the [HtmlUnit] that was resolved by this task 13937 * @return the [HtmlUnit] that was resolved by this task
12639 */ 13938 */
12640 ht.HtmlUnit get resolvedUnit => _resolvedUnit; 13939 ht.HtmlUnit get resolvedUnit => _resolvedUnit;
12641 13940
12642 @override 13941 @override
12643 String get taskDescription => "resolving Angular template ${source}"; 13942 String get taskDescription => "resolve as Angular template ${source}";
12644 13943
12645 @override 13944 @override
12646 void internalPerform() { 13945 void internalPerform() {
12647 // 13946 //
12648 // Prepare for resolution. 13947 // Prepare for resolution.
12649 // 13948 //
12650 RecordingErrorListener errorListener = new RecordingErrorListener(); 13949 RecordingErrorListener errorListener = new RecordingErrorListener();
12651 LineInfo lineInfo = context.getLineInfo(source); 13950 LineInfo lineInfo = context.getLineInfo(source);
12652 // 13951 //
12653 // Perform resolution. 13952 // Perform resolution.
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
13298 } 14597 }
13299 14598
13300 @override 14599 @override
13301 void logInformation(String message) { 14600 void logInformation(String message) {
13302 } 14601 }
13303 14602
13304 @override 14603 @override
13305 void logInformation2(String message, Exception exception) { 14604 void logInformation2(String message, Exception exception) {
13306 } 14605 }
13307 } 14606 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/lib/src/generated/error.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698