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

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

Issue 630743002: Remove cache entry copying (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/engine_test.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 'dart:collection'; 10 import 'dart:collection';
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 * This method should be used rather than the method [Source#exists] because c ontexts can 405 * This method should be used rather than the method [Source#exists] because c ontexts can
406 * have local overrides of the content of a source that the source is not awar e of and a source 406 * have local overrides of the content of a source that the source is not awar e of and a source
407 * with local content is considered to exist even if there is no file on disk. 407 * with local content is considered to exist even if there is no file on disk.
408 * 408 *
409 * @param source the source whose modification stamp is to be returned 409 * @param source the source whose modification stamp is to be returned
410 * @return `true` if the source exists 410 * @return `true` if the source exists
411 */ 411 */
412 bool exists(Source source); 412 bool exists(Source source);
413 413
414 /** 414 /**
415 * Create a new context in which analysis can be performed. Any sources in the specified container
416 * will be removed from this context and added to the newly created context.
417 *
418 * @param container the container containing sources that should be removed fr om this context and
419 * added to the returned context
420 * @return the analysis context that was created
421 */
422 AnalysisContext extractContext(SourceContainer container);
423
424 /**
425 * Return the set of analysis options controlling the behavior of this context . Clients should not 415 * Return the set of analysis options controlling the behavior of this context . Clients should not
426 * modify the returned set of options. The options should only be set by invok ing the method 416 * modify the returned set of options. The options should only be set by invok ing the method
427 * [setAnalysisOptions]. 417 * [setAnalysisOptions].
428 * 418 *
429 * @return the set of analysis options controlling the behavior of this contex t 419 * @return the set of analysis options controlling the behavior of this contex t
430 */ 420 */
431 AnalysisOptions get analysisOptions; 421 AnalysisOptions get analysisOptions;
432 422
433 /** 423 /**
434 * Return the Angular application that contains the HTML file defined by the g iven source, or 424 * Return the Angular application that contains the HTML file defined by the g iven source, or
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 * to be a library that cannot be run on the server, this method will also ret urn `false` if 701 * to be a library that cannot be run on the server, this method will also ret urn `false` if
712 * the source is not known to be a library or if we do not know whether it can be run on the 702 * the source is not known to be a library or if we do not know whether it can be run on the
713 * server. 703 * server.
714 * 704 *
715 * @param librarySource the source being tested 705 * @param librarySource the source being tested
716 * @return `true` if the given source is known to be a library that can be run on the server 706 * @return `true` if the given source is known to be a library that can be run on the server
717 */ 707 */
718 bool isServerLibrary(Source librarySource); 708 bool isServerLibrary(Source librarySource);
719 709
720 /** 710 /**
721 * Add the sources contained in the specified context to this context's collec tion of sources.
722 * This method is called when an existing context's pubspec has been removed, and the contained
723 * sources should be reanalyzed as part of this context.
724 *
725 * @param context the context being merged
726 */
727 void mergeContext(AnalysisContext context);
728
729 /**
730 * Parse a single source to produce an AST structure. The resulting AST struct ure may or may not 711 * Parse a single source to produce an AST structure. The resulting AST struct ure may or may not
731 * be resolved, and may have a slightly different structure depending upon whe ther it is resolved. 712 * be resolved, and may have a slightly different structure depending upon whe ther it is resolved.
732 * 713 *
733 * <b>Note:</b> This method cannot be used in an async environment. 714 * <b>Note:</b> This method cannot be used in an async environment.
734 * 715 *
735 * @param source the source to be parsed 716 * @param source the source to be parsed
736 * @return the AST structure representing the content of the source 717 * @return the AST structure representing the content of the source
737 * @throws AnalysisException if the analysis could not be performed 718 * @throws AnalysisException if the analysis could not be performed
738 */ 719 */
739 CompilationUnit parseCompilationUnit(Source source); 720 CompilationUnit parseCompilationUnit(Source source);
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 SourceEntry sourceEntry = iterator.value; 1080 SourceEntry sourceEntry = iterator.value;
1100 if (!source.isInSystemLibrary && (sourceEntry is DartEntry || sourceEntr y is HtmlEntry)) { 1081 if (!source.isInSystemLibrary && (sourceEntry is DartEntry || sourceEntr y is HtmlEntry)) {
1101 sourcesToInvalidate.add(source); 1082 sourcesToInvalidate.add(source);
1102 } 1083 }
1103 } 1084 }
1104 int count = sourcesToInvalidate.length; 1085 int count = sourcesToInvalidate.length;
1105 for (int i = 0; i < count; i++) { 1086 for (int i = 0; i < count; i++) {
1106 Source source = sourcesToInvalidate[i]; 1087 Source source = sourcesToInvalidate[i];
1107 SourceEntry entry = _getReadableSourceEntry(source); 1088 SourceEntry entry = _getReadableSourceEntry(source);
1108 if (entry is DartEntry) { 1089 if (entry is DartEntry) {
1109 DartEntry dartEntry = entry; 1090 (entry as DartEntryImpl).invalidateAllResolutionInformation(false);
1110 DartEntryImpl dartCopy = dartEntry.writableCopy; 1091 _workManager.add(source, _computePriority(entry));
1111 dartCopy.invalidateAllResolutionInformation(false);
1112 _cache.put(source, dartCopy);
1113 _workManager.add(source, _computePriority(dartCopy));
1114 } else if (entry is HtmlEntry) { 1092 } else if (entry is HtmlEntry) {
1115 HtmlEntry htmlEntry = entry; 1093 (entry as HtmlEntryImpl).invalidateAllResolutionInformation(false);
1116 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
1117 htmlCopy.invalidateAllResolutionInformation(false);
1118 _cache.put(source, htmlCopy);
1119 _workManager.add(source, SourcePriority.HTML); 1094 _workManager.add(source, SourcePriority.HTML);
1120 } 1095 }
1121 } 1096 }
1122 } 1097 }
1123 } 1098 }
1124 1099
1125 @override 1100 @override
1126 String computeDocumentationComment(Element element) { 1101 String computeDocumentationComment(Element element) {
1127 if (element == null) { 1102 if (element == null) {
1128 return null; 1103 return null;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 return _getDartScanData2(source, SourceEntry.LINE_INFO, null); 1220 return _getDartScanData2(source, SourceEntry.LINE_INFO, null);
1246 } 1221 }
1247 } on ObsoleteSourceAnalysisException catch (exception) { 1222 } on ObsoleteSourceAnalysisException catch (exception) {
1248 AnalysisEngine.instance.logger.logInformation2("Could not compute ${Source Entry.LINE_INFO.toString()}", exception); 1223 AnalysisEngine.instance.logger.logInformation2("Could not compute ${Source Entry.LINE_INFO.toString()}", exception);
1249 } 1224 }
1250 return null; 1225 return null;
1251 } 1226 }
1252 1227
1253 @override 1228 @override
1254 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) { 1229 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) {
1255 DartEntry dartEntry = _getReadableDartEntry(source); 1230 DartEntryImpl dartEntry = _getReadableDartEntry(source);
1256 if (dartEntry == null) { 1231 if (dartEntry == null) {
1257 throw new AnalysisException("computeResolvableCompilationUnit for non-Dart : ${source.fullName}"); 1232 throw new AnalysisException("computeResolvableCompilationUnit for non-Dart : ${source.fullName}");
1258 } 1233 }
1259 dartEntry = _cacheDartParseData(source, dartEntry, DartEntry.PARSED_UNIT); 1234 dartEntry = _cacheDartParseData(source, dartEntry, DartEntry.PARSED_UNIT);
1260 DartEntryImpl dartCopy = dartEntry.writableCopy; 1235 CompilationUnit unit = dartEntry.resolvableCompilationUnit;
1261 CompilationUnit unit = dartCopy.resolvableCompilationUnit;
1262 if (unit == null) { 1236 if (unit == null) {
1263 throw new AnalysisException("Internal error: computeResolvableCompilationU nit could not parse ${source.fullName}", new CaughtException(dartEntry.exception , null)); 1237 throw new AnalysisException("Internal error: computeResolvableCompilationU nit could not parse ${source.fullName}", new CaughtException(dartEntry.exception , null));
1264 } 1238 }
1265 _cache.put(source, dartCopy); 1239 return new ResolvableCompilationUnit.con1(dartEntry.modificationTime, unit);
1266 return new ResolvableCompilationUnit.con1(dartCopy.modificationTime, unit);
1267 } 1240 }
1268 1241
1269 @override 1242 @override
1270 void dispose() { 1243 void dispose() {
1271 _disposed = true; 1244 _disposed = true;
1272 } 1245 }
1273 1246
1274 @override 1247 @override
1275 bool exists(Source source) { 1248 bool exists(Source source) {
1276 if (source == null) { 1249 if (source == null) {
1277 return false; 1250 return false;
1278 } 1251 }
1279 if (_contentCache.getContents(source) != null) { 1252 if (_contentCache.getContents(source) != null) {
1280 return true; 1253 return true;
1281 } 1254 }
1282 return source.exists(); 1255 return source.exists();
1283 } 1256 }
1284 1257
1285 @override 1258 @override
1286 AnalysisContext extractContext(SourceContainer container) => extractContextInt o(container, AnalysisEngine.instance.createAnalysisContext() as InternalAnalysis Context);
1287
1288 @override
1289 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) {
1290 List<Source> sourcesToRemove = new List<Source>();
1291 // Move sources in the specified directory to the new context
1292 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
1293 while (iterator.moveNext()) {
1294 Source source = iterator.key;
1295 SourceEntry sourceEntry = iterator.value;
1296 if (container.contains(source)) {
1297 sourcesToRemove.add(source);
1298 newContext.addSourceInfo(source, sourceEntry.writableCopy);
1299 }
1300 }
1301 return newContext;
1302 }
1303
1304 @override
1305 AnalysisOptions get analysisOptions => _options; 1259 AnalysisOptions get analysisOptions => _options;
1306 1260
1307 @override 1261 @override
1308 AngularApplication getAngularApplicationWithHtml(Source htmlSource) { 1262 AngularApplication getAngularApplicationWithHtml(Source htmlSource) {
1309 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(htmlSource); 1263 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(htmlSource);
1310 if (sourceEntry is HtmlEntry) { 1264 if (sourceEntry is HtmlEntry) {
1311 HtmlEntry htmlEntry = sourceEntry; 1265 HtmlEntry htmlEntry = sourceEntry;
1312 AngularApplication application = htmlEntry.getValue(HtmlEntry.ANGULAR_APPL ICATION); 1266 AngularApplication application = htmlEntry.getValue(HtmlEntry.ANGULAR_APPL ICATION);
1313 if (application != null) { 1267 if (application != null) {
1314 return application; 1268 return application;
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 } 1517 }
1564 1518
1565 @override 1519 @override
1566 List<Source> get prioritySources => _priorityOrder; 1520 List<Source> get prioritySources => _priorityOrder;
1567 1521
1568 @override 1522 @override
1569 Namespace getPublicNamespace(LibraryElement library) { 1523 Namespace getPublicNamespace(LibraryElement library) {
1570 // TODO(brianwilkerson) Rename this to not start with 'get'. Note that this is not part of the 1524 // TODO(brianwilkerson) Rename this to not start with 'get'. Note that this is not part of the
1571 // API of the interface. 1525 // API of the interface.
1572 Source source = library.definingCompilationUnit.source; 1526 Source source = library.definingCompilationUnit.source;
1573 DartEntry dartEntry = _getReadableDartEntry(source); 1527 DartEntryImpl dartEntry = _getReadableDartEntry(source);
1574 if (dartEntry == null) { 1528 if (dartEntry == null) {
1575 return null; 1529 return null;
1576 } 1530 }
1577 Namespace namespace = null; 1531 Namespace namespace = null;
1578 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { 1532 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) {
1579 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); 1533 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE);
1580 } 1534 }
1581 if (namespace == null) { 1535 if (namespace == null) {
1582 NamespaceBuilder builder = new NamespaceBuilder(); 1536 NamespaceBuilder builder = new NamespaceBuilder();
1583 namespace = builder.createPublicNamespaceForLibrary(library); 1537 namespace = builder.createPublicNamespaceForLibrary(library);
1584 dartEntry = _getReadableDartEntry(source);
1585 if (dartEntry == null) { 1538 if (dartEntry == null) {
1586 AnalysisEngine.instance.logger.logError2("Could not compute the public n amespace for ${library.source.fullName}", new CaughtException(new AnalysisExcept ion("A Dart file became a non-Dart file: ${source.fullName}"), null)); 1539 AnalysisEngine.instance.logger.logError2("Could not compute the public n amespace for ${library.source.fullName}", new CaughtException(new AnalysisExcept ion("A Dart file became a non-Dart file: ${source.fullName}"), null));
1587 return null; 1540 return null;
1588 } 1541 }
1589 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { 1542 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) {
1590 DartEntryImpl dartCopy = _getReadableDartEntry(source).writableCopy; 1543 dartEntry.setValue(DartEntry.PUBLIC_NAMESPACE, namespace);
1591 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace);
1592 _cache.put(source, dartCopy);
1593 } 1544 }
1594 } 1545 }
1595 return namespace; 1546 return namespace;
1596 } 1547 }
1597 1548
1598 @override 1549 @override
1599 List<Source> get refactoringUnsafeSources { 1550 List<Source> get refactoringUnsafeSources {
1600 List<Source> sources = new List<Source>(); 1551 List<Source> sources = new List<Source>();
1601 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); 1552 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
1602 while (iterator.moveNext()) { 1553 while (iterator.moveNext()) {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 bool isServerLibrary(Source librarySource) { 1702 bool isServerLibrary(Source librarySource) {
1752 SourceEntry sourceEntry = _getReadableSourceEntry(librarySource); 1703 SourceEntry sourceEntry = _getReadableSourceEntry(librarySource);
1753 if (sourceEntry is DartEntry) { 1704 if (sourceEntry is DartEntry) {
1754 DartEntry dartEntry = sourceEntry; 1705 DartEntry dartEntry = sourceEntry;
1755 return !dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(Dart Entry.IS_LAUNCHABLE); 1706 return !dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(Dart Entry.IS_LAUNCHABLE);
1756 } 1707 }
1757 return false; 1708 return false;
1758 } 1709 }
1759 1710
1760 @override 1711 @override
1761 void mergeContext(AnalysisContext context) {
1762 if (context is InstrumentedAnalysisContextImpl) {
1763 context = (context as InstrumentedAnalysisContextImpl).basis;
1764 }
1765 if (context is! AnalysisContextImpl) {
1766 return;
1767 }
1768 // TODO(brianwilkerson) This does not lock against the other context's cache Lock.
1769 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
1770 while (iterator.moveNext()) {
1771 Source newSource = iterator.key;
1772 SourceEntry existingEntry = _getReadableSourceEntry(newSource);
1773 if (existingEntry == null) {
1774 // TODO(brianwilkerson) Decide whether we really need to copy the info.
1775 _cache.put(newSource, iterator.value.writableCopy);
1776 } else {
1777 // TODO(brianwilkerson) Decide whether/how to merge the entries.
1778 }
1779 }
1780 }
1781
1782 @override
1783 CompilationUnit parseCompilationUnit(Source source) => _getDartParseData2(sour ce, DartEntry.PARSED_UNIT, null); 1712 CompilationUnit parseCompilationUnit(Source source) => _getDartParseData2(sour ce, DartEntry.PARSED_UNIT, null);
1784 1713
1785 @override 1714 @override
1786 ht.HtmlUnit parseHtmlUnit(Source source) => _getHtmlParseData(source, HtmlEntr y.PARSED_UNIT, null); 1715 ht.HtmlUnit parseHtmlUnit(Source source) => _getHtmlParseData(source, HtmlEntr y.PARSED_UNIT, null);
1787 1716
1788 @override 1717 @override
1789 AnalysisResult performAnalysisTask() { 1718 AnalysisResult performAnalysisTask() {
1790 if (_TRACE_PERFORM_TASK) { 1719 if (_TRACE_PERFORM_TASK) {
1791 print("----------------------------------------"); 1720 print("----------------------------------------");
1792 } 1721 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 1776
1848 @override 1777 @override
1849 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { 1778 void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
1850 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); 1779 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML);
1851 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap)) { 1780 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap)) {
1852 Source librarySource = entry.getKey(); 1781 Source librarySource = entry.getKey();
1853 LibraryElement library = entry.getValue(); 1782 LibraryElement library = entry.getValue();
1854 // 1783 //
1855 // Cache the element in the library's info. 1784 // Cache the element in the library's info.
1856 // 1785 //
1857 DartEntry dartEntry = _getReadableDartEntry(librarySource); 1786 DartEntryImpl dartEntry = _getReadableDartEntry(librarySource);
1858 if (dartEntry != null) { 1787 if (dartEntry != null) {
1859 DartEntryImpl dartCopy = dartEntry.writableCopy; 1788 _recordElementData(dartEntry, library, library.source, htmlSource);
1860 _recordElementData(dartCopy, library, library.source, htmlSource); 1789 dartEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED);
1861 dartCopy.setState(SourceEntry.CONTENT, CacheState.FLUSHED); 1790 dartEntry.setValue(SourceEntry.LINE_INFO, new LineInfo(<int> [0]));
1862 dartCopy.setValue(SourceEntry.LINE_INFO, new LineInfo(<int> [0])); 1791 dartEntry.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS);
1863 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS);
1864 // DartEntry.ELEMENT - set in recordElementData 1792 // DartEntry.ELEMENT - set in recordElementData
1865 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY); 1793 dartEntry.setValue(DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY);
1866 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY); 1794 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY);
1867 dartCopy.setValue(DartEntry.INCLUDED_PARTS, Source.EMPTY_ARRAY); 1795 dartEntry.setValue(DartEntry.INCLUDED_PARTS, Source.EMPTY_ARRAY);
1868 // DartEntry.IS_CLIENT - set in recordElementData 1796 // DartEntry.IS_CLIENT - set in recordElementData
1869 // DartEntry.IS_LAUNCHABLE - set in recordElementData 1797 // DartEntry.IS_LAUNCHABLE - set in recordElementData
1870 dartCopy.setValue(DartEntry.PARSE_ERRORS, AnalysisError.NO_ERRORS); 1798 dartEntry.setValue(DartEntry.PARSE_ERRORS, AnalysisError.NO_ERRORS);
1871 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); 1799 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
1872 dartCopy.setState(DartEntry.PUBLIC_NAMESPACE, CacheState.FLUSHED); 1800 dartEntry.setState(DartEntry.PUBLIC_NAMESPACE, CacheState.FLUSHED);
1873 dartCopy.setValue(DartEntry.SCAN_ERRORS, AnalysisError.NO_ERRORS); 1801 dartEntry.setValue(DartEntry.SCAN_ERRORS, AnalysisError.NO_ERRORS);
1874 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); 1802 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
1875 dartCopy.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED); 1803 dartEntry.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED);
1876 dartCopy.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySource, A nalysisError.NO_ERRORS); 1804 dartEntry.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySource, AnalysisError.NO_ERRORS);
1877 dartCopy.setStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource, Cache State.FLUSHED); 1805 dartEntry.setStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource, Cach eState.FLUSHED);
1878 dartCopy.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource, AnalysisError.NO_ERRORS); 1806 dartEntry.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource , AnalysisError.NO_ERRORS);
1879 dartCopy.setValueInLibrary(DartEntry.HINTS, librarySource, AnalysisError .NO_ERRORS); 1807 dartEntry.setValueInLibrary(DartEntry.HINTS, librarySource, AnalysisErro r.NO_ERRORS);
1880 _cache.put(librarySource, dartCopy);
1881 } 1808 }
1882 } 1809 }
1883 } 1810 }
1884 1811
1885 @override 1812 @override
1886 void removeListener(AnalysisListener listener) { 1813 void removeListener(AnalysisListener listener) {
1887 _listeners.remove(listener); 1814 _listeners.remove(listener);
1888 } 1815 }
1889 1816
1890 @override 1817 @override
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 void setChangedContents(Source source, String contents, int offset, int oldLen gth, int newLength) { 1895 void setChangedContents(Source source, String contents, int offset, int oldLen gth, int newLength) {
1969 _recentTasks.clear(); 1896 _recentTasks.clear();
1970 _reportedLoop = false; 1897 _reportedLoop = false;
1971 String originalContents = _contentCache.setContents(source, contents); 1898 String originalContents = _contentCache.setContents(source, contents);
1972 if (contents != null) { 1899 if (contents != null) {
1973 if (contents != originalContents) { 1900 if (contents != originalContents) {
1974 if (_options.incremental) { 1901 if (_options.incremental) {
1975 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increment alAnalysisCache, source, originalContents, contents, offset, oldLength, newLengt h, _getReadableSourceEntry(source)); 1902 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increment alAnalysisCache, source, originalContents, contents, offset, oldLength, newLengt h, _getReadableSourceEntry(source));
1976 } 1903 }
1977 _sourceChanged(source); 1904 _sourceChanged(source);
1978 SourceEntry sourceEntry = _cache.get(source); 1905 SourceEntryImpl sourceEntry = _cache.get(source);
1979 if (sourceEntry != null) { 1906 if (sourceEntry != null) {
1980 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; 1907 sourceEntry.modificationTime = _contentCache.getModificationStamp(sour ce);
1981 sourceCopy.modificationTime = _contentCache.getModificationStamp(sourc e); 1908 sourceEntry.setValue(SourceEntry.CONTENT, contents);
1982 sourceCopy.setValue(SourceEntry.CONTENT, contents);
1983 _cache.put(source, sourceCopy);
1984 } 1909 }
1985 } 1910 }
1986 } else if (originalContents != null) { 1911 } else if (originalContents != null) {
1987 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna lysisCache, source); 1912 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna lysisCache, source);
1988 _sourceChanged(source); 1913 _sourceChanged(source);
1989 } 1914 }
1990 } 1915 }
1991 1916
1992 @override 1917 @override
1993 void setContents(Source source, String contents) { 1918 void setContents(Source source, String contents) {
1994 _recentTasks.clear(); 1919 _recentTasks.clear();
1995 _reportedLoop = false; 1920 _reportedLoop = false;
1996 String originalContents = _contentCache.setContents(source, contents); 1921 String originalContents = _contentCache.setContents(source, contents);
1997 if (contents != null) { 1922 if (contents != null) {
1998 if (contents != originalContents) { 1923 if (contents != originalContents) {
1999 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA nalysisCache, source); 1924 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA nalysisCache, source);
2000 _sourceChanged(source); 1925 _sourceChanged(source);
2001 SourceEntry sourceEntry = _cache.get(source); 1926 SourceEntryImpl sourceEntry = _cache.get(source);
2002 if (sourceEntry != null) { 1927 if (sourceEntry != null) {
2003 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; 1928 sourceEntry.modificationTime = _contentCache.getModificationStamp(sour ce);
2004 sourceCopy.modificationTime = _contentCache.getModificationStamp(sourc e); 1929 sourceEntry.setValue(SourceEntry.CONTENT, contents);
2005 sourceCopy.setValue(SourceEntry.CONTENT, contents);
2006 _cache.put(source, sourceCopy);
2007 } 1930 }
2008 } 1931 }
2009 } else if (originalContents != null) { 1932 } else if (originalContents != null) {
2010 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna lysisCache, source); 1933 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna lysisCache, source);
2011 _sourceChanged(source); 1934 _sourceChanged(source);
2012 } 1935 }
2013 } 1936 }
2014 1937
2015 @override 1938 @override
2016 void set sourceFactory(SourceFactory factory) { 1939 void set sourceFactory(SourceFactory factory) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 * Record the results produced by performing a [ResolveDartLibraryCycleTask]. If the results 1975 * Record the results produced by performing a [ResolveDartLibraryCycleTask]. If the results
2053 * were computed from data that is now out-of-date, then the results will not be recorded. 1976 * were computed from data that is now out-of-date, then the results will not be recorded.
2054 * 1977 *
2055 * @param task the task that was performed 1978 * @param task the task that was performed
2056 * @return an entry containing the computed results 1979 * @return an entry containing the computed results
2057 * @throws AnalysisException if the results could not be recorded 1980 * @throws AnalysisException if the results could not be recorded
2058 */ 1981 */
2059 DartEntry recordResolveDartLibraryCycleTaskResults(ResolveDartLibraryCycleTask task) { 1982 DartEntry recordResolveDartLibraryCycleTaskResults(ResolveDartLibraryCycleTask task) {
2060 LibraryResolver2 resolver = task.libraryResolver; 1983 LibraryResolver2 resolver = task.libraryResolver;
2061 CaughtException thrownException = task.exception; 1984 CaughtException thrownException = task.exception;
2062 DartEntry unitEntry = null; 1985 DartEntryImpl unitEntry = null;
2063 Source unitSource = task.unitSource; 1986 Source unitSource = task.unitSource;
2064 if (resolver != null) { 1987 if (resolver != null) {
2065 // 1988 //
2066 // The resolver should only be null if an exception was thrown before (or while) it was 1989 // The resolver should only be null if an exception was thrown before (or while) it was
2067 // being created. 1990 // being created.
2068 // 1991 //
2069 List<ResolvableLibrary> resolvedLibraries = resolver.resolvedLibraries; 1992 List<ResolvableLibrary> resolvedLibraries = resolver.resolvedLibraries;
2070 if (resolvedLibraries == null) { 1993 if (resolvedLibraries == null) {
2071 // 1994 //
2072 // The resolved libraries should only be null if an exception was thrown during resolution. 1995 // The resolved libraries should only be null if an exception was thrown during resolution.
2073 // 1996 //
2074 unitEntry = _getReadableDartEntry(unitSource); 1997 unitEntry = _getReadableDartEntry(unitSource);
2075 if (unitEntry == null) { 1998 if (unitEntry == null) {
2076 throw new AnalysisException("A Dart file became a non-Dart file: ${uni tSource.fullName}"); 1999 throw new AnalysisException("A Dart file became a non-Dart file: ${uni tSource.fullName}");
2077 } 2000 }
2078 DartEntryImpl dartCopy = unitEntry.writableCopy;
2079 if (thrownException == null) { 2001 if (thrownException == null) {
2080 dartCopy.recordResolutionError(new CaughtException(new AnalysisExcepti on("In recordResolveDartLibraryCycleTaskResults, resolvedLibraries was null and there was no thrown exception"), null)); 2002 unitEntry.recordResolutionError(new CaughtException(new AnalysisExcept ion("In recordResolveDartLibraryCycleTaskResults, resolvedLibraries was null and there was no thrown exception"), null));
2081 } else { 2003 } else {
2082 dartCopy.recordResolutionError(thrownException); 2004 unitEntry.recordResolutionError(thrownException);
2083 } 2005 }
2084 _cache.put(unitSource, dartCopy);
2085 _cache.remove(unitSource); 2006 _cache.remove(unitSource);
2086 if (thrownException != null) { 2007 if (thrownException != null) {
2087 throw new AnalysisException('<rethrow>', thrownException); 2008 throw new AnalysisException('<rethrow>', thrownException);
2088 } 2009 }
2089 return dartCopy; 2010 return unitEntry;
2090 } 2011 }
2091 if (_allModificationTimesMatch(resolvedLibraries)) { 2012 if (_allModificationTimesMatch(resolvedLibraries)) {
2092 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); 2013 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
2093 RecordingErrorListener errorListener = resolver.errorListener; 2014 RecordingErrorListener errorListener = resolver.errorListener;
2094 for (ResolvableLibrary library in resolvedLibraries) { 2015 for (ResolvableLibrary library in resolvedLibraries) {
2095 Source librarySource = library.librarySource; 2016 Source librarySource = library.librarySource;
2096 for (Source source in library.compilationUnitSources) { 2017 for (Source source in library.compilationUnitSources) {
2097 CompilationUnit unit = library.getAST(source); 2018 CompilationUnit unit = library.getAST(source);
2098 List<AnalysisError> errors = errorListener.getErrorsForSource(source ); 2019 List<AnalysisError> errors = errorListener.getErrorsForSource(source );
2099 LineInfo lineInfo = getLineInfo(source); 2020 LineInfo lineInfo = getLineInfo(source);
2100 DartEntryImpl dartCopy = _cache.get(source).writableCopy as DartEntr yImpl; 2021 DartEntryImpl dartEntry = _cache.get(source);
2101 if (thrownException == null) { 2022 if (thrownException == null) {
2102 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); 2023 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
2103 dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, unit); 2024 dartEntry.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource , unit);
2104 dartCopy.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySou rce, errors); 2025 dartEntry.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySo urce, errors);
2105 if (source == librarySource) { 2026 if (source == librarySource) {
2106 _recordElementData(dartCopy, library.libraryElement, librarySour ce, htmlSource); 2027 _recordElementData(dartEntry, library.libraryElement, librarySou rce, htmlSource);
2107 } 2028 }
2108 _cache.storedAst(source); 2029 _cache.storedAst(source);
2109 } else { 2030 } else {
2110 dartCopy.recordResolutionErrorInLibrary(librarySource, thrownExcep tion); 2031 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownExce ption);
2111 _cache.remove(source); 2032 _cache.remove(source);
2112 } 2033 }
2113 _cache.put(source, dartCopy);
2114 if (source != librarySource) { 2034 if (source != librarySource) {
2115 _workManager.add(source, SourcePriority.PRIORITY_PART); 2035 _workManager.add(source, SourcePriority.PRIORITY_PART);
2116 } 2036 }
2117 if (source == unitSource) { 2037 if (source == unitSource) {
2118 unitEntry = dartCopy; 2038 unitEntry = dartEntry;
2119 } 2039 }
2120 ChangeNoticeImpl notice = _getNotice(source); 2040 ChangeNoticeImpl notice = _getNotice(source);
2121 notice.compilationUnit = unit; 2041 notice.compilationUnit = unit;
2122 notice.setErrors(dartCopy.allErrors, lineInfo); 2042 notice.setErrors(dartEntry.allErrors, lineInfo);
2123 } 2043 }
2124 } 2044 }
2125 } else { 2045 } else {
2126 PrintStringWriter writer = new PrintStringWriter(); 2046 PrintStringWriter writer = new PrintStringWriter();
2127 writer.println("Library resolution results discarded for"); 2047 writer.println("Library resolution results discarded for");
2128 for (ResolvableLibrary library in resolvedLibraries) { 2048 for (ResolvableLibrary library in resolvedLibraries) {
2129 for (Source source in library.compilationUnitSources) { 2049 for (Source source in library.compilationUnitSources) {
2130 DartEntry dartEntry = _getReadableDartEntry(source); 2050 DartEntryImpl dartEntry = _getReadableDartEntry(source);
2131 if (dartEntry != null) { 2051 if (dartEntry != null) {
2132 int resultTime = library.getModificationTime(source); 2052 int resultTime = library.getModificationTime(source);
2133 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.m odificationTime}"); 2053 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.m odificationTime}");
2134 DartEntryImpl dartCopy = dartEntry.writableCopy;
2135 if (thrownException == null || resultTime >= 0) { 2054 if (thrownException == null || resultTime >= 0) {
2136 // 2055 //
2137 // The analysis was performed on out-of-date sources. Mark the c ache so that the 2056 // The analysis was performed on out-of-date sources. Mark the c ache so that the
2138 // sources will be re-analyzed using the up-to-date sources. 2057 // sources will be re-analyzed using the up-to-date sources.
2139 // 2058 //
2140 dartCopy.recordResolutionNotInProcess(); 2059 dartEntry.recordResolutionNotInProcess();
2141 } else { 2060 } else {
2142 // 2061 //
2143 // We could not determine whether the sources were up-to-date or out-of-date. Mark 2062 // We could not determine whether the sources were up-to-date or out-of-date. Mark
2144 // the cache so that we won't attempt to re-analyze the sources until there's a 2063 // the cache so that we won't attempt to re-analyze the sources until there's a
2145 // good chance that we'll be able to do so without error. 2064 // good chance that we'll be able to do so without error.
2146 // 2065 //
2147 dartCopy.recordResolutionError(thrownException); 2066 dartEntry.recordResolutionError(thrownException);
2148 _cache.remove(source); 2067 _cache.remove(source);
2149 } 2068 }
2150 _cache.put(source, dartCopy);
2151 if (source == unitSource) { 2069 if (source == unitSource) {
2152 unitEntry = dartCopy; 2070 unitEntry = dartEntry;
2153 } 2071 }
2154 } else { 2072 } else {
2155 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, no entry"); 2073 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, no entry");
2156 } 2074 }
2157 } 2075 }
2158 } 2076 }
2159 _logInformation(writer.toString()); 2077 _logInformation(writer.toString());
2160 } 2078 }
2161 } 2079 }
2162 if (thrownException != null) { 2080 if (thrownException != null) {
2163 throw new AnalysisException('<rethrow>', thrownException); 2081 throw new AnalysisException('<rethrow>', thrownException);
2164 } 2082 }
2165 if (unitEntry == null) { 2083 if (unitEntry == null) {
2166 unitEntry = _getReadableDartEntry(unitSource); 2084 unitEntry = _getReadableDartEntry(unitSource);
2167 if (unitEntry == null) { 2085 if (unitEntry == null) {
2168 throw new AnalysisException("A Dart file became a non-Dart file: ${unitS ource.fullName}"); 2086 throw new AnalysisException("A Dart file became a non-Dart file: ${unitS ource.fullName}");
2169 } 2087 }
2170 } 2088 }
2171 return unitEntry; 2089 return unitEntry;
2172 } 2090 }
2173 2091
2174 DartEntry recordResolveDartLibraryTaskResults(ResolveDartLibraryTask task) { 2092 DartEntry recordResolveDartLibraryTaskResults(ResolveDartLibraryTask task) {
2175 LibraryResolver resolver = task.libraryResolver; 2093 LibraryResolver resolver = task.libraryResolver;
2176 CaughtException thrownException = task.exception; 2094 CaughtException thrownException = task.exception;
2177 DartEntry unitEntry = null; 2095 DartEntryImpl unitEntry = null;
2178 Source unitSource = task.unitSource; 2096 Source unitSource = task.unitSource;
2179 if (resolver != null) { 2097 if (resolver != null) {
2180 // 2098 //
2181 // The resolver should only be null if an exception was thrown before (or while) it was 2099 // The resolver should only be null if an exception was thrown before (or while) it was
2182 // being created. 2100 // being created.
2183 // 2101 //
2184 Set<Library> resolvedLibraries = resolver.resolvedLibraries; 2102 Set<Library> resolvedLibraries = resolver.resolvedLibraries;
2185 if (resolvedLibraries == null) { 2103 if (resolvedLibraries == null) {
2186 // 2104 //
2187 // The resolved libraries should only be null if an exception was thrown during resolution. 2105 // The resolved libraries should only be null if an exception was thrown during resolution.
2188 // 2106 //
2189 unitEntry = _getReadableDartEntry(unitSource); 2107 unitEntry = _getReadableDartEntry(unitSource);
2190 if (unitEntry == null) { 2108 if (unitEntry == null) {
2191 throw new AnalysisException("A Dart file became a non-Dart file: ${uni tSource.fullName}"); 2109 throw new AnalysisException("A Dart file became a non-Dart file: ${uni tSource.fullName}");
2192 } 2110 }
2193 DartEntryImpl dartCopy = unitEntry.writableCopy;
2194 if (thrownException == null) { 2111 if (thrownException == null) {
2195 dartCopy.recordResolutionError(new CaughtException(new AnalysisExcepti on("In recordResolveDartLibraryTaskResults, resolvedLibraries was null and there was no thrown exception"), null)); 2112 unitEntry.recordResolutionError(new CaughtException(new AnalysisExcept ion("In recordResolveDartLibraryTaskResults, resolvedLibraries was null and ther e was no thrown exception"), null));
2196 } else { 2113 } else {
2197 dartCopy.recordResolutionError(thrownException); 2114 unitEntry.recordResolutionError(thrownException);
2198 } 2115 }
2199 _cache.put(unitSource, dartCopy);
2200 _cache.remove(unitSource); 2116 _cache.remove(unitSource);
2201 if (thrownException != null) { 2117 if (thrownException != null) {
2202 throw new AnalysisException('<rethrow>', thrownException); 2118 throw new AnalysisException('<rethrow>', thrownException);
2203 } 2119 }
2204 return dartCopy; 2120 return unitEntry;
2205 } 2121 }
2206 if (_allModificationTimesMatch2(resolvedLibraries)) { 2122 if (_allModificationTimesMatch2(resolvedLibraries)) {
2207 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); 2123 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
2208 RecordingErrorListener errorListener = resolver.errorListener; 2124 RecordingErrorListener errorListener = resolver.errorListener;
2209 for (Library library in resolvedLibraries) { 2125 for (Library library in resolvedLibraries) {
2210 Source librarySource = library.librarySource; 2126 Source librarySource = library.librarySource;
2211 for (Source source in library.compilationUnitSources) { 2127 for (Source source in library.compilationUnitSources) {
2212 CompilationUnit unit = library.getAST(source); 2128 CompilationUnit unit = library.getAST(source);
2213 List<AnalysisError> errors = errorListener.getErrorsForSource(source ); 2129 List<AnalysisError> errors = errorListener.getErrorsForSource(source );
2214 LineInfo lineInfo = getLineInfo(source); 2130 LineInfo lineInfo = getLineInfo(source);
2215 DartEntry dartEntry = _cache.get(source) as DartEntry; 2131 DartEntryImpl dartEntry = _cache.get(source);
2216 int sourceTime = getModificationStamp(source); 2132 int sourceTime = getModificationStamp(source);
2217 if (dartEntry.modificationTime != sourceTime) { 2133 if (dartEntry.modificationTime != sourceTime) {
2218 // The source has changed without the context being notified. Simu late notification. 2134 // The source has changed without the context being notified. Simu late notification.
2219 _sourceChanged(source); 2135 _sourceChanged(source);
2220 dartEntry = _getReadableDartEntry(source); 2136 dartEntry = _getReadableDartEntry(source);
2221 if (dartEntry == null) { 2137 if (dartEntry == null) {
2222 throw new AnalysisException("A Dart file became a non-Dart file: ${source.fullName}"); 2138 throw new AnalysisException("A Dart file became a non-Dart file: ${source.fullName}");
2223 } 2139 }
2224 } 2140 }
2225 DartEntryImpl dartCopy = dartEntry.writableCopy;
2226 if (thrownException == null) { 2141 if (thrownException == null) {
2227 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); 2142 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo);
2228 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); 2143 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
2229 dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, unit); 2144 dartEntry.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource , unit);
2230 dartCopy.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySou rce, errors); 2145 dartEntry.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySo urce, errors);
2231 if (source == librarySource) { 2146 if (source == librarySource) {
2232 _recordElementData(dartCopy, library.libraryElement, librarySour ce, htmlSource); 2147 _recordElementData(dartEntry, library.libraryElement, librarySou rce, htmlSource);
2233 } 2148 }
2234 _cache.storedAst(source); 2149 _cache.storedAst(source);
2235 } else { 2150 } else {
2236 dartCopy.recordResolutionErrorInLibrary(librarySource, thrownExcep tion); 2151 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownExce ption);
2237 _cache.remove(source); 2152 _cache.remove(source);
2238 } 2153 }
2239 _cache.put(source, dartCopy);
2240 if (source != librarySource) { 2154 if (source != librarySource) {
2241 _workManager.add(source, SourcePriority.PRIORITY_PART); 2155 _workManager.add(source, SourcePriority.PRIORITY_PART);
2242 } 2156 }
2243 if (source == unitSource) { 2157 if (source == unitSource) {
2244 unitEntry = dartCopy; 2158 unitEntry = dartEntry;
2245 } 2159 }
2246 ChangeNoticeImpl notice = _getNotice(source); 2160 ChangeNoticeImpl notice = _getNotice(source);
2247 notice.compilationUnit = unit; 2161 notice.compilationUnit = unit;
2248 notice.setErrors(dartCopy.allErrors, lineInfo); 2162 notice.setErrors(dartEntry.allErrors, lineInfo);
2249 } 2163 }
2250 } 2164 }
2251 } else { 2165 } else {
2252 PrintStringWriter writer = new PrintStringWriter(); 2166 PrintStringWriter writer = new PrintStringWriter();
2253 writer.println("Library resolution results discarded for"); 2167 writer.println("Library resolution results discarded for");
2254 for (Library library in resolvedLibraries) { 2168 for (Library library in resolvedLibraries) {
2255 for (Source source in library.compilationUnitSources) { 2169 for (Source source in library.compilationUnitSources) {
2256 DartEntry dartEntry = _getReadableDartEntry(source); 2170 DartEntryImpl dartEntry = _getReadableDartEntry(source);
2257 if (dartEntry != null) { 2171 if (dartEntry != null) {
2258 int resultTime = library.getModificationTime(source); 2172 int resultTime = library.getModificationTime(source);
2259 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.m odificationTime}"); 2173 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.m odificationTime}");
2260 DartEntryImpl dartCopy = dartEntry.writableCopy;
2261 if (thrownException == null || resultTime >= 0) { 2174 if (thrownException == null || resultTime >= 0) {
2262 // 2175 //
2263 // The analysis was performed on out-of-date sources. Mark the c ache so that the 2176 // The analysis was performed on out-of-date sources. Mark the c ache so that the
2264 // sources will be re-analyzed using the up-to-date sources. 2177 // sources will be re-analyzed using the up-to-date sources.
2265 // 2178 //
2266 dartCopy.recordResolutionNotInProcess(); 2179 dartEntry.recordResolutionNotInProcess();
2267 } else { 2180 } else {
2268 // 2181 //
2269 // We could not determine whether the sources were up-to-date or out-of-date. Mark 2182 // We could not determine whether the sources were up-to-date or out-of-date. Mark
2270 // the cache so that we won't attempt to re-analyze the sources until there's a 2183 // the cache so that we won't attempt to re-analyze the sources until there's a
2271 // good chance that we'll be able to do so without error. 2184 // good chance that we'll be able to do so without error.
2272 // 2185 //
2273 dartCopy.recordResolutionError(thrownException); 2186 dartEntry.recordResolutionError(thrownException);
2274 _cache.remove(source); 2187 _cache.remove(source);
2275 } 2188 }
2276 _cache.put(source, dartCopy);
2277 if (source == unitSource) { 2189 if (source == unitSource) {
2278 unitEntry = dartCopy; 2190 unitEntry = dartEntry;
2279 } 2191 }
2280 } else { 2192 } else {
2281 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, no entry"); 2193 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, no entry");
2282 } 2194 }
2283 } 2195 }
2284 } 2196 }
2285 _logInformation(writer.toString()); 2197 _logInformation(writer.toString());
2286 } 2198 }
2287 } 2199 }
2288 if (thrownException != null) { 2200 if (thrownException != null) {
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
2733 * Create a [GenerateDartErrorsTask] for the given source, marking the verific ation errors 2645 * Create a [GenerateDartErrorsTask] for the given source, marking the verific ation errors
2734 * as being in-process. The compilation unit and the library can be the same i f the compilation 2646 * as being in-process. The compilation unit and the library can be the same i f the compilation
2735 * unit is the defining compilation unit of the library. 2647 * unit is the defining compilation unit of the library.
2736 * 2648 *
2737 * @param unitSource the source for the compilation unit to be verified 2649 * @param unitSource the source for the compilation unit to be verified
2738 * @param unitEntry the entry for the compilation unit 2650 * @param unitEntry the entry for the compilation unit
2739 * @param librarySource the source for the library containing the compilation unit 2651 * @param librarySource the source for the library containing the compilation unit
2740 * @param libraryEntry the entry for the library 2652 * @param libraryEntry the entry for the library
2741 * @return task data representing the created task 2653 * @return task data representing the created task
2742 */ 2654 */
2743 AnalysisContextImpl_TaskData _createGenerateDartErrorsTask(Source unitSource, DartEntry unitEntry, Source librarySource, DartEntry libraryEntry) { 2655 AnalysisContextImpl_TaskData _createGenerateDartErrorsTask(Source unitSource, DartEntryImpl unitEntry, Source librarySource, DartEntry libraryEntry) {
2744 if (unitEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) != C acheState.VALID || libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID) { 2656 if (unitEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) != C acheState.VALID || libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID) {
2745 return _createResolveDartLibraryTask(librarySource, libraryEntry); 2657 return _createResolveDartLibraryTask(librarySource, libraryEntry);
2746 } 2658 }
2747 CompilationUnit unit = unitEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource); 2659 CompilationUnit unit = unitEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource);
2748 if (unit == null) { 2660 if (unit == null) {
2749 CaughtException exception = new CaughtException(new AnalysisException("Ent ry has VALID state for RESOLVED_UNIT but null value for ${unitSource.fullName} i n ${librarySource.fullName}"), null); 2661 CaughtException exception = new CaughtException(new AnalysisException("Ent ry has VALID state for RESOLVED_UNIT but null value for ${unitSource.fullName} i n ${librarySource.fullName}"), null);
2750 AnalysisEngine.instance.logger.logInformation2(exception.toString(), excep tion); 2662 AnalysisEngine.instance.logger.logInformation2(exception.toString(), excep tion);
2751 DartEntryImpl dartCopy = unitEntry.writableCopy; 2663 unitEntry.recordResolutionError(exception);
2752 dartCopy.recordResolutionError(exception);
2753 _cache.put(unitSource, dartCopy);
2754 return new AnalysisContextImpl_TaskData(null, false); 2664 return new AnalysisContextImpl_TaskData(null, false);
2755 } 2665 }
2756 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); 2666 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT);
2757 DartEntryImpl dartCopy = unitEntry.writableCopy; 2667 unitEntry.setStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource, Ca cheState.IN_PROCESS);
2758 dartCopy.setStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource, Cac heState.IN_PROCESS); 2668 return new AnalysisContextImpl_TaskData(new GenerateDartErrorsTask(this, uni tSource, unitEntry.modificationTime, unit, libraryElement), false);
2759 _cache.put(unitSource, dartCopy);
2760 return new AnalysisContextImpl_TaskData(new GenerateDartErrorsTask(this, uni tSource, dartCopy.modificationTime, unit, libraryElement), false);
2761 } 2669 }
2762 2670
2763 /** 2671 /**
2764 * Create a [GenerateDartHintsTask] for the given source, marking the hints as being 2672 * Create a [GenerateDartHintsTask] for the given source, marking the hints as being
2765 * in-process. 2673 * in-process.
2766 * 2674 *
2767 * @param source the source whose content is to be verified 2675 * @param source the source whose content is to be verified
2768 * @param dartEntry the entry for the source 2676 * @param dartEntry the entry for the source
2769 * @param librarySource the source for the library containing the source 2677 * @param librarySource the source for the library containing the source
2770 * @param libraryEntry the entry for the library 2678 * @param libraryEntry the entry for the library
2771 * @return task data representing the created task 2679 * @return task data representing the created task
2772 */ 2680 */
2773 AnalysisContextImpl_TaskData _createGenerateDartHintsTask(Source source, DartE ntry dartEntry, Source librarySource, DartEntry libraryEntry) { 2681 AnalysisContextImpl_TaskData _createGenerateDartHintsTask(Source source, DartE ntryImpl dartEntry, Source librarySource, DartEntry libraryEntry) {
2774 if (libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID) { 2682 if (libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID) {
2775 return _createResolveDartLibraryTask(librarySource, libraryEntry); 2683 return _createResolveDartLibraryTask(librarySource, libraryEntry);
2776 } 2684 }
2777 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); 2685 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT);
2778 CompilationUnitElement definingUnit = libraryElement.definingCompilationUnit ; 2686 CompilationUnitElement definingUnit = libraryElement.definingCompilationUnit ;
2779 List<CompilationUnitElement> parts = libraryElement.parts; 2687 List<CompilationUnitElement> parts = libraryElement.parts;
2780 List<TimestampedData<CompilationUnit>> units = new List<TimestampedData>(par ts.length + 1); 2688 List<TimestampedData<CompilationUnit>> units = new List<TimestampedData>(par ts.length + 1);
2781 units[0] = _getResolvedUnit(definingUnit, librarySource); 2689 units[0] = _getResolvedUnit(definingUnit, librarySource);
2782 if (units[0] == null) { 2690 if (units[0] == null) {
2783 // TODO(brianwilkerson) We should return a ResolveDartUnitTask (unless the re are multiple ASTs 2691 // TODO(brianwilkerson) We should return a ResolveDartUnitTask (unless the re are multiple ASTs
2784 // that need to be resolved. 2692 // that need to be resolved.
2785 return _createResolveDartLibraryTask(librarySource, libraryEntry); 2693 return _createResolveDartLibraryTask(librarySource, libraryEntry);
2786 } 2694 }
2787 for (int i = 0; i < parts.length; i++) { 2695 for (int i = 0; i < parts.length; i++) {
2788 units[i + 1] = _getResolvedUnit(parts[i], librarySource); 2696 units[i + 1] = _getResolvedUnit(parts[i], librarySource);
2789 if (units[i + 1] == null) { 2697 if (units[i + 1] == null) {
2790 // TODO(brianwilkerson) We should return a ResolveDartUnitTask (unless t here are multiple 2698 // TODO(brianwilkerson) We should return a ResolveDartUnitTask (unless t here are multiple
2791 // ASTs that need to be resolved. 2699 // ASTs that need to be resolved.
2792 return _createResolveDartLibraryTask(librarySource, libraryEntry); 2700 return _createResolveDartLibraryTask(librarySource, libraryEntry);
2793 } 2701 }
2794 } 2702 }
2795 DartEntryImpl dartCopy = dartEntry.writableCopy; 2703 dartEntry.setStateInLibrary(DartEntry.HINTS, librarySource, CacheState.IN_PR OCESS);
2796 dartCopy.setStateInLibrary(DartEntry.HINTS, librarySource, CacheState.IN_PRO CESS);
2797 _cache.put(source, dartCopy);
2798 return new AnalysisContextImpl_TaskData(new GenerateDartHintsTask(this, unit s, libraryElement), false); 2704 return new AnalysisContextImpl_TaskData(new GenerateDartHintsTask(this, unit s, libraryElement), false);
2799 } 2705 }
2800 2706
2801 /** 2707 /**
2802 * Create a [GetContentTask] for the given source, marking the content as bein g in-process. 2708 * Create a [GetContentTask] for the given source, marking the content as bein g in-process.
2803 * 2709 *
2804 * @param source the source whose content is to be accessed 2710 * @param source the source whose content is to be accessed
2805 * @param sourceEntry the entry for the source 2711 * @param sourceEntry the entry for the source
2806 * @return task data representing the created task 2712 * @return task data representing the created task
2807 */ 2713 */
2808 AnalysisContextImpl_TaskData _createGetContentTask(Source source, SourceEntry sourceEntry) { 2714 AnalysisContextImpl_TaskData _createGetContentTask(Source source, SourceEntryI mpl sourceEntry) {
2809 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; 2715 sourceEntry.setState(SourceEntry.CONTENT, CacheState.IN_PROCESS);
2810 sourceCopy.setState(SourceEntry.CONTENT, CacheState.IN_PROCESS);
2811 _cache.put(source, sourceCopy);
2812 return new AnalysisContextImpl_TaskData(new GetContentTask(this, source), fa lse); 2716 return new AnalysisContextImpl_TaskData(new GetContentTask(this, source), fa lse);
2813 } 2717 }
2814 2718
2815 /** 2719 /**
2816 * Create a [ParseDartTask] for the given source, marking the parse errors as being 2720 * Create a [ParseDartTask] for the given source, marking the parse errors as being
2817 * in-process. 2721 * in-process.
2818 * 2722 *
2819 * @param source the source whose content is to be parsed 2723 * @param source the source whose content is to be parsed
2820 * @param dartEntry the entry for the source 2724 * @param dartEntry the entry for the source
2821 * @return task data representing the created task 2725 * @return task data representing the created task
2822 */ 2726 */
2823 AnalysisContextImpl_TaskData _createParseDartTask(Source source, DartEntry dar tEntry) { 2727 AnalysisContextImpl_TaskData _createParseDartTask(Source source, DartEntryImpl dartEntry) {
2824 if (dartEntry.getState(DartEntry.TOKEN_STREAM) != CacheState.VALID || dartEn try.getState(SourceEntry.LINE_INFO) != CacheState.VALID) { 2728 if (dartEntry.getState(DartEntry.TOKEN_STREAM) != CacheState.VALID || dartEn try.getState(SourceEntry.LINE_INFO) != CacheState.VALID) {
2825 return _createScanDartTask(source, dartEntry); 2729 return _createScanDartTask(source, dartEntry);
2826 } 2730 }
2827 Token tokenStream = dartEntry.getValue(DartEntry.TOKEN_STREAM); 2731 Token tokenStream = dartEntry.getValue(DartEntry.TOKEN_STREAM);
2828 DartEntryImpl dartCopy = dartEntry.writableCopy; 2732 dartEntry.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED);
2829 dartCopy.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED); 2733 dartEntry.setState(DartEntry.PARSE_ERRORS, CacheState.IN_PROCESS);
2830 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.IN_PROCESS); 2734 return new AnalysisContextImpl_TaskData(new ParseDartTask(this, source, dart Entry.modificationTime, tokenStream, dartEntry.getValue(SourceEntry.LINE_INFO)), false);
2831 _cache.put(source, dartCopy);
2832 return new AnalysisContextImpl_TaskData(new ParseDartTask(this, source, dart Copy.modificationTime, tokenStream, dartEntry.getValue(SourceEntry.LINE_INFO)), false);
2833 } 2735 }
2834 2736
2835 /** 2737 /**
2836 * Create a [ParseHtmlTask] for the given source, marking the parse errors as being 2738 * Create a [ParseHtmlTask] for the given source, marking the parse errors as being
2837 * in-process. 2739 * in-process.
2838 * 2740 *
2839 * @param source the source whose content is to be parsed 2741 * @param source the source whose content is to be parsed
2840 * @param htmlEntry the entry for the source 2742 * @param htmlEntry the entry for the source
2841 * @return task data representing the created task 2743 * @return task data representing the created task
2842 */ 2744 */
2843 AnalysisContextImpl_TaskData _createParseHtmlTask(Source source, HtmlEntry htm lEntry) { 2745 AnalysisContextImpl_TaskData _createParseHtmlTask(Source source, HtmlEntryImpl htmlEntry) {
2844 if (htmlEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { 2746 if (htmlEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) {
2845 return _createGetContentTask(source, htmlEntry); 2747 return _createGetContentTask(source, htmlEntry);
2846 } 2748 }
2847 String content = htmlEntry.getValue(SourceEntry.CONTENT); 2749 String content = htmlEntry.getValue(SourceEntry.CONTENT);
2848 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 2750 htmlEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED);
2849 htmlCopy.setState(SourceEntry.CONTENT, CacheState.FLUSHED); 2751 htmlEntry.setState(HtmlEntry.PARSE_ERRORS, CacheState.IN_PROCESS);
2850 htmlCopy.setState(HtmlEntry.PARSE_ERRORS, CacheState.IN_PROCESS); 2752 return new AnalysisContextImpl_TaskData(new ParseHtmlTask(this, source, html Entry.modificationTime, content), false);
2851 _cache.put(source, htmlCopy);
2852 return new AnalysisContextImpl_TaskData(new ParseHtmlTask(this, source, html Copy.modificationTime, content), false);
2853 } 2753 }
2854 2754
2855 /** 2755 /**
2856 * Create a [PolymerBuildHtmlTask] for the given source, marking the Polymer e lements as 2756 * Create a [PolymerBuildHtmlTask] for the given source, marking the Polymer e lements as
2857 * being in-process. 2757 * being in-process.
2858 * 2758 *
2859 * @param source the source whose content is to be processed 2759 * @param source the source whose content is to be processed
2860 * @param htmlEntry the entry for the source 2760 * @param htmlEntry the entry for the source
2861 * @return task data representing the created task 2761 * @return task data representing the created task
2862 */ 2762 */
2863 AnalysisContextImpl_TaskData _createPolymerBuildHtmlTask(Source source, HtmlEn try htmlEntry) { 2763 AnalysisContextImpl_TaskData _createPolymerBuildHtmlTask(Source source, HtmlEn tryImpl htmlEntry) {
2864 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) { 2764 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) {
2865 return _createResolveHtmlTask(source, htmlEntry); 2765 return _createResolveHtmlTask(source, htmlEntry);
2866 } 2766 }
2867 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 2767 htmlEntry.setState(HtmlEntry.POLYMER_BUILD_ERRORS, CacheState.IN_PROCESS);
2868 htmlCopy.setState(HtmlEntry.POLYMER_BUILD_ERRORS, CacheState.IN_PROCESS); 2768 return new AnalysisContextImpl_TaskData(new PolymerBuildHtmlTask(this, sourc e, htmlEntry.modificationTime, htmlEntry.getValue(SourceEntry.LINE_INFO), htmlEn try.getValue(HtmlEntry.RESOLVED_UNIT)), false);
2869 _cache.put(source, htmlCopy);
2870 return new AnalysisContextImpl_TaskData(new PolymerBuildHtmlTask(this, sourc e, htmlCopy.modificationTime, htmlEntry.getValue(SourceEntry.LINE_INFO), htmlCop y.getValue(HtmlEntry.RESOLVED_UNIT)), false);
2871 } 2769 }
2872 2770
2873 /** 2771 /**
2874 * Create a [PolymerResolveHtmlTask] for the given source, marking the Polymer errors as 2772 * Create a [PolymerResolveHtmlTask] for the given source, marking the Polymer errors as
2875 * being in-process. 2773 * being in-process.
2876 * 2774 *
2877 * @param source the source whose content is to be resolved 2775 * @param source the source whose content is to be resolved
2878 * @param htmlEntry the entry for the source 2776 * @param htmlEntry the entry for the source
2879 * @return task data representing the created task 2777 * @return task data representing the created task
2880 */ 2778 */
2881 AnalysisContextImpl_TaskData _createPolymerResolveHtmlTask(Source source, Html Entry htmlEntry) { 2779 AnalysisContextImpl_TaskData _createPolymerResolveHtmlTask(Source source, Html EntryImpl htmlEntry) {
2882 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) { 2780 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) {
2883 return _createResolveHtmlTask(source, htmlEntry); 2781 return _createResolveHtmlTask(source, htmlEntry);
2884 } 2782 }
2885 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 2783 htmlEntry.setState(HtmlEntry.POLYMER_RESOLUTION_ERRORS, CacheState.IN_PROCES S);
2886 htmlCopy.setState(HtmlEntry.POLYMER_RESOLUTION_ERRORS, CacheState.IN_PROCESS ); 2784 return new AnalysisContextImpl_TaskData(new PolymerResolveHtmlTask(this, sou rce, htmlEntry.modificationTime, htmlEntry.getValue(SourceEntry.LINE_INFO), html Entry.getValue(HtmlEntry.RESOLVED_UNIT)), false);
2887 _cache.put(source, htmlCopy);
2888 return new AnalysisContextImpl_TaskData(new PolymerResolveHtmlTask(this, sou rce, htmlCopy.modificationTime, htmlEntry.getValue(SourceEntry.LINE_INFO), htmlC opy.getValue(HtmlEntry.RESOLVED_UNIT)), false);
2889 } 2785 }
2890 2786
2891 /** 2787 /**
2892 * Create a [ResolveAngularComponentTemplateTask] for the given source, markin g the angular 2788 * Create a [ResolveAngularComponentTemplateTask] for the given source, markin g the angular
2893 * errors as being in-process. 2789 * errors as being in-process.
2894 * 2790 *
2895 * @param source the source whose content is to be resolved 2791 * @param source the source whose content is to be resolved
2896 * @param htmlEntry the entry for the source 2792 * @param htmlEntry the entry for the source
2897 * @return task data representing the created task 2793 * @return task data representing the created task
2898 */ 2794 */
2899 AnalysisContextImpl_TaskData _createResolveAngularComponentTemplateTask(Source source, HtmlEntry htmlEntry) { 2795 AnalysisContextImpl_TaskData _createResolveAngularComponentTemplateTask(Source source, HtmlEntryImpl htmlEntry) {
2900 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) { 2796 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) {
2901 return _createResolveHtmlTask(source, htmlEntry); 2797 return _createResolveHtmlTask(source, htmlEntry);
2902 } 2798 }
2903 AngularApplication application = htmlEntry.getValue(HtmlEntry.ANGULAR_APPLIC ATION); 2799 AngularApplication application = htmlEntry.getValue(HtmlEntry.ANGULAR_APPLIC ATION);
2904 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANGULAR_COM PONENT); 2800 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANGULAR_COM PONENT);
2905 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 2801 htmlEntry.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.IN_PROCESS);
2906 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.IN_PROCESS); 2802 return new AnalysisContextImpl_TaskData(new ResolveAngularComponentTemplateT ask(this, source, htmlEntry.modificationTime, htmlEntry.getValue(HtmlEntry.RESOL VED_UNIT), component, application), false);
2907 _cache.put(source, htmlCopy);
2908 return new AnalysisContextImpl_TaskData(new ResolveAngularComponentTemplateT ask(this, source, htmlCopy.modificationTime, htmlCopy.getValue(HtmlEntry.RESOLVE D_UNIT), component, application), false);
2909 } 2803 }
2910 2804
2911 /** 2805 /**
2912 * Create a [ResolveAngularEntryHtmlTask] for the given source, marking the an gular entry as 2806 * Create a [ResolveAngularEntryHtmlTask] for the given source, marking the an gular entry as
2913 * being in-process. 2807 * being in-process.
2914 * 2808 *
2915 * @param source the source whose content is to be resolved 2809 * @param source the source whose content is to be resolved
2916 * @param htmlEntry the entry for the source 2810 * @param htmlEntry the entry for the source
2917 * @return task data representing the created task 2811 * @return task data representing the created task
2918 */ 2812 */
2919 AnalysisContextImpl_TaskData _createResolveAngularEntryHtmlTask(Source source, HtmlEntry htmlEntry) { 2813 AnalysisContextImpl_TaskData _createResolveAngularEntryHtmlTask(Source source, HtmlEntryImpl htmlEntry) {
2920 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) { 2814 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) {
2921 return _createResolveHtmlTask(source, htmlEntry); 2815 return _createResolveHtmlTask(source, htmlEntry);
2922 } 2816 }
2923 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 2817 htmlEntry.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.IN_PROCESS);
2924 htmlCopy.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.IN_PROCESS); 2818 return new AnalysisContextImpl_TaskData(new ResolveAngularEntryHtmlTask(this , source, htmlEntry.modificationTime, htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT )), false);
2925 _cache.put(source, htmlCopy);
2926 return new AnalysisContextImpl_TaskData(new ResolveAngularEntryHtmlTask(this , source, htmlCopy.modificationTime, htmlCopy.getValue(HtmlEntry.RESOLVED_UNIT)) , false);
2927 } 2819 }
2928 2820
2929 /** 2821 /**
2930 * Create a [ResolveDartLibraryTask] for the given source, marking ? as being in-process. 2822 * Create a [ResolveDartLibraryTask] for the given source, marking ? as being in-process.
2931 * 2823 *
2932 * @param source the source whose content is to be resolved 2824 * @param source the source whose content is to be resolved
2933 * @param dartEntry the entry for the source 2825 * @param dartEntry the entry for the source
2934 * @return task data representing the created task 2826 * @return task data representing the created task
2935 */ 2827 */
2936 AnalysisContextImpl_TaskData _createResolveDartLibraryTask(Source source, Dart Entry dartEntry) { 2828 AnalysisContextImpl_TaskData _createResolveDartLibraryTask(Source source, Dart EntryImpl dartEntry) {
2937 try { 2829 try {
2938 AnalysisContextImpl_CycleBuilder builder = new AnalysisContextImpl_CycleBu ilder(this); 2830 AnalysisContextImpl_CycleBuilder builder = new AnalysisContextImpl_CycleBu ilder(this);
2939 builder.computeCycleContaining(source); 2831 builder.computeCycleContaining(source);
2940 AnalysisContextImpl_TaskData taskData = builder.taskData; 2832 AnalysisContextImpl_TaskData taskData = builder.taskData;
2941 if (taskData != null) { 2833 if (taskData != null) {
2942 return taskData; 2834 return taskData;
2943 } 2835 }
2944 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryCycleTask(th is, source, source, builder.librariesInCycle), false); 2836 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryCycleTask(th is, source, source, builder.librariesInCycle), false);
2945 } on AnalysisException catch (exception, stackTrace) { 2837 } on AnalysisException catch (exception, stackTrace) {
2946 DartEntryImpl dartCopy = dartEntry.writableCopy; 2838 dartEntry.recordResolutionError(new CaughtException(exception, stackTrace) );
2947 dartCopy.recordResolutionError(new CaughtException(exception, stackTrace)) ;
2948 _cache.put(source, dartCopy);
2949 AnalysisEngine.instance.logger.logError2("Internal error trying to create a ResolveDartLibraryTask", new CaughtException(exception, stackTrace)); 2839 AnalysisEngine.instance.logger.logError2("Internal error trying to create a ResolveDartLibraryTask", new CaughtException(exception, stackTrace));
2950 } 2840 }
2951 return new AnalysisContextImpl_TaskData(null, false); 2841 return new AnalysisContextImpl_TaskData(null, false);
2952 } 2842 }
2953 2843
2954 /** 2844 /**
2955 * Create a [ResolveHtmlTask] for the given source, marking the resolved unit as being 2845 * Create a [ResolveHtmlTask] for the given source, marking the resolved unit as being
2956 * in-process. 2846 * in-process.
2957 * 2847 *
2958 * @param source the source whose content is to be resolved 2848 * @param source the source whose content is to be resolved
2959 * @param htmlEntry the entry for the source 2849 * @param htmlEntry the entry for the source
2960 * @return task data representing the created task 2850 * @return task data representing the created task
2961 */ 2851 */
2962 AnalysisContextImpl_TaskData _createResolveHtmlTask(Source source, HtmlEntry h tmlEntry) { 2852 AnalysisContextImpl_TaskData _createResolveHtmlTask(Source source, HtmlEntryIm pl htmlEntry) {
2963 if (htmlEntry.getState(HtmlEntry.PARSED_UNIT) != CacheState.VALID) { 2853 if (htmlEntry.getState(HtmlEntry.PARSED_UNIT) != CacheState.VALID) {
2964 return _createParseHtmlTask(source, htmlEntry); 2854 return _createParseHtmlTask(source, htmlEntry);
2965 } 2855 }
2966 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 2856 htmlEntry.setState(HtmlEntry.RESOLVED_UNIT, CacheState.IN_PROCESS);
2967 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.IN_PROCESS); 2857 return new AnalysisContextImpl_TaskData(new ResolveHtmlTask(this, source, ht mlEntry.modificationTime, htmlEntry.getValue(HtmlEntry.PARSED_UNIT)), false);
2968 _cache.put(source, htmlCopy);
2969 return new AnalysisContextImpl_TaskData(new ResolveHtmlTask(this, source, ht mlCopy.modificationTime, htmlCopy.getValue(HtmlEntry.PARSED_UNIT)), false);
2970 } 2858 }
2971 2859
2972 /** 2860 /**
2973 * Create a [ScanDartTask] for the given source, marking the scan errors as be ing 2861 * Create a [ScanDartTask] for the given source, marking the scan errors as be ing
2974 * in-process. 2862 * in-process.
2975 * 2863 *
2976 * @param source the source whose content is to be scanned 2864 * @param source the source whose content is to be scanned
2977 * @param dartEntry the entry for the source 2865 * @param dartEntry the entry for the source
2978 * @return task data representing the created task 2866 * @return task data representing the created task
2979 */ 2867 */
2980 AnalysisContextImpl_TaskData _createScanDartTask(Source source, DartEntry dart Entry) { 2868 AnalysisContextImpl_TaskData _createScanDartTask(Source source, DartEntryImpl dartEntry) {
2981 if (dartEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { 2869 if (dartEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) {
2982 return _createGetContentTask(source, dartEntry); 2870 return _createGetContentTask(source, dartEntry);
2983 } 2871 }
2984 String content = dartEntry.getValue(SourceEntry.CONTENT); 2872 String content = dartEntry.getValue(SourceEntry.CONTENT);
2985 DartEntryImpl dartCopy = dartEntry.writableCopy; 2873 dartEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED);
2986 dartCopy.setState(SourceEntry.CONTENT, CacheState.FLUSHED); 2874 dartEntry.setState(DartEntry.SCAN_ERRORS, CacheState.IN_PROCESS);
2987 dartCopy.setState(DartEntry.SCAN_ERRORS, CacheState.IN_PROCESS); 2875 return new AnalysisContextImpl_TaskData(new ScanDartTask(this, source, dartE ntry.modificationTime, content), false);
2988 _cache.put(source, dartCopy);
2989 return new AnalysisContextImpl_TaskData(new ScanDartTask(this, source, dartC opy.modificationTime, content), false);
2990 } 2876 }
2991 2877
2992 /** 2878 /**
2993 * Create a source information object suitable for the given source. Return th e source information 2879 * Create a source information object suitable for the given source. Return th e source information
2994 * object that was created, or `null` if the source should not be tracked by t his context. 2880 * object that was created, or `null` if the source should not be tracked by t his context.
2995 * 2881 *
2996 * @param source the source for which an information object is being created 2882 * @param source the source for which an information object is being created
2997 * @param explicitlyAdded `true` if the source was explicitly added to the con text 2883 * @param explicitlyAdded `true` if the source was explicitly added to the con text
2998 * @return the source information object that was created 2884 * @return the source information object that was created
2999 */ 2885 */
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
3424 return _createGetContentTask(source, sourceEntry); 3310 return _createGetContentTask(source, sourceEntry);
3425 } else if (contentState == CacheState.IN_PROCESS) { 3311 } else if (contentState == CacheState.IN_PROCESS) {
3426 // We are already in the process of getting the content. There's nothing e lse we can do with 3312 // We are already in the process of getting the content. There's nothing e lse we can do with
3427 // this source until that's complete. 3313 // this source until that's complete.
3428 return new AnalysisContextImpl_TaskData(null, true); 3314 return new AnalysisContextImpl_TaskData(null, true);
3429 } else if (contentState == CacheState.ERROR) { 3315 } else if (contentState == CacheState.ERROR) {
3430 // We have done all of the analysis we can for this source because we cann ot get its content. 3316 // We have done all of the analysis we can for this source because we cann ot get its content.
3431 return new AnalysisContextImpl_TaskData(null, false); 3317 return new AnalysisContextImpl_TaskData(null, false);
3432 } 3318 }
3433 if (sourceEntry is DartEntry) { 3319 if (sourceEntry is DartEntry) {
3434 DartEntry dartEntry = sourceEntry; 3320 DartEntryImpl dartEntry = sourceEntry;
3435 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS); 3321 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS);
3436 if (scanErrorsState == CacheState.INVALID || (isPriority && scanErrorsStat e == CacheState.FLUSHED)) { 3322 if (scanErrorsState == CacheState.INVALID || (isPriority && scanErrorsStat e == CacheState.FLUSHED)) {
3437 return _createScanDartTask(source, dartEntry); 3323 return _createScanDartTask(source, dartEntry);
3438 } 3324 }
3439 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); 3325 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS);
3440 if (parseErrorsState == CacheState.INVALID || (isPriority && parseErrorsSt ate == CacheState.FLUSHED)) { 3326 if (parseErrorsState == CacheState.INVALID || (isPriority && parseErrorsSt ate == CacheState.FLUSHED)) {
3441 return _createParseDartTask(source, dartEntry); 3327 return _createParseDartTask(source, dartEntry);
3442 } 3328 }
3443 if (isPriority && parseErrorsState != CacheState.ERROR) { 3329 if (isPriority && parseErrorsState != CacheState.ERROR) {
3444 if (!dartEntry.hasResolvableCompilationUnit) { 3330 if (!dartEntry.hasResolvableCompilationUnit) {
3445 return _createParseDartTask(source, dartEntry); 3331 return _createParseDartTask(source, dartEntry);
3446 } 3332 }
3447 } 3333 }
3448 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); 3334 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND);
3449 if (kind == SourceKind.UNKNOWN) { 3335 if (kind == SourceKind.UNKNOWN) {
3450 return _createParseDartTask(source, dartEntry); 3336 return _createParseDartTask(source, dartEntry);
3451 } else if (kind == SourceKind.LIBRARY) { 3337 } else if (kind == SourceKind.LIBRARY) {
3452 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); 3338 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT);
3453 if (elementState == CacheState.INVALID) { 3339 if (elementState == CacheState.INVALID) {
3454 return _createResolveDartLibraryTask(source, dartEntry); 3340 return _createResolveDartLibraryTask(source, dartEntry);
3455 } 3341 }
3456 } 3342 }
3457 List<Source> librariesContaining = dartEntry.getValue(DartEntry.CONTAINING _LIBRARIES); 3343 List<Source> librariesContaining = dartEntry.getValue(DartEntry.CONTAINING _LIBRARIES);
3458 for (Source librarySource in librariesContaining) { 3344 for (Source librarySource in librariesContaining) {
3459 SourceEntry librarySourceEntry = _cache.get(librarySource); 3345 SourceEntry librarySourceEntry = _cache.get(librarySource);
3460 if (librarySourceEntry is DartEntry) { 3346 if (librarySourceEntry is DartEntry) {
3461 DartEntry libraryEntry = librarySourceEntry; 3347 DartEntryImpl libraryEntry = librarySourceEntry;
3462 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); 3348 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT);
3463 if (elementState == CacheState.INVALID || (isPriority && elementState == CacheState.FLUSHED)) { 3349 if (elementState == CacheState.INVALID || (isPriority && elementState == CacheState.FLUSHED)) {
3464 //return createResolveDartLibraryTask(librarySource, (DartEntry) lib raryEntry); 3350 //return createResolveDartLibraryTask(librarySource, (DartEntry) lib raryEntry);
3465 DartEntryImpl libraryCopy = libraryEntry.writableCopy; 3351 libraryEntry.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS);
3466 libraryCopy.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS);
3467 _cache.put(librarySource, libraryCopy);
3468 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t his, source, librarySource), false); 3352 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t his, source, librarySource), false);
3469 } 3353 }
3470 CacheState resolvedUnitState = dartEntry.getStateInLibrary(DartEntry.R ESOLVED_UNIT, librarySource); 3354 CacheState resolvedUnitState = dartEntry.getStateInLibrary(DartEntry.R ESOLVED_UNIT, librarySource);
3471 if (resolvedUnitState == CacheState.INVALID || (isPriority && resolved UnitState == CacheState.FLUSHED)) { 3355 if (resolvedUnitState == CacheState.INVALID || (isPriority && resolved UnitState == CacheState.FLUSHED)) {
3472 // 3356 //
3473 // The commented out lines below are an optimization that doesn't qu ite work yet. The 3357 // The commented out lines below are an optimization that doesn't qu ite work yet. The
3474 // problem is that if the source was not resolved because it wasn't part of any library, 3358 // problem is that if the source was not resolved because it wasn't part of any library,
3475 // then there won't be any elements in the element model that we can use to resolve it. 3359 // then there won't be any elements in the element model that we can use to resolve it.
3476 // 3360 //
3477 //LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL EMENT); 3361 //LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL EMENT);
3478 //if (libraryElement != null) { 3362 //if (libraryElement != null) {
3479 // return new ResolveDartUnitTask(this, source, libraryElement); 3363 // return new ResolveDartUnitTask(this, source, libraryElement);
3480 //} 3364 //}
3481 // Possibly replace with: return createResolveDartLibraryTask(librar ySource, (DartEntry) libraryEntry); 3365 // Possibly replace with: return createResolveDartLibraryTask(librar ySource, (DartEntry) libraryEntry);
3482 DartEntryImpl dartCopy = dartEntry.writableCopy; 3366 dartEntry.setStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource, CacheState.IN_PROCESS);
3483 dartCopy.setStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource, C acheState.IN_PROCESS);
3484 _cache.put(source, dartCopy);
3485 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t his, source, librarySource), false); 3367 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t his, source, librarySource), false);
3486 } 3368 }
3487 if (_generateSdkErrors || !source.isInSystemLibrary) { 3369 if (_generateSdkErrors || !source.isInSystemLibrary) {
3488 CacheState verificationErrorsState = dartEntry.getStateInLibrary(Dar tEntry.VERIFICATION_ERRORS, librarySource); 3370 CacheState verificationErrorsState = dartEntry.getStateInLibrary(Dar tEntry.VERIFICATION_ERRORS, librarySource);
3489 if (verificationErrorsState == CacheState.INVALID || (isPriority && verificationErrorsState == CacheState.FLUSHED)) { 3371 if (verificationErrorsState == CacheState.INVALID || (isPriority && verificationErrorsState == CacheState.FLUSHED)) {
3490 return _createGenerateDartErrorsTask(source, dartEntry, librarySou rce, libraryEntry); 3372 return _createGenerateDartErrorsTask(source, dartEntry, librarySou rce, libraryEntry);
3491 } 3373 }
3492 if (hintsEnabled) { 3374 if (hintsEnabled) {
3493 CacheState hintsState = dartEntry.getStateInLibrary(DartEntry.HINT S, librarySource); 3375 CacheState hintsState = dartEntry.getStateInLibrary(DartEntry.HINT S, librarySource);
3494 if (hintsState == CacheState.INVALID || (isPriority && hintsState == CacheState.FLUSHED)) { 3376 if (hintsState == CacheState.INVALID || (isPriority && hintsState == CacheState.FLUSHED)) {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
3785 * @param invalidateUris `true` if the cached results of converting URIs to so urce files 3667 * @param invalidateUris `true` if the cached results of converting URIs to so urce files
3786 * should also be invalidated. 3668 * should also be invalidated.
3787 */ 3669 */
3788 void _invalidateAllLocalResolutionInformation(bool invalidateUris) { 3670 void _invalidateAllLocalResolutionInformation(bool invalidateUris) {
3789 HashMap<Source, List<Source>> oldPartMap = new HashMap<Source, List<Source>> (); 3671 HashMap<Source, List<Source>> oldPartMap = new HashMap<Source, List<Source>> ();
3790 MapIterator<Source, SourceEntry> iterator = _privatePartition.iterator(); 3672 MapIterator<Source, SourceEntry> iterator = _privatePartition.iterator();
3791 while (iterator.moveNext()) { 3673 while (iterator.moveNext()) {
3792 Source source = iterator.key; 3674 Source source = iterator.key;
3793 SourceEntry sourceEntry = iterator.value; 3675 SourceEntry sourceEntry = iterator.value;
3794 if (sourceEntry is HtmlEntry) { 3676 if (sourceEntry is HtmlEntry) {
3795 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; 3677 HtmlEntryImpl htmlEntry = sourceEntry;
3796 htmlCopy.invalidateAllResolutionInformation(invalidateUris); 3678 htmlEntry.invalidateAllResolutionInformation(invalidateUris);
3797 iterator.value = htmlCopy; 3679 iterator.value = htmlEntry;
3798 _workManager.add(source, SourcePriority.HTML); 3680 _workManager.add(source, SourcePriority.HTML);
3799 } else if (sourceEntry is DartEntry) { 3681 } else if (sourceEntry is DartEntry) {
3800 DartEntry dartEntry = sourceEntry; 3682 DartEntryImpl dartEntry = sourceEntry;
3801 oldPartMap[source] = dartEntry.getValue(DartEntry.INCLUDED_PARTS); 3683 oldPartMap[source] = dartEntry.getValue(DartEntry.INCLUDED_PARTS);
3802 DartEntryImpl dartCopy = dartEntry.writableCopy; 3684 dartEntry.invalidateAllResolutionInformation(invalidateUris);
3803 dartCopy.invalidateAllResolutionInformation(invalidateUris); 3685 iterator.value = dartEntry;
3804 iterator.value = dartCopy; 3686 _workManager.add(source, _computePriority(dartEntry));
3805 _workManager.add(source, _computePriority(dartCopy));
3806 } 3687 }
3807 } 3688 }
3808 _removeFromPartsUsingMap(oldPartMap); 3689 _removeFromPartsUsingMap(oldPartMap);
3809 _recentTasks.clear(); 3690 _recentTasks.clear();
3810 _reportedLoop = false; 3691 _reportedLoop = false;
3811 } 3692 }
3812 3693
3813 /** 3694 /**
3814 * In response to a change to Angular entry point [HtmlElement], invalidate an y results that 3695 * In response to a change to Angular entry point [HtmlElement], invalidate an y results that
3815 * depend on it. 3696 * depend on it.
(...skipping 13 matching lines...) Expand all
3829 _angularApplications.remove(application); 3710 _angularApplications.remove(application);
3830 // invalidate Entry 3711 // invalidate Entry
3831 entryCopy.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.INVALID); 3712 entryCopy.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.INVALID);
3832 // reset HTML sources 3713 // reset HTML sources
3833 List<AngularElement> oldAngularElements = application.elements; 3714 List<AngularElement> oldAngularElements = application.elements;
3834 for (AngularElement angularElement in oldAngularElements) { 3715 for (AngularElement angularElement in oldAngularElements) {
3835 if (angularElement is AngularHasTemplateElement) { 3716 if (angularElement is AngularHasTemplateElement) {
3836 AngularHasTemplateElement hasTemplate = angularElement; 3717 AngularHasTemplateElement hasTemplate = angularElement;
3837 Source templateSource = hasTemplate.templateSource; 3718 Source templateSource = hasTemplate.templateSource;
3838 if (templateSource != null) { 3719 if (templateSource != null) {
3839 HtmlEntry htmlEntry = _getReadableHtmlEntry(templateSource); 3720 HtmlEntryImpl htmlEntry = _getReadableHtmlEntry(templateSource);
3840 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 3721 htmlEntry.setValue(HtmlEntry.ANGULAR_APPLICATION, null);
3841 htmlCopy.setValue(HtmlEntry.ANGULAR_APPLICATION, null); 3722 htmlEntry.setValue(HtmlEntry.ANGULAR_COMPONENT, null);
3842 htmlCopy.setValue(HtmlEntry.ANGULAR_COMPONENT, null); 3723 htmlEntry.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID);
3843 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID);
3844 _cache.put(templateSource, htmlCopy);
3845 _workManager.add(templateSource, SourcePriority.HTML); 3724 _workManager.add(templateSource, SourcePriority.HTML);
3846 } 3725 }
3847 } 3726 }
3848 } 3727 }
3849 // reset Dart sources 3728 // reset Dart sources
3850 List<Source> oldElementSources = application.elementSources; 3729 List<Source> oldElementSources = application.elementSources;
3851 for (Source elementSource in oldElementSources) { 3730 for (Source elementSource in oldElementSources) {
3852 DartEntry dartEntry = _getReadableDartEntry(elementSource); 3731 DartEntryImpl dartEntry = _getReadableDartEntry(elementSource);
3853 DartEntryImpl dartCopy = dartEntry.writableCopy; 3732 dartEntry.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS);
3854 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS);
3855 _cache.put(elementSource, dartCopy);
3856 // notify about (disappeared) Angular errors 3733 // notify about (disappeared) Angular errors
3857 ChangeNoticeImpl notice = _getNotice(elementSource); 3734 ChangeNoticeImpl notice = _getNotice(elementSource);
3858 notice.setErrors(dartCopy.allErrors, dartEntry.getValue(SourceEntry.LINE_I NFO)); 3735 notice.setErrors(dartEntry.allErrors, dartEntry.getValue(SourceEntry.LINE_ INFO));
3859 } 3736 }
3860 } 3737 }
3861 3738
3862 /** 3739 /**
3863 * In response to a change to at least one of the compilation units in the giv en library, 3740 * In response to a change to at least one of the compilation units in the giv en library,
3864 * invalidate any results that are dependent on the result of resolving that l ibrary. 3741 * invalidate any results that are dependent on the result of resolving that l ibrary.
3865 * 3742 *
3866 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 3743 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
3867 * 3744 *
3868 * <b>Note:</b> Any cache entries that were accessed before this method was in voked must be 3745 * <b>Note:</b> Any cache entries that were accessed before this method was in voked must be
3869 * re-accessed after this method returns. 3746 * re-accessed after this method returns.
3870 * 3747 *
3871 * @param librarySource the source of the library being invalidated 3748 * @param librarySource the source of the library being invalidated
3872 */ 3749 */
3873 void _invalidateLibraryResolution(Source librarySource) { 3750 void _invalidateLibraryResolution(Source librarySource) {
3874 // TODO(brianwilkerson) This could be optimized. There's no need to flush al l of these entries 3751 // TODO(brianwilkerson) This could be optimized. There's no need to flush al l of these entries
3875 // if the public namespace hasn't changed, which will be a fairly common cas e. The question is 3752 // if the public namespace hasn't changed, which will be a fairly common cas e. The question is
3876 // whether we can afford the time to compute the namespace to look for diffe rences. 3753 // whether we can afford the time to compute the namespace to look for diffe rences.
3877 DartEntry libraryEntry = _getReadableDartEntry(librarySource); 3754 DartEntryImpl libraryEntry = _getReadableDartEntry(librarySource);
3878 if (libraryEntry != null) { 3755 if (libraryEntry != null) {
3879 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART S); 3756 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART S);
3880 DartEntryImpl libraryCopy = libraryEntry.writableCopy; 3757 libraryEntry.invalidateAllResolutionInformation(false);
3881 libraryCopy.invalidateAllResolutionInformation(false);
3882 _cache.put(librarySource, libraryCopy);
3883 _workManager.add(librarySource, SourcePriority.LIBRARY); 3758 _workManager.add(librarySource, SourcePriority.LIBRARY);
3884 for (Source partSource in includedParts) { 3759 for (Source partSource in includedParts) {
3885 SourceEntry partEntry = _cache.get(partSource); 3760 SourceEntry partEntry = _cache.get(partSource);
3886 if (partEntry is DartEntry) { 3761 if (partEntry is DartEntry) {
3887 DartEntryImpl partCopy = partEntry.writableCopy; 3762 (partEntry as DartEntryImpl).invalidateAllResolutionInformation(false) ;
3888 partCopy.invalidateAllResolutionInformation(false);
3889 _cache.put(partSource, partCopy);
3890 } 3763 }
3891 } 3764 }
3892 } 3765 }
3893 // invalidate Angular applications 3766 // invalidate Angular applications
3894 List<AngularApplication> angularApplicationsCopy = []; 3767 List<AngularApplication> angularApplicationsCopy = [];
3895 for (AngularApplication application in angularApplicationsCopy) { 3768 for (AngularApplication application in angularApplicationsCopy) {
3896 if (application.dependsOn(librarySource)) { 3769 if (application.dependsOn(librarySource)) {
3897 Source entryPointSource = application.entryPoint; 3770 Source entryPointSource = application.entryPoint;
3898 HtmlEntry entry = _getReadableHtmlEntry(entryPointSource); 3771 HtmlEntryImpl htmlEntry = _getReadableHtmlEntry(entryPointSource);
3899 HtmlEntryImpl entryCopy = entry.writableCopy; 3772 _invalidateAngularResolution(htmlEntry);
3900 _invalidateAngularResolution(entryCopy);
3901 _cache.put(entryPointSource, entryCopy);
3902 _workManager.add(entryPointSource, SourcePriority.HTML); 3773 _workManager.add(entryPointSource, SourcePriority.HTML);
3903 } 3774 }
3904 } 3775 }
3905 } 3776 }
3906 3777
3907 /** 3778 /**
3908 * Return `true` if this library is, or depends on, dart:html. 3779 * Return `true` if this library is, or depends on, dart:html.
3909 * 3780 *
3910 * @param library the library being tested 3781 * @param library the library being tested
3911 * @param visitedLibraries a collection of the libraries that have been visite d, used to prevent 3782 * @param visitedLibraries a collection of the libraries that have been visite d, used to prevent
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
4073 _angularApplications.add(application); 3944 _angularApplications.add(application);
4074 // if this is an entry point, then we already resolved it 3945 // if this is an entry point, then we already resolved it
4075 entry.setValue(HtmlEntry.ANGULAR_ERRORS, task.entryErrors); 3946 entry.setValue(HtmlEntry.ANGULAR_ERRORS, task.entryErrors);
4076 // schedule HTML templates analysis 3947 // schedule HTML templates analysis
4077 List<AngularElement> newAngularElements = application.elements; 3948 List<AngularElement> newAngularElements = application.elements;
4078 for (AngularElement angularElement in newAngularElements) { 3949 for (AngularElement angularElement in newAngularElements) {
4079 if (angularElement is AngularHasTemplateElement) { 3950 if (angularElement is AngularHasTemplateElement) {
4080 AngularHasTemplateElement hasTemplate = angularElement; 3951 AngularHasTemplateElement hasTemplate = angularElement;
4081 Source templateSource = hasTemplate.templateSource; 3952 Source templateSource = hasTemplate.templateSource;
4082 if (templateSource != null) { 3953 if (templateSource != null) {
4083 HtmlEntry htmlEntry = _getReadableHtmlEntry(templateSource); 3954 HtmlEntryImpl htmlEntry = _getReadableHtmlEntry(templateSource);
4084 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 3955 htmlEntry.setValue(HtmlEntry.ANGULAR_APPLICATION, application);
4085 htmlCopy.setValue(HtmlEntry.ANGULAR_APPLICATION, application);
4086 if (hasTemplate is AngularComponentElement) { 3956 if (hasTemplate is AngularComponentElement) {
4087 AngularComponentElement component = hasTemplate; 3957 AngularComponentElement component = hasTemplate;
4088 htmlCopy.setValue(HtmlEntry.ANGULAR_COMPONENT, component); 3958 htmlEntry.setValue(HtmlEntry.ANGULAR_COMPONENT, component);
4089 } 3959 }
4090 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID); 3960 htmlEntry.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID);
4091 _cache.put(templateSource, htmlCopy);
4092 _workManager.add(templateSource, SourcePriority.HTML); 3961 _workManager.add(templateSource, SourcePriority.HTML);
4093 } 3962 }
4094 } 3963 }
4095 } 3964 }
4096 // update Dart sources errors 3965 // update Dart sources errors
4097 List<Source> newElementSources = application.elementSources; 3966 List<Source> newElementSources = application.elementSources;
4098 for (Source elementSource in newElementSources) { 3967 for (Source elementSource in newElementSources) {
4099 DartEntry dartEntry = _getReadableDartEntry(elementSource); 3968 DartEntryImpl dartEntry = _getReadableDartEntry(elementSource);
4100 DartEntryImpl dartCopy = dartEntry.writableCopy; 3969 dartEntry.setValue(DartEntry.ANGULAR_ERRORS, task.getErrors(elementSourc e));
4101 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, task.getErrors(elementSource ));
4102 _cache.put(elementSource, dartCopy);
4103 // notify about Dart errors 3970 // notify about Dart errors
4104 ChangeNoticeImpl notice = _getNotice(elementSource); 3971 ChangeNoticeImpl notice = _getNotice(elementSource);
4105 notice.setErrors(dartCopy.allErrors, computeLineInfo(elementSource)); 3972 notice.setErrors(dartEntry.allErrors, computeLineInfo(elementSource));
4106 } 3973 }
4107 } 3974 }
4108 // remember Angular entry point 3975 // remember Angular entry point
4109 entry.setValue(HtmlEntry.ANGULAR_ENTRY, application); 3976 entry.setValue(HtmlEntry.ANGULAR_ENTRY, application);
4110 } 3977 }
4111 3978
4112 /** 3979 /**
4113 * Given a cache entry and a library element, record the library element and o ther information 3980 * Given a cache entry and a library element, record the library element and o ther information
4114 * gleaned from the element in the cache entry. 3981 * gleaned from the element in the cache entry.
4115 * 3982 *
4116 * @param dartCopy the cache entry in which data is to be recorded 3983 * @param dartCopy the cache entry in which data is to be recorded
4117 * @param library the library element used to record information 3984 * @param library the library element used to record information
4118 * @param librarySource the source for the library used to record information 3985 * @param librarySource the source for the library used to record information
4119 * @param htmlSource the source for the HTML library 3986 * @param htmlSource the source for the HTML library
4120 */ 3987 */
4121 void _recordElementData(DartEntryImpl dartCopy, LibraryElement library, Source librarySource, Source htmlSource) { 3988 void _recordElementData(DartEntryImpl dartEntry, LibraryElement library, Sourc e librarySource, Source htmlSource) {
4122 dartCopy.setValue(DartEntry.ELEMENT, library); 3989 dartEntry.setValue(DartEntry.ELEMENT, library);
4123 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); 3990 dartEntry.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null);
4124 dartCopy.setValue(DartEntry.IS_CLIENT, _isClient(library, htmlSource, new Ha shSet<LibraryElement>())); 3991 dartEntry.setValue(DartEntry.IS_CLIENT, _isClient(library, htmlSource, new H ashSet<LibraryElement>()));
4125 } 3992 }
4126 3993
4127 /** 3994 /**
4128 * Record the results produced by performing a [GenerateDartErrorsTask]. If th e results were 3995 * Record the results produced by performing a [GenerateDartErrorsTask]. If th e results were
4129 * computed from data that is now out-of-date, then the results will not be re corded. 3996 * computed from data that is now out-of-date, then the results will not be re corded.
4130 * 3997 *
4131 * @param task the task that was performed 3998 * @param task the task that was performed
4132 * @return an entry containing the computed results 3999 * @return an entry containing the computed results
4133 * @throws AnalysisException if the results could not be recorded 4000 * @throws AnalysisException if the results could not be recorded
4134 */ 4001 */
4135 DartEntry _recordGenerateDartErrorsTask(GenerateDartErrorsTask task) { 4002 DartEntry _recordGenerateDartErrorsTask(GenerateDartErrorsTask task) {
4136 Source source = task.source; 4003 Source source = task.source;
4137 Source librarySource = task.libraryElement.source; 4004 Source librarySource = task.libraryElement.source;
4138 CaughtException thrownException = task.exception; 4005 CaughtException thrownException = task.exception;
4139 DartEntry dartEntry = null; 4006 DartEntryImpl dartEntry = null;
4140 SourceEntry sourceEntry = _cache.get(source); 4007 SourceEntry sourceEntry = _cache.get(source);
4141 if (sourceEntry == null) { 4008 if (sourceEntry == null) {
4142 throw new ObsoleteSourceAnalysisException(source); 4009 throw new ObsoleteSourceAnalysisException(source);
4143 } else if (sourceEntry is! DartEntry) { 4010 } else if (sourceEntry is! DartEntry) {
4144 // This shouldn't be possible because we should never have performed the t ask if the source 4011 // This shouldn't be possible because we should never have performed the t ask if the source
4145 // didn't represent a Dart file, but check to be safe. 4012 // didn't represent a Dart file, but check to be safe.
4146 throw new AnalysisException("Internal error: attempting to verify non-Dart file as a Dart file: ${source.fullName}"); 4013 throw new AnalysisException("Internal error: attempting to verify non-Dart file as a Dart file: ${source.fullName}");
4147 } 4014 }
4148 dartEntry = sourceEntry as DartEntry; 4015 dartEntry = sourceEntry as DartEntry;
4149 int sourceTime = getModificationStamp(source); 4016 int sourceTime = getModificationStamp(source);
4150 int resultTime = task.modificationTime; 4017 int resultTime = task.modificationTime;
4151 if (sourceTime == resultTime) { 4018 if (sourceTime == resultTime) {
4152 if (dartEntry.modificationTime != sourceTime) { 4019 if (dartEntry.modificationTime != sourceTime) {
4153 // The source has changed without the context being notified. Simulate n otification. 4020 // The source has changed without the context being notified. Simulate n otification.
4154 _sourceChanged(source); 4021 _sourceChanged(source);
4155 dartEntry = _getReadableDartEntry(source); 4022 dartEntry = _getReadableDartEntry(source);
4156 if (dartEntry == null) { 4023 if (dartEntry == null) {
4157 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}"); 4024 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}");
4158 } 4025 }
4159 } 4026 }
4160 DartEntryImpl dartCopy = dartEntry.writableCopy;
4161 if (thrownException == null) { 4027 if (thrownException == null) {
4162 dartCopy.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource, task.errors); 4028 dartEntry.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource , task.errors);
4163 ChangeNoticeImpl notice = _getNotice(source); 4029 ChangeNoticeImpl notice = _getNotice(source);
4164 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LINE_ INFO)); 4030 notice.setErrors(dartEntry.allErrors, dartEntry.getValue(SourceEntry.LIN E_INFO));
4165 } else { 4031 } else {
4166 dartCopy.recordVerificationErrorInLibrary(librarySource, thrownException ); 4032 dartEntry.recordVerificationErrorInLibrary(librarySource, thrownExceptio n);
4167 } 4033 }
4168 _cache.put(source, dartCopy);
4169 dartEntry = dartCopy;
4170 } else { 4034 } else {
4171 _logInformation2("Generated errors discarded for ${_debuggingString(source )}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEn try.modificationTime}", thrownException); 4035 _logInformation2("Generated errors discarded for ${_debuggingString(source )}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEn try.modificationTime}", thrownException);
4172 DartEntryImpl dartCopy = dartEntry.writableCopy;
4173 if (thrownException == null || resultTime >= 0) { 4036 if (thrownException == null || resultTime >= 0) {
4174 // 4037 //
4175 // The analysis was performed on out-of-date sources. Mark the cache so that the source 4038 // The analysis was performed on out-of-date sources. Mark the cache so that the source
4176 // will be re-verified using the up-to-date sources. 4039 // will be re-verified using the up-to-date sources.
4177 // 4040 //
4178 // dartCopy.setState(DartEntry.VERIFICATION_ERRORS, librarySour ce, CacheState.INVALID); 4041 // dartCopy.setState(DartEntry.VERIFICATION_ERRORS, librarySour ce, CacheState.INVALID);
4179 _removeFromParts(source, dartEntry); 4042 _removeFromParts(source, dartEntry);
4180 dartCopy.invalidateAllInformation(); 4043 dartEntry.invalidateAllInformation();
4181 dartCopy.modificationTime = sourceTime; 4044 dartEntry.modificationTime = sourceTime;
4182 _cache.removedAst(source); 4045 _cache.removedAst(source);
4183 _workManager.add(source, SourcePriority.UNKNOWN); 4046 _workManager.add(source, SourcePriority.UNKNOWN);
4184 } else { 4047 } else {
4185 // 4048 //
4186 // We could not determine whether the sources were up-to-date or out-of- date. Mark the 4049 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4187 // cache so that we won't attempt to re-verify the source until there's a good chance 4050 // cache so that we won't attempt to re-verify the source until there's a good chance
4188 // that we'll be able to do so without error. 4051 // that we'll be able to do so without error.
4189 // 4052 //
4190 dartCopy.recordVerificationErrorInLibrary(librarySource, thrownException ); 4053 dartEntry.recordVerificationErrorInLibrary(librarySource, thrownExceptio n);
4191 } 4054 }
4192 _cache.put(source, dartCopy);
4193 dartEntry = dartCopy;
4194 } 4055 }
4195 if (thrownException != null) { 4056 if (thrownException != null) {
4196 throw new AnalysisException('<rethrow>', thrownException); 4057 throw new AnalysisException('<rethrow>', thrownException);
4197 } 4058 }
4198 return dartEntry; 4059 return dartEntry;
4199 } 4060 }
4200 4061
4201 /** 4062 /**
4202 * Record the results produced by performing a [GenerateDartHintsTask]. If the results were 4063 * Record the results produced by performing a [GenerateDartHintsTask]. If the results were
4203 * computed from data that is now out-of-date, then the results will not be re corded. 4064 * computed from data that is now out-of-date, then the results will not be re corded.
(...skipping 14 matching lines...) Expand all
4218 if (sourceEntry == null) { 4079 if (sourceEntry == null) {
4219 throw new ObsoleteSourceAnalysisException(librarySource); 4080 throw new ObsoleteSourceAnalysisException(librarySource);
4220 } else if (sourceEntry is! DartEntry) { 4081 } else if (sourceEntry is! DartEntry) {
4221 // This shouldn't be possible because we should never have performed the task if the source 4082 // This shouldn't be possible because we should never have performed the task if the source
4222 // didn't represent a Dart file, but check to be safe. 4083 // didn't represent a Dart file, but check to be safe.
4223 throw new AnalysisException("Internal error: attempting to generate hint s for non-Dart file as a Dart file: ${librarySource.fullName}"); 4084 throw new AnalysisException("Internal error: attempting to generate hint s for non-Dart file as a Dart file: ${librarySource.fullName}");
4224 } 4085 }
4225 if (thrownException == null) { 4086 if (thrownException == null) {
4226 thrownException = new CaughtException(new AnalysisException("GenerateDar tHintsTask returned a null hint map without throwing an exception: ${librarySour ce.fullName}"), null); 4087 thrownException = new CaughtException(new AnalysisException("GenerateDar tHintsTask returned a null hint map without throwing an exception: ${librarySour ce.fullName}"), null);
4227 } 4088 }
4228 DartEntryImpl dartCopy = (sourceEntry as DartEntry).writableCopy; 4089 (sourceEntry as DartEntryImpl).recordHintErrorInLibrary(librarySource, thr ownException);
4229 dartCopy.recordHintErrorInLibrary(librarySource, thrownException);
4230 _cache.put(librarySource, dartCopy);
4231 throw new AnalysisException('<rethrow>', thrownException); 4090 throw new AnalysisException('<rethrow>', thrownException);
4232 } 4091 }
4233 for (MapEntry<Source, TimestampedData<List<AnalysisError>>> entry in getMapE ntrySet(hintMap)) { 4092 for (MapEntry<Source, TimestampedData<List<AnalysisError>>> entry in getMapE ntrySet(hintMap)) {
4234 Source unitSource = entry.getKey(); 4093 Source unitSource = entry.getKey();
4235 TimestampedData<List<AnalysisError>> results = entry.getValue(); 4094 TimestampedData<List<AnalysisError>> results = entry.getValue();
4236 SourceEntry sourceEntry = _cache.get(unitSource); 4095 SourceEntry sourceEntry = _cache.get(unitSource);
4237 if (sourceEntry is! DartEntry) { 4096 if (sourceEntry is! DartEntry) {
4238 // This shouldn't be possible because we should never have performed the task if the source 4097 // This shouldn't be possible because we should never have performed the task if the source
4239 // didn't represent a Dart file, but check to be safe. 4098 // didn't represent a Dart file, but check to be safe.
4240 throw new AnalysisException("Internal error: attempting to parse non-Dar t file as a Dart file: ${unitSource.fullName}"); 4099 throw new AnalysisException("Internal error: attempting to parse non-Dar t file as a Dart file: ${unitSource.fullName}");
4241 } 4100 }
4242 DartEntry dartEntry = sourceEntry as DartEntry; 4101 DartEntryImpl dartEntry = sourceEntry;
4243 if (unitSource == librarySource) { 4102 if (unitSource == librarySource) {
4244 libraryEntry = dartEntry; 4103 libraryEntry = dartEntry;
4245 } 4104 }
4246 int sourceTime = getModificationStamp(unitSource); 4105 int sourceTime = getModificationStamp(unitSource);
4247 int resultTime = results.modificationTime; 4106 int resultTime = results.modificationTime;
4248 if (sourceTime == resultTime) { 4107 if (sourceTime == resultTime) {
4249 if (dartEntry.modificationTime != sourceTime) { 4108 if (dartEntry.modificationTime != sourceTime) {
4250 // The source has changed without the context being notified. Simulate notification. 4109 // The source has changed without the context being notified. Simulate notification.
4251 _sourceChanged(unitSource); 4110 _sourceChanged(unitSource);
4252 dartEntry = _getReadableDartEntry(unitSource); 4111 dartEntry = _getReadableDartEntry(unitSource);
4253 if (dartEntry == null) { 4112 if (dartEntry == null) {
4254 throw new AnalysisException("A Dart file became a non-Dart file: ${u nitSource.fullName}"); 4113 throw new AnalysisException("A Dart file became a non-Dart file: ${u nitSource.fullName}");
4255 } 4114 }
4256 } 4115 }
4257 DartEntryImpl dartCopy = dartEntry.writableCopy;
4258 if (thrownException == null) { 4116 if (thrownException == null) {
4259 dartCopy.setValueInLibrary(DartEntry.HINTS, librarySource, results.dat a); 4117 dartEntry.setValueInLibrary(DartEntry.HINTS, librarySource, results.da ta);
4260 ChangeNoticeImpl notice = _getNotice(unitSource); 4118 ChangeNoticeImpl notice = _getNotice(unitSource);
4261 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LIN E_INFO)); 4119 notice.setErrors(dartEntry.allErrors, dartEntry.getValue(SourceEntry.L INE_INFO));
4262 } else { 4120 } else {
4263 dartCopy.recordHintErrorInLibrary(librarySource, thrownException); 4121 dartEntry.recordHintErrorInLibrary(librarySource, thrownException);
4264 } 4122 }
4265 _cache.put(unitSource, dartCopy);
4266 dartEntry = dartCopy;
4267 } else { 4123 } else {
4268 _logInformation2("Generated hints discarded for ${_debuggingString(unitS ource)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${d artEntry.modificationTime}", thrownException); 4124 _logInformation2("Generated hints discarded for ${_debuggingString(unitS ource)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${d artEntry.modificationTime}", thrownException);
4269 if (dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource) == Cache State.IN_PROCESS) { 4125 if (dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource) == Cache State.IN_PROCESS) {
4270 DartEntryImpl dartCopy = dartEntry.writableCopy;
4271 if (thrownException == null || resultTime >= 0) { 4126 if (thrownException == null || resultTime >= 0) {
4272 // 4127 //
4273 // The analysis was performed on out-of-date sources. Mark the cache so that the sources 4128 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4274 // will be re-analyzed using the up-to-date sources. 4129 // will be re-analyzed using the up-to-date sources.
4275 // 4130 //
4276 // dartCopy.setState(DartEntry.HINTS, librarySource, Ca cheState.INVALID); 4131 // dartCopy.setState(DartEntry.HINTS, librarySource, Ca cheState.INVALID);
4277 _removeFromParts(unitSource, dartEntry); 4132 _removeFromParts(unitSource, dartEntry);
4278 dartCopy.invalidateAllInformation(); 4133 dartEntry.invalidateAllInformation();
4279 dartCopy.modificationTime = sourceTime; 4134 dartEntry.modificationTime = sourceTime;
4280 _cache.removedAst(unitSource); 4135 _cache.removedAst(unitSource);
4281 _workManager.add(unitSource, SourcePriority.UNKNOWN); 4136 _workManager.add(unitSource, SourcePriority.UNKNOWN);
4282 } else { 4137 } else {
4283 // 4138 //
4284 // We could not determine whether the sources were up-to-date or out -of-date. Mark the 4139 // We could not determine whether the sources were up-to-date or out -of-date. Mark the
4285 // cache so that we won't attempt to re-analyze the sources until th ere's a good chance 4140 // cache so that we won't attempt to re-analyze the sources until th ere's a good chance
4286 // that we'll be able to do so without error. 4141 // that we'll be able to do so without error.
4287 // 4142 //
4288 dartCopy.recordHintErrorInLibrary(librarySource, thrownException); 4143 dartEntry.recordHintErrorInLibrary(librarySource, thrownException);
4289 } 4144 }
4290 _cache.put(unitSource, dartCopy);
4291 dartEntry = dartCopy;
4292 } 4145 }
4293 } 4146 }
4294 } 4147 }
4295 if (thrownException != null) { 4148 if (thrownException != null) {
4296 throw new AnalysisException('<rethrow>', thrownException); 4149 throw new AnalysisException('<rethrow>', thrownException);
4297 } 4150 }
4298 return libraryEntry; 4151 return libraryEntry;
4299 } 4152 }
4300 4153
4301 /** 4154 /**
4302 * Record the results produced by performing a [GetContentTask]. 4155 * Record the results produced by performing a [GetContentTask].
4303 * 4156 *
4304 * @param task the task that was performed 4157 * @param task the task that was performed
4305 * @return an entry containing the computed results 4158 * @return an entry containing the computed results
4306 * @throws AnalysisException if the results could not be recorded 4159 * @throws AnalysisException if the results could not be recorded
4307 */ 4160 */
4308 SourceEntry _recordGetContentsTask(GetContentTask task) { 4161 SourceEntry _recordGetContentsTask(GetContentTask task) {
4309 if (!task.isComplete) { 4162 if (!task.isComplete) {
4310 return null; 4163 return null;
4311 } 4164 }
4312 Source source = task.source; 4165 Source source = task.source;
4313 CaughtException thrownException = task.exception; 4166 CaughtException thrownException = task.exception;
4314 SourceEntry sourceEntry = null; 4167 SourceEntryImpl sourceEntry = null;
4315 sourceEntry = _cache.get(source); 4168 sourceEntry = _cache.get(source);
4316 if (sourceEntry == null) { 4169 if (sourceEntry == null) {
4317 throw new ObsoleteSourceAnalysisException(source); 4170 throw new ObsoleteSourceAnalysisException(source);
4318 } 4171 }
4319 SourceEntryImpl sourceCopy = sourceEntry.writableCopy;
4320 if (thrownException == null) { 4172 if (thrownException == null) {
4321 sourceCopy.modificationTime = task.modificationTime; 4173 sourceEntry.modificationTime = task.modificationTime;
4322 sourceCopy.setValue(SourceEntry.CONTENT, task.content); 4174 sourceEntry.setValue(SourceEntry.CONTENT, task.content);
4323 } else { 4175 } else {
4324 sourceCopy.recordContentError(thrownException); 4176 sourceEntry.recordContentError(thrownException);
4325 _workManager.remove(source); 4177 _workManager.remove(source);
4326 } 4178 }
4327 _cache.put(source, sourceCopy);
4328 sourceEntry = sourceCopy;
4329 if (thrownException != null) { 4179 if (thrownException != null) {
4330 throw new AnalysisException('<rethrow>', thrownException); 4180 throw new AnalysisException('<rethrow>', thrownException);
4331 } 4181 }
4332 return sourceEntry; 4182 return sourceEntry;
4333 } 4183 }
4334 4184
4335 /** 4185 /**
4336 * Record the results produced by performing a [IncrementalAnalysisTask]. 4186 * Record the results produced by performing a [IncrementalAnalysisTask].
4337 * 4187 *
4338 * @param task the task that was performed 4188 * @param task the task that was performed
(...skipping 14 matching lines...) Expand all
4353 * Record the results produced by performing a [ParseDartTask]. If the results were computed 4203 * Record the results produced by performing a [ParseDartTask]. If the results were computed
4354 * from data that is now out-of-date, then the results will not be recorded. 4204 * from data that is now out-of-date, then the results will not be recorded.
4355 * 4205 *
4356 * @param task the task that was performed 4206 * @param task the task that was performed
4357 * @return an entry containing the computed results 4207 * @return an entry containing the computed results
4358 * @throws AnalysisException if the results could not be recorded 4208 * @throws AnalysisException if the results could not be recorded
4359 */ 4209 */
4360 DartEntry _recordParseDartTaskResults(ParseDartTask task) { 4210 DartEntry _recordParseDartTaskResults(ParseDartTask task) {
4361 Source source = task.source; 4211 Source source = task.source;
4362 CaughtException thrownException = task.exception; 4212 CaughtException thrownException = task.exception;
4363 DartEntry dartEntry = null; 4213 DartEntryImpl dartEntry = null;
4364 SourceEntry sourceEntry = _cache.get(source); 4214 SourceEntry sourceEntry = _cache.get(source);
4365 if (sourceEntry == null) { 4215 if (sourceEntry == null) {
4366 throw new ObsoleteSourceAnalysisException(source); 4216 throw new ObsoleteSourceAnalysisException(source);
4367 } else if (sourceEntry is! DartEntry) { 4217 } else if (sourceEntry is! DartEntry) {
4368 // This shouldn't be possible because we should never have performed the t ask if the source 4218 // This shouldn't be possible because we should never have performed the t ask if the source
4369 // didn't represent a Dart file, but check to be safe. 4219 // didn't represent a Dart file, but check to be safe.
4370 throw new AnalysisException("Internal error: attempting to parse non-Dart file as a Dart file: ${source.fullName}"); 4220 throw new AnalysisException("Internal error: attempting to parse non-Dart file as a Dart file: ${source.fullName}");
4371 } 4221 }
4372 dartEntry = sourceEntry as DartEntry; 4222 dartEntry = sourceEntry as DartEntry;
4373 int sourceTime = getModificationStamp(source); 4223 int sourceTime = getModificationStamp(source);
4374 int resultTime = task.modificationTime; 4224 int resultTime = task.modificationTime;
4375 if (sourceTime == resultTime) { 4225 if (sourceTime == resultTime) {
4376 if (dartEntry.modificationTime != sourceTime) { 4226 if (dartEntry.modificationTime != sourceTime) {
4377 // The source has changed without the context being notified. Simulate n otification. 4227 // The source has changed without the context being notified. Simulate n otification.
4378 _sourceChanged(source); 4228 _sourceChanged(source);
4379 dartEntry = _getReadableDartEntry(source); 4229 dartEntry = _getReadableDartEntry(source);
4380 if (dartEntry == null) { 4230 if (dartEntry == null) {
4381 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}"); 4231 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}");
4382 } 4232 }
4383 } 4233 }
4384 _removeFromParts(source, dartEntry); 4234 _removeFromParts(source, dartEntry);
4385 DartEntryImpl dartCopy = dartEntry.writableCopy;
4386 if (thrownException == null) { 4235 if (thrownException == null) {
4387 if (task.hasNonPartOfDirective) { 4236 if (task.hasNonPartOfDirective) {
4388 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); 4237 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
4389 dartCopy.containingLibrary = source; 4238 dartEntry.containingLibrary = source;
4390 _workManager.add(source, SourcePriority.LIBRARY); 4239 _workManager.add(source, SourcePriority.LIBRARY);
4391 } else if (task.hasPartOfDirective) { 4240 } else if (task.hasPartOfDirective) {
4392 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); 4241 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
4393 dartCopy.removeContainingLibrary(source); 4242 dartEntry.removeContainingLibrary(source);
4394 _workManager.add(source, SourcePriority.NORMAL_PART); 4243 _workManager.add(source, SourcePriority.NORMAL_PART);
4395 } else { 4244 } else {
4396 // The file contains no directives. 4245 // The file contains no directives.
4397 List<Source> containingLibraries = dartCopy.containingLibraries; 4246 List<Source> containingLibraries = dartEntry.containingLibraries;
4398 if (containingLibraries.length > 1 || (containingLibraries.length == 1 && containingLibraries[0] != source)) { 4247 if (containingLibraries.length > 1 || (containingLibraries.length == 1 && containingLibraries[0] != source)) {
4399 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); 4248 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
4400 dartCopy.removeContainingLibrary(source); 4249 dartEntry.removeContainingLibrary(source);
4401 _workManager.add(source, SourcePriority.NORMAL_PART); 4250 _workManager.add(source, SourcePriority.NORMAL_PART);
4402 } else { 4251 } else {
4403 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); 4252 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
4404 dartCopy.containingLibrary = source; 4253 dartEntry.containingLibrary = source;
4405 _workManager.add(source, SourcePriority.LIBRARY); 4254 _workManager.add(source, SourcePriority.LIBRARY);
4406 } 4255 }
4407 } 4256 }
4408 List<Source> newParts = task.includedSources; 4257 List<Source> newParts = task.includedSources;
4409 for (int i = 0; i < newParts.length; i++) { 4258 for (int i = 0; i < newParts.length; i++) {
4410 Source partSource = newParts[i]; 4259 Source partSource = newParts[i];
4411 DartEntry partEntry = _getReadableDartEntry(partSource); 4260 DartEntryImpl partEntry = _getReadableDartEntry(partSource);
4412 if (partEntry != null && !identical(partEntry, dartEntry)) { 4261 if (partEntry != null && !identical(partEntry, dartEntry)) {
4413 DartEntryImpl partCopy = partEntry.writableCopy;
4414 // TODO(brianwilkerson) Change the kind of the "part" if it was mark ed as a library 4262 // TODO(brianwilkerson) Change the kind of the "part" if it was mark ed as a library
4415 // and it has no directives. 4263 // and it has no directives.
4416 partCopy.addContainingLibrary(source); 4264 partEntry.addContainingLibrary(source);
4417 _cache.put(partSource, partCopy);
4418 } 4265 }
4419 } 4266 }
4420 dartCopy.setValue(DartEntry.PARSED_UNIT, task.compilationUnit); 4267 dartEntry.setValue(DartEntry.PARSED_UNIT, task.compilationUnit);
4421 dartCopy.setValue(DartEntry.PARSE_ERRORS, task.errors); 4268 dartEntry.setValue(DartEntry.PARSE_ERRORS, task.errors);
4422 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources); 4269 dartEntry.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources);
4423 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources); 4270 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources);
4424 dartCopy.setValue(DartEntry.INCLUDED_PARTS, newParts); 4271 dartEntry.setValue(DartEntry.INCLUDED_PARTS, newParts);
4425 _cache.storedAst(source); 4272 _cache.storedAst(source);
4426 ChangeNoticeImpl notice = _getNotice(source); 4273 ChangeNoticeImpl notice = _getNotice(source);
4427 notice.setErrors(dartCopy.allErrors, task.lineInfo); 4274 notice.setErrors(dartEntry.allErrors, task.lineInfo);
4428 // Verify that the incrementally parsed and resolved unit in the increme ntal cache 4275 // Verify that the incrementally parsed and resolved unit in the increme ntal cache
4429 // is structurally equivalent to the fully parsed unit 4276 // is structurally equivalent to the fully parsed unit
4430 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_in crementalAnalysisCache, source, task.compilationUnit); 4277 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_in crementalAnalysisCache, source, task.compilationUnit);
4431 } else { 4278 } else {
4432 _removeFromParts(source, dartEntry); 4279 _removeFromParts(source, dartEntry);
4433 dartCopy.recordParseError(thrownException); 4280 dartEntry.recordParseError(thrownException);
4434 _cache.removedAst(source); 4281 _cache.removedAst(source);
4435 } 4282 }
4436 _cache.put(source, dartCopy);
4437 dartEntry = dartCopy;
4438 } else { 4283 } else {
4439 _logInformation2("Parse results discarded for ${_debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry .modificationTime}", thrownException); 4284 _logInformation2("Parse results discarded for ${_debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry .modificationTime}", thrownException);
4440 DartEntryImpl dartCopy = dartEntry.writableCopy;
4441 if (thrownException == null || resultTime >= 0) { 4285 if (thrownException == null || resultTime >= 0) {
4442 // 4286 //
4443 // The analysis was performed on out-of-date sources. Mark the cache so that the sources 4287 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4444 // will be re-analyzed using the up-to-date sources. 4288 // will be re-analyzed using the up-to-date sources.
4445 // 4289 //
4446 // dartCopy.recordParseNotInProcess(); 4290 // dartCopy.recordParseNotInProcess();
4447 _removeFromParts(source, dartEntry); 4291 _removeFromParts(source, dartEntry);
4448 dartCopy.invalidateAllInformation(); 4292 dartEntry.invalidateAllInformation();
4449 dartCopy.modificationTime = sourceTime; 4293 dartEntry.modificationTime = sourceTime;
4450 _cache.removedAst(source); 4294 _cache.removedAst(source);
4451 _workManager.add(source, SourcePriority.UNKNOWN); 4295 _workManager.add(source, SourcePriority.UNKNOWN);
4452 } else { 4296 } else {
4453 // 4297 //
4454 // We could not determine whether the sources were up-to-date or out-of- date. Mark the 4298 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4455 // cache so that we won't attempt to re-analyze the sources until there' s a good chance 4299 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4456 // that we'll be able to do so without error. 4300 // that we'll be able to do so without error.
4457 // 4301 //
4458 dartCopy.recordParseError(thrownException); 4302 dartEntry.recordParseError(thrownException);
4459 } 4303 }
4460 _cache.put(source, dartCopy);
4461 dartEntry = dartCopy;
4462 } 4304 }
4463 if (thrownException != null) { 4305 if (thrownException != null) {
4464 throw new AnalysisException('<rethrow>', thrownException); 4306 throw new AnalysisException('<rethrow>', thrownException);
4465 } 4307 }
4466 return dartEntry; 4308 return dartEntry;
4467 } 4309 }
4468 4310
4469 /** 4311 /**
4470 * Record the results produced by performing a [ParseHtmlTask]. If the results were computed 4312 * Record the results produced by performing a [ParseHtmlTask]. If the results were computed
4471 * from data that is now out-of-date, then the results will not be recorded. 4313 * from data that is now out-of-date, then the results will not be recorded.
4472 * 4314 *
4473 * @param task the task that was performed 4315 * @param task the task that was performed
4474 * @return an entry containing the computed results 4316 * @return an entry containing the computed results
4475 * @throws AnalysisException if the results could not be recorded 4317 * @throws AnalysisException if the results could not be recorded
4476 */ 4318 */
4477 HtmlEntry _recordParseHtmlTaskResults(ParseHtmlTask task) { 4319 HtmlEntry _recordParseHtmlTaskResults(ParseHtmlTask task) {
4478 Source source = task.source; 4320 Source source = task.source;
4479 CaughtException thrownException = task.exception; 4321 CaughtException thrownException = task.exception;
4480 HtmlEntry htmlEntry = null;
4481 SourceEntry sourceEntry = _cache.get(source); 4322 SourceEntry sourceEntry = _cache.get(source);
4482 if (sourceEntry == null) { 4323 if (sourceEntry == null) {
4483 throw new ObsoleteSourceAnalysisException(source); 4324 throw new ObsoleteSourceAnalysisException(source);
4484 } else if (sourceEntry is! HtmlEntry) { 4325 } else if (sourceEntry is! HtmlEntry) {
4485 // This shouldn't be possible because we should never have performed the t ask if the source 4326 // This shouldn't be possible because we should never have performed the t ask if the source
4486 // didn't represent an HTML file, but check to be safe. 4327 // didn't represent an HTML file, but check to be safe.
4487 throw new AnalysisException("Internal error: attempting to parse non-HTML file as a HTML file: ${source.fullName}"); 4328 throw new AnalysisException("Internal error: attempting to parse non-HTML file as a HTML file: ${source.fullName}");
4488 } 4329 }
4489 htmlEntry = sourceEntry as HtmlEntry; 4330 HtmlEntryImpl htmlEntry = sourceEntry;
4490 int sourceTime = getModificationStamp(source); 4331 int sourceTime = getModificationStamp(source);
4491 int resultTime = task.modificationTime; 4332 int resultTime = task.modificationTime;
4492 if (sourceTime == resultTime) { 4333 if (sourceTime == resultTime) {
4493 if (htmlEntry.modificationTime != sourceTime) { 4334 if (htmlEntry.modificationTime != sourceTime) {
4494 // The source has changed without the context being notified. Simulate n otification. 4335 // The source has changed without the context being notified. Simulate n otification.
4495 _sourceChanged(source); 4336 _sourceChanged(source);
4496 htmlEntry = _getReadableHtmlEntry(source); 4337 htmlEntry = _getReadableHtmlEntry(source);
4497 if (htmlEntry == null) { 4338 if (htmlEntry == null) {
4498 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4339 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4499 } 4340 }
4500 } 4341 }
4501 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy;
4502 if (thrownException == null) { 4342 if (thrownException == null) {
4503 LineInfo lineInfo = task.lineInfo; 4343 LineInfo lineInfo = task.lineInfo;
4504 ht.HtmlUnit unit = task.htmlUnit; 4344 ht.HtmlUnit unit = task.htmlUnit;
4505 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo); 4345 htmlEntry.setValue(SourceEntry.LINE_INFO, lineInfo);
4506 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); 4346 htmlEntry.setValue(HtmlEntry.PARSED_UNIT, unit);
4507 htmlCopy.setValue(HtmlEntry.PARSE_ERRORS, task.errors); 4347 htmlEntry.setValue(HtmlEntry.PARSE_ERRORS, task.errors);
4508 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibrari es); 4348 htmlEntry.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibrar ies);
4509 _cache.storedAst(source); 4349 _cache.storedAst(source);
4510 ChangeNoticeImpl notice = _getNotice(source); 4350 ChangeNoticeImpl notice = _getNotice(source);
4511 notice.setErrors(htmlCopy.allErrors, lineInfo); 4351 notice.setErrors(htmlEntry.allErrors, lineInfo);
4512 } else { 4352 } else {
4513 htmlCopy.recordParseError(thrownException); 4353 htmlEntry.recordParseError(thrownException);
4514 _cache.removedAst(source); 4354 _cache.removedAst(source);
4515 } 4355 }
4516 _cache.put(source, htmlCopy);
4517 htmlEntry = htmlCopy;
4518 } else { 4356 } else {
4519 _logInformation2("Parse results discarded for ${_debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry .modificationTime}", thrownException); 4357 _logInformation2("Parse results discarded for ${_debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry .modificationTime}", thrownException);
4520 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy;
4521 if (thrownException == null || resultTime >= 0) { 4358 if (thrownException == null || resultTime >= 0) {
4522 // 4359 //
4523 // The analysis was performed on out-of-date sources. Mark the cache so that the sources 4360 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4524 // will be re-analyzed using the up-to-date sources. 4361 // will be re-analyzed using the up-to-date sources.
4525 // 4362 //
4526 // if (htmlCopy.getState(SourceEntry.LINE_INFO) == CacheState.I N_PROCESS) { 4363 // if (htmlCopy.getState(SourceEntry.LINE_INFO) == CacheState.I N_PROCESS) {
4527 // htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALI D); 4364 // htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALI D);
4528 // } 4365 // }
4529 // if (htmlCopy.getState(HtmlEntry.PARSED_UNIT) == CacheState.I N_PROCESS) { 4366 // if (htmlCopy.getState(HtmlEntry.PARSED_UNIT) == CacheState.I N_PROCESS) {
4530 // htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALI D); 4367 // htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALI D);
4531 // } 4368 // }
4532 // if (htmlCopy.getState(HtmlEntry.REFERENCED_LIBRARIES) == Cac heState.IN_PROCESS) { 4369 // if (htmlCopy.getState(HtmlEntry.REFERENCED_LIBRARIES) == Cac heState.IN_PROCESS) {
4533 // htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheSta te.INVALID); 4370 // htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheSta te.INVALID);
4534 // } 4371 // }
4535 htmlCopy.invalidateAllInformation(); 4372 htmlEntry.invalidateAllInformation();
4536 htmlCopy.modificationTime = sourceTime; 4373 htmlEntry.modificationTime = sourceTime;
4537 _cache.removedAst(source); 4374 _cache.removedAst(source);
4538 } else { 4375 } else {
4539 // 4376 //
4540 // We could not determine whether the sources were up-to-date or out-of- date. Mark the 4377 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4541 // cache so that we won't attempt to re-analyze the sources until there' s a good chance 4378 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4542 // that we'll be able to do so without error. 4379 // that we'll be able to do so without error.
4543 // 4380 //
4544 htmlCopy.recordParseError(thrownException); 4381 htmlEntry.recordParseError(thrownException);
4545 } 4382 }
4546 _cache.put(source, htmlCopy);
4547 htmlEntry = htmlCopy;
4548 } 4383 }
4549 if (thrownException != null) { 4384 if (thrownException != null) {
4550 throw new AnalysisException('<rethrow>', thrownException); 4385 throw new AnalysisException('<rethrow>', thrownException);
4551 } 4386 }
4552 return htmlEntry; 4387 return htmlEntry;
4553 } 4388 }
4554 4389
4555 /** 4390 /**
4556 * Record the results produced by performing a [PolymerBuildHtmlTask]. If the results were 4391 * Record the results produced by performing a [PolymerBuildHtmlTask]. If the results were
4557 * computed from data that is now out-of-date, then the results will not be re corded. 4392 * computed from data that is now out-of-date, then the results will not be re corded.
4558 * 4393 *
4559 * @param task the task that was performed 4394 * @param task the task that was performed
4560 * @throws AnalysisException if the results could not be recorded 4395 * @throws AnalysisException if the results could not be recorded
4561 */ 4396 */
4562 HtmlEntry _recordPolymerBuildHtmlTaskResults(PolymerBuildHtmlTask task) { 4397 HtmlEntry _recordPolymerBuildHtmlTaskResults(PolymerBuildHtmlTask task) {
4563 Source source = task.source; 4398 Source source = task.source;
4564 CaughtException thrownException = task.exception; 4399 CaughtException thrownException = task.exception;
4565 HtmlEntry htmlEntry = null;
4566 SourceEntry sourceEntry = _cache.get(source); 4400 SourceEntry sourceEntry = _cache.get(source);
4567 if (sourceEntry == null) { 4401 if (sourceEntry == null) {
4568 throw new ObsoleteSourceAnalysisException(source); 4402 throw new ObsoleteSourceAnalysisException(source);
4569 } else if (sourceEntry is! HtmlEntry) { 4403 } else if (sourceEntry is! HtmlEntry) {
4570 // This shouldn't be possible because we should never have performed the t ask if the source 4404 // This shouldn't be possible because we should never have performed the t ask if the source
4571 // didn't represent an HTML file, but check to be safe. 4405 // didn't represent an HTML file, but check to be safe.
4572 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4406 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}");
4573 } 4407 }
4574 htmlEntry = sourceEntry as HtmlEntry; 4408 HtmlEntryImpl htmlEntry = sourceEntry;
4575 int sourceTime = getModificationStamp(source); 4409 int sourceTime = getModificationStamp(source);
4576 int resultTime = task.modificationTime; 4410 int resultTime = task.modificationTime;
4577 if (sourceTime == resultTime) { 4411 if (sourceTime == resultTime) {
4578 if (htmlEntry.modificationTime != sourceTime) { 4412 if (htmlEntry.modificationTime != sourceTime) {
4579 // The source has changed without the context being notified. Simulate n otification. 4413 // The source has changed without the context being notified. Simulate n otification.
4580 _sourceChanged(source); 4414 _sourceChanged(source);
4581 htmlEntry = _getReadableHtmlEntry(source); 4415 htmlEntry = _getReadableHtmlEntry(source);
4582 if (htmlEntry == null) { 4416 if (htmlEntry == null) {
4583 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4417 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4584 } 4418 }
4585 } 4419 }
4586 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
4587 if (thrownException == null) { 4420 if (thrownException == null) {
4588 htmlCopy.setValue(HtmlEntry.POLYMER_BUILD_ERRORS, task.errors); 4421 htmlEntry.setValue(HtmlEntry.POLYMER_BUILD_ERRORS, task.errors);
4589 // notify about errors 4422 // notify about errors
4590 ChangeNoticeImpl notice = _getNotice(source); 4423 ChangeNoticeImpl notice = _getNotice(source);
4591 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_ INFO)); 4424 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LIN E_INFO));
4592 } else { 4425 } else {
4593 htmlCopy.recordResolutionError(thrownException); 4426 htmlEntry.recordResolutionError(thrownException);
4594 } 4427 }
4595 _cache.put(source, htmlCopy);
4596 htmlEntry = htmlCopy;
4597 } else { 4428 } else {
4598 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
4599 if (thrownException == null || resultTime >= 0) { 4429 if (thrownException == null || resultTime >= 0) {
4600 // 4430 //
4601 // The analysis was performed on out-of-date sources. Mark the cache so that the sources 4431 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4602 // will be re-analyzed using the up-to-date sources. 4432 // will be re-analyzed using the up-to-date sources.
4603 // 4433 //
4604 htmlCopy.invalidateAllInformation(); 4434 htmlEntry.invalidateAllInformation();
4605 htmlCopy.modificationTime = sourceTime; 4435 htmlEntry.modificationTime = sourceTime;
4606 _cache.removedAst(source); 4436 _cache.removedAst(source);
4607 } else { 4437 } else {
4608 // 4438 //
4609 // We could not determine whether the sources were up-to-date or out-of- date. Mark the 4439 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4610 // cache so that we won't attempt to re-analyze the sources until there' s a good chance 4440 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4611 // that we'll be able to do so without error. 4441 // that we'll be able to do so without error.
4612 // 4442 //
4613 htmlCopy.recordResolutionError(thrownException); 4443 htmlEntry.recordResolutionError(thrownException);
4614 } 4444 }
4615 _cache.put(source, htmlCopy);
4616 htmlEntry = htmlCopy;
4617 } 4445 }
4618 if (thrownException != null) { 4446 if (thrownException != null) {
4619 throw new AnalysisException('<rethrow>', thrownException); 4447 throw new AnalysisException('<rethrow>', thrownException);
4620 } 4448 }
4621 return htmlEntry; 4449 return htmlEntry;
4622 } 4450 }
4623 4451
4624 /** 4452 /**
4625 * Record the results produced by performing a [PolymerResolveHtmlTask]. If th e results were 4453 * Record the results produced by performing a [PolymerResolveHtmlTask]. If th e results were
4626 * computed from data that is now out-of-date, then the results will not be re corded. 4454 * computed from data that is now out-of-date, then the results will not be re corded.
4627 * 4455 *
4628 * @param task the task that was performed 4456 * @param task the task that was performed
4629 * @throws AnalysisException if the results could not be recorded 4457 * @throws AnalysisException if the results could not be recorded
4630 */ 4458 */
4631 HtmlEntry _recordPolymerResolveHtmlTaskResults(PolymerResolveHtmlTask task) { 4459 HtmlEntry _recordPolymerResolveHtmlTaskResults(PolymerResolveHtmlTask task) {
4632 Source source = task.source; 4460 Source source = task.source;
4633 CaughtException thrownException = task.exception; 4461 CaughtException thrownException = task.exception;
4634 HtmlEntry htmlEntry = null;
4635 SourceEntry sourceEntry = _cache.get(source); 4462 SourceEntry sourceEntry = _cache.get(source);
4636 if (sourceEntry == null) { 4463 if (sourceEntry == null) {
4637 throw new ObsoleteSourceAnalysisException(source); 4464 throw new ObsoleteSourceAnalysisException(source);
4638 } else if (sourceEntry is! HtmlEntry) { 4465 } else if (sourceEntry is! HtmlEntry) {
4639 // This shouldn't be possible because we should never have performed the t ask if the source 4466 // This shouldn't be possible because we should never have performed the t ask if the source
4640 // didn't represent an HTML file, but check to be safe. 4467 // didn't represent an HTML file, but check to be safe.
4641 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4468 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}");
4642 } 4469 }
4643 htmlEntry = sourceEntry as HtmlEntry; 4470 HtmlEntryImpl htmlEntry = sourceEntry;
4644 int sourceTime = getModificationStamp(source); 4471 int sourceTime = getModificationStamp(source);
4645 int resultTime = task.modificationTime; 4472 int resultTime = task.modificationTime;
4646 if (sourceTime == resultTime) { 4473 if (sourceTime == resultTime) {
4647 if (htmlEntry.modificationTime != sourceTime) { 4474 if (htmlEntry.modificationTime != sourceTime) {
4648 // The source has changed without the context being notified. Simulate n otification. 4475 // The source has changed without the context being notified. Simulate n otification.
4649 _sourceChanged(source); 4476 _sourceChanged(source);
4650 htmlEntry = _getReadableHtmlEntry(source); 4477 htmlEntry = _getReadableHtmlEntry(source);
4651 if (htmlEntry == null) { 4478 if (htmlEntry == null) {
4652 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4479 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4653 } 4480 }
4654 } 4481 }
4655 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
4656 if (thrownException == null) { 4482 if (thrownException == null) {
4657 htmlCopy.setValue(HtmlEntry.POLYMER_RESOLUTION_ERRORS, task.errors); 4483 htmlEntry.setValue(HtmlEntry.POLYMER_RESOLUTION_ERRORS, task.errors);
4658 // notify about errors 4484 // notify about errors
4659 ChangeNoticeImpl notice = _getNotice(source); 4485 ChangeNoticeImpl notice = _getNotice(source);
4660 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_ INFO)); 4486 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LIN E_INFO));
4661 } else { 4487 } else {
4662 htmlCopy.recordResolutionError(thrownException); 4488 htmlEntry.recordResolutionError(thrownException);
4663 } 4489 }
4664 _cache.put(source, htmlCopy);
4665 htmlEntry = htmlCopy;
4666 } else { 4490 } else {
4667 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
4668 if (thrownException == null || resultTime >= 0) { 4491 if (thrownException == null || resultTime >= 0) {
4669 // 4492 //
4670 // The analysis was performed on out-of-date sources. Mark the cache so that the sources 4493 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4671 // will be re-analyzed using the up-to-date sources. 4494 // will be re-analyzed using the up-to-date sources.
4672 // 4495 //
4673 htmlCopy.invalidateAllInformation(); 4496 htmlEntry.invalidateAllInformation();
4674 htmlCopy.modificationTime = sourceTime; 4497 htmlEntry.modificationTime = sourceTime;
4675 _cache.removedAst(source); 4498 _cache.removedAst(source);
4676 } else { 4499 } else {
4677 // 4500 //
4678 // We could not determine whether the sources were up-to-date or out-of- date. Mark the 4501 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4679 // cache so that we won't attempt to re-analyze the sources until there' s a good chance 4502 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4680 // that we'll be able to do so without error. 4503 // that we'll be able to do so without error.
4681 // 4504 //
4682 htmlCopy.recordResolutionError(thrownException); 4505 htmlEntry.recordResolutionError(thrownException);
4683 } 4506 }
4684 _cache.put(source, htmlCopy);
4685 htmlEntry = htmlCopy;
4686 } 4507 }
4687 if (thrownException != null) { 4508 if (thrownException != null) {
4688 throw new AnalysisException('<rethrow>', thrownException); 4509 throw new AnalysisException('<rethrow>', thrownException);
4689 } 4510 }
4690 return htmlEntry; 4511 return htmlEntry;
4691 } 4512 }
4692 4513
4693 /** 4514 /**
4694 * Record the results produced by performing a [ResolveAngularComponentTemplat eTask]. If the 4515 * Record the results produced by performing a [ResolveAngularComponentTemplat eTask]. If the
4695 * results were computed from data that is now out-of-date, then the results w ill not be recorded. 4516 * results were computed from data that is now out-of-date, then the results w ill not be recorded.
4696 * 4517 *
4697 * @param task the task that was performed 4518 * @param task the task that was performed
4698 * @throws AnalysisException if the results could not be recorded 4519 * @throws AnalysisException if the results could not be recorded
4699 */ 4520 */
4700 HtmlEntry _recordResolveAngularComponentTemplateTaskResults(ResolveAngularComp onentTemplateTask task) { 4521 HtmlEntry _recordResolveAngularComponentTemplateTaskResults(ResolveAngularComp onentTemplateTask task) {
4701 Source source = task.source; 4522 Source source = task.source;
4702 CaughtException thrownException = task.exception; 4523 CaughtException thrownException = task.exception;
4703 HtmlEntry htmlEntry = null;
4704 SourceEntry sourceEntry = _cache.get(source); 4524 SourceEntry sourceEntry = _cache.get(source);
4705 if (sourceEntry == null) { 4525 if (sourceEntry == null) {
4706 throw new ObsoleteSourceAnalysisException(source); 4526 throw new ObsoleteSourceAnalysisException(source);
4707 } else if (sourceEntry is! HtmlEntry) { 4527 } else if (sourceEntry is! HtmlEntry) {
4708 // This shouldn't be possible because we should never have performed the t ask if the source 4528 // This shouldn't be possible because we should never have performed the t ask if the source
4709 // didn't represent an HTML file, but check to be safe. 4529 // didn't represent an HTML file, but check to be safe.
4710 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4530 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}");
4711 } 4531 }
4712 htmlEntry = sourceEntry as HtmlEntry; 4532 HtmlEntryImpl htmlEntry = sourceEntry;
4713 int sourceTime = getModificationStamp(source); 4533 int sourceTime = getModificationStamp(source);
4714 int resultTime = task.modificationTime; 4534 int resultTime = task.modificationTime;
4715 if (sourceTime == resultTime) { 4535 if (sourceTime == resultTime) {
4716 if (htmlEntry.modificationTime != sourceTime) { 4536 if (htmlEntry.modificationTime != sourceTime) {
4717 // The source has changed without the context being notified. Simulate n otification. 4537 // The source has changed without the context being notified. Simulate n otification.
4718 _sourceChanged(source); 4538 _sourceChanged(source);
4719 htmlEntry = _getReadableHtmlEntry(source); 4539 htmlEntry = _getReadableHtmlEntry(source);
4720 if (htmlEntry == null) { 4540 if (htmlEntry == null) {
4721 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4541 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4722 } 4542 }
4723 } 4543 }
4724 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
4725 if (thrownException == null) { 4544 if (thrownException == null) {
4726 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors); 4545 htmlEntry.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors);
4727 // notify about errors 4546 // notify about errors
4728 ChangeNoticeImpl notice = _getNotice(source); 4547 ChangeNoticeImpl notice = _getNotice(source);
4729 notice.htmlUnit = task.resolvedUnit; 4548 notice.htmlUnit = task.resolvedUnit;
4730 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_ INFO)); 4549 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LIN E_INFO));
4731 } else { 4550 } else {
4732 htmlCopy.recordResolutionError(thrownException); 4551 htmlEntry.recordResolutionError(thrownException);
4733 } 4552 }
4734 _cache.put(source, htmlCopy);
4735 htmlEntry = htmlCopy;
4736 } else { 4553 } else {
4737 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
4738 if (thrownException == null || resultTime >= 0) { 4554 if (thrownException == null || resultTime >= 0) {
4739 // 4555 //
4740 // The analysis was performed on out-of-date sources. Mark the cache so that the sources 4556 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4741 // will be re-analyzed using the up-to-date sources. 4557 // will be re-analyzed using the up-to-date sources.
4742 // 4558 //
4743 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheStat e.IN_PROCESS) { 4559 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheStat e.IN_PROCESS) {
4744 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INV ALID); 4560 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INV ALID);
4745 // } 4561 // }
4746 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) { 4562 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) {
4747 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); 4563 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
4748 // } 4564 // }
4749 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) { 4565 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) {
4750 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID); 4566 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID);
4751 // } 4567 // }
4752 htmlCopy.invalidateAllInformation(); 4568 htmlEntry.invalidateAllInformation();
4753 htmlCopy.modificationTime = sourceTime; 4569 htmlEntry.modificationTime = sourceTime;
4754 _cache.removedAst(source); 4570 _cache.removedAst(source);
4755 } else { 4571 } else {
4756 // 4572 //
4757 // We could not determine whether the sources were up-to-date or out-of- date. Mark the 4573 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4758 // cache so that we won't attempt to re-analyze the sources until there' s a good chance 4574 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4759 // that we'll be able to do so without error. 4575 // that we'll be able to do so without error.
4760 // 4576 //
4761 htmlCopy.recordResolutionError(thrownException); 4577 htmlEntry.recordResolutionError(thrownException);
4762 } 4578 }
4763 _cache.put(source, htmlCopy);
4764 htmlEntry = htmlCopy;
4765 } 4579 }
4766 if (thrownException != null) { 4580 if (thrownException != null) {
4767 throw new AnalysisException('<rethrow>', thrownException); 4581 throw new AnalysisException('<rethrow>', thrownException);
4768 } 4582 }
4769 return htmlEntry; 4583 return htmlEntry;
4770 } 4584 }
4771 4585
4772 /** 4586 /**
4773 * Record the results produced by performing a [ResolveAngularEntryHtmlTask]. If the results 4587 * Record the results produced by performing a [ResolveAngularEntryHtmlTask]. If the results
4774 * were computed from data that is now out-of-date, then the results will not be recorded. 4588 * were computed from data that is now out-of-date, then the results will not be recorded.
4775 * 4589 *
4776 * @param task the task that was performed 4590 * @param task the task that was performed
4777 * @throws AnalysisException if the results could not be recorded 4591 * @throws AnalysisException if the results could not be recorded
4778 */ 4592 */
4779 HtmlEntry _recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTas k task) { 4593 HtmlEntry _recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTas k task) {
4780 Source source = task.source; 4594 Source source = task.source;
4781 CaughtException thrownException = task.exception; 4595 CaughtException thrownException = task.exception;
4782 HtmlEntry htmlEntry = null; 4596 HtmlEntryImpl htmlEntry = null;
4783 SourceEntry sourceEntry = _cache.get(source); 4597 SourceEntry sourceEntry = _cache.get(source);
4784 if (sourceEntry == null) { 4598 if (sourceEntry == null) {
4785 throw new ObsoleteSourceAnalysisException(source); 4599 throw new ObsoleteSourceAnalysisException(source);
4786 } else if (sourceEntry is! HtmlEntry) { 4600 } else if (sourceEntry is! HtmlEntry) {
4787 // This shouldn't be possible because we should never have performed the t ask if the source 4601 // This shouldn't be possible because we should never have performed the t ask if the source
4788 // didn't represent an HTML file, but check to be safe. 4602 // didn't represent an HTML file, but check to be safe.
4789 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4603 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}");
4790 } 4604 }
4791 htmlEntry = sourceEntry as HtmlEntry; 4605 htmlEntry = sourceEntry as HtmlEntry;
4792 int sourceTime = getModificationStamp(source); 4606 int sourceTime = getModificationStamp(source);
4793 int resultTime = task.modificationTime; 4607 int resultTime = task.modificationTime;
4794 if (sourceTime == resultTime) { 4608 if (sourceTime == resultTime) {
4795 if (htmlEntry.modificationTime != sourceTime) { 4609 if (htmlEntry.modificationTime != sourceTime) {
4796 // The source has changed without the context being notified. Simulate n otification. 4610 // The source has changed without the context being notified. Simulate n otification.
4797 _sourceChanged(source); 4611 _sourceChanged(source);
4798 htmlEntry = _getReadableHtmlEntry(source); 4612 htmlEntry = _getReadableHtmlEntry(source);
4799 if (htmlEntry == null) { 4613 if (htmlEntry == null) {
4800 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4614 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4801 } 4615 }
4802 } 4616 }
4803 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
4804 if (thrownException == null) { 4617 if (thrownException == null) {
4805 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); 4618 htmlEntry.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit);
4806 _recordAngularEntryPoint(htmlCopy, task); 4619 _recordAngularEntryPoint(htmlEntry, task);
4807 _cache.storedAst(source); 4620 _cache.storedAst(source);
4808 ChangeNoticeImpl notice = _getNotice(source); 4621 ChangeNoticeImpl notice = _getNotice(source);
4809 notice.htmlUnit = task.resolvedUnit; 4622 notice.htmlUnit = task.resolvedUnit;
4810 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_ INFO)); 4623 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LIN E_INFO));
4811 } else { 4624 } else {
4812 htmlCopy.recordResolutionError(thrownException); 4625 htmlEntry.recordResolutionError(thrownException);
4813 } 4626 }
4814 _cache.put(source, htmlCopy);
4815 htmlEntry = htmlCopy;
4816 } else { 4627 } else {
4817 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
4818 if (thrownException == null || resultTime >= 0) { 4628 if (thrownException == null || resultTime >= 0) {
4819 // 4629 //
4820 // The analysis was performed on out-of-date sources. Mark the cache so that the sources 4630 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4821 // will be re-analyzed using the up-to-date sources. 4631 // will be re-analyzed using the up-to-date sources.
4822 // 4632 //
4823 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheStat e.IN_PROCESS) { 4633 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheStat e.IN_PROCESS) {
4824 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INV ALID); 4634 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INV ALID);
4825 // } 4635 // }
4826 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) { 4636 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) {
4827 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); 4637 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
4828 // } 4638 // }
4829 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) { 4639 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) {
4830 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID); 4640 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID);
4831 // } 4641 // }
4832 htmlCopy.invalidateAllInformation(); 4642 htmlEntry.invalidateAllInformation();
4833 htmlCopy.modificationTime = sourceTime; 4643 htmlEntry.modificationTime = sourceTime;
4834 _cache.removedAst(source); 4644 _cache.removedAst(source);
4835 } else { 4645 } else {
4836 // 4646 //
4837 // We could not determine whether the sources were up-to-date or out-of- date. Mark the 4647 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4838 // cache so that we won't attempt to re-analyze the sources until there' s a good chance 4648 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4839 // that we'll be able to do so without error. 4649 // that we'll be able to do so without error.
4840 // 4650 //
4841 htmlCopy.recordResolutionError(thrownException); 4651 htmlEntry.recordResolutionError(thrownException);
4842 } 4652 }
4843 _cache.put(source, htmlCopy);
4844 htmlEntry = htmlCopy;
4845 } 4653 }
4846 if (thrownException != null) { 4654 if (thrownException != null) {
4847 throw new AnalysisException('<rethrow>', thrownException); 4655 throw new AnalysisException('<rethrow>', thrownException);
4848 } 4656 }
4849 return htmlEntry; 4657 return htmlEntry;
4850 } 4658 }
4851 4659
4852 /** 4660 /**
4853 * Record the results produced by performing a [ResolveDartUnitTask]. If the r esults were 4661 * Record the results produced by performing a [ResolveDartUnitTask]. If the r esults were
4854 * computed from data that is now out-of-date, then the results will not be re corded. 4662 * computed from data that is now out-of-date, then the results will not be re corded.
4855 * 4663 *
4856 * @param task the task that was performed 4664 * @param task the task that was performed
4857 * @return an entry containing the computed results 4665 * @return an entry containing the computed results
4858 * @throws AnalysisException if the results could not be recorded 4666 * @throws AnalysisException if the results could not be recorded
4859 */ 4667 */
4860 DartEntry _recordResolveDartUnitTaskResults(ResolveDartUnitTask task) { 4668 DartEntry _recordResolveDartUnitTaskResults(ResolveDartUnitTask task) {
4861 Source unitSource = task.source; 4669 Source unitSource = task.source;
4862 Source librarySource = task.librarySource; 4670 Source librarySource = task.librarySource;
4863 CaughtException thrownException = task.exception; 4671 CaughtException thrownException = task.exception;
4864 DartEntry dartEntry = null; 4672 DartEntryImpl dartEntry = null;
4865 SourceEntry sourceEntry = _cache.get(unitSource); 4673 SourceEntry sourceEntry = _cache.get(unitSource);
4866 if (sourceEntry == null) { 4674 if (sourceEntry == null) {
4867 throw new ObsoleteSourceAnalysisException(unitSource); 4675 throw new ObsoleteSourceAnalysisException(unitSource);
4868 } else if (sourceEntry is! DartEntry) { 4676 } else if (sourceEntry is! DartEntry) {
4869 // This shouldn't be possible because we should never have performed the t ask if the source 4677 // This shouldn't be possible because we should never have performed the t ask if the source
4870 // didn't represent a Dart file, but check to be safe. 4678 // didn't represent a Dart file, but check to be safe.
4871 throw new AnalysisException("Internal error: attempting to resolve non-Dar t file as a Dart file: ${unitSource.fullName}"); 4679 throw new AnalysisException("Internal error: attempting to resolve non-Dar t file as a Dart file: ${unitSource.fullName}");
4872 } 4680 }
4873 dartEntry = sourceEntry as DartEntry; 4681 dartEntry = sourceEntry as DartEntry;
4874 int sourceTime = getModificationStamp(unitSource); 4682 int sourceTime = getModificationStamp(unitSource);
4875 int resultTime = task.modificationTime; 4683 int resultTime = task.modificationTime;
4876 if (sourceTime == resultTime) { 4684 if (sourceTime == resultTime) {
4877 if (dartEntry.modificationTime != sourceTime) { 4685 if (dartEntry.modificationTime != sourceTime) {
4878 // The source has changed without the context being notified. Simulate n otification. 4686 // The source has changed without the context being notified. Simulate n otification.
4879 _sourceChanged(unitSource); 4687 _sourceChanged(unitSource);
4880 dartEntry = _getReadableDartEntry(unitSource); 4688 dartEntry = _getReadableDartEntry(unitSource);
4881 if (dartEntry == null) { 4689 if (dartEntry == null) {
4882 throw new AnalysisException("A Dart file became a non-Dart file: ${uni tSource.fullName}"); 4690 throw new AnalysisException("A Dart file became a non-Dart file: ${uni tSource.fullName}");
4883 } 4691 }
4884 } 4692 }
4885 DartEntryImpl dartCopy = dartEntry.writableCopy;
4886 if (thrownException == null) { 4693 if (thrownException == null) {
4887 dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, task. resolvedUnit); 4694 dartEntry.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, task .resolvedUnit);
4888 _cache.storedAst(unitSource); 4695 _cache.storedAst(unitSource);
4889 } else { 4696 } else {
4890 dartCopy.recordResolutionErrorInLibrary(librarySource, thrownException); 4697 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownException) ;
4891 _cache.removedAst(unitSource); 4698 _cache.removedAst(unitSource);
4892 } 4699 }
4893 _cache.put(unitSource, dartCopy);
4894 dartEntry = dartCopy;
4895 } else { 4700 } else {
4896 _logInformation2("Resolution results discarded for ${_debuggingString(unit Source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${ dartEntry.modificationTime}", thrownException); 4701 _logInformation2("Resolution results discarded for ${_debuggingString(unit Source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${ dartEntry.modificationTime}", thrownException);
4897 DartEntryImpl dartCopy = dartEntry.writableCopy;
4898 if (thrownException == null || resultTime >= 0) { 4702 if (thrownException == null || resultTime >= 0) {
4899 // 4703 //
4900 // The analysis was performed on out-of-date sources. Mark the cache so that the sources 4704 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4901 // will be re-analyzed using the up-to-date sources. 4705 // will be re-analyzed using the up-to-date sources.
4902 // 4706 //
4903 // if (dartCopy.getState(DartEntry.RESOLVED_UNIT) == CacheState .IN_PROCESS) { 4707 // if (dartCopy.getState(DartEntry.RESOLVED_UNIT) == CacheState .IN_PROCESS) {
4904 // dartCopy.setState(DartEntry.RESOLVED_UNIT, librarySource, CacheState.INVALID); 4708 // dartCopy.setState(DartEntry.RESOLVED_UNIT, librarySource, CacheState.INVALID);
4905 // } 4709 // }
4906 _removeFromParts(unitSource, dartEntry); 4710 _removeFromParts(unitSource, dartEntry);
4907 dartCopy.invalidateAllInformation(); 4711 dartEntry.invalidateAllInformation();
4908 dartCopy.modificationTime = sourceTime; 4712 dartEntry.modificationTime = sourceTime;
4909 _cache.removedAst(unitSource); 4713 _cache.removedAst(unitSource);
4910 _workManager.add(unitSource, SourcePriority.UNKNOWN); 4714 _workManager.add(unitSource, SourcePriority.UNKNOWN);
4911 } else { 4715 } else {
4912 // 4716 //
4913 // We could not determine whether the sources were up-to-date or out-of- date. Mark the 4717 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4914 // cache so that we won't attempt to re-analyze the sources until there' s a good chance 4718 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4915 // that we'll be able to do so without error. 4719 // that we'll be able to do so without error.
4916 // 4720 //
4917 dartCopy.recordResolutionErrorInLibrary(librarySource, thrownException); 4721 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownException) ;
4918 } 4722 }
4919 _cache.put(unitSource, dartCopy);
4920 dartEntry = dartCopy;
4921 } 4723 }
4922 if (thrownException != null) { 4724 if (thrownException != null) {
4923 throw new AnalysisException('<rethrow>', thrownException); 4725 throw new AnalysisException('<rethrow>', thrownException);
4924 } 4726 }
4925 return dartEntry; 4727 return dartEntry;
4926 } 4728 }
4927 4729
4928 /** 4730 /**
4929 * Record the results produced by performing a [ResolveHtmlTask]. If the resul ts were 4731 * Record the results produced by performing a [ResolveHtmlTask]. If the resul ts were
4930 * computed from data that is now out-of-date, then the results will not be re corded. 4732 * computed from data that is now out-of-date, then the results will not be re corded.
4931 * 4733 *
4932 * @param task the task that was performed 4734 * @param task the task that was performed
4933 * @return an entry containing the computed results 4735 * @return an entry containing the computed results
4934 * @throws AnalysisException if the results could not be recorded 4736 * @throws AnalysisException if the results could not be recorded
4935 */ 4737 */
4936 HtmlEntry _recordResolveHtmlTaskResults(ResolveHtmlTask task) { 4738 HtmlEntry _recordResolveHtmlTaskResults(ResolveHtmlTask task) {
4937 Source source = task.source; 4739 Source source = task.source;
4938 CaughtException thrownException = task.exception; 4740 CaughtException thrownException = task.exception;
4939 HtmlEntry htmlEntry = null; 4741 HtmlEntryImpl htmlEntry = null;
4940 SourceEntry sourceEntry = _cache.get(source); 4742 SourceEntry sourceEntry = _cache.get(source);
4941 if (sourceEntry == null) { 4743 if (sourceEntry == null) {
4942 throw new ObsoleteSourceAnalysisException(source); 4744 throw new ObsoleteSourceAnalysisException(source);
4943 } else if (sourceEntry is! HtmlEntry) { 4745 } else if (sourceEntry is! HtmlEntry) {
4944 // This shouldn't be possible because we should never have performed the t ask if the source 4746 // This shouldn't be possible because we should never have performed the t ask if the source
4945 // didn't represent an HTML file, but check to be safe. 4747 // didn't represent an HTML file, but check to be safe.
4946 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4748 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}");
4947 } 4749 }
4948 htmlEntry = sourceEntry as HtmlEntry; 4750 htmlEntry = sourceEntry as HtmlEntry;
4949 int sourceTime = getModificationStamp(source); 4751 int sourceTime = getModificationStamp(source);
4950 int resultTime = task.modificationTime; 4752 int resultTime = task.modificationTime;
4951 if (sourceTime == resultTime) { 4753 if (sourceTime == resultTime) {
4952 if (htmlEntry.modificationTime != sourceTime) { 4754 if (htmlEntry.modificationTime != sourceTime) {
4953 // The source has changed without the context being notified. Simulate n otification. 4755 // The source has changed without the context being notified. Simulate n otification.
4954 _sourceChanged(source); 4756 _sourceChanged(source);
4955 htmlEntry = _getReadableHtmlEntry(source); 4757 htmlEntry = _getReadableHtmlEntry(source);
4956 if (htmlEntry == null) { 4758 if (htmlEntry == null) {
4957 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4759 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4958 } 4760 }
4959 } 4761 }
4960 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
4961 if (thrownException == null) { 4762 if (thrownException == null) {
4962 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); 4763 htmlEntry.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED);
4963 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); 4764 htmlEntry.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit);
4964 htmlCopy.setValue(HtmlEntry.ELEMENT, task.element); 4765 htmlEntry.setValue(HtmlEntry.ELEMENT, task.element);
4965 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors); 4766 htmlEntry.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors);
4966 _cache.storedAst(source); 4767 _cache.storedAst(source);
4967 ChangeNoticeImpl notice = _getNotice(source); 4768 ChangeNoticeImpl notice = _getNotice(source);
4968 notice.htmlUnit = task.resolvedUnit; 4769 notice.htmlUnit = task.resolvedUnit;
4969 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_ INFO)); 4770 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LIN E_INFO));
4970 } else { 4771 } else {
4971 htmlCopy.recordResolutionError(thrownException); 4772 htmlEntry.recordResolutionError(thrownException);
4972 _cache.removedAst(source); 4773 _cache.removedAst(source);
4973 } 4774 }
4974 _cache.put(source, htmlCopy);
4975 htmlEntry = htmlCopy;
4976 } else { 4775 } else {
4977 _logInformation2("Resolution results discarded for ${_debuggingString(sour ce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${html Entry.modificationTime}", thrownException); 4776 _logInformation2("Resolution results discarded for ${_debuggingString(sour ce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${html Entry.modificationTime}", thrownException);
4978 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
4979 if (thrownException == null || resultTime >= 0) { 4777 if (thrownException == null || resultTime >= 0) {
4980 // 4778 //
4981 // The analysis was performed on out-of-date sources. Mark the cache so that the sources 4779 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4982 // will be re-analyzed using the up-to-date sources. 4780 // will be re-analyzed using the up-to-date sources.
4983 // 4781 //
4984 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) { 4782 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) {
4985 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); 4783 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
4986 // } 4784 // }
4987 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) { 4785 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) {
4988 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID); 4786 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID);
4989 // } 4787 // }
4990 htmlCopy.invalidateAllInformation(); 4788 htmlEntry.invalidateAllInformation();
4991 htmlCopy.modificationTime = sourceTime; 4789 htmlEntry.modificationTime = sourceTime;
4992 _cache.removedAst(source); 4790 _cache.removedAst(source);
4993 } else { 4791 } else {
4994 // 4792 //
4995 // We could not determine whether the sources were up-to-date or out-of- date. Mark the 4793 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4996 // cache so that we won't attempt to re-analyze the sources until there' s a good chance 4794 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4997 // that we'll be able to do so without error. 4795 // that we'll be able to do so without error.
4998 // 4796 //
4999 htmlCopy.recordResolutionError(thrownException); 4797 htmlEntry.recordResolutionError(thrownException);
5000 } 4798 }
5001 _cache.put(source, htmlCopy);
5002 htmlEntry = htmlCopy;
5003 } 4799 }
5004 if (thrownException != null) { 4800 if (thrownException != null) {
5005 throw new AnalysisException('<rethrow>', thrownException); 4801 throw new AnalysisException('<rethrow>', thrownException);
5006 } 4802 }
5007 return htmlEntry; 4803 return htmlEntry;
5008 } 4804 }
5009 4805
5010 /** 4806 /**
5011 * Record the results produced by performing a [ScanDartTask]. If the results were computed 4807 * Record the results produced by performing a [ScanDartTask]. If the results were computed
5012 * from data that is now out-of-date, then the results will not be recorded. 4808 * from data that is now out-of-date, then the results will not be recorded.
5013 * 4809 *
5014 * @param task the task that was performed 4810 * @param task the task that was performed
5015 * @return an entry containing the computed results 4811 * @return an entry containing the computed results
5016 * @throws AnalysisException if the results could not be recorded 4812 * @throws AnalysisException if the results could not be recorded
5017 */ 4813 */
5018 DartEntry _recordScanDartTaskResults(ScanDartTask task) { 4814 DartEntry _recordScanDartTaskResults(ScanDartTask task) {
5019 Source source = task.source; 4815 Source source = task.source;
5020 CaughtException thrownException = task.exception; 4816 CaughtException thrownException = task.exception;
5021 DartEntry dartEntry = null; 4817 DartEntryImpl dartEntry = null;
5022 SourceEntry sourceEntry = _cache.get(source); 4818 SourceEntry sourceEntry = _cache.get(source);
5023 if (sourceEntry == null) { 4819 if (sourceEntry == null) {
5024 throw new ObsoleteSourceAnalysisException(source); 4820 throw new ObsoleteSourceAnalysisException(source);
5025 } else if (sourceEntry is! DartEntry) { 4821 } else if (sourceEntry is! DartEntry) {
5026 // This shouldn't be possible because we should never have performed the t ask if the source 4822 // This shouldn't be possible because we should never have performed the t ask if the source
5027 // didn't represent a Dart file, but check to be safe. 4823 // didn't represent a Dart file, but check to be safe.
5028 throw new AnalysisException("Internal error: attempting to parse non-Dart file as a Dart file: ${source.fullName}"); 4824 throw new AnalysisException("Internal error: attempting to parse non-Dart file as a Dart file: ${source.fullName}");
5029 } 4825 }
5030 dartEntry = sourceEntry as DartEntry; 4826 dartEntry = sourceEntry as DartEntry;
5031 int sourceTime = getModificationStamp(source); 4827 int sourceTime = getModificationStamp(source);
5032 int resultTime = task.modificationTime; 4828 int resultTime = task.modificationTime;
5033 if (sourceTime == resultTime) { 4829 if (sourceTime == resultTime) {
5034 if (dartEntry.modificationTime != sourceTime) { 4830 if (dartEntry.modificationTime != sourceTime) {
5035 // The source has changed without the context being notified. Simulate n otification. 4831 // The source has changed without the context being notified. Simulate n otification.
5036 _sourceChanged(source); 4832 _sourceChanged(source);
5037 dartEntry = _getReadableDartEntry(source); 4833 dartEntry = _getReadableDartEntry(source);
5038 if (dartEntry == null) { 4834 if (dartEntry == null) {
5039 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}"); 4835 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}");
5040 } 4836 }
5041 } 4837 }
5042 DartEntryImpl dartCopy = dartEntry.writableCopy;
5043 if (thrownException == null) { 4838 if (thrownException == null) {
5044 LineInfo lineInfo = task.lineInfo; 4839 LineInfo lineInfo = task.lineInfo;
5045 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); 4840 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo);
5046 dartCopy.setValue(DartEntry.TOKEN_STREAM, task.tokenStream); 4841 dartEntry.setValue(DartEntry.TOKEN_STREAM, task.tokenStream);
5047 dartCopy.setValue(DartEntry.SCAN_ERRORS, task.errors); 4842 dartEntry.setValue(DartEntry.SCAN_ERRORS, task.errors);
5048 _cache.storedAst(source); 4843 _cache.storedAst(source);
5049 ChangeNoticeImpl notice = _getNotice(source); 4844 ChangeNoticeImpl notice = _getNotice(source);
5050 notice.setErrors(dartEntry.allErrors, lineInfo); 4845 notice.setErrors(dartEntry.allErrors, lineInfo);
5051 } else { 4846 } else {
5052 _removeFromParts(source, dartEntry); 4847 _removeFromParts(source, dartEntry);
5053 dartCopy.recordScanError(thrownException); 4848 dartEntry.recordScanError(thrownException);
5054 _cache.removedAst(source); 4849 _cache.removedAst(source);
5055 } 4850 }
5056 _cache.put(source, dartCopy);
5057 dartEntry = dartCopy;
5058 } else { 4851 } else {
5059 _logInformation2("Scan results discarded for ${_debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry. modificationTime}", thrownException); 4852 _logInformation2("Scan results discarded for ${_debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry. modificationTime}", thrownException);
5060 DartEntryImpl dartCopy = dartEntry.writableCopy;
5061 if (thrownException == null || resultTime >= 0) { 4853 if (thrownException == null || resultTime >= 0) {
5062 // 4854 //
5063 // The analysis was performed on out-of-date sources. Mark the cache so that the sources 4855 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
5064 // will be re-analyzed using the up-to-date sources. 4856 // will be re-analyzed using the up-to-date sources.
5065 // 4857 //
5066 // dartCopy.recordScanNotInProcess(); 4858 // dartCopy.recordScanNotInProcess();
5067 _removeFromParts(source, dartEntry); 4859 _removeFromParts(source, dartEntry);
5068 dartCopy.invalidateAllInformation(); 4860 dartEntry.invalidateAllInformation();
5069 dartCopy.modificationTime = sourceTime; 4861 dartEntry.modificationTime = sourceTime;
5070 _cache.removedAst(source); 4862 _cache.removedAst(source);
5071 _workManager.add(source, SourcePriority.UNKNOWN); 4863 _workManager.add(source, SourcePriority.UNKNOWN);
5072 } else { 4864 } else {
5073 // 4865 //
5074 // We could not determine whether the sources were up-to-date or out-of- date. Mark the 4866 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
5075 // cache so that we won't attempt to re-analyze the sources until there' s a good chance 4867 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
5076 // that we'll be able to do so without error. 4868 // that we'll be able to do so without error.
5077 // 4869 //
5078 dartCopy.recordScanError(thrownException); 4870 dartEntry.recordScanError(thrownException);
5079 } 4871 }
5080 _cache.put(source, dartCopy);
5081 dartEntry = dartCopy;
5082 } 4872 }
5083 if (thrownException != null) { 4873 if (thrownException != null) {
5084 throw new AnalysisException('<rethrow>', thrownException); 4874 throw new AnalysisException('<rethrow>', thrownException);
5085 } 4875 }
5086 return dartEntry; 4876 return dartEntry;
5087 } 4877 }
5088 4878
5089 /** 4879 /**
5090 * Remove the given library from the list of containing libraries for all of t he parts referenced 4880 * Remove the given library from the list of containing libraries for all of t he parts referenced
5091 * by the given entry. 4881 * by the given entry.
5092 * 4882 *
5093 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4883 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
5094 * 4884 *
5095 * @param librarySource the library to be removed 4885 * @param librarySource the library to be removed
5096 * @param dartEntry the entry containing the list of included parts 4886 * @param dartEntry the entry containing the list of included parts
5097 */ 4887 */
5098 void _removeFromParts(Source librarySource, DartEntry dartEntry) { 4888 void _removeFromParts(Source librarySource, DartEntry dartEntry) {
5099 List<Source> oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS); 4889 List<Source> oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS);
5100 for (int i = 0; i < oldParts.length; i++) { 4890 for (int i = 0; i < oldParts.length; i++) {
5101 Source partSource = oldParts[i]; 4891 Source partSource = oldParts[i];
5102 DartEntry partEntry = _getReadableDartEntry(partSource); 4892 DartEntryImpl partEntry = _getReadableDartEntry(partSource);
5103 if (partEntry != null && !identical(partEntry, dartEntry)) { 4893 if (partEntry != null && !identical(partEntry, dartEntry)) {
5104 DartEntryImpl partCopy = partEntry.writableCopy; 4894 partEntry.removeContainingLibrary(librarySource);
5105 partCopy.removeContainingLibrary(librarySource); 4895 if (partEntry.containingLibraries.length == 0 && !exists(partSource)) {
5106 if (partCopy.containingLibraries.length == 0 && !exists(partSource)) {
5107 _cache.remove(partSource); 4896 _cache.remove(partSource);
5108 } else {
5109 _cache.put(partSource, partCopy);
5110 } 4897 }
5111 } 4898 }
5112 } 4899 }
5113 } 4900 }
5114 4901
5115 /** 4902 /**
5116 * Remove the given libraries that are keys in the given map from the list of containing libraries 4903 * Remove the given libraries that are keys in the given map from the list of containing libraries
5117 * for each of the parts in the corresponding value. 4904 * for each of the parts in the corresponding value.
5118 * 4905 *
5119 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4906 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
5120 * 4907 *
5121 * @param oldPartMap the table containing the parts associated with each libra ry 4908 * @param oldPartMap the table containing the parts associated with each libra ry
5122 */ 4909 */
5123 void _removeFromPartsUsingMap(HashMap<Source, List<Source>> oldPartMap) { 4910 void _removeFromPartsUsingMap(HashMap<Source, List<Source>> oldPartMap) {
5124 for (MapEntry<Source, List<Source>> entry in getMapEntrySet(oldPartMap)) { 4911 for (MapEntry<Source, List<Source>> entry in getMapEntrySet(oldPartMap)) {
5125 Source librarySource = entry.getKey(); 4912 Source librarySource = entry.getKey();
5126 List<Source> oldParts = entry.getValue(); 4913 List<Source> oldParts = entry.getValue();
5127 for (int i = 0; i < oldParts.length; i++) { 4914 for (int i = 0; i < oldParts.length; i++) {
5128 Source partSource = oldParts[i]; 4915 Source partSource = oldParts[i];
5129 if (partSource != librarySource) { 4916 if (partSource != librarySource) {
5130 DartEntry partEntry = _getReadableDartEntry(partSource); 4917 DartEntryImpl partEntry = _getReadableDartEntry(partSource);
5131 if (partEntry != null) { 4918 if (partEntry != null) {
5132 DartEntryImpl partCopy = partEntry.writableCopy; 4919 partEntry.removeContainingLibrary(librarySource);
5133 partCopy.removeContainingLibrary(librarySource); 4920 if (partEntry.containingLibraries.length == 0 && !exists(partSource) ) {
5134 if (partCopy.containingLibraries.length == 0 && !exists(partSource)) {
5135 _cache.remove(partSource); 4921 _cache.remove(partSource);
5136 } else {
5137 _cache.put(partSource, partCopy);
5138 } 4922 }
5139 } 4923 }
5140 } 4924 }
5141 } 4925 }
5142 } 4926 }
5143 } 4927 }
5144 4928
5145 /** 4929 /**
5146 * Remove the given source from the priority order if it is in the list. 4930 * Remove the given source from the priority order if it is in the list.
5147 * 4931 *
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
5191 * @param source the source that has been changed 4975 * @param source the source that has been changed
5192 */ 4976 */
5193 void _sourceChanged(Source source) { 4977 void _sourceChanged(Source source) {
5194 SourceEntry sourceEntry = _cache.get(source); 4978 SourceEntry sourceEntry = _cache.get(source);
5195 if (sourceEntry == null || sourceEntry.modificationTime == getModificationSt amp(source)) { 4979 if (sourceEntry == null || sourceEntry.modificationTime == getModificationSt amp(source)) {
5196 // Either we have removed this source, in which case we don't care that it is changed, or we 4980 // Either we have removed this source, in which case we don't care that it is changed, or we
5197 // have already invalidated the cache and don't need to invalidate it agai n. 4981 // have already invalidated the cache and don't need to invalidate it agai n.
5198 return; 4982 return;
5199 } 4983 }
5200 if (sourceEntry is HtmlEntry) { 4984 if (sourceEntry is HtmlEntry) {
5201 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; 4985 HtmlEntryImpl htmlEntry = sourceEntry;
5202 htmlCopy.modificationTime = getModificationStamp(source); 4986 htmlEntry.modificationTime = getModificationStamp(source);
5203 _invalidateAngularResolution(htmlCopy); 4987 _invalidateAngularResolution(htmlEntry);
5204 htmlCopy.invalidateAllInformation(); 4988 htmlEntry.invalidateAllInformation();
5205 _cache.put(source, htmlCopy);
5206 _cache.removedAst(source); 4989 _cache.removedAst(source);
5207 _workManager.add(source, SourcePriority.HTML); 4990 _workManager.add(source, SourcePriority.HTML);
5208 } else if (sourceEntry is DartEntry) { 4991 } else if (sourceEntry is DartEntry) {
5209 List<Source> containingLibraries = getLibrariesContaining(source); 4992 List<Source> containingLibraries = getLibrariesContaining(source);
5210 HashSet<Source> librariesToInvalidate = new HashSet<Source>(); 4993 HashSet<Source> librariesToInvalidate = new HashSet<Source>();
5211 for (Source containingLibrary in containingLibraries) { 4994 for (Source containingLibrary in containingLibraries) {
5212 _computeAllLibrariesDependingOn(containingLibrary, librariesToInvalidate ); 4995 _computeAllLibrariesDependingOn(containingLibrary, librariesToInvalidate );
5213 } 4996 }
5214 for (Source library in librariesToInvalidate) { 4997 for (Source library in librariesToInvalidate) {
5215 _invalidateLibraryResolution(library); 4998 _invalidateLibraryResolution(library);
5216 } 4999 }
5217 _removeFromParts(source, _cache.get(source) as DartEntry); 5000 DartEntryImpl dartEntry = _cache.get(source);
5218 DartEntryImpl dartCopy = (_cache.get(source) as DartEntry).writableCopy; 5001 _removeFromParts(source, dartEntry);
5219 dartCopy.modificationTime = getModificationStamp(source); 5002 dartEntry.modificationTime = getModificationStamp(source);
5220 dartCopy.invalidateAllInformation(); 5003 dartEntry.invalidateAllInformation();
5221 _cache.put(source, dartCopy);
5222 _cache.removedAst(source); 5004 _cache.removedAst(source);
5223 _workManager.add(source, SourcePriority.UNKNOWN); 5005 _workManager.add(source, SourcePriority.UNKNOWN);
5224 } 5006 }
5225 } 5007 }
5226 5008
5227 /** 5009 /**
5228 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 5010 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
5229 * 5011 *
5230 * @param source the source that has been deleted 5012 * @param source the source that has been deleted
5231 */ 5013 */
5232 void _sourceDeleted(Source source) { 5014 void _sourceDeleted(Source source) {
5233 SourceEntry sourceEntry = _cache.get(source); 5015 SourceEntry sourceEntry = _cache.get(source);
5234 if (sourceEntry is HtmlEntry) { 5016 if (sourceEntry is HtmlEntry) {
5235 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; 5017 HtmlEntryImpl htmlEntry = sourceEntry;
5236 _invalidateAngularResolution(htmlCopy); 5018 _invalidateAngularResolution(htmlEntry);
5237 htmlCopy.recordContentError(new CaughtException(new AnalysisException("Thi s source was marked as being deleted"), null)); 5019 htmlEntry.recordContentError(new CaughtException(new AnalysisException("Th is source was marked as being deleted"), null));
5238 _cache.put(source, htmlCopy);
5239 } else if (sourceEntry is DartEntry) { 5020 } else if (sourceEntry is DartEntry) {
5021 DartEntryImpl dartEntry = sourceEntry;
5240 HashSet<Source> libraries = new HashSet<Source>(); 5022 HashSet<Source> libraries = new HashSet<Source>();
5241 for (Source librarySource in getLibrariesContaining(source)) { 5023 for (Source librarySource in getLibrariesContaining(source)) {
5242 libraries.add(librarySource); 5024 libraries.add(librarySource);
5243 for (Source dependentLibrary in getLibrariesDependingOn(librarySource)) { 5025 for (Source dependentLibrary in getLibrariesDependingOn(librarySource)) {
5244 libraries.add(dependentLibrary); 5026 libraries.add(dependentLibrary);
5245 } 5027 }
5246 } 5028 }
5247 for (Source librarySource in libraries) { 5029 for (Source librarySource in libraries) {
5248 _invalidateLibraryResolution(librarySource); 5030 _invalidateLibraryResolution(librarySource);
5249 } 5031 }
5250 DartEntryImpl dartCopy = sourceEntry.writableCopy; 5032 dartEntry.recordContentError(new CaughtException(new AnalysisException("Th is source was marked as being deleted"), null));
5251 dartCopy.recordContentError(new CaughtException(new AnalysisException("Thi s source was marked as being deleted"), null));
5252 _cache.put(source, dartCopy);
5253 } 5033 }
5254 _workManager.remove(source); 5034 _workManager.remove(source);
5255 _removeFromPriorityOrder(source); 5035 _removeFromPriorityOrder(source);
5256 } 5036 }
5257 5037
5258 /** 5038 /**
5259 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 5039 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
5260 * 5040 *
5261 * @param source the source that has been removed 5041 * @param source the source that has been removed
5262 */ 5042 */
5263 void _sourceRemoved(Source source) { 5043 void _sourceRemoved(Source source) {
5264 SourceEntry sourceEntry = _cache.get(source); 5044 SourceEntry sourceEntry = _cache.get(source);
5265 if (sourceEntry is HtmlEntry) { 5045 if (sourceEntry is HtmlEntry) {
5266 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; 5046 _invalidateAngularResolution(sourceEntry);
5267 _invalidateAngularResolution(htmlCopy);
5268 } else if (sourceEntry is DartEntry) { 5047 } else if (sourceEntry is DartEntry) {
5269 HashSet<Source> libraries = new HashSet<Source>(); 5048 HashSet<Source> libraries = new HashSet<Source>();
5270 for (Source librarySource in getLibrariesContaining(source)) { 5049 for (Source librarySource in getLibrariesContaining(source)) {
5271 libraries.add(librarySource); 5050 libraries.add(librarySource);
5272 for (Source dependentLibrary in getLibrariesDependingOn(librarySource)) { 5051 for (Source dependentLibrary in getLibrariesDependingOn(librarySource)) {
5273 libraries.add(dependentLibrary); 5052 libraries.add(dependentLibrary);
5274 } 5053 }
5275 } 5054 }
5276 for (Source librarySource in libraries) { 5055 for (Source librarySource in libraries) {
5277 _invalidateLibraryResolution(librarySource); 5056 _invalidateLibraryResolution(librarySource);
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
5663 * for all of the compilation units in the library 5442 * for all of the compilation units in the library
5664 */ 5443 */
5665 void _computePartsInLibrary(CycleBuilder_LibraryPair libraryPair) { 5444 void _computePartsInLibrary(CycleBuilder_LibraryPair libraryPair) {
5666 ResolvableLibrary library = libraryPair.library; 5445 ResolvableLibrary library = libraryPair.library;
5667 List<CycleBuilder_SourceEntryPair> entryPairs = libraryPair.entryPairs; 5446 List<CycleBuilder_SourceEntryPair> entryPairs = libraryPair.entryPairs;
5668 int count = entryPairs.length; 5447 int count = entryPairs.length;
5669 List<ResolvableCompilationUnit> units = new List<ResolvableCompilationUnit>( count); 5448 List<ResolvableCompilationUnit> units = new List<ResolvableCompilationUnit>( count);
5670 for (int i = 0; i < count; i++) { 5449 for (int i = 0; i < count; i++) {
5671 CycleBuilder_SourceEntryPair entryPair = entryPairs[i]; 5450 CycleBuilder_SourceEntryPair entryPair = entryPairs[i];
5672 Source source = entryPair.source; 5451 Source source = entryPair.source;
5673 DartEntryImpl dartCopy = entryPair.entry.writableCopy; 5452 DartEntryImpl dartEntry = entryPair.entry;
5674 units[i] = new ResolvableCompilationUnit.con2(dartCopy.modificationTime, d artCopy.resolvableCompilationUnit, source); 5453 units[i] = new ResolvableCompilationUnit.con2(dartEntry.modificationTime, dartEntry.resolvableCompilationUnit, source);
5675 AnalysisContextImpl_this._cache.put(source, dartCopy);
5676 } 5454 }
5677 library.resolvableCompilationUnits = units; 5455 library.resolvableCompilationUnits = units;
5678 } 5456 }
5679 5457
5680 /** 5458 /**
5681 * Create an object to represent the information about the library defined by the compilation 5459 * Create an object to represent the information about the library defined by the compilation
5682 * unit with the given source. 5460 * unit with the given source.
5683 * 5461 *
5684 * @param librarySource the source of the library's defining compilation unit 5462 * @param librarySource the source of the library's defining compilation unit
5685 * @return the library object that was created 5463 * @return the library object that was created
(...skipping 2435 matching lines...) Expand 10 before | Expand all | Expand 10 after
8121 * 7899 *
8122 * @return `true` if a structure was flushed 7900 * @return `true` if a structure was flushed
8123 */ 7901 */
8124 bool _flushAstFromCache() { 7902 bool _flushAstFromCache() {
8125 Source removedSource = _removeAstToFlush(); 7903 Source removedSource = _removeAstToFlush();
8126 if (removedSource == null) { 7904 if (removedSource == null) {
8127 return false; 7905 return false;
8128 } 7906 }
8129 SourceEntry sourceEntry = _sourceMap[removedSource]; 7907 SourceEntry sourceEntry = _sourceMap[removedSource];
8130 if (sourceEntry is HtmlEntry) { 7908 if (sourceEntry is HtmlEntry) {
8131 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; 7909 HtmlEntryImpl htmlEntry = sourceEntry;
8132 htmlCopy.flushAstStructures(); 7910 htmlEntry.flushAstStructures();
8133 _sourceMap[removedSource] = htmlCopy;
8134 } else if (sourceEntry is DartEntry) { 7911 } else if (sourceEntry is DartEntry) {
8135 DartEntryImpl dartCopy = sourceEntry.writableCopy; 7912 DartEntryImpl dartEntry = sourceEntry;
8136 dartCopy.flushAstStructures(); 7913 dartEntry.flushAstStructures();
8137 _sourceMap[removedSource] = dartCopy;
8138 } 7914 }
8139 return true; 7915 return true;
8140 } 7916 }
8141 7917
8142 /** 7918 /**
8143 * Remove and return one source from the list of recently used sources whose A ST structure can be 7919 * Remove and return one source from the list of recently used sources whose A ST structure can be
8144 * flushed from the cache. The source that will be returned will be the source that has been 7920 * flushed from the cache. The source that will be returned will be the source that has been
8145 * unreferenced for the longest period of time but that is not a priority for analysis. 7921 * unreferenced for the longest period of time but that is not a priority for analysis.
8146 * 7922 *
8147 * @return the source that was removed 7923 * @return the source that was removed
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
8789 * Return the value of the data represented by the given descriptor in the con text of the given 8565 * Return the value of the data represented by the given descriptor in the con text of the given
8790 * library, or `null` if the data represented by the descriptor is not in the cache. 8566 * library, or `null` if the data represented by the descriptor is not in the cache.
8791 * 8567 *
8792 * @param descriptor the descriptor representing which data is to be returned 8568 * @param descriptor the descriptor representing which data is to be returned
8793 * @param librarySource the source of the defining compilation unit of the lib rary that is the 8569 * @param librarySource the source of the defining compilation unit of the lib rary that is the
8794 * context for the data 8570 * context for the data
8795 * @return the value of the data represented by the given descriptor and libra ry 8571 * @return the value of the data represented by the given descriptor and libra ry
8796 */ 8572 */
8797 Object getValueInLibrary(DataDescriptor descriptor, Source librarySource); 8573 Object getValueInLibrary(DataDescriptor descriptor, Source librarySource);
8798 8574
8799 @override
8800 DartEntryImpl get writableCopy;
8801
8802 /** 8575 /**
8803 * Return `true` if the data represented by the given descriptor is marked as being invalid. 8576 * Return `true` if the data represented by the given descriptor is marked as being invalid.
8804 * If the descriptor represents library-specific data then this method will re turn `true` if 8577 * If the descriptor represents library-specific data then this method will re turn `true` if
8805 * the data associated with any library it marked as invalid. 8578 * the data associated with any library it marked as invalid.
8806 * 8579 *
8807 * @param descriptor the descriptor representing which data is being tested 8580 * @param descriptor the descriptor representing which data is being tested
8808 * @return `true` if the data is marked as being invalid 8581 * @return `true` if the data is marked as being invalid
8809 */ 8582 */
8810 bool hasInvalidData(DataDescriptor descriptor); 8583 bool hasInvalidData(DataDescriptor descriptor);
8811 8584
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
9231 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript or, DartEntry.VERIFICATION_ERRORS) || identical(descriptor, DartEntry.HINTS)) { 9004 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript or, DartEntry.VERIFICATION_ERRORS) || identical(descriptor, DartEntry.HINTS)) {
9232 return AnalysisError.NO_ERRORS; 9005 return AnalysisError.NO_ERRORS;
9233 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 9006 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
9234 return null; 9007 return null;
9235 } else { 9008 } else {
9236 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 9009 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
9237 } 9010 }
9238 } 9011 }
9239 9012
9240 @override 9013 @override
9241 DartEntryImpl get writableCopy {
9242 DartEntryImpl copy = new DartEntryImpl();
9243 copy.copyFrom(this);
9244 return copy;
9245 }
9246
9247 @override
9248 bool hasInvalidData(DataDescriptor descriptor) { 9014 bool hasInvalidData(DataDescriptor descriptor) {
9249 if (identical(descriptor, DartEntry.ELEMENT)) { 9015 if (identical(descriptor, DartEntry.ELEMENT)) {
9250 return _elementState == CacheState.INVALID; 9016 return _elementState == CacheState.INVALID;
9251 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { 9017 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) {
9252 return _exportedLibrariesState == CacheState.INVALID; 9018 return _exportedLibrariesState == CacheState.INVALID;
9253 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { 9019 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) {
9254 return _importedLibrariesState == CacheState.INVALID; 9020 return _importedLibrariesState == CacheState.INVALID;
9255 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { 9021 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) {
9256 return _includedPartsState == CacheState.INVALID; 9022 return _includedPartsState == CacheState.INVALID;
9257 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { 9023 } else if (identical(descriptor, DartEntry.IS_CLIENT)) {
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
9810 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 9576 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
9811 state._verificationErrors = value == null ? AnalysisError.NO_ERRORS : (val ue as List<AnalysisError>); 9577 state._verificationErrors = value == null ? AnalysisError.NO_ERRORS : (val ue as List<AnalysisError>);
9812 state._verificationErrorsState = CacheState.VALID; 9578 state._verificationErrorsState = CacheState.VALID;
9813 } else if (identical(descriptor, DartEntry.HINTS)) { 9579 } else if (identical(descriptor, DartEntry.HINTS)) {
9814 state._hints = value == null ? AnalysisError.NO_ERRORS : (value as List<An alysisError>); 9580 state._hints = value == null ? AnalysisError.NO_ERRORS : (value as List<An alysisError>);
9815 state._hintsState = CacheState.VALID; 9581 state._hintsState = CacheState.VALID;
9816 } 9582 }
9817 } 9583 }
9818 9584
9819 @override 9585 @override
9820 void copyFrom(SourceEntryImpl entry) {
9821 super.copyFrom(entry);
9822 DartEntryImpl other = entry as DartEntryImpl;
9823 _scanErrorsState = other._scanErrorsState;
9824 _scanErrors = other._scanErrors;
9825 _tokenStreamState = other._tokenStreamState;
9826 _tokenStream = other._tokenStream;
9827 _sourceKindState = other._sourceKindState;
9828 _sourceKind = other._sourceKind;
9829 _parsedUnitState = other._parsedUnitState;
9830 _parsedUnit = other._parsedUnit;
9831 _parsedUnitAccessed = other._parsedUnitAccessed;
9832 _parseErrorsState = other._parseErrorsState;
9833 _parseErrors = other._parseErrors;
9834 _includedPartsState = other._includedPartsState;
9835 _includedParts = other._includedParts;
9836 _exportedLibrariesState = other._exportedLibrariesState;
9837 _exportedLibraries = other._exportedLibraries;
9838 _importedLibrariesState = other._importedLibrariesState;
9839 _importedLibraries = other._importedLibraries;
9840 _containingLibraries = new List<Source>.from(other._containingLibraries);
9841 _resolutionState.copyFrom(other._resolutionState);
9842 _elementState = other._elementState;
9843 _element = other._element;
9844 _publicNamespaceState = other._publicNamespaceState;
9845 _publicNamespace = other._publicNamespace;
9846 _clientServerState = other._clientServerState;
9847 _launchableState = other._launchableState;
9848 _angularErrors = other._angularErrors;
9849 }
9850
9851 @override
9852 bool get hasErrorState => super.hasErrorState || _scanErrorsState == CacheStat e.ERROR || _tokenStreamState == CacheState.ERROR || _sourceKindState == CacheSta te.ERROR || _parsedUnitState == CacheState.ERROR || _parseErrorsState == CacheSt ate.ERROR || _importedLibrariesState == CacheState.ERROR || _exportedLibrariesSt ate == CacheState.ERROR || _includedPartsState == CacheState.ERROR || _elementSt ate == CacheState.ERROR || _publicNamespaceState == CacheState.ERROR || _clientS erverState == CacheState.ERROR || _launchableState == CacheState.ERROR || _resol utionState.hasErrorState; 9586 bool get hasErrorState => super.hasErrorState || _scanErrorsState == CacheStat e.ERROR || _tokenStreamState == CacheState.ERROR || _sourceKindState == CacheSta te.ERROR || _parsedUnitState == CacheState.ERROR || _parseErrorsState == CacheSt ate.ERROR || _importedLibrariesState == CacheState.ERROR || _exportedLibrariesSt ate == CacheState.ERROR || _includedPartsState == CacheState.ERROR || _elementSt ate == CacheState.ERROR || _publicNamespaceState == CacheState.ERROR || _clientS erverState == CacheState.ERROR || _launchableState == CacheState.ERROR || _resol utionState.hasErrorState;
9853 9587
9854 @override 9588 @override
9855 bool writeDiffOn(JavaStringBuilder builder, SourceEntry oldEntry) { 9589 bool writeDiffOn(JavaStringBuilder builder, SourceEntry oldEntry) {
9856 bool needsSeparator = super.writeDiffOn(builder, oldEntry); 9590 bool needsSeparator = super.writeDiffOn(builder, oldEntry);
9857 if (oldEntry is! DartEntryImpl) { 9591 if (oldEntry is! DartEntryImpl) {
9858 if (needsSeparator) { 9592 if (needsSeparator) {
9859 builder.append("; "); 9593 builder.append("; ");
9860 } 9594 }
9861 builder.append("entry type changed; was ${oldEntry.runtimeType.toString()} "); 9595 builder.append("entry type changed; was ${oldEntry.runtimeType.toString()} ");
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
10108 */ 9842 */
10109 CacheState _hintsState = CacheState.INVALID; 9843 CacheState _hintsState = CacheState.INVALID;
10110 9844
10111 /** 9845 /**
10112 * The hints produced while auditing the compilation unit, or an empty array i f the hints are 9846 * The hints produced while auditing the compilation unit, or an empty array i f the hints are
10113 * not currently cached. 9847 * not currently cached.
10114 */ 9848 */
10115 List<AnalysisError> _hints = AnalysisError.NO_ERRORS; 9849 List<AnalysisError> _hints = AnalysisError.NO_ERRORS;
10116 9850
10117 /** 9851 /**
10118 * Set this state to be exactly like the given state, recursively copying the next state as
10119 * necessary.
10120 *
10121 * @param other the state to be copied
10122 */
10123 void copyFrom(DartEntryImpl_ResolutionState other) {
10124 _librarySource = other._librarySource;
10125 _builtUnitState = other._builtUnitState;
10126 _builtUnit = other._builtUnit;
10127 _buildElementErrorsState = other._buildElementErrorsState;
10128 _buildElementErrors = other._buildElementErrors;
10129 _resolvedUnitState = other._resolvedUnitState;
10130 _resolvedUnit = other._resolvedUnit;
10131 _resolutionErrorsState = other._resolutionErrorsState;
10132 _resolutionErrors = other._resolutionErrors;
10133 _verificationErrorsState = other._verificationErrorsState;
10134 _verificationErrors = other._verificationErrors;
10135 _hintsState = other._hintsState;
10136 _hints = other._hints;
10137 if (other._nextState != null) {
10138 _nextState = new DartEntryImpl_ResolutionState();
10139 _nextState.copyFrom(other._nextState);
10140 }
10141 }
10142
10143 /**
10144 * Flush any AST structures being maintained by this state. 9852 * Flush any AST structures being maintained by this state.
10145 */ 9853 */
10146 void flushAstStructures() { 9854 void flushAstStructures() {
10147 if (_builtUnitState == CacheState.VALID) { 9855 if (_builtUnitState == CacheState.VALID) {
10148 _builtUnitState = CacheState.FLUSHED; 9856 _builtUnitState = CacheState.FLUSHED;
10149 _builtUnit = null; 9857 _builtUnit = null;
10150 } 9858 }
10151 if (_resolvedUnitState == CacheState.VALID) { 9859 if (_resolvedUnitState == CacheState.VALID) {
10152 _resolvedUnitState = CacheState.FLUSHED; 9860 _resolvedUnitState = CacheState.FLUSHED;
10153 _resolvedUnit = null; 9861 _resolvedUnit = null;
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
10801 */ 10509 */
10802 List<AnalysisError> get allErrors; 10510 List<AnalysisError> get allErrors;
10803 10511
10804 /** 10512 /**
10805 * Return a valid parsed unit, either an unresolved AST structure or the resul t of resolving the 10513 * Return a valid parsed unit, either an unresolved AST structure or the resul t of resolving the
10806 * AST structure, or `null` if there is no parsed unit available. 10514 * AST structure, or `null` if there is no parsed unit available.
10807 * 10515 *
10808 * @return a valid parsed unit 10516 * @return a valid parsed unit
10809 */ 10517 */
10810 ht.HtmlUnit get anyParsedUnit; 10518 ht.HtmlUnit get anyParsedUnit;
10811
10812 @override
10813 HtmlEntryImpl get writableCopy;
10814 } 10519 }
10815 10520
10816 /** 10521 /**
10817 * Instances of the class `HtmlEntryImpl` implement an [HtmlEntry]. 10522 * Instances of the class `HtmlEntryImpl` implement an [HtmlEntry].
10818 */ 10523 */
10819 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry { 10524 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry {
10820 /** 10525 /**
10821 * The state of the cached parsed (but not resolved) HTML unit. 10526 * The state of the cached parsed (but not resolved) HTML unit.
10822 */ 10527 */
10823 CacheState _parsedUnitState = CacheState.INVALID; 10528 CacheState _parsedUnitState = CacheState.INVALID;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
11087 return _hints; 10792 return _hints;
11088 } else if (identical(descriptor, HtmlEntry.POLYMER_BUILD_ERRORS)) { 10793 } else if (identical(descriptor, HtmlEntry.POLYMER_BUILD_ERRORS)) {
11089 return _polymerBuildErrors; 10794 return _polymerBuildErrors;
11090 } else if (identical(descriptor, HtmlEntry.POLYMER_RESOLUTION_ERRORS)) { 10795 } else if (identical(descriptor, HtmlEntry.POLYMER_RESOLUTION_ERRORS)) {
11091 return _polymerResolutionErrors; 10796 return _polymerResolutionErrors;
11092 } 10797 }
11093 return super.getValue(descriptor); 10798 return super.getValue(descriptor);
11094 } 10799 }
11095 10800
11096 @override 10801 @override
11097 HtmlEntryImpl get writableCopy {
11098 HtmlEntryImpl copy = new HtmlEntryImpl();
11099 copy.copyFrom(this);
11100 return copy;
11101 }
11102
11103 @override
11104 void invalidateAllInformation() { 10802 void invalidateAllInformation() {
11105 super.invalidateAllInformation(); 10803 super.invalidateAllInformation();
11106 _parseErrors = AnalysisError.NO_ERRORS; 10804 _parseErrors = AnalysisError.NO_ERRORS;
11107 _parseErrorsState = CacheState.INVALID; 10805 _parseErrorsState = CacheState.INVALID;
11108 _parsedUnit = null; 10806 _parsedUnit = null;
11109 _parsedUnitState = CacheState.INVALID; 10807 _parsedUnitState = CacheState.INVALID;
11110 _resolvedUnit = null; 10808 _resolvedUnit = null;
11111 _resolvedUnitState = CacheState.INVALID; 10809 _resolvedUnitState = CacheState.INVALID;
11112 invalidateAllResolutionInformation(true); 10810 invalidateAllResolutionInformation(true);
11113 } 10811 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
11273 _polymerBuildErrorsState = CacheState.VALID; 10971 _polymerBuildErrorsState = CacheState.VALID;
11274 } else if (identical(descriptor, HtmlEntry.POLYMER_RESOLUTION_ERRORS)) { 10972 } else if (identical(descriptor, HtmlEntry.POLYMER_RESOLUTION_ERRORS)) {
11275 _polymerResolutionErrors = value as List<AnalysisError>; 10973 _polymerResolutionErrors = value as List<AnalysisError>;
11276 _polymerResolutionErrorsState = CacheState.VALID; 10974 _polymerResolutionErrorsState = CacheState.VALID;
11277 } else { 10975 } else {
11278 super.setValue(descriptor, value); 10976 super.setValue(descriptor, value);
11279 } 10977 }
11280 } 10978 }
11281 10979
11282 @override 10980 @override
11283 void copyFrom(SourceEntryImpl entry) {
11284 super.copyFrom(entry);
11285 HtmlEntryImpl other = entry as HtmlEntryImpl;
11286 _angularApplicationState = other._angularApplicationState;
11287 _angularApplication = other._angularApplication;
11288 _angularComponentState = other._angularComponentState;
11289 _angularComponent = other._angularComponent;
11290 _angularEntryState = other._angularEntryState;
11291 _angularEntry = other._angularEntry;
11292 _angularErrorsState = other._angularErrorsState;
11293 _angularErrors = other._angularErrors;
11294 _parseErrorsState = other._parseErrorsState;
11295 _parseErrors = other._parseErrors;
11296 _parsedUnitState = other._parsedUnitState;
11297 _parsedUnit = other._parsedUnit;
11298 _resolvedUnitState = other._resolvedUnitState;
11299 _resolvedUnit = other._resolvedUnit;
11300 _referencedLibrariesState = other._referencedLibrariesState;
11301 _referencedLibraries = other._referencedLibraries;
11302 _resolutionErrorsState = other._resolutionErrorsState;
11303 _resolutionErrors = other._resolutionErrors;
11304 _elementState = other._elementState;
11305 _element = other._element;
11306 _hintsState = other._hintsState;
11307 _hints = other._hints;
11308 _polymerBuildErrorsState = other._polymerBuildErrorsState;
11309 _polymerBuildErrors = other._polymerBuildErrors;
11310 _polymerResolutionErrorsState = other._polymerResolutionErrorsState;
11311 _polymerResolutionErrors = other._polymerResolutionErrors;
11312 }
11313
11314 @override
11315 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; 10981 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;
11316 10982
11317 @override 10983 @override
11318 bool writeDiffOn(JavaStringBuilder builder, SourceEntry oldEntry) { 10984 bool writeDiffOn(JavaStringBuilder builder, SourceEntry oldEntry) {
11319 bool needsSeparator = super.writeDiffOn(builder, oldEntry); 10985 bool needsSeparator = super.writeDiffOn(builder, oldEntry);
11320 if (oldEntry is! HtmlEntryImpl) { 10986 if (oldEntry is! HtmlEntryImpl) {
11321 if (needsSeparator) { 10987 if (needsSeparator) {
11322 builder.append("; "); 10988 builder.append("; ");
11323 } 10989 }
11324 builder.append("entry type changed; was ${oldEntry.runtimeType.toString()} "); 10990 builder.append("entry type changed; was ${oldEntry.runtimeType.toString()} ");
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
11829 _checkThread(instrumentation); 11495 _checkThread(instrumentation);
11830 try { 11496 try {
11831 instrumentation.metric3("contextId", _contextId); 11497 instrumentation.metric3("contextId", _contextId);
11832 return _basis.exists(source); 11498 return _basis.exists(source);
11833 } finally { 11499 } finally {
11834 instrumentation.log(); 11500 instrumentation.log();
11835 } 11501 }
11836 } 11502 }
11837 11503
11838 @override 11504 @override
11839 AnalysisContext extractContext(SourceContainer container) {
11840 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- extractContext");
11841 _checkThread(instrumentation);
11842 try {
11843 instrumentation.metric3("contextId", _contextId);
11844 InstrumentedAnalysisContextImpl newContext = new InstrumentedAnalysisConte xtImpl();
11845 _basis.extractContextInto(container, newContext._basis);
11846 return newContext;
11847 } finally {
11848 instrumentation.log();
11849 }
11850 }
11851
11852 @override
11853 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) => _basis.extractContextInto(container, newContext);
11854
11855 @override
11856 AnalysisOptions get analysisOptions { 11505 AnalysisOptions get analysisOptions {
11857 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getAnalysisOptions"); 11506 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getAnalysisOptions");
11858 _checkThread(instrumentation); 11507 _checkThread(instrumentation);
11859 try { 11508 try {
11860 instrumentation.metric3("contextId", _contextId); 11509 instrumentation.metric3("contextId", _contextId);
11861 return _basis.analysisOptions; 11510 return _basis.analysisOptions;
11862 } finally { 11511 } finally {
11863 instrumentation.log(); 11512 instrumentation.log();
11864 } 11513 }
11865 } 11514 }
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
12237 _checkThread(instrumentation); 11886 _checkThread(instrumentation);
12238 try { 11887 try {
12239 instrumentation.metric3("contextId", _contextId); 11888 instrumentation.metric3("contextId", _contextId);
12240 return _basis.isServerLibrary(librarySource); 11889 return _basis.isServerLibrary(librarySource);
12241 } finally { 11890 } finally {
12242 instrumentation.log(); 11891 instrumentation.log();
12243 } 11892 }
12244 } 11893 }
12245 11894
12246 @override 11895 @override
12247 void mergeContext(AnalysisContext context) {
12248 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- mergeContext");
12249 _checkThread(instrumentation);
12250 try {
12251 instrumentation.metric3("contextId", _contextId);
12252 if (context is InstrumentedAnalysisContextImpl) {
12253 context = (context as InstrumentedAnalysisContextImpl)._basis;
12254 }
12255 _basis.mergeContext(context);
12256 } finally {
12257 instrumentation.log();
12258 }
12259 }
12260
12261 @override
12262 CompilationUnit parseCompilationUnit(Source source) { 11896 CompilationUnit parseCompilationUnit(Source source) {
12263 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- parseCompilationUnit"); 11897 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- parseCompilationUnit");
12264 _checkThread(instrumentation); 11898 _checkThread(instrumentation);
12265 try { 11899 try {
12266 instrumentation.metric3("contextId", _contextId); 11900 instrumentation.metric3("contextId", _contextId);
12267 return _basis.parseCompilationUnit(source); 11901 return _basis.parseCompilationUnit(source);
12268 } on AnalysisException catch (e, stackTrace) { 11902 } on AnalysisException catch (e, stackTrace) {
12269 _recordAnalysisException(instrumentation, new CaughtException(e, stackTrac e)); 11903 _recordAnalysisException(instrumentation, new CaughtException(e, stackTrac e));
12270 throw e; 11904 throw e;
12271 } finally { 11905 } finally {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
12463 * 12097 *
12464 * <b>Note:</b> This method cannot be used in an async environment 12098 * <b>Note:</b> This method cannot be used in an async environment
12465 * 12099 *
12466 * @param source the compilation unit for which an AST structure should be ret urned 12100 * @param source the compilation unit for which an AST structure should be ret urned
12467 * @return the AST structure representing the content of the source 12101 * @return the AST structure representing the content of the source
12468 * @throws AnalysisException if the analysis could not be performed 12102 * @throws AnalysisException if the analysis could not be performed
12469 */ 12103 */
12470 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source); 12104 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source);
12471 12105
12472 /** 12106 /**
12473 * Initialize the specified context by removing the specified sources from the receiver and adding
12474 * them to the specified context.
12475 *
12476 * @param container the container containing sources that should be removed fr om this context and
12477 * added to the returned context
12478 * @param newContext the context to be initialized
12479 * @return the analysis context that was initialized
12480 */
12481 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext);
12482
12483 /**
12484 * Return context that owns the given source. 12107 * Return context that owns the given source.
12485 * 12108 *
12486 * @param source the source whose context is to be returned 12109 * @param source the source whose context is to be returned
12487 * @return the context that owns the partition that contains the source 12110 * @return the context that owns the partition that contains the source
12488 */ 12111 */
12489 InternalAnalysisContext getContextFor(Source source); 12112 InternalAnalysisContext getContextFor(Source source);
12490 12113
12491 /** 12114 /**
12492 * Return an array containing all of the sources that have been marked as prio rity sources. 12115 * Return an array containing all of the sources that have been marked as prio rity sources.
12493 * Clients must not modify the returned array. 12116 * Clients must not modify the returned array.
(...skipping 2437 matching lines...) Expand 10 before | Expand all | Expand 10 after
14931 CacheState getState(DataDescriptor descriptor); 14554 CacheState getState(DataDescriptor descriptor);
14932 14555
14933 /** 14556 /**
14934 * Return the value of the data represented by the given descriptor, or `null` if the data 14557 * Return the value of the data represented by the given descriptor, or `null` if the data
14935 * represented by the descriptor is not in the cache. 14558 * represented by the descriptor is not in the cache.
14936 * 14559 *
14937 * @param descriptor the descriptor representing which data is to be returned 14560 * @param descriptor the descriptor representing which data is to be returned
14938 * @return the value of the data represented by the given descriptor 14561 * @return the value of the data represented by the given descriptor
14939 */ 14562 */
14940 Object getValue(DataDescriptor descriptor); 14563 Object getValue(DataDescriptor descriptor);
14941
14942 /**
14943 * Return a new entry that is initialized to the same state as this entry but that can be
14944 * modified.
14945 *
14946 * @return a writable copy of this entry
14947 */
14948 SourceEntryImpl get writableCopy;
14949 } 14564 }
14950 14565
14951 /** 14566 /**
14952 * Instances of the abstract class `SourceEntryImpl` implement the behavior comm on to all 14567 * Instances of the abstract class `SourceEntryImpl` implement the behavior comm on to all
14953 * [SourceEntry]. 14568 * [SourceEntry].
14954 */ 14569 */
14955 abstract class SourceEntryImpl implements SourceEntry { 14570 abstract class SourceEntryImpl implements SourceEntry {
14956 /** 14571 /**
14957 * The most recent time at which the state of the source matched the state rep resented by this 14572 * The most recent time at which the state of the source matched the state rep resented by this
14958 * entry. 14573 * entry.
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
15173 * 14788 *
15174 * @param indexes the indexes of the flags whose value is to be set to false 14789 * @param indexes the indexes of the flags whose value is to be set to false
15175 */ 14790 */
15176 void clearFlags(List<int> indexes) { 14791 void clearFlags(List<int> indexes) {
15177 for (int i = 0; i < indexes.length; i++) { 14792 for (int i = 0; i < indexes.length; i++) {
15178 _flags = BooleanArray.set(_flags, indexes[i], false); 14793 _flags = BooleanArray.set(_flags, indexes[i], false);
15179 } 14794 }
15180 } 14795 }
15181 14796
15182 /** 14797 /**
15183 * Copy the information from the given cache entry.
15184 *
15185 * @param entry the cache entry from which information will be copied
15186 */
15187 void copyFrom(SourceEntryImpl entry) {
15188 _modificationTime = entry._modificationTime;
15189 _flags = entry._flags;
15190 _exception = entry._exception;
15191 _contentState = entry._contentState;
15192 _content = entry._content;
15193 _lineInfoState = entry._lineInfoState;
15194 _lineInfo = entry._lineInfo;
15195 }
15196
15197 /**
15198 * Return the value of the flag with the given index. 14798 * Return the value of the flag with the given index.
15199 * 14799 *
15200 * @param index the index of the flag whose value is to be returned 14800 * @param index the index of the flag whose value is to be returned
15201 * @return the value of the flag with the given index 14801 * @return the value of the flag with the given index
15202 */ 14802 */
15203 bool getFlag(int index) => BooleanArray.get(_flags, index); 14803 bool getFlag(int index) => BooleanArray.get(_flags, index);
15204 14804
15205 /** 14805 /**
15206 * Return `true` if the state of any data value is [CacheState#ERROR]. 14806 * Return `true` if the state of any data value is [CacheState#ERROR].
15207 * 14807 *
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
15640 _index++; 15240 _index++;
15641 if (_index >= _manager._workQueues[_queueIndex].length) { 15241 if (_index >= _manager._workQueues[_queueIndex].length) {
15642 _index = 0; 15242 _index = 0;
15643 _queueIndex++; 15243 _queueIndex++;
15644 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_ queueIndex].isEmpty) { 15244 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_ queueIndex].isEmpty) {
15645 _queueIndex++; 15245 _queueIndex++;
15646 } 15246 }
15647 } 15247 }
15648 } 15248 }
15649 } 15249 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698