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

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

Issue 630763004: Unify Entry and EntryImpl classes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Additional Clean-up 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
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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 return new MultipleMapIterator<Source, SourceEntry>(maps); 144 return new MultipleMapIterator<Source, SourceEntry>(maps);
145 } 145 }
146 146
147 /** 147 /**
148 * Associate the given entry with the given source. 148 * Associate the given entry with the given source.
149 * 149 *
150 * @param source the source with which the entry is to be associated 150 * @param source the source with which the entry is to be associated
151 * @param entry the entry to be associated with the source 151 * @param entry the entry to be associated with the source
152 */ 152 */
153 void put(Source source, SourceEntry entry) { 153 void put(Source source, SourceEntry entry) {
154 (entry as SourceEntryImpl).fixExceptionState(); 154 entry.fixExceptionState();
155 int count = _partitions.length; 155 int count = _partitions.length;
156 for (int i = 0; i < count; i++) { 156 for (int i = 0; i < count; i++) {
157 if (_partitions[i].contains(source)) { 157 if (_partitions[i].contains(source)) {
158 if (_TRACE_CHANGES) { 158 if (_TRACE_CHANGES) {
159 try { 159 try {
160 SourceEntry oldEntry = _partitions[i].get(source); 160 SourceEntry oldEntry = _partitions[i].get(source);
161 if (oldEntry == null) { 161 if (oldEntry == null) {
162 AnalysisEngine.instance.logger.logInformation("Added a cache entry for '${source.fullName}'."); 162 AnalysisEngine.instance.logger.logInformation("Added a cache entry for '${source.fullName}'.");
163 } else { 163 } else {
164 AnalysisEngine.instance.logger.logInformation("Modified the cache entry for ${source.fullName}'. Diff = ${(entry as SourceEntryImpl).getDiff(oldEn try)}"); 164 AnalysisEngine.instance.logger.logInformation("Modified the cache entry for ${source.fullName}'. Diff = ${entry.getDiff(oldEntry)}");
165 } 165 }
166 } catch (exception) { 166 } catch (exception) {
167 // Ignored 167 // Ignored
168 JavaSystem.currentTimeMillis(); 168 JavaSystem.currentTimeMillis();
169 } 169 }
170 } 170 }
171 _partitions[i].put(source, entry); 171 _partitions[i].put(source, entry);
172 return; 172 return;
173 } 173 }
174 } 174 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 * @param source the source defining the HTML file whose element model is to b e returned 345 * @param source the source defining the HTML file whose element model is to b e returned
346 * @return the element model corresponding to the HTML file defined by the giv en source 346 * @return the element model corresponding to the HTML file defined by the giv en source
347 * @throws AnalysisException if the element model could not be determined beca use the analysis 347 * @throws AnalysisException if the element model could not be determined beca use the analysis
348 * could not be performed 348 * could not be performed
349 * @see #getHtmlElement(Source) 349 * @see #getHtmlElement(Source)
350 */ 350 */
351 HtmlElement computeHtmlElement(Source source); 351 HtmlElement computeHtmlElement(Source source);
352 352
353 /** 353 /**
354 * Return the kind of the given source, computing it's kind if it is not alrea dy known. Return 354 * Return the kind of the given source, computing it's kind if it is not alrea dy known. Return
355 * [SourceKind#UNKNOWN] if the source is not contained in this context. 355 * [SourceKind.UNKNOWN] if the source is not contained in this context.
356 * 356 *
357 * <b>Note:</b> This method cannot be used in an async environment. 357 * <b>Note:</b> This method cannot be used in an async environment.
358 * 358 *
359 * @param source the source whose kind is to be returned 359 * @param source the source whose kind is to be returned
360 * @return the kind of the given source 360 * @return the kind of the given source
361 * @see #getKindOf(Source) 361 * @see #getKindOf(Source)
362 */ 362 */
363 SourceKind computeKindOf(Source source); 363 SourceKind computeKindOf(Source source);
364 364
365 /** 365 /**
(...skipping 29 matching lines...) Expand all
395 LineInfo computeLineInfo(Source source); 395 LineInfo computeLineInfo(Source source);
396 396
397 /** 397 /**
398 * Notifies the context that the client is going to stop using this context. 398 * Notifies the context that the client is going to stop using this context.
399 */ 399 */
400 void dispose(); 400 void dispose();
401 401
402 /** 402 /**
403 * Return `true` if the given source exists. 403 * Return `true` if the given source exists.
404 * 404 *
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 * 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
(...skipping 22 matching lines...) Expand all
438 * @param unitSource the source of the compilation unit 438 * @param unitSource the source of the compilation unit
439 * @param librarySource the source of the defining compilation unit of the lib rary containing the 439 * @param librarySource the source of the defining compilation unit of the lib rary containing the
440 * compilation unit 440 * compilation unit
441 * @return the element model corresponding to the compilation unit defined by the given source 441 * @return the element model corresponding to the compilation unit defined by the given source
442 */ 442 */
443 CompilationUnitElement getCompilationUnitElement(Source unitSource, Source lib rarySource); 443 CompilationUnitElement getCompilationUnitElement(Source unitSource, Source lib rarySource);
444 444
445 /** 445 /**
446 * Get the contents and timestamp of the given source. 446 * Get the contents and timestamp of the given source.
447 * 447 *
448 * This method should be used rather than the method [Source#getContents] beca use contexts 448 * This method should be used rather than the method [Source.getContents] beca use contexts
449 * can have local overrides of the content of a source that the source is not aware of. 449 * can have local overrides of the content of a source that the source is not aware of.
450 * 450 *
451 * @param source the source whose content is to be returned 451 * @param source the source whose content is to be returned
452 * @return the contents and timestamp of the source 452 * @return the contents and timestamp of the source
453 * @throws Exception if the contents of the source could not be accessed 453 * @throws Exception if the contents of the source could not be accessed
454 */ 454 */
455 TimestampedData<String> getContents(Source source); 455 TimestampedData<String> getContents(Source source);
456 456
457 /** 457 /**
458 * Return the set of declared variables used when computing constant values. 458 * Return the set of declared variables used when computing constant values.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 */ 608 */
609 LineInfo getLineInfo(Source source); 609 LineInfo getLineInfo(Source source);
610 610
611 /** 611 /**
612 * Return the modification stamp for the given source. A modification stamp is a non-negative 612 * Return the modification stamp for the given source. A modification stamp is a non-negative
613 * integer with the property that if the contents of the source have not been modified since the 613 * integer with the property that if the contents of the source have not been modified since the
614 * last time the modification stamp was accessed then the same value will be r eturned, but if the 614 * last time the modification stamp was accessed then the same value will be r eturned, but if the
615 * contents of the source have been modified one or more times (even if the ne t change is zero) 615 * contents of the source have been modified one or more times (even if the ne t change is zero)
616 * the stamps will be different. 616 * the stamps will be different.
617 * 617 *
618 * This method should be used rather than the method [Source#getModificationSt amp] because 618 * This method should be used rather than the method [Source.getModificationSt amp] because
619 * contexts can have local overrides of the content of a source that the sourc e is not aware of. 619 * contexts can have local overrides of the content of a source that the sourc e is not aware of.
620 * 620 *
621 * @param source the source whose modification stamp is to be returned 621 * @param source the source whose modification stamp is to be returned
622 * @return the modification stamp for the source 622 * @return the modification stamp for the source
623 */ 623 */
624 int getModificationStamp(Source source); 624 int getModificationStamp(Source source);
625 625
626 /** 626 /**
627 * Return an array containing all of the sources known to this context and the ir resolution state 627 * Return an array containing all of the sources known to this context and the ir resolution state
628 * is not valid or flush. So, these sources are not safe to update during refa ctoring, because we 628 * is not valid or flush. So, these sources are not safe to update during refa ctoring, because we
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 SourceEntry sourceEntry = iterator.value; 1066 SourceEntry sourceEntry = iterator.value;
1067 if (!source.isInSystemLibrary && (sourceEntry is DartEntry || sourceEntr y is HtmlEntry)) { 1067 if (!source.isInSystemLibrary && (sourceEntry is DartEntry || sourceEntr y is HtmlEntry)) {
1068 sourcesToInvalidate.add(source); 1068 sourcesToInvalidate.add(source);
1069 } 1069 }
1070 } 1070 }
1071 int count = sourcesToInvalidate.length; 1071 int count = sourcesToInvalidate.length;
1072 for (int i = 0; i < count; i++) { 1072 for (int i = 0; i < count; i++) {
1073 Source source = sourcesToInvalidate[i]; 1073 Source source = sourcesToInvalidate[i];
1074 SourceEntry entry = _getReadableSourceEntry(source); 1074 SourceEntry entry = _getReadableSourceEntry(source);
1075 if (entry is DartEntry) { 1075 if (entry is DartEntry) {
1076 (entry as DartEntryImpl).invalidateAllResolutionInformation(false); 1076 entry.invalidateAllResolutionInformation(false);
1077 _workManager.add(source, _computePriority(entry)); 1077 _workManager.add(source, _computePriority(entry));
1078 } else if (entry is HtmlEntry) { 1078 } else if (entry is HtmlEntry) {
1079 (entry as HtmlEntryImpl).invalidateAllResolutionInformation(false); 1079 entry.invalidateAllResolutionInformation(false);
1080 _workManager.add(source, SourcePriority.HTML); 1080 _workManager.add(source, SourcePriority.HTML);
1081 } 1081 }
1082 } 1082 }
1083 } 1083 }
1084 } 1084 }
1085 1085
1086 @override 1086 @override
1087 String computeDocumentationComment(Element element) { 1087 String computeDocumentationComment(Element element) {
1088 if (element == null) { 1088 if (element == null) {
1089 return null; 1089 return null;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 return _getDartScanData2(source, SourceEntry.LINE_INFO, null); 1206 return _getDartScanData2(source, SourceEntry.LINE_INFO, null);
1207 } 1207 }
1208 } on ObsoleteSourceAnalysisException catch (exception) { 1208 } on ObsoleteSourceAnalysisException catch (exception) {
1209 AnalysisEngine.instance.logger.logInformation2("Could not compute ${Source Entry.LINE_INFO.toString()}", exception); 1209 AnalysisEngine.instance.logger.logInformation2("Could not compute ${Source Entry.LINE_INFO.toString()}", exception);
1210 } 1210 }
1211 return null; 1211 return null;
1212 } 1212 }
1213 1213
1214 @override 1214 @override
1215 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) { 1215 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) {
1216 DartEntryImpl dartEntry = _getReadableDartEntry(source); 1216 DartEntry dartEntry = _getReadableDartEntry(source);
1217 if (dartEntry == null) { 1217 if (dartEntry == null) {
1218 throw new AnalysisException("computeResolvableCompilationUnit for non-Dart : ${source.fullName}"); 1218 throw new AnalysisException("computeResolvableCompilationUnit for non-Dart : ${source.fullName}");
1219 } 1219 }
1220 dartEntry = _cacheDartParseData(source, dartEntry, DartEntry.PARSED_UNIT); 1220 dartEntry = _cacheDartParseData(source, dartEntry, DartEntry.PARSED_UNIT);
1221 CompilationUnit unit = dartEntry.resolvableCompilationUnit; 1221 CompilationUnit unit = dartEntry.resolvableCompilationUnit;
1222 if (unit == null) { 1222 if (unit == null) {
1223 throw new AnalysisException("Internal error: computeResolvableCompilationU nit could not parse ${source.fullName}", new CaughtException(dartEntry.exception , null)); 1223 throw new AnalysisException("Internal error: computeResolvableCompilationU nit could not parse ${source.fullName}", new CaughtException(dartEntry.exception , null));
1224 } 1224 }
1225 return new ResolvableCompilationUnit.con1(dartEntry.modificationTime, unit); 1225 return new ResolvableCompilationUnit.con1(dartEntry.modificationTime, unit);
1226 } 1226 }
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 } 1503 }
1504 1504
1505 @override 1505 @override
1506 List<Source> get prioritySources => _priorityOrder; 1506 List<Source> get prioritySources => _priorityOrder;
1507 1507
1508 @override 1508 @override
1509 Namespace getPublicNamespace(LibraryElement library) { 1509 Namespace getPublicNamespace(LibraryElement library) {
1510 // TODO(brianwilkerson) Rename this to not start with 'get'. Note that this is not part of the 1510 // TODO(brianwilkerson) Rename this to not start with 'get'. Note that this is not part of the
1511 // API of the interface. 1511 // API of the interface.
1512 Source source = library.definingCompilationUnit.source; 1512 Source source = library.definingCompilationUnit.source;
1513 DartEntryImpl dartEntry = _getReadableDartEntry(source); 1513 DartEntry dartEntry = _getReadableDartEntry(source);
1514 if (dartEntry == null) { 1514 if (dartEntry == null) {
1515 return null; 1515 return null;
1516 } 1516 }
1517 Namespace namespace = null; 1517 Namespace namespace = null;
1518 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { 1518 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) {
1519 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); 1519 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE);
1520 } 1520 }
1521 if (namespace == null) { 1521 if (namespace == null) {
1522 NamespaceBuilder builder = new NamespaceBuilder(); 1522 NamespaceBuilder builder = new NamespaceBuilder();
1523 namespace = builder.createPublicNamespaceForLibrary(library); 1523 namespace = builder.createPublicNamespaceForLibrary(library);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1750 1750
1751 @override 1751 @override
1752 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { 1752 void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
1753 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); 1753 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML);
1754 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap)) { 1754 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap)) {
1755 Source librarySource = entry.getKey(); 1755 Source librarySource = entry.getKey();
1756 LibraryElement library = entry.getValue(); 1756 LibraryElement library = entry.getValue();
1757 // 1757 //
1758 // Cache the element in the library's info. 1758 // Cache the element in the library's info.
1759 // 1759 //
1760 DartEntryImpl dartEntry = _getReadableDartEntry(librarySource); 1760 DartEntry dartEntry = _getReadableDartEntry(librarySource);
1761 if (dartEntry != null) { 1761 if (dartEntry != null) {
1762 _recordElementData(dartEntry, library, library.source, htmlSource); 1762 _recordElementData(dartEntry, library, library.source, htmlSource);
1763 dartEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED); 1763 dartEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED);
1764 dartEntry.setValue(SourceEntry.LINE_INFO, new LineInfo(<int> [0])); 1764 dartEntry.setValue(SourceEntry.LINE_INFO, new LineInfo(<int> [0]));
1765 dartEntry.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS); 1765 dartEntry.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS);
1766 // DartEntry.ELEMENT - set in recordElementData 1766 // DartEntry.ELEMENT - set in recordElementData
1767 dartEntry.setValue(DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY); 1767 dartEntry.setValue(DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY);
1768 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY); 1768 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY);
1769 dartEntry.setValue(DartEntry.INCLUDED_PARTS, Source.EMPTY_ARRAY); 1769 dartEntry.setValue(DartEntry.INCLUDED_PARTS, Source.EMPTY_ARRAY);
1770 // DartEntry.IS_CLIENT - set in recordElementData 1770 // DartEntry.IS_CLIENT - set in recordElementData
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 1867
1868 @override 1868 @override
1869 void setChangedContents(Source source, String contents, int offset, int oldLen gth, int newLength) { 1869 void setChangedContents(Source source, String contents, int offset, int oldLen gth, int newLength) {
1870 String originalContents = _contentCache.setContents(source, contents); 1870 String originalContents = _contentCache.setContents(source, contents);
1871 if (contents != null) { 1871 if (contents != null) {
1872 if (contents != originalContents) { 1872 if (contents != originalContents) {
1873 if (_options.incremental) { 1873 if (_options.incremental) {
1874 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increment alAnalysisCache, source, originalContents, contents, offset, oldLength, newLengt h, _getReadableSourceEntry(source)); 1874 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increment alAnalysisCache, source, originalContents, contents, offset, oldLength, newLengt h, _getReadableSourceEntry(source));
1875 } 1875 }
1876 _sourceChanged(source); 1876 _sourceChanged(source);
1877 SourceEntryImpl sourceEntry = _cache.get(source); 1877 SourceEntry sourceEntry = _cache.get(source);
1878 if (sourceEntry != null) { 1878 if (sourceEntry != null) {
1879 sourceEntry.modificationTime = _contentCache.getModificationStamp(sour ce); 1879 sourceEntry.modificationTime = _contentCache.getModificationStamp(sour ce);
1880 sourceEntry.setValue(SourceEntry.CONTENT, contents); 1880 sourceEntry.setValue(SourceEntry.CONTENT, contents);
1881 } 1881 }
1882 } 1882 }
1883 } else if (originalContents != null) { 1883 } else if (originalContents != null) {
1884 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna lysisCache, source); 1884 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna lysisCache, source);
1885 _sourceChanged(source); 1885 _sourceChanged(source);
1886 } 1886 }
1887 } 1887 }
1888 1888
1889 @override 1889 @override
1890 void setContents(Source source, String contents) { 1890 void setContents(Source source, String contents) {
1891 String originalContents = _contentCache.setContents(source, contents); 1891 String originalContents = _contentCache.setContents(source, contents);
1892 if (contents != null) { 1892 if (contents != null) {
1893 if (contents != originalContents) { 1893 if (contents != originalContents) {
1894 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA nalysisCache, source); 1894 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA nalysisCache, source);
1895 _sourceChanged(source); 1895 _sourceChanged(source);
1896 SourceEntryImpl sourceEntry = _cache.get(source); 1896 SourceEntry sourceEntry = _cache.get(source);
1897 if (sourceEntry != null) { 1897 if (sourceEntry != null) {
1898 sourceEntry.modificationTime = _contentCache.getModificationStamp(sour ce); 1898 sourceEntry.modificationTime = _contentCache.getModificationStamp(sour ce);
1899 sourceEntry.setValue(SourceEntry.CONTENT, contents); 1899 sourceEntry.setValue(SourceEntry.CONTENT, contents);
1900 } 1900 }
1901 } 1901 }
1902 } else if (originalContents != null) { 1902 } else if (originalContents != null) {
1903 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna lysisCache, source); 1903 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna lysisCache, source);
1904 _sourceChanged(source); 1904 _sourceChanged(source);
1905 } 1905 }
1906 } 1906 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 * Record the results produced by performing a [ResolveDartLibraryCycleTask]. If the results 1945 * Record the results produced by performing a [ResolveDartLibraryCycleTask]. If the results
1946 * were computed from data that is now out-of-date, then the results will not be recorded. 1946 * were computed from data that is now out-of-date, then the results will not be recorded.
1947 * 1947 *
1948 * @param task the task that was performed 1948 * @param task the task that was performed
1949 * @return an entry containing the computed results 1949 * @return an entry containing the computed results
1950 * @throws AnalysisException if the results could not be recorded 1950 * @throws AnalysisException if the results could not be recorded
1951 */ 1951 */
1952 DartEntry recordResolveDartLibraryCycleTaskResults(ResolveDartLibraryCycleTask task) { 1952 DartEntry recordResolveDartLibraryCycleTaskResults(ResolveDartLibraryCycleTask task) {
1953 LibraryResolver2 resolver = task.libraryResolver; 1953 LibraryResolver2 resolver = task.libraryResolver;
1954 CaughtException thrownException = task.exception; 1954 CaughtException thrownException = task.exception;
1955 DartEntryImpl unitEntry = null; 1955 DartEntry unitEntry = null;
1956 Source unitSource = task.unitSource; 1956 Source unitSource = task.unitSource;
1957 if (resolver != null) { 1957 if (resolver != null) {
1958 // 1958 //
1959 // The resolver should only be null if an exception was thrown before (or while) it was 1959 // The resolver should only be null if an exception was thrown before (or while) it was
1960 // being created. 1960 // being created.
1961 // 1961 //
1962 List<ResolvableLibrary> resolvedLibraries = resolver.resolvedLibraries; 1962 List<ResolvableLibrary> resolvedLibraries = resolver.resolvedLibraries;
1963 if (resolvedLibraries == null) { 1963 if (resolvedLibraries == null) {
1964 // 1964 //
1965 // The resolved libraries should only be null if an exception was thrown during resolution. 1965 // The resolved libraries should only be null if an exception was thrown during resolution.
(...skipping 15 matching lines...) Expand all
1981 } 1981 }
1982 if (_allModificationTimesMatch(resolvedLibraries)) { 1982 if (_allModificationTimesMatch(resolvedLibraries)) {
1983 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); 1983 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
1984 RecordingErrorListener errorListener = resolver.errorListener; 1984 RecordingErrorListener errorListener = resolver.errorListener;
1985 for (ResolvableLibrary library in resolvedLibraries) { 1985 for (ResolvableLibrary library in resolvedLibraries) {
1986 Source librarySource = library.librarySource; 1986 Source librarySource = library.librarySource;
1987 for (Source source in library.compilationUnitSources) { 1987 for (Source source in library.compilationUnitSources) {
1988 CompilationUnit unit = library.getAST(source); 1988 CompilationUnit unit = library.getAST(source);
1989 List<AnalysisError> errors = errorListener.getErrorsForSource(source ); 1989 List<AnalysisError> errors = errorListener.getErrorsForSource(source );
1990 LineInfo lineInfo = getLineInfo(source); 1990 LineInfo lineInfo = getLineInfo(source);
1991 DartEntryImpl dartEntry = _cache.get(source); 1991 DartEntry dartEntry = _cache.get(source);
1992 if (thrownException == null) { 1992 if (thrownException == null) {
1993 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); 1993 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
1994 dartEntry.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource , unit); 1994 dartEntry.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource , unit);
1995 dartEntry.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySo urce, errors); 1995 dartEntry.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySo urce, errors);
1996 if (source == librarySource) { 1996 if (source == librarySource) {
1997 _recordElementData(dartEntry, library.libraryElement, librarySou rce, htmlSource); 1997 _recordElementData(dartEntry, library.libraryElement, librarySou rce, htmlSource);
1998 } 1998 }
1999 _cache.storedAst(source); 1999 _cache.storedAst(source);
2000 } else { 2000 } else {
2001 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownExce ption); 2001 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownExce ption);
2002 _cache.remove(source); 2002 _cache.remove(source);
2003 } 2003 }
2004 if (source != librarySource) { 2004 if (source != librarySource) {
2005 _workManager.add(source, SourcePriority.PRIORITY_PART); 2005 _workManager.add(source, SourcePriority.PRIORITY_PART);
2006 } 2006 }
2007 if (source == unitSource) { 2007 if (source == unitSource) {
2008 unitEntry = dartEntry; 2008 unitEntry = dartEntry;
2009 } 2009 }
2010 ChangeNoticeImpl notice = _getNotice(source); 2010 ChangeNoticeImpl notice = _getNotice(source);
2011 notice.compilationUnit = unit; 2011 notice.compilationUnit = unit;
2012 notice.setErrors(dartEntry.allErrors, lineInfo); 2012 notice.setErrors(dartEntry.allErrors, lineInfo);
2013 } 2013 }
2014 } 2014 }
2015 } else { 2015 } else {
2016 PrintStringWriter writer = new PrintStringWriter(); 2016 PrintStringWriter writer = new PrintStringWriter();
2017 writer.println("Library resolution results discarded for"); 2017 writer.println("Library resolution results discarded for");
2018 for (ResolvableLibrary library in resolvedLibraries) { 2018 for (ResolvableLibrary library in resolvedLibraries) {
2019 for (Source source in library.compilationUnitSources) { 2019 for (Source source in library.compilationUnitSources) {
2020 DartEntryImpl dartEntry = _getReadableDartEntry(source); 2020 DartEntry dartEntry = _getReadableDartEntry(source);
2021 if (dartEntry != null) { 2021 if (dartEntry != null) {
2022 int resultTime = library.getModificationTime(source); 2022 int resultTime = library.getModificationTime(source);
2023 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.m odificationTime}"); 2023 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.m odificationTime}");
2024 if (thrownException == null || resultTime >= 0) { 2024 if (thrownException == null || resultTime >= 0) {
2025 // 2025 //
2026 // The analysis was performed on out-of-date sources. Mark the c ache so that the 2026 // The analysis was performed on out-of-date sources. Mark the c ache so that the
2027 // sources will be re-analyzed using the up-to-date sources. 2027 // sources will be re-analyzed using the up-to-date sources.
2028 // 2028 //
2029 dartEntry.recordResolutionNotInProcess(); 2029 dartEntry.recordResolutionNotInProcess();
2030 } else { 2030 } else {
(...skipping 24 matching lines...) Expand all
2055 if (unitEntry == null) { 2055 if (unitEntry == null) {
2056 throw new AnalysisException("A Dart file became a non-Dart file: ${unitS ource.fullName}"); 2056 throw new AnalysisException("A Dart file became a non-Dart file: ${unitS ource.fullName}");
2057 } 2057 }
2058 } 2058 }
2059 return unitEntry; 2059 return unitEntry;
2060 } 2060 }
2061 2061
2062 DartEntry recordResolveDartLibraryTaskResults(ResolveDartLibraryTask task) { 2062 DartEntry recordResolveDartLibraryTaskResults(ResolveDartLibraryTask task) {
2063 LibraryResolver resolver = task.libraryResolver; 2063 LibraryResolver resolver = task.libraryResolver;
2064 CaughtException thrownException = task.exception; 2064 CaughtException thrownException = task.exception;
2065 DartEntryImpl unitEntry = null; 2065 DartEntry unitEntry = null;
2066 Source unitSource = task.unitSource; 2066 Source unitSource = task.unitSource;
2067 if (resolver != null) { 2067 if (resolver != null) {
2068 // 2068 //
2069 // The resolver should only be null if an exception was thrown before (or while) it was 2069 // The resolver should only be null if an exception was thrown before (or while) it was
2070 // being created. 2070 // being created.
2071 // 2071 //
2072 Set<Library> resolvedLibraries = resolver.resolvedLibraries; 2072 Set<Library> resolvedLibraries = resolver.resolvedLibraries;
2073 if (resolvedLibraries == null) { 2073 if (resolvedLibraries == null) {
2074 // 2074 //
2075 // The resolved libraries should only be null if an exception was thrown during resolution. 2075 // The resolved libraries should only be null if an exception was thrown during resolution.
(...skipping 15 matching lines...) Expand all
2091 } 2091 }
2092 if (_allModificationTimesMatch2(resolvedLibraries)) { 2092 if (_allModificationTimesMatch2(resolvedLibraries)) {
2093 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); 2093 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
2094 RecordingErrorListener errorListener = resolver.errorListener; 2094 RecordingErrorListener errorListener = resolver.errorListener;
2095 for (Library library in resolvedLibraries) { 2095 for (Library library in resolvedLibraries) {
2096 Source librarySource = library.librarySource; 2096 Source librarySource = library.librarySource;
2097 for (Source source in library.compilationUnitSources) { 2097 for (Source source in library.compilationUnitSources) {
2098 CompilationUnit unit = library.getAST(source); 2098 CompilationUnit unit = library.getAST(source);
2099 List<AnalysisError> errors = errorListener.getErrorsForSource(source ); 2099 List<AnalysisError> errors = errorListener.getErrorsForSource(source );
2100 LineInfo lineInfo = getLineInfo(source); 2100 LineInfo lineInfo = getLineInfo(source);
2101 DartEntryImpl dartEntry = _cache.get(source); 2101 DartEntry dartEntry = _cache.get(source);
2102 int sourceTime = getModificationStamp(source); 2102 int sourceTime = getModificationStamp(source);
2103 if (dartEntry.modificationTime != sourceTime) { 2103 if (dartEntry.modificationTime != sourceTime) {
2104 // The source has changed without the context being notified. Simu late notification. 2104 // The source has changed without the context being notified. Simu late notification.
2105 _sourceChanged(source); 2105 _sourceChanged(source);
2106 dartEntry = _getReadableDartEntry(source); 2106 dartEntry = _getReadableDartEntry(source);
2107 if (dartEntry == null) { 2107 if (dartEntry == null) {
2108 throw new AnalysisException("A Dart file became a non-Dart file: ${source.fullName}"); 2108 throw new AnalysisException("A Dart file became a non-Dart file: ${source.fullName}");
2109 } 2109 }
2110 } 2110 }
2111 if (thrownException == null) { 2111 if (thrownException == null) {
(...skipping 18 matching lines...) Expand all
2130 ChangeNoticeImpl notice = _getNotice(source); 2130 ChangeNoticeImpl notice = _getNotice(source);
2131 notice.compilationUnit = unit; 2131 notice.compilationUnit = unit;
2132 notice.setErrors(dartEntry.allErrors, lineInfo); 2132 notice.setErrors(dartEntry.allErrors, lineInfo);
2133 } 2133 }
2134 } 2134 }
2135 } else { 2135 } else {
2136 PrintStringWriter writer = new PrintStringWriter(); 2136 PrintStringWriter writer = new PrintStringWriter();
2137 writer.println("Library resolution results discarded for"); 2137 writer.println("Library resolution results discarded for");
2138 for (Library library in resolvedLibraries) { 2138 for (Library library in resolvedLibraries) {
2139 for (Source source in library.compilationUnitSources) { 2139 for (Source source in library.compilationUnitSources) {
2140 DartEntryImpl dartEntry = _getReadableDartEntry(source); 2140 DartEntry dartEntry = _getReadableDartEntry(source);
2141 if (dartEntry != null) { 2141 if (dartEntry != null) {
2142 int resultTime = library.getModificationTime(source); 2142 int resultTime = library.getModificationTime(source);
2143 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.m odificationTime}"); 2143 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.m odificationTime}");
2144 if (thrownException == null || resultTime >= 0) { 2144 if (thrownException == null || resultTime >= 0) {
2145 // 2145 //
2146 // The analysis was performed on out-of-date sources. Mark the c ache so that the 2146 // The analysis was performed on out-of-date sources. Mark the c ache so that the
2147 // sources will be re-analyzed using the up-to-date sources. 2147 // sources will be re-analyzed using the up-to-date sources.
2148 // 2148 //
2149 dartEntry.recordResolutionNotInProcess(); 2149 dartEntry.recordResolutionNotInProcess();
2150 } else { 2150 } else {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2264 _sourceChanged(source); 2264 _sourceChanged(source);
2265 allTimesMatch = false; 2265 allTimesMatch = false;
2266 } 2266 }
2267 } 2267 }
2268 } 2268 }
2269 return allTimesMatch; 2269 return allTimesMatch;
2270 } 2270 }
2271 2271
2272 /** 2272 /**
2273 * Given a source for a Dart file and the library that contains it, return a c ache entry in which 2273 * Given a source for a Dart file and the library that contains it, return a c ache entry in which
2274 * the state of the data represented by the given descriptor is either [CacheS tate#VALID] or 2274 * the state of the data represented by the given descriptor is either [CacheS tate.VALID] or
2275 * [CacheState#ERROR]. This method assumes that the data can be produced by ge nerating hints 2275 * [CacheState#ERROR]. This method assumes that the data can be produced by ge nerating hints
2276 * for the library if the data is not already cached. 2276 * for the library if the data is not already cached.
2277 * 2277 *
2278 * <b>Note:</b> This method cannot be used in an async environment. 2278 * <b>Note:</b> This method cannot be used in an async environment.
2279 * 2279 *
2280 * @param unitSource the source representing the Dart file 2280 * @param unitSource the source representing the Dart file
2281 * @param librarySource the source representing the library containing the Dar t file 2281 * @param librarySource the source representing the library containing the Dar t file
2282 * @param dartEntry the cache entry associated with the Dart file 2282 * @param dartEntry the cache entry associated with the Dart file
2283 * @param descriptor the descriptor representing the data to be returned 2283 * @param descriptor the descriptor representing the data to be returned
2284 * @return a cache entry containing the required data 2284 * @return a cache entry containing the required data
(...skipping 28 matching lines...) Expand all
2313 } 2313 }
2314 } 2314 }
2315 dartEntry = new GenerateDartHintsTask(this, units, getLibraryElement(libra rySource)).perform(_resultRecorder) as DartEntry; 2315 dartEntry = new GenerateDartHintsTask(this, units, getLibraryElement(libra rySource)).perform(_resultRecorder) as DartEntry;
2316 state = dartEntry.getStateInLibrary(descriptor, librarySource); 2316 state = dartEntry.getStateInLibrary(descriptor, librarySource);
2317 } 2317 }
2318 return dartEntry; 2318 return dartEntry;
2319 } 2319 }
2320 2320
2321 /** 2321 /**
2322 * Given a source for a Dart file, return a cache entry in which the state of the data represented 2322 * Given a source for a Dart file, return a cache entry in which the state of the data represented
2323 * by the given descriptor is either [CacheState#VALID] or [CacheState#ERROR]. This 2323 * by the given descriptor is either [CacheState.VALID] or [CacheState.ERROR]. This
2324 * method assumes that the data can be produced by parsing the source if it is not already cached. 2324 * method assumes that the data can be produced by parsing the source if it is not already cached.
2325 * 2325 *
2326 * <b>Note:</b> This method cannot be used in an async environment. 2326 * <b>Note:</b> This method cannot be used in an async environment.
2327 * 2327 *
2328 * @param source the source representing the Dart file 2328 * @param source the source representing the Dart file
2329 * @param dartEntry the cache entry associated with the Dart file 2329 * @param dartEntry the cache entry associated with the Dart file
2330 * @param descriptor the descriptor representing the data to be returned 2330 * @param descriptor the descriptor representing the data to be returned
2331 * @return a cache entry containing the required data 2331 * @return a cache entry containing the required data
2332 * @throws AnalysisException if data could not be returned because the source could not be parsed 2332 * @throws AnalysisException if data could not be returned because the source could not be parsed
2333 */ 2333 */
(...skipping 14 matching lines...) Expand all
2348 // 2348 //
2349 dartEntry = _cacheDartScanData(source, dartEntry, DartEntry.TOKEN_STREAM); 2349 dartEntry = _cacheDartScanData(source, dartEntry, DartEntry.TOKEN_STREAM);
2350 dartEntry = new ParseDartTask(this, source, dartEntry.modificationTime, da rtEntry.getValue(DartEntry.TOKEN_STREAM), dartEntry.getValue(SourceEntry.LINE_IN FO)).perform(_resultRecorder) as DartEntry; 2350 dartEntry = new ParseDartTask(this, source, dartEntry.modificationTime, da rtEntry.getValue(DartEntry.TOKEN_STREAM), dartEntry.getValue(SourceEntry.LINE_IN FO)).perform(_resultRecorder) as DartEntry;
2351 state = dartEntry.getState(descriptor); 2351 state = dartEntry.getState(descriptor);
2352 } 2352 }
2353 return dartEntry; 2353 return dartEntry;
2354 } 2354 }
2355 2355
2356 /** 2356 /**
2357 * Given a source for a Dart file and the library that contains it, return a c ache entry in which 2357 * Given a source for a Dart file and the library that contains it, return a c ache entry in which
2358 * the state of the data represented by the given descriptor is either [CacheS tate#VALID] or 2358 * the state of the data represented by the given descriptor is either [CacheS tate.VALID] or
2359 * [CacheState#ERROR]. This method assumes that the data can be produced by re solving the 2359 * [CacheState.ERROR]. This method assumes that the data can be produced by re solving the
2360 * source in the context of the library if it is not already cached. 2360 * source in the context of the library if it is not already cached.
2361 * 2361 *
2362 * <b>Note:</b> This method cannot be used in an async environment. 2362 * <b>Note:</b> This method cannot be used in an async environment.
2363 * 2363 *
2364 * @param unitSource the source representing the Dart file 2364 * @param unitSource the source representing the Dart file
2365 * @param librarySource the source representing the library containing the Dar t file 2365 * @param librarySource the source representing the library containing the Dar t file
2366 * @param dartEntry the cache entry associated with the Dart file 2366 * @param dartEntry the cache entry associated with the Dart file
2367 * @param descriptor the descriptor representing the data to be returned 2367 * @param descriptor the descriptor representing the data to be returned
2368 * @return a cache entry containing the required data 2368 * @return a cache entry containing the required data
2369 * @throws AnalysisException if data could not be returned because the source could not be parsed 2369 * @throws AnalysisException if data could not be returned because the source could not be parsed
(...skipping 11 matching lines...) Expand all
2381 // TODO(brianwilkerson) As an optimization, if we already have the element model for the 2381 // TODO(brianwilkerson) As an optimization, if we already have the element model for the
2382 // library we can use ResolveDartUnitTask to produce the resolved AST stru cture much faster. 2382 // library we can use ResolveDartUnitTask to produce the resolved AST stru cture much faster.
2383 dartEntry = new ResolveDartLibraryTask(this, unitSource, librarySource).pe rform(_resultRecorder) as DartEntry; 2383 dartEntry = new ResolveDartLibraryTask(this, unitSource, librarySource).pe rform(_resultRecorder) as DartEntry;
2384 state = (identical(descriptor, DartEntry.ELEMENT)) ? dartEntry.getState(de scriptor) : dartEntry.getStateInLibrary(descriptor, librarySource); 2384 state = (identical(descriptor, DartEntry.ELEMENT)) ? dartEntry.getState(de scriptor) : dartEntry.getStateInLibrary(descriptor, librarySource);
2385 } 2385 }
2386 return dartEntry; 2386 return dartEntry;
2387 } 2387 }
2388 2388
2389 /** 2389 /**
2390 * Given a source for a Dart file, return a cache entry in which the state of the data represented 2390 * Given a source for a Dart file, return a cache entry in which the state of the data represented
2391 * by the given descriptor is either [CacheState#VALID] or [CacheState#ERROR]. This 2391 * by the given descriptor is either [CacheState.VALID] or [CacheState.ERROR]. This
2392 * method assumes that the data can be produced by scanning the source if it i s not already 2392 * method assumes that the data can be produced by scanning the source if it i s not already
2393 * cached. 2393 * cached.
2394 * 2394 *
2395 * <b>Note:</b> This method cannot be used in an async environment. 2395 * <b>Note:</b> This method cannot be used in an async environment.
2396 * 2396 *
2397 * @param source the source representing the Dart file 2397 * @param source the source representing the Dart file
2398 * @param dartEntry the cache entry associated with the Dart file 2398 * @param dartEntry the cache entry associated with the Dart file
2399 * @param descriptor the descriptor representing the data to be returned 2399 * @param descriptor the descriptor representing the data to be returned
2400 * @return a cache entry containing the required data 2400 * @return a cache entry containing the required data
2401 * @throws AnalysisException if data could not be returned because the source could not be scanned 2401 * @throws AnalysisException if data could not be returned because the source could not be scanned
(...skipping 18 matching lines...) Expand all
2420 } catch (exception, stackTrace) { 2420 } catch (exception, stackTrace) {
2421 throw new AnalysisException("Exception", new CaughtException(exception, stackTrace)); 2421 throw new AnalysisException("Exception", new CaughtException(exception, stackTrace));
2422 } 2422 }
2423 state = dartEntry.getState(descriptor); 2423 state = dartEntry.getState(descriptor);
2424 } 2424 }
2425 return dartEntry; 2425 return dartEntry;
2426 } 2426 }
2427 2427
2428 /** 2428 /**
2429 * Given a source for a Dart file and the library that contains it, return a c ache entry in which 2429 * Given a source for a Dart file and the library that contains it, return a c ache entry in which
2430 * the state of the data represented by the given descriptor is either [CacheS tate#VALID] or 2430 * the state of the data represented by the given descriptor is either [CacheS tate.VALID] or
2431 * [CacheState#ERROR]. This method assumes that the data can be produced by ve rifying the 2431 * [CacheState.ERROR]. This method assumes that the data can be produced by ve rifying the
2432 * source in the given library if the data is not already cached. 2432 * source in the given library if the data is not already cached.
2433 * 2433 *
2434 * <b>Note:</b> This method cannot be used in an async environment. 2434 * <b>Note:</b> This method cannot be used in an async environment.
2435 * 2435 *
2436 * @param unitSource the source representing the Dart file 2436 * @param unitSource the source representing the Dart file
2437 * @param librarySource the source representing the library containing the Dar t file 2437 * @param librarySource the source representing the library containing the Dar t file
2438 * @param dartEntry the cache entry associated with the Dart file 2438 * @param dartEntry the cache entry associated with the Dart file
2439 * @param descriptor the descriptor representing the data to be returned 2439 * @param descriptor the descriptor representing the data to be returned
2440 * @return a cache entry containing the required data 2440 * @return a cache entry containing the required data
2441 * @throws AnalysisException if data could not be returned because the source could not be parsed 2441 * @throws AnalysisException if data could not be returned because the source could not be parsed
(...skipping 14 matching lines...) Expand all
2456 throw new AnalysisException("Could not resolve compilation unit ${unitSo urce.fullName} in ${librarySource.fullName}"); 2456 throw new AnalysisException("Could not resolve compilation unit ${unitSo urce.fullName} in ${librarySource.fullName}");
2457 } 2457 }
2458 dartEntry = new GenerateDartErrorsTask(this, unitSource, dartEntry.modific ationTime, unit, library).perform(_resultRecorder) as DartEntry; 2458 dartEntry = new GenerateDartErrorsTask(this, unitSource, dartEntry.modific ationTime, unit, library).perform(_resultRecorder) as DartEntry;
2459 state = dartEntry.getStateInLibrary(descriptor, librarySource); 2459 state = dartEntry.getStateInLibrary(descriptor, librarySource);
2460 } 2460 }
2461 return dartEntry; 2461 return dartEntry;
2462 } 2462 }
2463 2463
2464 /** 2464 /**
2465 * Given a source for an HTML file, return a cache entry in which all of the d ata represented by 2465 * Given a source for an HTML file, return a cache entry in which all of the d ata represented by
2466 * the state of the given descriptors is either [CacheState#VALID] or 2466 * the state of the given descriptors is either [CacheState.VALID] or
2467 * [CacheState#ERROR]. This method assumes that the data can be produced by pa rsing the 2467 * [CacheState.ERROR]. This method assumes that the data can be produced by pa rsing the
2468 * source if it is not already cached. 2468 * source if it is not already cached.
2469 * 2469 *
2470 * <b>Note:</b> This method cannot be used in an async environment. 2470 * <b>Note:</b> This method cannot be used in an async environment.
2471 * 2471 *
2472 * @param source the source representing the HTML file 2472 * @param source the source representing the HTML file
2473 * @param htmlEntry the cache entry associated with the HTML file 2473 * @param htmlEntry the cache entry associated with the HTML file
2474 * @param descriptor the descriptor representing the data to be returned 2474 * @param descriptor the descriptor representing the data to be returned
2475 * @return a cache entry containing the required data 2475 * @return a cache entry containing the required data
2476 * @throws AnalysisException if data could not be returned because the source could not be 2476 * @throws AnalysisException if data could not be returned because the source could not be
2477 * resolved 2477 * resolved
(...skipping 24 matching lines...) Expand all
2502 } catch (exception, stackTrace) { 2502 } catch (exception, stackTrace) {
2503 throw new AnalysisException("Exception", new CaughtException(exception, stackTrace)); 2503 throw new AnalysisException("Exception", new CaughtException(exception, stackTrace));
2504 } 2504 }
2505 state = htmlEntry.getState(descriptor); 2505 state = htmlEntry.getState(descriptor);
2506 } 2506 }
2507 return htmlEntry; 2507 return htmlEntry;
2508 } 2508 }
2509 2509
2510 /** 2510 /**
2511 * Given a source for an HTML file, return a cache entry in which the state of the data 2511 * Given a source for an HTML file, return a cache entry in which the state of the data
2512 * represented by the given descriptor is either [CacheState#VALID] or 2512 * represented by the given descriptor is either [CacheState.VALID] or
2513 * [CacheState#ERROR]. This method assumes that the data can be produced by re solving the 2513 * [CacheState.ERROR]. This method assumes that the data can be produced by re solving the
2514 * source if it is not already cached. 2514 * source if it is not already cached.
2515 * 2515 *
2516 * <b>Note:</b> This method cannot be used in an async environment. 2516 * <b>Note:</b> This method cannot be used in an async environment.
2517 * 2517 *
2518 * @param source the source representing the HTML file 2518 * @param source the source representing the HTML file
2519 * @param dartEntry the cache entry associated with the HTML file 2519 * @param dartEntry the cache entry associated with the HTML file
2520 * @param descriptor the descriptor representing the data to be returned 2520 * @param descriptor the descriptor representing the data to be returned
2521 * @return a cache entry containing the required data 2521 * @return a cache entry containing the required data
2522 * @throws AnalysisException if data could not be returned because the source could not be 2522 * @throws AnalysisException if data could not be returned because the source could not be
2523 * resolved 2523 * resolved
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2615 * Create a [GenerateDartErrorsTask] for the given source, marking the verific ation errors 2615 * Create a [GenerateDartErrorsTask] for the given source, marking the verific ation errors
2616 * as being in-process. The compilation unit and the library can be the same i f the compilation 2616 * as being in-process. The compilation unit and the library can be the same i f the compilation
2617 * unit is the defining compilation unit of the library. 2617 * unit is the defining compilation unit of the library.
2618 * 2618 *
2619 * @param unitSource the source for the compilation unit to be verified 2619 * @param unitSource the source for the compilation unit to be verified
2620 * @param unitEntry the entry for the compilation unit 2620 * @param unitEntry the entry for the compilation unit
2621 * @param librarySource the source for the library containing the compilation unit 2621 * @param librarySource the source for the library containing the compilation unit
2622 * @param libraryEntry the entry for the library 2622 * @param libraryEntry the entry for the library
2623 * @return task data representing the created task 2623 * @return task data representing the created task
2624 */ 2624 */
2625 AnalysisContextImpl_TaskData _createGenerateDartErrorsTask(Source unitSource, DartEntryImpl unitEntry, Source librarySource, DartEntry libraryEntry) { 2625 AnalysisContextImpl_TaskData _createGenerateDartErrorsTask(Source unitSource, DartEntry unitEntry, Source librarySource, DartEntry libraryEntry) {
2626 if (unitEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) != C acheState.VALID || libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID) { 2626 if (unitEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) != C acheState.VALID || libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID) {
2627 return _createResolveDartLibraryTask(librarySource, libraryEntry); 2627 return _createResolveDartLibraryTask(librarySource, libraryEntry);
2628 } 2628 }
2629 CompilationUnit unit = unitEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource); 2629 CompilationUnit unit = unitEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource);
2630 if (unit == null) { 2630 if (unit == null) {
2631 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); 2631 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);
2632 AnalysisEngine.instance.logger.logInformation2(exception.toString(), excep tion); 2632 AnalysisEngine.instance.logger.logInformation2(exception.toString(), excep tion);
2633 unitEntry.recordResolutionError(exception); 2633 unitEntry.recordResolutionError(exception);
2634 return new AnalysisContextImpl_TaskData(null, false); 2634 return new AnalysisContextImpl_TaskData(null, false);
2635 } 2635 }
2636 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); 2636 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT);
2637 unitEntry.setStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource, Ca cheState.IN_PROCESS); 2637 unitEntry.setStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource, Ca cheState.IN_PROCESS);
2638 return new AnalysisContextImpl_TaskData(new GenerateDartErrorsTask(this, uni tSource, unitEntry.modificationTime, unit, libraryElement), false); 2638 return new AnalysisContextImpl_TaskData(new GenerateDartErrorsTask(this, uni tSource, unitEntry.modificationTime, unit, libraryElement), false);
2639 } 2639 }
2640 2640
2641 /** 2641 /**
2642 * Create a [GenerateDartHintsTask] for the given source, marking the hints as being 2642 * Create a [GenerateDartHintsTask] for the given source, marking the hints as being
2643 * in-process. 2643 * in-process.
2644 * 2644 *
2645 * @param source the source whose content is to be verified 2645 * @param source the source whose content is to be verified
2646 * @param dartEntry the entry for the source 2646 * @param dartEntry the entry for the source
2647 * @param librarySource the source for the library containing the source 2647 * @param librarySource the source for the library containing the source
2648 * @param libraryEntry the entry for the library 2648 * @param libraryEntry the entry for the library
2649 * @return task data representing the created task 2649 * @return task data representing the created task
2650 */ 2650 */
2651 AnalysisContextImpl_TaskData _createGenerateDartHintsTask(Source source, DartE ntryImpl dartEntry, Source librarySource, DartEntry libraryEntry) { 2651 AnalysisContextImpl_TaskData _createGenerateDartHintsTask(Source source, DartE ntry dartEntry, Source librarySource, DartEntry libraryEntry) {
2652 if (libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID) { 2652 if (libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID) {
2653 return _createResolveDartLibraryTask(librarySource, libraryEntry); 2653 return _createResolveDartLibraryTask(librarySource, libraryEntry);
2654 } 2654 }
2655 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); 2655 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT);
2656 CompilationUnitElement definingUnit = libraryElement.definingCompilationUnit ; 2656 CompilationUnitElement definingUnit = libraryElement.definingCompilationUnit ;
2657 List<CompilationUnitElement> parts = libraryElement.parts; 2657 List<CompilationUnitElement> parts = libraryElement.parts;
2658 List<TimestampedData<CompilationUnit>> units = new List<TimestampedData>(par ts.length + 1); 2658 List<TimestampedData<CompilationUnit>> units = new List<TimestampedData>(par ts.length + 1);
2659 units[0] = _getResolvedUnit(definingUnit, librarySource); 2659 units[0] = _getResolvedUnit(definingUnit, librarySource);
2660 if (units[0] == null) { 2660 if (units[0] == null) {
2661 // TODO(brianwilkerson) We should return a ResolveDartUnitTask (unless the re are multiple ASTs 2661 // TODO(brianwilkerson) We should return a ResolveDartUnitTask (unless the re are multiple ASTs
(...skipping 12 matching lines...) Expand all
2674 return new AnalysisContextImpl_TaskData(new GenerateDartHintsTask(this, unit s, libraryElement), false); 2674 return new AnalysisContextImpl_TaskData(new GenerateDartHintsTask(this, unit s, libraryElement), false);
2675 } 2675 }
2676 2676
2677 /** 2677 /**
2678 * Create a [GetContentTask] for the given source, marking the content as bein g in-process. 2678 * Create a [GetContentTask] for the given source, marking the content as bein g in-process.
2679 * 2679 *
2680 * @param source the source whose content is to be accessed 2680 * @param source the source whose content is to be accessed
2681 * @param sourceEntry the entry for the source 2681 * @param sourceEntry the entry for the source
2682 * @return task data representing the created task 2682 * @return task data representing the created task
2683 */ 2683 */
2684 AnalysisContextImpl_TaskData _createGetContentTask(Source source, SourceEntryI mpl sourceEntry) { 2684 AnalysisContextImpl_TaskData _createGetContentTask(Source source, SourceEntry sourceEntry) {
2685 sourceEntry.setState(SourceEntry.CONTENT, CacheState.IN_PROCESS); 2685 sourceEntry.setState(SourceEntry.CONTENT, CacheState.IN_PROCESS);
2686 return new AnalysisContextImpl_TaskData(new GetContentTask(this, source), fa lse); 2686 return new AnalysisContextImpl_TaskData(new GetContentTask(this, source), fa lse);
2687 } 2687 }
2688 2688
2689 /** 2689 /**
2690 * Create a [ParseDartTask] for the given source, marking the parse errors as being 2690 * Create a [ParseDartTask] for the given source, marking the parse errors as being
2691 * in-process. 2691 * in-process.
2692 * 2692 *
2693 * @param source the source whose content is to be parsed 2693 * @param source the source whose content is to be parsed
2694 * @param dartEntry the entry for the source 2694 * @param dartEntry the entry for the source
2695 * @return task data representing the created task 2695 * @return task data representing the created task
2696 */ 2696 */
2697 AnalysisContextImpl_TaskData _createParseDartTask(Source source, DartEntryImpl dartEntry) { 2697 AnalysisContextImpl_TaskData _createParseDartTask(Source source, DartEntry dar tEntry) {
2698 if (dartEntry.getState(DartEntry.TOKEN_STREAM) != CacheState.VALID || dartEn try.getState(SourceEntry.LINE_INFO) != CacheState.VALID) { 2698 if (dartEntry.getState(DartEntry.TOKEN_STREAM) != CacheState.VALID || dartEn try.getState(SourceEntry.LINE_INFO) != CacheState.VALID) {
2699 return _createScanDartTask(source, dartEntry); 2699 return _createScanDartTask(source, dartEntry);
2700 } 2700 }
2701 Token tokenStream = dartEntry.getValue(DartEntry.TOKEN_STREAM); 2701 Token tokenStream = dartEntry.getValue(DartEntry.TOKEN_STREAM);
2702 dartEntry.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED); 2702 dartEntry.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED);
2703 dartEntry.setState(DartEntry.PARSE_ERRORS, CacheState.IN_PROCESS); 2703 dartEntry.setState(DartEntry.PARSE_ERRORS, CacheState.IN_PROCESS);
2704 return new AnalysisContextImpl_TaskData(new ParseDartTask(this, source, dart Entry.modificationTime, tokenStream, dartEntry.getValue(SourceEntry.LINE_INFO)), false); 2704 return new AnalysisContextImpl_TaskData(new ParseDartTask(this, source, dart Entry.modificationTime, tokenStream, dartEntry.getValue(SourceEntry.LINE_INFO)), false);
2705 } 2705 }
2706 2706
2707 /** 2707 /**
2708 * Create a [ParseHtmlTask] for the given source, marking the parse errors as being 2708 * Create a [ParseHtmlTask] for the given source, marking the parse errors as being
2709 * in-process. 2709 * in-process.
2710 * 2710 *
2711 * @param source the source whose content is to be parsed 2711 * @param source the source whose content is to be parsed
2712 * @param htmlEntry the entry for the source 2712 * @param htmlEntry the entry for the source
2713 * @return task data representing the created task 2713 * @return task data representing the created task
2714 */ 2714 */
2715 AnalysisContextImpl_TaskData _createParseHtmlTask(Source source, HtmlEntryImpl htmlEntry) { 2715 AnalysisContextImpl_TaskData _createParseHtmlTask(Source source, HtmlEntry htm lEntry) {
2716 if (htmlEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { 2716 if (htmlEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) {
2717 return _createGetContentTask(source, htmlEntry); 2717 return _createGetContentTask(source, htmlEntry);
2718 } 2718 }
2719 String content = htmlEntry.getValue(SourceEntry.CONTENT); 2719 String content = htmlEntry.getValue(SourceEntry.CONTENT);
2720 htmlEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED); 2720 htmlEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED);
2721 htmlEntry.setState(HtmlEntry.PARSE_ERRORS, CacheState.IN_PROCESS); 2721 htmlEntry.setState(HtmlEntry.PARSE_ERRORS, CacheState.IN_PROCESS);
2722 return new AnalysisContextImpl_TaskData(new ParseHtmlTask(this, source, html Entry.modificationTime, content), false); 2722 return new AnalysisContextImpl_TaskData(new ParseHtmlTask(this, source, html Entry.modificationTime, content), false);
2723 } 2723 }
2724 2724
2725 /** 2725 /**
2726 * Create a [PolymerBuildHtmlTask] for the given source, marking the Polymer e lements as 2726 * Create a [PolymerBuildHtmlTask] for the given source, marking the Polymer e lements as
2727 * being in-process. 2727 * being in-process.
2728 * 2728 *
2729 * @param source the source whose content is to be processed 2729 * @param source the source whose content is to be processed
2730 * @param htmlEntry the entry for the source 2730 * @param htmlEntry the entry for the source
2731 * @return task data representing the created task 2731 * @return task data representing the created task
2732 */ 2732 */
2733 AnalysisContextImpl_TaskData _createPolymerBuildHtmlTask(Source source, HtmlEn tryImpl htmlEntry) { 2733 AnalysisContextImpl_TaskData _createPolymerBuildHtmlTask(Source source, HtmlEn try htmlEntry) {
2734 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) { 2734 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) {
2735 return _createResolveHtmlTask(source, htmlEntry); 2735 return _createResolveHtmlTask(source, htmlEntry);
2736 } 2736 }
2737 htmlEntry.setState(HtmlEntry.POLYMER_BUILD_ERRORS, CacheState.IN_PROCESS); 2737 htmlEntry.setState(HtmlEntry.POLYMER_BUILD_ERRORS, CacheState.IN_PROCESS);
2738 return new AnalysisContextImpl_TaskData(new PolymerBuildHtmlTask(this, sourc e, htmlEntry.modificationTime, htmlEntry.getValue(SourceEntry.LINE_INFO), htmlEn try.getValue(HtmlEntry.RESOLVED_UNIT)), false); 2738 return new AnalysisContextImpl_TaskData(new PolymerBuildHtmlTask(this, sourc e, htmlEntry.modificationTime, htmlEntry.getValue(SourceEntry.LINE_INFO), htmlEn try.getValue(HtmlEntry.RESOLVED_UNIT)), false);
2739 } 2739 }
2740 2740
2741 /** 2741 /**
2742 * Create a [PolymerResolveHtmlTask] for the given source, marking the Polymer errors as 2742 * Create a [PolymerResolveHtmlTask] for the given source, marking the Polymer errors as
2743 * being in-process. 2743 * being in-process.
2744 * 2744 *
2745 * @param source the source whose content is to be resolved 2745 * @param source the source whose content is to be resolved
2746 * @param htmlEntry the entry for the source 2746 * @param htmlEntry the entry for the source
2747 * @return task data representing the created task 2747 * @return task data representing the created task
2748 */ 2748 */
2749 AnalysisContextImpl_TaskData _createPolymerResolveHtmlTask(Source source, Html EntryImpl htmlEntry) { 2749 AnalysisContextImpl_TaskData _createPolymerResolveHtmlTask(Source source, Html Entry htmlEntry) {
2750 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) { 2750 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) {
2751 return _createResolveHtmlTask(source, htmlEntry); 2751 return _createResolveHtmlTask(source, htmlEntry);
2752 } 2752 }
2753 htmlEntry.setState(HtmlEntry.POLYMER_RESOLUTION_ERRORS, CacheState.IN_PROCES S); 2753 htmlEntry.setState(HtmlEntry.POLYMER_RESOLUTION_ERRORS, CacheState.IN_PROCES S);
2754 return new AnalysisContextImpl_TaskData(new PolymerResolveHtmlTask(this, sou rce, htmlEntry.modificationTime, htmlEntry.getValue(SourceEntry.LINE_INFO), html Entry.getValue(HtmlEntry.RESOLVED_UNIT)), false); 2754 return new AnalysisContextImpl_TaskData(new PolymerResolveHtmlTask(this, sou rce, htmlEntry.modificationTime, htmlEntry.getValue(SourceEntry.LINE_INFO), html Entry.getValue(HtmlEntry.RESOLVED_UNIT)), false);
2755 } 2755 }
2756 2756
2757 /** 2757 /**
2758 * Create a [ResolveAngularComponentTemplateTask] for the given source, markin g the angular 2758 * Create a [ResolveAngularComponentTemplateTask] for the given source, markin g the angular
2759 * errors as being in-process. 2759 * errors as being in-process.
2760 * 2760 *
2761 * @param source the source whose content is to be resolved 2761 * @param source the source whose content is to be resolved
2762 * @param htmlEntry the entry for the source 2762 * @param htmlEntry the entry for the source
2763 * @return task data representing the created task 2763 * @return task data representing the created task
2764 */ 2764 */
2765 AnalysisContextImpl_TaskData _createResolveAngularComponentTemplateTask(Source source, HtmlEntryImpl htmlEntry) { 2765 AnalysisContextImpl_TaskData _createResolveAngularComponentTemplateTask(Source source, HtmlEntry htmlEntry) {
2766 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) { 2766 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) {
2767 return _createResolveHtmlTask(source, htmlEntry); 2767 return _createResolveHtmlTask(source, htmlEntry);
2768 } 2768 }
2769 AngularApplication application = htmlEntry.getValue(HtmlEntry.ANGULAR_APPLIC ATION); 2769 AngularApplication application = htmlEntry.getValue(HtmlEntry.ANGULAR_APPLIC ATION);
2770 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANGULAR_COM PONENT); 2770 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANGULAR_COM PONENT);
2771 htmlEntry.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.IN_PROCESS); 2771 htmlEntry.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.IN_PROCESS);
2772 return new AnalysisContextImpl_TaskData(new ResolveAngularComponentTemplateT ask(this, source, htmlEntry.modificationTime, htmlEntry.getValue(HtmlEntry.RESOL VED_UNIT), component, application), false); 2772 return new AnalysisContextImpl_TaskData(new ResolveAngularComponentTemplateT ask(this, source, htmlEntry.modificationTime, htmlEntry.getValue(HtmlEntry.RESOL VED_UNIT), component, application), false);
2773 } 2773 }
2774 2774
2775 /** 2775 /**
2776 * Create a [ResolveAngularEntryHtmlTask] for the given source, marking the an gular entry as 2776 * Create a [ResolveAngularEntryHtmlTask] for the given source, marking the an gular entry as
2777 * being in-process. 2777 * being in-process.
2778 * 2778 *
2779 * @param source the source whose content is to be resolved 2779 * @param source the source whose content is to be resolved
2780 * @param htmlEntry the entry for the source 2780 * @param htmlEntry the entry for the source
2781 * @return task data representing the created task 2781 * @return task data representing the created task
2782 */ 2782 */
2783 AnalysisContextImpl_TaskData _createResolveAngularEntryHtmlTask(Source source, HtmlEntryImpl htmlEntry) { 2783 AnalysisContextImpl_TaskData _createResolveAngularEntryHtmlTask(Source source, HtmlEntry htmlEntry) {
2784 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) { 2784 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) {
2785 return _createResolveHtmlTask(source, htmlEntry); 2785 return _createResolveHtmlTask(source, htmlEntry);
2786 } 2786 }
2787 htmlEntry.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.IN_PROCESS); 2787 htmlEntry.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.IN_PROCESS);
2788 return new AnalysisContextImpl_TaskData(new ResolveAngularEntryHtmlTask(this , source, htmlEntry.modificationTime, htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT )), false); 2788 return new AnalysisContextImpl_TaskData(new ResolveAngularEntryHtmlTask(this , source, htmlEntry.modificationTime, htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT )), false);
2789 } 2789 }
2790 2790
2791 /** 2791 /**
2792 * Create a [ResolveDartLibraryTask] for the given source, marking ? as being in-process. 2792 * Create a [ResolveDartLibraryTask] for the given source, marking ? as being in-process.
2793 * 2793 *
2794 * @param source the source whose content is to be resolved 2794 * @param source the source whose content is to be resolved
2795 * @param dartEntry the entry for the source 2795 * @param dartEntry the entry for the source
2796 * @return task data representing the created task 2796 * @return task data representing the created task
2797 */ 2797 */
2798 AnalysisContextImpl_TaskData _createResolveDartLibraryTask(Source source, Dart EntryImpl dartEntry) { 2798 AnalysisContextImpl_TaskData _createResolveDartLibraryTask(Source source, Dart Entry dartEntry) {
2799 try { 2799 try {
2800 AnalysisContextImpl_CycleBuilder builder = new AnalysisContextImpl_CycleBu ilder(this); 2800 AnalysisContextImpl_CycleBuilder builder = new AnalysisContextImpl_CycleBu ilder(this);
2801 builder.computeCycleContaining(source); 2801 builder.computeCycleContaining(source);
2802 AnalysisContextImpl_TaskData taskData = builder.taskData; 2802 AnalysisContextImpl_TaskData taskData = builder.taskData;
2803 if (taskData != null) { 2803 if (taskData != null) {
2804 return taskData; 2804 return taskData;
2805 } 2805 }
2806 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryCycleTask(th is, source, source, builder.librariesInCycle), false); 2806 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryCycleTask(th is, source, source, builder.librariesInCycle), false);
2807 } on AnalysisException catch (exception, stackTrace) { 2807 } on AnalysisException catch (exception, stackTrace) {
2808 dartEntry.recordResolutionError(new CaughtException(exception, stackTrace) ); 2808 dartEntry.recordResolutionError(new CaughtException(exception, stackTrace) );
2809 AnalysisEngine.instance.logger.logError2("Internal error trying to create a ResolveDartLibraryTask", new CaughtException(exception, stackTrace)); 2809 AnalysisEngine.instance.logger.logError2("Internal error trying to create a ResolveDartLibraryTask", new CaughtException(exception, stackTrace));
2810 } 2810 }
2811 return new AnalysisContextImpl_TaskData(null, false); 2811 return new AnalysisContextImpl_TaskData(null, false);
2812 } 2812 }
2813 2813
2814 /** 2814 /**
2815 * Create a [ResolveHtmlTask] for the given source, marking the resolved unit as being 2815 * Create a [ResolveHtmlTask] for the given source, marking the resolved unit as being
2816 * in-process. 2816 * in-process.
2817 * 2817 *
2818 * @param source the source whose content is to be resolved 2818 * @param source the source whose content is to be resolved
2819 * @param htmlEntry the entry for the source 2819 * @param htmlEntry the entry for the source
2820 * @return task data representing the created task 2820 * @return task data representing the created task
2821 */ 2821 */
2822 AnalysisContextImpl_TaskData _createResolveHtmlTask(Source source, HtmlEntryIm pl htmlEntry) { 2822 AnalysisContextImpl_TaskData _createResolveHtmlTask(Source source, HtmlEntry h tmlEntry) {
2823 if (htmlEntry.getState(HtmlEntry.PARSED_UNIT) != CacheState.VALID) { 2823 if (htmlEntry.getState(HtmlEntry.PARSED_UNIT) != CacheState.VALID) {
2824 return _createParseHtmlTask(source, htmlEntry); 2824 return _createParseHtmlTask(source, htmlEntry);
2825 } 2825 }
2826 htmlEntry.setState(HtmlEntry.RESOLVED_UNIT, CacheState.IN_PROCESS); 2826 htmlEntry.setState(HtmlEntry.RESOLVED_UNIT, CacheState.IN_PROCESS);
2827 return new AnalysisContextImpl_TaskData(new ResolveHtmlTask(this, source, ht mlEntry.modificationTime, htmlEntry.getValue(HtmlEntry.PARSED_UNIT)), false); 2827 return new AnalysisContextImpl_TaskData(new ResolveHtmlTask(this, source, ht mlEntry.modificationTime, htmlEntry.getValue(HtmlEntry.PARSED_UNIT)), false);
2828 } 2828 }
2829 2829
2830 /** 2830 /**
2831 * Create a [ScanDartTask] for the given source, marking the scan errors as be ing 2831 * Create a [ScanDartTask] for the given source, marking the scan errors as be ing
2832 * in-process. 2832 * in-process.
2833 * 2833 *
2834 * @param source the source whose content is to be scanned 2834 * @param source the source whose content is to be scanned
2835 * @param dartEntry the entry for the source 2835 * @param dartEntry the entry for the source
2836 * @return task data representing the created task 2836 * @return task data representing the created task
2837 */ 2837 */
2838 AnalysisContextImpl_TaskData _createScanDartTask(Source source, DartEntryImpl dartEntry) { 2838 AnalysisContextImpl_TaskData _createScanDartTask(Source source, DartEntry dart Entry) {
2839 if (dartEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { 2839 if (dartEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) {
2840 return _createGetContentTask(source, dartEntry); 2840 return _createGetContentTask(source, dartEntry);
2841 } 2841 }
2842 String content = dartEntry.getValue(SourceEntry.CONTENT); 2842 String content = dartEntry.getValue(SourceEntry.CONTENT);
2843 dartEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED); 2843 dartEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED);
2844 dartEntry.setState(DartEntry.SCAN_ERRORS, CacheState.IN_PROCESS); 2844 dartEntry.setState(DartEntry.SCAN_ERRORS, CacheState.IN_PROCESS);
2845 return new AnalysisContextImpl_TaskData(new ScanDartTask(this, source, dartE ntry.modificationTime, content), false); 2845 return new AnalysisContextImpl_TaskData(new ScanDartTask(this, source, dartE ntry.modificationTime, content), false);
2846 } 2846 }
2847 2847
2848 /** 2848 /**
2849 * Create a source information object suitable for the given source. Return th e source information 2849 * Create a source information object suitable for the given source. Return th e source information
2850 * object that was created, or `null` if the source should not be tracked by t his context. 2850 * object that was created, or `null` if the source should not be tracked by t his context.
2851 * 2851 *
2852 * @param source the source for which an information object is being created 2852 * @param source the source for which an information object is being created
2853 * @param explicitlyAdded `true` if the source was explicitly added to the con text 2853 * @param explicitlyAdded `true` if the source was explicitly added to the con text
2854 * @return the source information object that was created 2854 * @return the source information object that was created
2855 */ 2855 */
2856 SourceEntry _createSourceEntry(Source source, bool explicitlyAdded) { 2856 SourceEntry _createSourceEntry(Source source, bool explicitlyAdded) {
2857 String name = source.shortName; 2857 String name = source.shortName;
2858 if (AnalysisEngine.isHtmlFileName(name)) { 2858 if (AnalysisEngine.isHtmlFileName(name)) {
2859 HtmlEntryImpl htmlEntry = new HtmlEntryImpl(); 2859 HtmlEntry htmlEntry = new HtmlEntry();
2860 htmlEntry.modificationTime = getModificationStamp(source); 2860 htmlEntry.modificationTime = getModificationStamp(source);
2861 htmlEntry.explicitlyAdded = explicitlyAdded; 2861 htmlEntry.explicitlyAdded = explicitlyAdded;
2862 _cache.put(source, htmlEntry); 2862 _cache.put(source, htmlEntry);
2863 return htmlEntry; 2863 return htmlEntry;
2864 } else { 2864 } else {
2865 DartEntryImpl dartEntry = new DartEntryImpl(); 2865 DartEntry dartEntry = new DartEntry();
2866 dartEntry.modificationTime = getModificationStamp(source); 2866 dartEntry.modificationTime = getModificationStamp(source);
2867 dartEntry.explicitlyAdded = explicitlyAdded; 2867 dartEntry.explicitlyAdded = explicitlyAdded;
2868 _cache.put(source, dartEntry); 2868 _cache.put(source, dartEntry);
2869 return dartEntry; 2869 return dartEntry;
2870 } 2870 }
2871 } 2871 }
2872 2872
2873 /** 2873 /**
2874 * Return a string with debugging information about the given source (the full name and 2874 * Return a string with debugging information about the given source (the full name and
2875 * modification stamp of the source). 2875 * modification stamp of the source).
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
3280 return _createGetContentTask(source, sourceEntry); 3280 return _createGetContentTask(source, sourceEntry);
3281 } else if (contentState == CacheState.IN_PROCESS) { 3281 } else if (contentState == CacheState.IN_PROCESS) {
3282 // We are already in the process of getting the content. There's nothing e lse we can do with 3282 // We are already in the process of getting the content. There's nothing e lse we can do with
3283 // this source until that's complete. 3283 // this source until that's complete.
3284 return new AnalysisContextImpl_TaskData(null, true); 3284 return new AnalysisContextImpl_TaskData(null, true);
3285 } else if (contentState == CacheState.ERROR) { 3285 } else if (contentState == CacheState.ERROR) {
3286 // We have done all of the analysis we can for this source because we cann ot get its content. 3286 // We have done all of the analysis we can for this source because we cann ot get its content.
3287 return new AnalysisContextImpl_TaskData(null, false); 3287 return new AnalysisContextImpl_TaskData(null, false);
3288 } 3288 }
3289 if (sourceEntry is DartEntry) { 3289 if (sourceEntry is DartEntry) {
3290 DartEntryImpl dartEntry = sourceEntry; 3290 DartEntry dartEntry = sourceEntry;
3291 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS); 3291 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS);
3292 if (scanErrorsState == CacheState.INVALID || (isPriority && scanErrorsStat e == CacheState.FLUSHED)) { 3292 if (scanErrorsState == CacheState.INVALID || (isPriority && scanErrorsStat e == CacheState.FLUSHED)) {
3293 return _createScanDartTask(source, dartEntry); 3293 return _createScanDartTask(source, dartEntry);
3294 } 3294 }
3295 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); 3295 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS);
3296 if (parseErrorsState == CacheState.INVALID || (isPriority && parseErrorsSt ate == CacheState.FLUSHED)) { 3296 if (parseErrorsState == CacheState.INVALID || (isPriority && parseErrorsSt ate == CacheState.FLUSHED)) {
3297 return _createParseDartTask(source, dartEntry); 3297 return _createParseDartTask(source, dartEntry);
3298 } 3298 }
3299 if (isPriority && parseErrorsState != CacheState.ERROR) { 3299 if (isPriority && parseErrorsState != CacheState.ERROR) {
3300 if (!dartEntry.hasResolvableCompilationUnit) { 3300 if (!dartEntry.hasResolvableCompilationUnit) {
3301 return _createParseDartTask(source, dartEntry); 3301 return _createParseDartTask(source, dartEntry);
3302 } 3302 }
3303 } 3303 }
3304 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); 3304 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND);
3305 if (kind == SourceKind.UNKNOWN) { 3305 if (kind == SourceKind.UNKNOWN) {
3306 return _createParseDartTask(source, dartEntry); 3306 return _createParseDartTask(source, dartEntry);
3307 } else if (kind == SourceKind.LIBRARY) { 3307 } else if (kind == SourceKind.LIBRARY) {
3308 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); 3308 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT);
3309 if (elementState == CacheState.INVALID) { 3309 if (elementState == CacheState.INVALID) {
3310 return _createResolveDartLibraryTask(source, dartEntry); 3310 return _createResolveDartLibraryTask(source, dartEntry);
3311 } 3311 }
3312 } 3312 }
3313 List<Source> librariesContaining = dartEntry.getValue(DartEntry.CONTAINING _LIBRARIES); 3313 List<Source> librariesContaining = dartEntry.getValue(DartEntry.CONTAINING _LIBRARIES);
3314 for (Source librarySource in librariesContaining) { 3314 for (Source librarySource in librariesContaining) {
3315 SourceEntry librarySourceEntry = _cache.get(librarySource); 3315 SourceEntry librarySourceEntry = _cache.get(librarySource);
3316 if (librarySourceEntry is DartEntry) { 3316 if (librarySourceEntry is DartEntry) {
3317 DartEntryImpl libraryEntry = librarySourceEntry; 3317 DartEntry libraryEntry = librarySourceEntry;
3318 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); 3318 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT);
3319 if (elementState == CacheState.INVALID || (isPriority && elementState == CacheState.FLUSHED)) { 3319 if (elementState == CacheState.INVALID || (isPriority && elementState == CacheState.FLUSHED)) {
3320 //return createResolveDartLibraryTask(librarySource, (DartEntry) lib raryEntry); 3320 //return createResolveDartLibraryTask(librarySource, (DartEntry) lib raryEntry);
3321 libraryEntry.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS); 3321 libraryEntry.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS);
3322 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t his, source, librarySource), false); 3322 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t his, source, librarySource), false);
3323 } 3323 }
3324 CacheState resolvedUnitState = dartEntry.getStateInLibrary(DartEntry.R ESOLVED_UNIT, librarySource); 3324 CacheState resolvedUnitState = dartEntry.getStateInLibrary(DartEntry.R ESOLVED_UNIT, librarySource);
3325 if (resolvedUnitState == CacheState.INVALID || (isPriority && resolved UnitState == CacheState.FLUSHED)) { 3325 if (resolvedUnitState == CacheState.INVALID || (isPriority && resolved UnitState == CacheState.FLUSHED)) {
3326 // 3326 //
3327 // The commented out lines below are an optimization that doesn't qu ite work yet. The 3327 // The commented out lines below are an optimization that doesn't qu ite work yet. The
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
3637 * @param invalidateUris `true` if the cached results of converting URIs to so urce files 3637 * @param invalidateUris `true` if the cached results of converting URIs to so urce files
3638 * should also be invalidated. 3638 * should also be invalidated.
3639 */ 3639 */
3640 void _invalidateAllLocalResolutionInformation(bool invalidateUris) { 3640 void _invalidateAllLocalResolutionInformation(bool invalidateUris) {
3641 HashMap<Source, List<Source>> oldPartMap = new HashMap<Source, List<Source>> (); 3641 HashMap<Source, List<Source>> oldPartMap = new HashMap<Source, List<Source>> ();
3642 MapIterator<Source, SourceEntry> iterator = _privatePartition.iterator(); 3642 MapIterator<Source, SourceEntry> iterator = _privatePartition.iterator();
3643 while (iterator.moveNext()) { 3643 while (iterator.moveNext()) {
3644 Source source = iterator.key; 3644 Source source = iterator.key;
3645 SourceEntry sourceEntry = iterator.value; 3645 SourceEntry sourceEntry = iterator.value;
3646 if (sourceEntry is HtmlEntry) { 3646 if (sourceEntry is HtmlEntry) {
3647 HtmlEntryImpl htmlEntry = sourceEntry; 3647 HtmlEntry htmlEntry = sourceEntry;
3648 htmlEntry.invalidateAllResolutionInformation(invalidateUris); 3648 htmlEntry.invalidateAllResolutionInformation(invalidateUris);
3649 iterator.value = htmlEntry; 3649 iterator.value = htmlEntry;
3650 _workManager.add(source, SourcePriority.HTML); 3650 _workManager.add(source, SourcePriority.HTML);
3651 } else if (sourceEntry is DartEntry) { 3651 } else if (sourceEntry is DartEntry) {
3652 DartEntryImpl dartEntry = sourceEntry; 3652 DartEntry dartEntry = sourceEntry;
3653 oldPartMap[source] = dartEntry.getValue(DartEntry.INCLUDED_PARTS); 3653 oldPartMap[source] = dartEntry.getValue(DartEntry.INCLUDED_PARTS);
3654 dartEntry.invalidateAllResolutionInformation(invalidateUris); 3654 dartEntry.invalidateAllResolutionInformation(invalidateUris);
3655 iterator.value = dartEntry; 3655 iterator.value = dartEntry;
3656 _workManager.add(source, _computePriority(dartEntry)); 3656 _workManager.add(source, _computePriority(dartEntry));
3657 } 3657 }
3658 } 3658 }
3659 _removeFromPartsUsingMap(oldPartMap); 3659 _removeFromPartsUsingMap(oldPartMap);
3660 } 3660 }
3661 3661
3662 /** 3662 /**
3663 * In response to a change to Angular entry point [HtmlElement], invalidate an y results that 3663 * In response to a change to Angular entry point [HtmlElement], invalidate an y results that
3664 * depend on it. 3664 * depend on it.
3665 * 3665 *
3666 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 3666 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
3667 * 3667 *
3668 * <b>Note:</b> Any cache entries that were accessed before this method was in voked must be 3668 * <b>Note:</b> Any cache entries that were accessed before this method was in voked must be
3669 * re-accessed after this method returns. 3669 * re-accessed after this method returns.
3670 * 3670 *
3671 * @param entryCopy the [HtmlEntryImpl] of the (maybe) Angular entry point bei ng invalidated 3671 * @param entryCopy the [HtmlEntry] of the (maybe) Angular entry point being i nvalidated
3672 */ 3672 */
3673 void _invalidateAngularResolution(HtmlEntryImpl entryCopy) { 3673 void _invalidateAngularResolution(HtmlEntry entryCopy) {
3674 AngularApplication application = entryCopy.getValue(HtmlEntry.ANGULAR_ENTRY) ; 3674 AngularApplication application = entryCopy.getValue(HtmlEntry.ANGULAR_ENTRY) ;
3675 if (application == null) { 3675 if (application == null) {
3676 return; 3676 return;
3677 } 3677 }
3678 _angularApplications.remove(application); 3678 _angularApplications.remove(application);
3679 // invalidate Entry 3679 // invalidate Entry
3680 entryCopy.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.INVALID); 3680 entryCopy.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.INVALID);
3681 // reset HTML sources 3681 // reset HTML sources
3682 List<AngularElement> oldAngularElements = application.elements; 3682 List<AngularElement> oldAngularElements = application.elements;
3683 for (AngularElement angularElement in oldAngularElements) { 3683 for (AngularElement angularElement in oldAngularElements) {
3684 if (angularElement is AngularHasTemplateElement) { 3684 if (angularElement is AngularHasTemplateElement) {
3685 AngularHasTemplateElement hasTemplate = angularElement; 3685 AngularHasTemplateElement hasTemplate = angularElement;
3686 Source templateSource = hasTemplate.templateSource; 3686 Source templateSource = hasTemplate.templateSource;
3687 if (templateSource != null) { 3687 if (templateSource != null) {
3688 HtmlEntryImpl htmlEntry = _getReadableHtmlEntry(templateSource); 3688 HtmlEntry htmlEntry = _getReadableHtmlEntry(templateSource);
3689 htmlEntry.setValue(HtmlEntry.ANGULAR_APPLICATION, null); 3689 htmlEntry.setValue(HtmlEntry.ANGULAR_APPLICATION, null);
3690 htmlEntry.setValue(HtmlEntry.ANGULAR_COMPONENT, null); 3690 htmlEntry.setValue(HtmlEntry.ANGULAR_COMPONENT, null);
3691 htmlEntry.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID); 3691 htmlEntry.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID);
3692 _workManager.add(templateSource, SourcePriority.HTML); 3692 _workManager.add(templateSource, SourcePriority.HTML);
3693 } 3693 }
3694 } 3694 }
3695 } 3695 }
3696 // reset Dart sources 3696 // reset Dart sources
3697 List<Source> oldElementSources = application.elementSources; 3697 List<Source> oldElementSources = application.elementSources;
3698 for (Source elementSource in oldElementSources) { 3698 for (Source elementSource in oldElementSources) {
3699 DartEntryImpl dartEntry = _getReadableDartEntry(elementSource); 3699 DartEntry dartEntry = _getReadableDartEntry(elementSource);
3700 dartEntry.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS); 3700 dartEntry.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS);
3701 // notify about (disappeared) Angular errors 3701 // notify about (disappeared) Angular errors
3702 ChangeNoticeImpl notice = _getNotice(elementSource); 3702 ChangeNoticeImpl notice = _getNotice(elementSource);
3703 notice.setErrors(dartEntry.allErrors, dartEntry.getValue(SourceEntry.LINE_ INFO)); 3703 notice.setErrors(dartEntry.allErrors, dartEntry.getValue(SourceEntry.LINE_ INFO));
3704 } 3704 }
3705 } 3705 }
3706 3706
3707 /** 3707 /**
3708 * In response to a change to at least one of the compilation units in the giv en library, 3708 * In response to a change to at least one of the compilation units in the giv en library,
3709 * invalidate any results that are dependent on the result of resolving that l ibrary. 3709 * invalidate any results that are dependent on the result of resolving that l ibrary.
3710 * 3710 *
3711 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 3711 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
3712 * 3712 *
3713 * <b>Note:</b> Any cache entries that were accessed before this method was in voked must be 3713 * <b>Note:</b> Any cache entries that were accessed before this method was in voked must be
3714 * re-accessed after this method returns. 3714 * re-accessed after this method returns.
3715 * 3715 *
3716 * @param librarySource the source of the library being invalidated 3716 * @param librarySource the source of the library being invalidated
3717 */ 3717 */
3718 void _invalidateLibraryResolution(Source librarySource) { 3718 void _invalidateLibraryResolution(Source librarySource) {
3719 // TODO(brianwilkerson) This could be optimized. There's no need to flush al l of these entries 3719 // TODO(brianwilkerson) This could be optimized. There's no need to flush al l of these entries
3720 // if the public namespace hasn't changed, which will be a fairly common cas e. The question is 3720 // if the public namespace hasn't changed, which will be a fairly common cas e. The question is
3721 // whether we can afford the time to compute the namespace to look for diffe rences. 3721 // whether we can afford the time to compute the namespace to look for diffe rences.
3722 DartEntryImpl libraryEntry = _getReadableDartEntry(librarySource); 3722 DartEntry libraryEntry = _getReadableDartEntry(librarySource);
3723 if (libraryEntry != null) { 3723 if (libraryEntry != null) {
3724 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART S); 3724 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART S);
3725 libraryEntry.invalidateAllResolutionInformation(false); 3725 libraryEntry.invalidateAllResolutionInformation(false);
3726 _workManager.add(librarySource, SourcePriority.LIBRARY); 3726 _workManager.add(librarySource, SourcePriority.LIBRARY);
3727 for (Source partSource in includedParts) { 3727 for (Source partSource in includedParts) {
3728 SourceEntry partEntry = _cache.get(partSource); 3728 SourceEntry partEntry = _cache.get(partSource);
3729 if (partEntry is DartEntry) { 3729 if (partEntry is DartEntry) {
3730 (partEntry as DartEntryImpl).invalidateAllResolutionInformation(false) ; 3730 partEntry.invalidateAllResolutionInformation(false);
3731 } 3731 }
3732 } 3732 }
3733 } 3733 }
3734 // invalidate Angular applications 3734 // invalidate Angular applications
3735 List<AngularApplication> angularApplicationsCopy = []; 3735 List<AngularApplication> angularApplicationsCopy = [];
3736 for (AngularApplication application in angularApplicationsCopy) { 3736 for (AngularApplication application in angularApplicationsCopy) {
3737 if (application.dependsOn(librarySource)) { 3737 if (application.dependsOn(librarySource)) {
3738 Source entryPointSource = application.entryPoint; 3738 Source entryPointSource = application.entryPoint;
3739 HtmlEntryImpl htmlEntry = _getReadableHtmlEntry(entryPointSource); 3739 HtmlEntry htmlEntry = _getReadableHtmlEntry(entryPointSource);
3740 _invalidateAngularResolution(htmlEntry); 3740 _invalidateAngularResolution(htmlEntry);
3741 _workManager.add(entryPointSource, SourcePriority.HTML); 3741 _workManager.add(entryPointSource, SourcePriority.HTML);
3742 } 3742 }
3743 } 3743 }
3744 } 3744 }
3745 3745
3746 /** 3746 /**
3747 * Return `true` if this library is, or depends on, dart:html. 3747 * Return `true` if this library is, or depends on, dart:html.
3748 * 3748 *
3749 * @param library the library being tested 3749 * @param library the library being tested
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
3899 int count = _listeners.length; 3899 int count = _listeners.length;
3900 for (int i = 0; i < count; i++) { 3900 for (int i = 0; i < count; i++) {
3901 _listeners[i].resolvedHtml(this, source, unit); 3901 _listeners[i].resolvedHtml(this, source, unit);
3902 } 3902 }
3903 } 3903 }
3904 3904
3905 /** 3905 /**
3906 * Updates [HtmlEntry]s that correspond to the previously known and new Angula r application 3906 * Updates [HtmlEntry]s that correspond to the previously known and new Angula r application
3907 * information. 3907 * information.
3908 */ 3908 */
3909 void _recordAngularEntryPoint(HtmlEntryImpl entry, ResolveAngularEntryHtmlTask task) { 3909 void _recordAngularEntryPoint(HtmlEntry entry, ResolveAngularEntryHtmlTask tas k) {
3910 AngularApplication application = task.application; 3910 AngularApplication application = task.application;
3911 if (application != null) { 3911 if (application != null) {
3912 _angularApplications.add(application); 3912 _angularApplications.add(application);
3913 // if this is an entry point, then we already resolved it 3913 // if this is an entry point, then we already resolved it
3914 entry.setValue(HtmlEntry.ANGULAR_ERRORS, task.entryErrors); 3914 entry.setValue(HtmlEntry.ANGULAR_ERRORS, task.entryErrors);
3915 // schedule HTML templates analysis 3915 // schedule HTML templates analysis
3916 List<AngularElement> newAngularElements = application.elements; 3916 List<AngularElement> newAngularElements = application.elements;
3917 for (AngularElement angularElement in newAngularElements) { 3917 for (AngularElement angularElement in newAngularElements) {
3918 if (angularElement is AngularHasTemplateElement) { 3918 if (angularElement is AngularHasTemplateElement) {
3919 AngularHasTemplateElement hasTemplate = angularElement; 3919 AngularHasTemplateElement hasTemplate = angularElement;
3920 Source templateSource = hasTemplate.templateSource; 3920 Source templateSource = hasTemplate.templateSource;
3921 if (templateSource != null) { 3921 if (templateSource != null) {
3922 HtmlEntryImpl htmlEntry = _getReadableHtmlEntry(templateSource); 3922 HtmlEntry htmlEntry = _getReadableHtmlEntry(templateSource);
3923 htmlEntry.setValue(HtmlEntry.ANGULAR_APPLICATION, application); 3923 htmlEntry.setValue(HtmlEntry.ANGULAR_APPLICATION, application);
3924 if (hasTemplate is AngularComponentElement) { 3924 if (hasTemplate is AngularComponentElement) {
3925 AngularComponentElement component = hasTemplate; 3925 AngularComponentElement component = hasTemplate;
3926 htmlEntry.setValue(HtmlEntry.ANGULAR_COMPONENT, component); 3926 htmlEntry.setValue(HtmlEntry.ANGULAR_COMPONENT, component);
3927 } 3927 }
3928 htmlEntry.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID); 3928 htmlEntry.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID);
3929 _workManager.add(templateSource, SourcePriority.HTML); 3929 _workManager.add(templateSource, SourcePriority.HTML);
3930 } 3930 }
3931 } 3931 }
3932 } 3932 }
3933 // update Dart sources errors 3933 // update Dart sources errors
3934 List<Source> newElementSources = application.elementSources; 3934 List<Source> newElementSources = application.elementSources;
3935 for (Source elementSource in newElementSources) { 3935 for (Source elementSource in newElementSources) {
3936 DartEntryImpl dartEntry = _getReadableDartEntry(elementSource); 3936 DartEntry dartEntry = _getReadableDartEntry(elementSource);
3937 dartEntry.setValue(DartEntry.ANGULAR_ERRORS, task.getErrors(elementSourc e)); 3937 dartEntry.setValue(DartEntry.ANGULAR_ERRORS, task.getErrors(elementSourc e));
3938 // notify about Dart errors 3938 // notify about Dart errors
3939 ChangeNoticeImpl notice = _getNotice(elementSource); 3939 ChangeNoticeImpl notice = _getNotice(elementSource);
3940 notice.setErrors(dartEntry.allErrors, computeLineInfo(elementSource)); 3940 notice.setErrors(dartEntry.allErrors, computeLineInfo(elementSource));
3941 } 3941 }
3942 } 3942 }
3943 // remember Angular entry point 3943 // remember Angular entry point
3944 entry.setValue(HtmlEntry.ANGULAR_ENTRY, application); 3944 entry.setValue(HtmlEntry.ANGULAR_ENTRY, application);
3945 } 3945 }
3946 3946
3947 /** 3947 /**
3948 * Given a cache entry and a library element, record the library element and o ther information 3948 * Given a cache entry and a library element, record the library element and o ther information
3949 * gleaned from the element in the cache entry. 3949 * gleaned from the element in the cache entry.
3950 * 3950 *
3951 * @param dartCopy the cache entry in which data is to be recorded 3951 * @param dartCopy the cache entry in which data is to be recorded
3952 * @param library the library element used to record information 3952 * @param library the library element used to record information
3953 * @param librarySource the source for the library used to record information 3953 * @param librarySource the source for the library used to record information
3954 * @param htmlSource the source for the HTML library 3954 * @param htmlSource the source for the HTML library
3955 */ 3955 */
3956 void _recordElementData(DartEntryImpl dartEntry, LibraryElement library, Sourc e librarySource, Source htmlSource) { 3956 void _recordElementData(DartEntry dartEntry, LibraryElement library, Source li brarySource, Source htmlSource) {
3957 dartEntry.setValue(DartEntry.ELEMENT, library); 3957 dartEntry.setValue(DartEntry.ELEMENT, library);
3958 dartEntry.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); 3958 dartEntry.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null);
3959 dartEntry.setValue(DartEntry.IS_CLIENT, _isClient(library, htmlSource, new H ashSet<LibraryElement>())); 3959 dartEntry.setValue(DartEntry.IS_CLIENT, _isClient(library, htmlSource, new H ashSet<LibraryElement>()));
3960 } 3960 }
3961 3961
3962 /** 3962 /**
3963 * Record the results produced by performing a [GenerateDartErrorsTask]. If th e results were 3963 * Record the results produced by performing a [GenerateDartErrorsTask]. If th e results were
3964 * computed from data that is now out-of-date, then the results will not be re corded. 3964 * computed from data that is now out-of-date, then the results will not be re corded.
3965 * 3965 *
3966 * @param task the task that was performed 3966 * @param task the task that was performed
3967 * @return an entry containing the computed results 3967 * @return an entry containing the computed results
3968 * @throws AnalysisException if the results could not be recorded 3968 * @throws AnalysisException if the results could not be recorded
3969 */ 3969 */
3970 DartEntry _recordGenerateDartErrorsTask(GenerateDartErrorsTask task) { 3970 DartEntry _recordGenerateDartErrorsTask(GenerateDartErrorsTask task) {
3971 Source source = task.source; 3971 Source source = task.source;
3972 Source librarySource = task.libraryElement.source; 3972 Source librarySource = task.libraryElement.source;
3973 CaughtException thrownException = task.exception; 3973 CaughtException thrownException = task.exception;
3974 DartEntryImpl dartEntry = null;
3975 SourceEntry sourceEntry = _cache.get(source); 3974 SourceEntry sourceEntry = _cache.get(source);
3976 if (sourceEntry == null) { 3975 if (sourceEntry == null) {
3977 throw new ObsoleteSourceAnalysisException(source); 3976 throw new ObsoleteSourceAnalysisException(source);
3978 } else if (sourceEntry is! DartEntry) { 3977 } else if (sourceEntry is! DartEntry) {
3979 // This shouldn't be possible because we should never have performed the t ask if the source 3978 // This shouldn't be possible because we should never have performed the t ask if the source
3980 // didn't represent a Dart file, but check to be safe. 3979 // didn't represent a Dart file, but check to be safe.
3981 throw new AnalysisException("Internal error: attempting to verify non-Dart file as a Dart file: ${source.fullName}"); 3980 throw new AnalysisException("Internal error: attempting to verify non-Dart file as a Dart file: ${source.fullName}");
3982 } 3981 }
3983 dartEntry = sourceEntry as DartEntry; 3982 DartEntry dartEntry = sourceEntry;
3984 int sourceTime = getModificationStamp(source); 3983 int sourceTime = getModificationStamp(source);
3985 int resultTime = task.modificationTime; 3984 int resultTime = task.modificationTime;
3986 if (sourceTime == resultTime) { 3985 if (sourceTime == resultTime) {
3987 if (dartEntry.modificationTime != sourceTime) { 3986 if (dartEntry.modificationTime != sourceTime) {
3988 // The source has changed without the context being notified. Simulate n otification. 3987 // The source has changed without the context being notified. Simulate n otification.
3989 _sourceChanged(source); 3988 _sourceChanged(source);
3990 dartEntry = _getReadableDartEntry(source); 3989 dartEntry = _getReadableDartEntry(source);
3991 if (dartEntry == null) { 3990 if (dartEntry == null) {
3992 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}"); 3991 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}");
3993 } 3992 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
4047 if (sourceEntry == null) { 4046 if (sourceEntry == null) {
4048 throw new ObsoleteSourceAnalysisException(librarySource); 4047 throw new ObsoleteSourceAnalysisException(librarySource);
4049 } else if (sourceEntry is! DartEntry) { 4048 } else if (sourceEntry is! DartEntry) {
4050 // This shouldn't be possible because we should never have performed the task if the source 4049 // This shouldn't be possible because we should never have performed the task if the source
4051 // didn't represent a Dart file, but check to be safe. 4050 // didn't represent a Dart file, but check to be safe.
4052 throw new AnalysisException("Internal error: attempting to generate hint s for non-Dart file as a Dart file: ${librarySource.fullName}"); 4051 throw new AnalysisException("Internal error: attempting to generate hint s for non-Dart file as a Dart file: ${librarySource.fullName}");
4053 } 4052 }
4054 if (thrownException == null) { 4053 if (thrownException == null) {
4055 thrownException = new CaughtException(new AnalysisException("GenerateDar tHintsTask returned a null hint map without throwing an exception: ${librarySour ce.fullName}"), null); 4054 thrownException = new CaughtException(new AnalysisException("GenerateDar tHintsTask returned a null hint map without throwing an exception: ${librarySour ce.fullName}"), null);
4056 } 4055 }
4057 (sourceEntry as DartEntryImpl).recordHintErrorInLibrary(librarySource, thr ownException); 4056 (sourceEntry as DartEntry).recordHintErrorInLibrary(librarySource, thrownE xception);
4058 throw new AnalysisException('<rethrow>', thrownException); 4057 throw new AnalysisException('<rethrow>', thrownException);
4059 } 4058 }
4060 for (MapEntry<Source, TimestampedData<List<AnalysisError>>> entry in getMapE ntrySet(hintMap)) { 4059 for (MapEntry<Source, TimestampedData<List<AnalysisError>>> entry in getMapE ntrySet(hintMap)) {
4061 Source unitSource = entry.getKey(); 4060 Source unitSource = entry.getKey();
4062 TimestampedData<List<AnalysisError>> results = entry.getValue(); 4061 TimestampedData<List<AnalysisError>> results = entry.getValue();
4063 SourceEntry sourceEntry = _cache.get(unitSource); 4062 SourceEntry sourceEntry = _cache.get(unitSource);
4064 if (sourceEntry is! DartEntry) { 4063 if (sourceEntry is! DartEntry) {
4065 // This shouldn't be possible because we should never have performed the task if the source 4064 // This shouldn't be possible because we should never have performed the task if the source
4066 // didn't represent a Dart file, but check to be safe. 4065 // didn't represent a Dart file, but check to be safe.
4067 throw new AnalysisException("Internal error: attempting to parse non-Dar t file as a Dart file: ${unitSource.fullName}"); 4066 throw new AnalysisException("Internal error: attempting to parse non-Dar t file as a Dart file: ${unitSource.fullName}");
4068 } 4067 }
4069 DartEntryImpl dartEntry = sourceEntry; 4068 DartEntry dartEntry = sourceEntry;
4070 if (unitSource == librarySource) { 4069 if (unitSource == librarySource) {
4071 libraryEntry = dartEntry; 4070 libraryEntry = dartEntry;
4072 } 4071 }
4073 int sourceTime = getModificationStamp(unitSource); 4072 int sourceTime = getModificationStamp(unitSource);
4074 int resultTime = results.modificationTime; 4073 int resultTime = results.modificationTime;
4075 if (sourceTime == resultTime) { 4074 if (sourceTime == resultTime) {
4076 if (dartEntry.modificationTime != sourceTime) { 4075 if (dartEntry.modificationTime != sourceTime) {
4077 // The source has changed without the context being notified. Simulate notification. 4076 // The source has changed without the context being notified. Simulate notification.
4078 _sourceChanged(unitSource); 4077 _sourceChanged(unitSource);
4079 dartEntry = _getReadableDartEntry(unitSource); 4078 dartEntry = _getReadableDartEntry(unitSource);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4125 * @param task the task that was performed 4124 * @param task the task that was performed
4126 * @return an entry containing the computed results 4125 * @return an entry containing the computed results
4127 * @throws AnalysisException if the results could not be recorded 4126 * @throws AnalysisException if the results could not be recorded
4128 */ 4127 */
4129 SourceEntry _recordGetContentsTask(GetContentTask task) { 4128 SourceEntry _recordGetContentsTask(GetContentTask task) {
4130 if (!task.isComplete) { 4129 if (!task.isComplete) {
4131 return null; 4130 return null;
4132 } 4131 }
4133 Source source = task.source; 4132 Source source = task.source;
4134 CaughtException thrownException = task.exception; 4133 CaughtException thrownException = task.exception;
4135 SourceEntryImpl sourceEntry = null; 4134 SourceEntry sourceEntry = _cache.get(source);
4136 sourceEntry = _cache.get(source);
4137 if (sourceEntry == null) { 4135 if (sourceEntry == null) {
4138 throw new ObsoleteSourceAnalysisException(source); 4136 throw new ObsoleteSourceAnalysisException(source);
4139 } 4137 }
4140 if (thrownException == null) { 4138 if (thrownException == null) {
4141 sourceEntry.modificationTime = task.modificationTime; 4139 sourceEntry.modificationTime = task.modificationTime;
4142 sourceEntry.setValue(SourceEntry.CONTENT, task.content); 4140 sourceEntry.setValue(SourceEntry.CONTENT, task.content);
4143 } else { 4141 } else {
4144 sourceEntry.recordContentError(thrownException); 4142 sourceEntry.recordContentError(thrownException);
4145 _workManager.remove(source); 4143 _workManager.remove(source);
4146 } 4144 }
(...skipping 24 matching lines...) Expand all
4171 * Record the results produced by performing a [ParseDartTask]. If the results were computed 4169 * Record the results produced by performing a [ParseDartTask]. If the results were computed
4172 * from data that is now out-of-date, then the results will not be recorded. 4170 * from data that is now out-of-date, then the results will not be recorded.
4173 * 4171 *
4174 * @param task the task that was performed 4172 * @param task the task that was performed
4175 * @return an entry containing the computed results 4173 * @return an entry containing the computed results
4176 * @throws AnalysisException if the results could not be recorded 4174 * @throws AnalysisException if the results could not be recorded
4177 */ 4175 */
4178 DartEntry _recordParseDartTaskResults(ParseDartTask task) { 4176 DartEntry _recordParseDartTaskResults(ParseDartTask task) {
4179 Source source = task.source; 4177 Source source = task.source;
4180 CaughtException thrownException = task.exception; 4178 CaughtException thrownException = task.exception;
4181 DartEntryImpl dartEntry = null;
4182 SourceEntry sourceEntry = _cache.get(source); 4179 SourceEntry sourceEntry = _cache.get(source);
4183 if (sourceEntry == null) { 4180 if (sourceEntry == null) {
4184 throw new ObsoleteSourceAnalysisException(source); 4181 throw new ObsoleteSourceAnalysisException(source);
4185 } else if (sourceEntry is! DartEntry) { 4182 } else if (sourceEntry is! DartEntry) {
4186 // This shouldn't be possible because we should never have performed the t ask if the source 4183 // This shouldn't be possible because we should never have performed the t ask if the source
4187 // didn't represent a Dart file, but check to be safe. 4184 // didn't represent a Dart file, but check to be safe.
4188 throw new AnalysisException("Internal error: attempting to parse non-Dart file as a Dart file: ${source.fullName}"); 4185 throw new AnalysisException("Internal error: attempting to parse non-Dart file as a Dart file: ${source.fullName}");
4189 } 4186 }
4190 dartEntry = sourceEntry as DartEntry; 4187 DartEntry dartEntry = sourceEntry as DartEntry;
4191 int sourceTime = getModificationStamp(source); 4188 int sourceTime = getModificationStamp(source);
4192 int resultTime = task.modificationTime; 4189 int resultTime = task.modificationTime;
4193 if (sourceTime == resultTime) { 4190 if (sourceTime == resultTime) {
4194 if (dartEntry.modificationTime != sourceTime) { 4191 if (dartEntry.modificationTime != sourceTime) {
4195 // The source has changed without the context being notified. Simulate n otification. 4192 // The source has changed without the context being notified. Simulate n otification.
4196 _sourceChanged(source); 4193 _sourceChanged(source);
4197 dartEntry = _getReadableDartEntry(source); 4194 dartEntry = _getReadableDartEntry(source);
4198 if (dartEntry == null) { 4195 if (dartEntry == null) {
4199 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}"); 4196 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}");
4200 } 4197 }
(...skipping 17 matching lines...) Expand all
4218 _workManager.add(source, SourcePriority.NORMAL_PART); 4215 _workManager.add(source, SourcePriority.NORMAL_PART);
4219 } else { 4216 } else {
4220 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); 4217 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
4221 dartEntry.containingLibrary = source; 4218 dartEntry.containingLibrary = source;
4222 _workManager.add(source, SourcePriority.LIBRARY); 4219 _workManager.add(source, SourcePriority.LIBRARY);
4223 } 4220 }
4224 } 4221 }
4225 List<Source> newParts = task.includedSources; 4222 List<Source> newParts = task.includedSources;
4226 for (int i = 0; i < newParts.length; i++) { 4223 for (int i = 0; i < newParts.length; i++) {
4227 Source partSource = newParts[i]; 4224 Source partSource = newParts[i];
4228 DartEntryImpl partEntry = _getReadableDartEntry(partSource); 4225 DartEntry partEntry = _getReadableDartEntry(partSource);
4229 if (partEntry != null && !identical(partEntry, dartEntry)) { 4226 if (partEntry != null && !identical(partEntry, dartEntry)) {
4230 // TODO(brianwilkerson) Change the kind of the "part" if it was mark ed as a library 4227 // TODO(brianwilkerson) Change the kind of the "part" if it was mark ed as a library
4231 // and it has no directives. 4228 // and it has no directives.
4232 partEntry.addContainingLibrary(source); 4229 partEntry.addContainingLibrary(source);
4233 } 4230 }
4234 } 4231 }
4235 dartEntry.setValue(DartEntry.PARSED_UNIT, task.compilationUnit); 4232 dartEntry.setValue(DartEntry.PARSED_UNIT, task.compilationUnit);
4236 dartEntry.setValue(DartEntry.PARSE_ERRORS, task.errors); 4233 dartEntry.setValue(DartEntry.PARSE_ERRORS, task.errors);
4237 dartEntry.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources); 4234 dartEntry.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources);
4238 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources); 4235 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
4288 Source source = task.source; 4285 Source source = task.source;
4289 CaughtException thrownException = task.exception; 4286 CaughtException thrownException = task.exception;
4290 SourceEntry sourceEntry = _cache.get(source); 4287 SourceEntry sourceEntry = _cache.get(source);
4291 if (sourceEntry == null) { 4288 if (sourceEntry == null) {
4292 throw new ObsoleteSourceAnalysisException(source); 4289 throw new ObsoleteSourceAnalysisException(source);
4293 } else if (sourceEntry is! HtmlEntry) { 4290 } else if (sourceEntry is! HtmlEntry) {
4294 // This shouldn't be possible because we should never have performed the t ask if the source 4291 // This shouldn't be possible because we should never have performed the t ask if the source
4295 // didn't represent an HTML file, but check to be safe. 4292 // didn't represent an HTML file, but check to be safe.
4296 throw new AnalysisException("Internal error: attempting to parse non-HTML file as a HTML file: ${source.fullName}"); 4293 throw new AnalysisException("Internal error: attempting to parse non-HTML file as a HTML file: ${source.fullName}");
4297 } 4294 }
4298 HtmlEntryImpl htmlEntry = sourceEntry; 4295 HtmlEntry htmlEntry = sourceEntry;
4299 int sourceTime = getModificationStamp(source); 4296 int sourceTime = getModificationStamp(source);
4300 int resultTime = task.modificationTime; 4297 int resultTime = task.modificationTime;
4301 if (sourceTime == resultTime) { 4298 if (sourceTime == resultTime) {
4302 if (htmlEntry.modificationTime != sourceTime) { 4299 if (htmlEntry.modificationTime != sourceTime) {
4303 // The source has changed without the context being notified. Simulate n otification. 4300 // The source has changed without the context being notified. Simulate n otification.
4304 _sourceChanged(source); 4301 _sourceChanged(source);
4305 htmlEntry = _getReadableHtmlEntry(source); 4302 htmlEntry = _getReadableHtmlEntry(source);
4306 if (htmlEntry == null) { 4303 if (htmlEntry == null) {
4307 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4304 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4308 } 4305 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
4366 Source source = task.source; 4363 Source source = task.source;
4367 CaughtException thrownException = task.exception; 4364 CaughtException thrownException = task.exception;
4368 SourceEntry sourceEntry = _cache.get(source); 4365 SourceEntry sourceEntry = _cache.get(source);
4369 if (sourceEntry == null) { 4366 if (sourceEntry == null) {
4370 throw new ObsoleteSourceAnalysisException(source); 4367 throw new ObsoleteSourceAnalysisException(source);
4371 } else if (sourceEntry is! HtmlEntry) { 4368 } else if (sourceEntry is! HtmlEntry) {
4372 // This shouldn't be possible because we should never have performed the t ask if the source 4369 // This shouldn't be possible because we should never have performed the t ask if the source
4373 // didn't represent an HTML file, but check to be safe. 4370 // didn't represent an HTML file, but check to be safe.
4374 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4371 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}");
4375 } 4372 }
4376 HtmlEntryImpl htmlEntry = sourceEntry; 4373 HtmlEntry htmlEntry = sourceEntry;
4377 int sourceTime = getModificationStamp(source); 4374 int sourceTime = getModificationStamp(source);
4378 int resultTime = task.modificationTime; 4375 int resultTime = task.modificationTime;
4379 if (sourceTime == resultTime) { 4376 if (sourceTime == resultTime) {
4380 if (htmlEntry.modificationTime != sourceTime) { 4377 if (htmlEntry.modificationTime != sourceTime) {
4381 // The source has changed without the context being notified. Simulate n otification. 4378 // The source has changed without the context being notified. Simulate n otification.
4382 _sourceChanged(source); 4379 _sourceChanged(source);
4383 htmlEntry = _getReadableHtmlEntry(source); 4380 htmlEntry = _getReadableHtmlEntry(source);
4384 if (htmlEntry == null) { 4381 if (htmlEntry == null) {
4385 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4382 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4386 } 4383 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
4428 Source source = task.source; 4425 Source source = task.source;
4429 CaughtException thrownException = task.exception; 4426 CaughtException thrownException = task.exception;
4430 SourceEntry sourceEntry = _cache.get(source); 4427 SourceEntry sourceEntry = _cache.get(source);
4431 if (sourceEntry == null) { 4428 if (sourceEntry == null) {
4432 throw new ObsoleteSourceAnalysisException(source); 4429 throw new ObsoleteSourceAnalysisException(source);
4433 } else if (sourceEntry is! HtmlEntry) { 4430 } else if (sourceEntry is! HtmlEntry) {
4434 // This shouldn't be possible because we should never have performed the t ask if the source 4431 // This shouldn't be possible because we should never have performed the t ask if the source
4435 // didn't represent an HTML file, but check to be safe. 4432 // didn't represent an HTML file, but check to be safe.
4436 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4433 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}");
4437 } 4434 }
4438 HtmlEntryImpl htmlEntry = sourceEntry; 4435 HtmlEntry htmlEntry = sourceEntry;
4439 int sourceTime = getModificationStamp(source); 4436 int sourceTime = getModificationStamp(source);
4440 int resultTime = task.modificationTime; 4437 int resultTime = task.modificationTime;
4441 if (sourceTime == resultTime) { 4438 if (sourceTime == resultTime) {
4442 if (htmlEntry.modificationTime != sourceTime) { 4439 if (htmlEntry.modificationTime != sourceTime) {
4443 // The source has changed without the context being notified. Simulate n otification. 4440 // The source has changed without the context being notified. Simulate n otification.
4444 _sourceChanged(source); 4441 _sourceChanged(source);
4445 htmlEntry = _getReadableHtmlEntry(source); 4442 htmlEntry = _getReadableHtmlEntry(source);
4446 if (htmlEntry == null) { 4443 if (htmlEntry == null) {
4447 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4444 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4448 } 4445 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
4490 Source source = task.source; 4487 Source source = task.source;
4491 CaughtException thrownException = task.exception; 4488 CaughtException thrownException = task.exception;
4492 SourceEntry sourceEntry = _cache.get(source); 4489 SourceEntry sourceEntry = _cache.get(source);
4493 if (sourceEntry == null) { 4490 if (sourceEntry == null) {
4494 throw new ObsoleteSourceAnalysisException(source); 4491 throw new ObsoleteSourceAnalysisException(source);
4495 } else if (sourceEntry is! HtmlEntry) { 4492 } else if (sourceEntry is! HtmlEntry) {
4496 // This shouldn't be possible because we should never have performed the t ask if the source 4493 // This shouldn't be possible because we should never have performed the t ask if the source
4497 // didn't represent an HTML file, but check to be safe. 4494 // didn't represent an HTML file, but check to be safe.
4498 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4495 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}");
4499 } 4496 }
4500 HtmlEntryImpl htmlEntry = sourceEntry; 4497 HtmlEntry htmlEntry = sourceEntry;
4501 int sourceTime = getModificationStamp(source); 4498 int sourceTime = getModificationStamp(source);
4502 int resultTime = task.modificationTime; 4499 int resultTime = task.modificationTime;
4503 if (sourceTime == resultTime) { 4500 if (sourceTime == resultTime) {
4504 if (htmlEntry.modificationTime != sourceTime) { 4501 if (htmlEntry.modificationTime != sourceTime) {
4505 // The source has changed without the context being notified. Simulate n otification. 4502 // The source has changed without the context being notified. Simulate n otification.
4506 _sourceChanged(source); 4503 _sourceChanged(source);
4507 htmlEntry = _getReadableHtmlEntry(source); 4504 htmlEntry = _getReadableHtmlEntry(source);
4508 if (htmlEntry == null) { 4505 if (htmlEntry == null) {
4509 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4506 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4510 } 4507 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
4554 /** 4551 /**
4555 * Record the results produced by performing a [ResolveAngularEntryHtmlTask]. If the results 4552 * Record the results produced by performing a [ResolveAngularEntryHtmlTask]. If the results
4556 * were computed from data that is now out-of-date, then the results will not be recorded. 4553 * were computed from data that is now out-of-date, then the results will not be recorded.
4557 * 4554 *
4558 * @param task the task that was performed 4555 * @param task the task that was performed
4559 * @throws AnalysisException if the results could not be recorded 4556 * @throws AnalysisException if the results could not be recorded
4560 */ 4557 */
4561 HtmlEntry _recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTas k task) { 4558 HtmlEntry _recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTas k task) {
4562 Source source = task.source; 4559 Source source = task.source;
4563 CaughtException thrownException = task.exception; 4560 CaughtException thrownException = task.exception;
4564 HtmlEntryImpl htmlEntry = null;
4565 SourceEntry sourceEntry = _cache.get(source); 4561 SourceEntry sourceEntry = _cache.get(source);
4566 if (sourceEntry == null) { 4562 if (sourceEntry == null) {
4567 throw new ObsoleteSourceAnalysisException(source); 4563 throw new ObsoleteSourceAnalysisException(source);
4568 } else if (sourceEntry is! HtmlEntry) { 4564 } else if (sourceEntry is! HtmlEntry) {
4569 // This shouldn't be possible because we should never have performed the t ask if the source 4565 // This shouldn't be possible because we should never have performed the t ask if the source
4570 // didn't represent an HTML file, but check to be safe. 4566 // didn't represent an HTML file, but check to be safe.
4571 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4567 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}");
4572 } 4568 }
4573 htmlEntry = sourceEntry as HtmlEntry; 4569 HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
4574 int sourceTime = getModificationStamp(source); 4570 int sourceTime = getModificationStamp(source);
4575 int resultTime = task.modificationTime; 4571 int resultTime = task.modificationTime;
4576 if (sourceTime == resultTime) { 4572 if (sourceTime == resultTime) {
4577 if (htmlEntry.modificationTime != sourceTime) { 4573 if (htmlEntry.modificationTime != sourceTime) {
4578 // The source has changed without the context being notified. Simulate n otification. 4574 // The source has changed without the context being notified. Simulate n otification.
4579 _sourceChanged(source); 4575 _sourceChanged(source);
4580 htmlEntry = _getReadableHtmlEntry(source); 4576 htmlEntry = _getReadableHtmlEntry(source);
4581 if (htmlEntry == null) { 4577 if (htmlEntry == null) {
4582 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4578 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4583 } 4579 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4630 * computed from data that is now out-of-date, then the results will not be re corded. 4626 * computed from data that is now out-of-date, then the results will not be re corded.
4631 * 4627 *
4632 * @param task the task that was performed 4628 * @param task the task that was performed
4633 * @return an entry containing the computed results 4629 * @return an entry containing the computed results
4634 * @throws AnalysisException if the results could not be recorded 4630 * @throws AnalysisException if the results could not be recorded
4635 */ 4631 */
4636 DartEntry _recordResolveDartUnitTaskResults(ResolveDartUnitTask task) { 4632 DartEntry _recordResolveDartUnitTaskResults(ResolveDartUnitTask task) {
4637 Source unitSource = task.source; 4633 Source unitSource = task.source;
4638 Source librarySource = task.librarySource; 4634 Source librarySource = task.librarySource;
4639 CaughtException thrownException = task.exception; 4635 CaughtException thrownException = task.exception;
4640 DartEntryImpl dartEntry = null;
4641 SourceEntry sourceEntry = _cache.get(unitSource); 4636 SourceEntry sourceEntry = _cache.get(unitSource);
4642 if (sourceEntry == null) { 4637 if (sourceEntry == null) {
4643 throw new ObsoleteSourceAnalysisException(unitSource); 4638 throw new ObsoleteSourceAnalysisException(unitSource);
4644 } else if (sourceEntry is! DartEntry) { 4639 } else if (sourceEntry is! DartEntry) {
4645 // This shouldn't be possible because we should never have performed the t ask if the source 4640 // This shouldn't be possible because we should never have performed the t ask if the source
4646 // didn't represent a Dart file, but check to be safe. 4641 // didn't represent a Dart file, but check to be safe.
4647 throw new AnalysisException("Internal error: attempting to resolve non-Dar t file as a Dart file: ${unitSource.fullName}"); 4642 throw new AnalysisException("Internal error: attempting to resolve non-Dar t file as a Dart file: ${unitSource.fullName}");
4648 } 4643 }
4649 dartEntry = sourceEntry as DartEntry; 4644 DartEntry dartEntry = sourceEntry as DartEntry;
4650 int sourceTime = getModificationStamp(unitSource); 4645 int sourceTime = getModificationStamp(unitSource);
4651 int resultTime = task.modificationTime; 4646 int resultTime = task.modificationTime;
4652 if (sourceTime == resultTime) { 4647 if (sourceTime == resultTime) {
4653 if (dartEntry.modificationTime != sourceTime) { 4648 if (dartEntry.modificationTime != sourceTime) {
4654 // The source has changed without the context being notified. Simulate n otification. 4649 // The source has changed without the context being notified. Simulate n otification.
4655 _sourceChanged(unitSource); 4650 _sourceChanged(unitSource);
4656 dartEntry = _getReadableDartEntry(unitSource); 4651 dartEntry = _getReadableDartEntry(unitSource);
4657 if (dartEntry == null) { 4652 if (dartEntry == null) {
4658 throw new AnalysisException("A Dart file became a non-Dart file: ${uni tSource.fullName}"); 4653 throw new AnalysisException("A Dart file became a non-Dart file: ${uni tSource.fullName}");
4659 } 4654 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4699 * Record the results produced by performing a [ResolveHtmlTask]. If the resul ts were 4694 * Record the results produced by performing a [ResolveHtmlTask]. If the resul ts were
4700 * computed from data that is now out-of-date, then the results will not be re corded. 4695 * computed from data that is now out-of-date, then the results will not be re corded.
4701 * 4696 *
4702 * @param task the task that was performed 4697 * @param task the task that was performed
4703 * @return an entry containing the computed results 4698 * @return an entry containing the computed results
4704 * @throws AnalysisException if the results could not be recorded 4699 * @throws AnalysisException if the results could not be recorded
4705 */ 4700 */
4706 HtmlEntry _recordResolveHtmlTaskResults(ResolveHtmlTask task) { 4701 HtmlEntry _recordResolveHtmlTaskResults(ResolveHtmlTask task) {
4707 Source source = task.source; 4702 Source source = task.source;
4708 CaughtException thrownException = task.exception; 4703 CaughtException thrownException = task.exception;
4709 HtmlEntryImpl htmlEntry = null;
4710 SourceEntry sourceEntry = _cache.get(source); 4704 SourceEntry sourceEntry = _cache.get(source);
4711 if (sourceEntry == null) { 4705 if (sourceEntry == null) {
4712 throw new ObsoleteSourceAnalysisException(source); 4706 throw new ObsoleteSourceAnalysisException(source);
4713 } else if (sourceEntry is! HtmlEntry) { 4707 } else if (sourceEntry is! HtmlEntry) {
4714 // This shouldn't be possible because we should never have performed the t ask if the source 4708 // This shouldn't be possible because we should never have performed the t ask if the source
4715 // didn't represent an HTML file, but check to be safe. 4709 // didn't represent an HTML file, but check to be safe.
4716 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4710 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}");
4717 } 4711 }
4718 htmlEntry = sourceEntry as HtmlEntry; 4712 HtmlEntry htmlEntry = sourceEntry;
4719 int sourceTime = getModificationStamp(source); 4713 int sourceTime = getModificationStamp(source);
4720 int resultTime = task.modificationTime; 4714 int resultTime = task.modificationTime;
4721 if (sourceTime == resultTime) { 4715 if (sourceTime == resultTime) {
4722 if (htmlEntry.modificationTime != sourceTime) { 4716 if (htmlEntry.modificationTime != sourceTime) {
4723 // The source has changed without the context being notified. Simulate n otification. 4717 // The source has changed without the context being notified. Simulate n otification.
4724 _sourceChanged(source); 4718 _sourceChanged(source);
4725 htmlEntry = _getReadableHtmlEntry(source); 4719 htmlEntry = _getReadableHtmlEntry(source);
4726 if (htmlEntry == null) { 4720 if (htmlEntry == null) {
4727 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4721 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4728 } 4722 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4775 * Record the results produced by performing a [ScanDartTask]. If the results were computed 4769 * Record the results produced by performing a [ScanDartTask]. If the results were computed
4776 * from data that is now out-of-date, then the results will not be recorded. 4770 * from data that is now out-of-date, then the results will not be recorded.
4777 * 4771 *
4778 * @param task the task that was performed 4772 * @param task the task that was performed
4779 * @return an entry containing the computed results 4773 * @return an entry containing the computed results
4780 * @throws AnalysisException if the results could not be recorded 4774 * @throws AnalysisException if the results could not be recorded
4781 */ 4775 */
4782 DartEntry _recordScanDartTaskResults(ScanDartTask task) { 4776 DartEntry _recordScanDartTaskResults(ScanDartTask task) {
4783 Source source = task.source; 4777 Source source = task.source;
4784 CaughtException thrownException = task.exception; 4778 CaughtException thrownException = task.exception;
4785 DartEntryImpl dartEntry = null;
4786 SourceEntry sourceEntry = _cache.get(source); 4779 SourceEntry sourceEntry = _cache.get(source);
4787 if (sourceEntry == null) { 4780 if (sourceEntry == null) {
4788 throw new ObsoleteSourceAnalysisException(source); 4781 throw new ObsoleteSourceAnalysisException(source);
4789 } else if (sourceEntry is! DartEntry) { 4782 } else if (sourceEntry is! DartEntry) {
4790 // This shouldn't be possible because we should never have performed the t ask if the source 4783 // This shouldn't be possible because we should never have performed the t ask if the source
4791 // didn't represent a Dart file, but check to be safe. 4784 // didn't represent a Dart file, but check to be safe.
4792 throw new AnalysisException("Internal error: attempting to parse non-Dart file as a Dart file: ${source.fullName}"); 4785 throw new AnalysisException("Internal error: attempting to parse non-Dart file as a Dart file: ${source.fullName}");
4793 } 4786 }
4794 dartEntry = sourceEntry as DartEntry; 4787 DartEntry dartEntry = sourceEntry;
4795 int sourceTime = getModificationStamp(source); 4788 int sourceTime = getModificationStamp(source);
4796 int resultTime = task.modificationTime; 4789 int resultTime = task.modificationTime;
4797 if (sourceTime == resultTime) { 4790 if (sourceTime == resultTime) {
4798 if (dartEntry.modificationTime != sourceTime) { 4791 if (dartEntry.modificationTime != sourceTime) {
4799 // The source has changed without the context being notified. Simulate n otification. 4792 // The source has changed without the context being notified. Simulate n otification.
4800 _sourceChanged(source); 4793 _sourceChanged(source);
4801 dartEntry = _getReadableDartEntry(source); 4794 dartEntry = _getReadableDartEntry(source);
4802 if (dartEntry == null) { 4795 if (dartEntry == null) {
4803 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}"); 4796 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}");
4804 } 4797 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4850 * 4843 *
4851 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4844 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
4852 * 4845 *
4853 * @param librarySource the library to be removed 4846 * @param librarySource the library to be removed
4854 * @param dartEntry the entry containing the list of included parts 4847 * @param dartEntry the entry containing the list of included parts
4855 */ 4848 */
4856 void _removeFromParts(Source librarySource, DartEntry dartEntry) { 4849 void _removeFromParts(Source librarySource, DartEntry dartEntry) {
4857 List<Source> oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS); 4850 List<Source> oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS);
4858 for (int i = 0; i < oldParts.length; i++) { 4851 for (int i = 0; i < oldParts.length; i++) {
4859 Source partSource = oldParts[i]; 4852 Source partSource = oldParts[i];
4860 DartEntryImpl partEntry = _getReadableDartEntry(partSource); 4853 DartEntry partEntry = _getReadableDartEntry(partSource);
4861 if (partEntry != null && !identical(partEntry, dartEntry)) { 4854 if (partEntry != null && !identical(partEntry, dartEntry)) {
4862 partEntry.removeContainingLibrary(librarySource); 4855 partEntry.removeContainingLibrary(librarySource);
4863 if (partEntry.containingLibraries.length == 0 && !exists(partSource)) { 4856 if (partEntry.containingLibraries.length == 0 && !exists(partSource)) {
4864 _cache.remove(partSource); 4857 _cache.remove(partSource);
4865 } 4858 }
4866 } 4859 }
4867 } 4860 }
4868 } 4861 }
4869 4862
4870 /** 4863 /**
4871 * Remove the given libraries that are keys in the given map from the list of containing libraries 4864 * Remove the given libraries that are keys in the given map from the list of containing libraries
4872 * for each of the parts in the corresponding value. 4865 * for each of the parts in the corresponding value.
4873 * 4866 *
4874 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4867 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
4875 * 4868 *
4876 * @param oldPartMap the table containing the parts associated with each libra ry 4869 * @param oldPartMap the table containing the parts associated with each libra ry
4877 */ 4870 */
4878 void _removeFromPartsUsingMap(HashMap<Source, List<Source>> oldPartMap) { 4871 void _removeFromPartsUsingMap(HashMap<Source, List<Source>> oldPartMap) {
4879 for (MapEntry<Source, List<Source>> entry in getMapEntrySet(oldPartMap)) { 4872 for (MapEntry<Source, List<Source>> entry in getMapEntrySet(oldPartMap)) {
4880 Source librarySource = entry.getKey(); 4873 Source librarySource = entry.getKey();
4881 List<Source> oldParts = entry.getValue(); 4874 List<Source> oldParts = entry.getValue();
4882 for (int i = 0; i < oldParts.length; i++) { 4875 for (int i = 0; i < oldParts.length; i++) {
4883 Source partSource = oldParts[i]; 4876 Source partSource = oldParts[i];
4884 if (partSource != librarySource) { 4877 if (partSource != librarySource) {
4885 DartEntryImpl partEntry = _getReadableDartEntry(partSource); 4878 DartEntry partEntry = _getReadableDartEntry(partSource);
4886 if (partEntry != null) { 4879 if (partEntry != null) {
4887 partEntry.removeContainingLibrary(librarySource); 4880 partEntry.removeContainingLibrary(librarySource);
4888 if (partEntry.containingLibraries.length == 0 && !exists(partSource) ) { 4881 if (partEntry.containingLibraries.length == 0 && !exists(partSource) ) {
4889 _cache.remove(partSource); 4882 _cache.remove(partSource);
4890 } 4883 }
4891 } 4884 }
4892 } 4885 }
4893 } 4886 }
4894 } 4887 }
4895 } 4888 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4943 * @param source the source that has been changed 4936 * @param source the source that has been changed
4944 */ 4937 */
4945 void _sourceChanged(Source source) { 4938 void _sourceChanged(Source source) {
4946 SourceEntry sourceEntry = _cache.get(source); 4939 SourceEntry sourceEntry = _cache.get(source);
4947 if (sourceEntry == null || sourceEntry.modificationTime == getModificationSt amp(source)) { 4940 if (sourceEntry == null || sourceEntry.modificationTime == getModificationSt amp(source)) {
4948 // Either we have removed this source, in which case we don't care that it is changed, or we 4941 // Either we have removed this source, in which case we don't care that it is changed, or we
4949 // have already invalidated the cache and don't need to invalidate it agai n. 4942 // have already invalidated the cache and don't need to invalidate it agai n.
4950 return; 4943 return;
4951 } 4944 }
4952 if (sourceEntry is HtmlEntry) { 4945 if (sourceEntry is HtmlEntry) {
4953 HtmlEntryImpl htmlEntry = sourceEntry; 4946 HtmlEntry htmlEntry = sourceEntry;
4954 htmlEntry.modificationTime = getModificationStamp(source); 4947 htmlEntry.modificationTime = getModificationStamp(source);
4955 _invalidateAngularResolution(htmlEntry); 4948 _invalidateAngularResolution(htmlEntry);
4956 htmlEntry.invalidateAllInformation(); 4949 htmlEntry.invalidateAllInformation();
4957 _cache.removedAst(source); 4950 _cache.removedAst(source);
4958 _workManager.add(source, SourcePriority.HTML); 4951 _workManager.add(source, SourcePriority.HTML);
4959 } else if (sourceEntry is DartEntry) { 4952 } else if (sourceEntry is DartEntry) {
4960 List<Source> containingLibraries = getLibrariesContaining(source); 4953 List<Source> containingLibraries = getLibrariesContaining(source);
4961 HashSet<Source> librariesToInvalidate = new HashSet<Source>(); 4954 HashSet<Source> librariesToInvalidate = new HashSet<Source>();
4962 for (Source containingLibrary in containingLibraries) { 4955 for (Source containingLibrary in containingLibraries) {
4963 _computeAllLibrariesDependingOn(containingLibrary, librariesToInvalidate ); 4956 _computeAllLibrariesDependingOn(containingLibrary, librariesToInvalidate );
4964 } 4957 }
4965 for (Source library in librariesToInvalidate) { 4958 for (Source library in librariesToInvalidate) {
4966 _invalidateLibraryResolution(library); 4959 _invalidateLibraryResolution(library);
4967 } 4960 }
4968 DartEntryImpl dartEntry = _cache.get(source); 4961 DartEntry dartEntry = _cache.get(source);
4969 _removeFromParts(source, dartEntry); 4962 _removeFromParts(source, dartEntry);
4970 dartEntry.modificationTime = getModificationStamp(source); 4963 dartEntry.modificationTime = getModificationStamp(source);
4971 dartEntry.invalidateAllInformation(); 4964 dartEntry.invalidateAllInformation();
4972 _cache.removedAst(source); 4965 _cache.removedAst(source);
4973 _workManager.add(source, SourcePriority.UNKNOWN); 4966 _workManager.add(source, SourcePriority.UNKNOWN);
4974 } 4967 }
4975 } 4968 }
4976 4969
4977 /** 4970 /**
4978 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4971 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
4979 * 4972 *
4980 * @param source the source that has been deleted 4973 * @param source the source that has been deleted
4981 */ 4974 */
4982 void _sourceDeleted(Source source) { 4975 void _sourceDeleted(Source source) {
4983 SourceEntry sourceEntry = _cache.get(source); 4976 SourceEntry sourceEntry = _cache.get(source);
4984 if (sourceEntry is HtmlEntry) { 4977 if (sourceEntry is HtmlEntry) {
4985 HtmlEntryImpl htmlEntry = sourceEntry; 4978 HtmlEntry htmlEntry = sourceEntry;
4986 _invalidateAngularResolution(htmlEntry); 4979 _invalidateAngularResolution(htmlEntry);
4987 htmlEntry.recordContentError(new CaughtException(new AnalysisException("Th is source was marked as being deleted"), null)); 4980 htmlEntry.recordContentError(new CaughtException(new AnalysisException("Th is source was marked as being deleted"), null));
4988 } else if (sourceEntry is DartEntry) { 4981 } else if (sourceEntry is DartEntry) {
4989 DartEntryImpl dartEntry = sourceEntry; 4982 DartEntry dartEntry = sourceEntry;
4990 HashSet<Source> libraries = new HashSet<Source>(); 4983 HashSet<Source> libraries = new HashSet<Source>();
4991 for (Source librarySource in getLibrariesContaining(source)) { 4984 for (Source librarySource in getLibrariesContaining(source)) {
4992 libraries.add(librarySource); 4985 libraries.add(librarySource);
4993 for (Source dependentLibrary in getLibrariesDependingOn(librarySource)) { 4986 for (Source dependentLibrary in getLibrariesDependingOn(librarySource)) {
4994 libraries.add(dependentLibrary); 4987 libraries.add(dependentLibrary);
4995 } 4988 }
4996 } 4989 }
4997 for (Source librarySource in libraries) { 4990 for (Source librarySource in libraries) {
4998 _invalidateLibraryResolution(librarySource); 4991 _invalidateLibraryResolution(librarySource);
4999 } 4992 }
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
5410 * for all of the compilation units in the library 5403 * for all of the compilation units in the library
5411 */ 5404 */
5412 void _computePartsInLibrary(CycleBuilder_LibraryPair libraryPair) { 5405 void _computePartsInLibrary(CycleBuilder_LibraryPair libraryPair) {
5413 ResolvableLibrary library = libraryPair.library; 5406 ResolvableLibrary library = libraryPair.library;
5414 List<CycleBuilder_SourceEntryPair> entryPairs = libraryPair.entryPairs; 5407 List<CycleBuilder_SourceEntryPair> entryPairs = libraryPair.entryPairs;
5415 int count = entryPairs.length; 5408 int count = entryPairs.length;
5416 List<ResolvableCompilationUnit> units = new List<ResolvableCompilationUnit>( count); 5409 List<ResolvableCompilationUnit> units = new List<ResolvableCompilationUnit>( count);
5417 for (int i = 0; i < count; i++) { 5410 for (int i = 0; i < count; i++) {
5418 CycleBuilder_SourceEntryPair entryPair = entryPairs[i]; 5411 CycleBuilder_SourceEntryPair entryPair = entryPairs[i];
5419 Source source = entryPair.source; 5412 Source source = entryPair.source;
5420 DartEntryImpl dartEntry = entryPair.entry; 5413 DartEntry dartEntry = entryPair.entry;
5421 units[i] = new ResolvableCompilationUnit.con2(dartEntry.modificationTime, dartEntry.resolvableCompilationUnit, source); 5414 units[i] = new ResolvableCompilationUnit.con2(dartEntry.modificationTime, dartEntry.resolvableCompilationUnit, source);
5422 } 5415 }
5423 library.resolvableCompilationUnits = units; 5416 library.resolvableCompilationUnits = units;
5424 } 5417 }
5425 5418
5426 /** 5419 /**
5427 * Create an object to represent the information about the library defined by the compilation 5420 * Create an object to represent the information about the library defined by the compilation
5428 * unit with the given source. 5421 * unit with the given source.
5429 * 5422 *
5430 * @param librarySource the source of the library's defining compilation unit 5423 * @param librarySource the source of the library's defining compilation unit
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
5689 * The interface `AnalysisContextStatistics` defines access to statistics about a single 5682 * The interface `AnalysisContextStatistics` defines access to statistics about a single
5690 * [AnalysisContext]. 5683 * [AnalysisContext].
5691 */ 5684 */
5692 abstract class AnalysisContextStatistics { 5685 abstract class AnalysisContextStatistics {
5693 /** 5686 /**
5694 * Return the statistics for each kind of cached data. 5687 * Return the statistics for each kind of cached data.
5695 */ 5688 */
5696 List<AnalysisContextStatistics_CacheRow> get cacheRows; 5689 List<AnalysisContextStatistics_CacheRow> get cacheRows;
5697 5690
5698 /** 5691 /**
5699 * Return the exceptions that caused some entries to have a state of [CacheSta te#ERROR]. 5692 * Return the exceptions that caused some entries to have a state of [CacheSta te.ERROR].
5700 */ 5693 */
5701 List<CaughtException> get exceptions; 5694 List<CaughtException> get exceptions;
5702 5695
5703 /** 5696 /**
5704 * Return information about each of the partitions in the cache. 5697 * Return information about each of the partitions in the cache.
5705 */ 5698 */
5706 List<AnalysisContextStatistics_PartitionData> get partitionData; 5699 List<AnalysisContextStatistics_PartitionData> get partitionData;
5707 5700
5708 /** 5701 /**
5709 * Return an array containing all of the sources in the cache. 5702 * Return an array containing all of the sources in the cache.
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
5835 final int totalCount; 5828 final int totalCount;
5836 5829
5837 AnalysisContextStatisticsImpl_PartitionDataImpl(this.astCount, this.totalCount ); 5830 AnalysisContextStatisticsImpl_PartitionDataImpl(this.astCount, this.totalCount );
5838 } 5831 }
5839 5832
5840 /** 5833 /**
5841 * Information about single piece of data in the cache. 5834 * Information about single piece of data in the cache.
5842 */ 5835 */
5843 abstract class AnalysisContextStatistics_CacheRow { 5836 abstract class AnalysisContextStatistics_CacheRow {
5844 /** 5837 /**
5845 * Return the number of entries whose state is [CacheState#ERROR]. 5838 * Return the number of entries whose state is [CacheState.ERROR].
5846 */ 5839 */
5847 int get errorCount; 5840 int get errorCount;
5848 5841
5849 /** 5842 /**
5850 * Return the number of entries whose state is [CacheState#FLUSHED]. 5843 * Return the number of entries whose state is [CacheState.FLUSHED].
5851 */ 5844 */
5852 int get flushedCount; 5845 int get flushedCount;
5853 5846
5854 /** 5847 /**
5855 * Return the number of entries whose state is [CacheState#IN_PROCESS]. 5848 * Return the number of entries whose state is [CacheState.IN_PROCESS].
5856 */ 5849 */
5857 int get inProcessCount; 5850 int get inProcessCount;
5858 5851
5859 /** 5852 /**
5860 * Return the number of entries whose state is [CacheState#INVALID]. 5853 * Return the number of entries whose state is [CacheState.INVALID].
5861 */ 5854 */
5862 int get invalidCount; 5855 int get invalidCount;
5863 5856
5864 /** 5857 /**
5865 * Return the name of the data represented by this object. 5858 * Return the name of the data represented by this object.
5866 */ 5859 */
5867 String get name; 5860 String get name;
5868 5861
5869 /** 5862 /**
5870 * Return the number of entries whose state is [CacheState#VALID]. 5863 * Return the number of entries whose state is [CacheState.VALID].
5871 */ 5864 */
5872 int get validCount; 5865 int get validCount;
5873 } 5866 }
5874 5867
5875 /** 5868 /**
5876 * Information about a single partition in the cache. 5869 * Information about a single partition in the cache.
5877 */ 5870 */
5878 abstract class AnalysisContextStatistics_PartitionData { 5871 abstract class AnalysisContextStatistics_PartitionData {
5879 /** 5872 /**
5880 * Return the number of entries in the partition that have an AST structure in one state or 5873 * Return the number of entries in the partition that have an AST structure in one state or
(...skipping 13 matching lines...) Expand all
5894 */ 5887 */
5895 class AnalysisDelta { 5888 class AnalysisDelta {
5896 /** 5889 /**
5897 * A mapping from source to what type of analysis should be performed on that source. 5890 * A mapping from source to what type of analysis should be performed on that source.
5898 */ 5891 */
5899 HashMap<Source, AnalysisLevel> _analysisMap = new HashMap<Source, AnalysisLeve l>(); 5892 HashMap<Source, AnalysisLevel> _analysisMap = new HashMap<Source, AnalysisLeve l>();
5900 5893
5901 /** 5894 /**
5902 * Return a collection of the sources that have been added. This is equivalent to calling 5895 * Return a collection of the sources that have been added. This is equivalent to calling
5903 * [getAnalysisLevels] and collecting all sources that do not have an analysis level of 5896 * [getAnalysisLevels] and collecting all sources that do not have an analysis level of
5904 * [AnalysisLevel#NONE]. 5897 * [AnalysisLevel.NONE].
5905 * 5898 *
5906 * @return a collection of the sources 5899 * @return a collection of the sources
5907 */ 5900 */
5908 Iterable<Source> get addedSources { 5901 Iterable<Source> get addedSources {
5909 List<Source> result = new List<Source>(); 5902 List<Source> result = new List<Source>();
5910 for (MapEntry<Source, AnalysisLevel> entry in getMapEntrySet(_analysisMap)) { 5903 for (MapEntry<Source, AnalysisLevel> entry in getMapEntrySet(_analysisMap)) {
5911 if (entry.getValue() != AnalysisLevel.NONE) { 5904 if (entry.getValue() != AnalysisLevel.NONE) {
5912 result.add(entry.getKey()); 5905 result.add(entry.getKey());
5913 } 5906 }
5914 } 5907 }
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
6809 * Return the offset of the first character in the expression's source range. 6802 * Return the offset of the first character in the expression's source range.
6810 */ 6803 */
6811 int get offset => expression.offset; 6804 int get offset => expression.offset;
6812 } 6805 }
6813 6806
6814 /** 6807 /**
6815 * Angular formatter argument. 6808 * Angular formatter argument.
6816 */ 6809 */
6817 class AngularFormatterArgument { 6810 class AngularFormatterArgument {
6818 /** 6811 /**
6819 * The [TokenType#COLON] token. 6812 * The [TokenType.COLON] token.
6820 */ 6813 */
6821 final Token token; 6814 final Token token;
6822 6815
6823 /** 6816 /**
6824 * The argument expression. 6817 * The argument expression.
6825 */ 6818 */
6826 final Expression expression; 6819 final Expression expression;
6827 6820
6828 /** 6821 /**
6829 * The optional sub-[Expression]s. 6822 * The optional sub-[Expression]s.
6830 */ 6823 */
6831 List<Expression> subExpressions = Expression.EMPTY_ARRAY; 6824 List<Expression> subExpressions = Expression.EMPTY_ARRAY;
6832 6825
6833 AngularFormatterArgument(this.token, this.expression); 6826 AngularFormatterArgument(this.token, this.expression);
6834 } 6827 }
6835 6828
6836 /** 6829 /**
6837 * Angular formatter node. 6830 * Angular formatter node.
6838 */ 6831 */
6839 class AngularFormatterNode { 6832 class AngularFormatterNode {
6840 /** 6833 /**
6841 * The [TokenType#BAR] token. 6834 * The [TokenType.BAR] token.
6842 */ 6835 */
6843 final Token token; 6836 final Token token;
6844 6837
6845 /** 6838 /**
6846 * The name of the formatter. 6839 * The name of the formatter.
6847 */ 6840 */
6848 final SimpleIdentifier name; 6841 final SimpleIdentifier name;
6849 6842
6850 /** 6843 /**
6851 * The arguments for this formatter. 6844 * The arguments for this formatter.
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
7794 */ 7787 */
7795 MapIterator<Source, SourceEntry> iterator() => new SingleMapIterator<Source, S ourceEntry>(_sourceMap); 7788 MapIterator<Source, SourceEntry> iterator() => new SingleMapIterator<Source, S ourceEntry>(_sourceMap);
7796 7789
7797 /** 7790 /**
7798 * Associate the given entry with the given source. 7791 * Associate the given entry with the given source.
7799 * 7792 *
7800 * @param source the source with which the entry is to be associated 7793 * @param source the source with which the entry is to be associated
7801 * @param entry the entry to be associated with the source 7794 * @param entry the entry to be associated with the source
7802 */ 7795 */
7803 void put(Source source, SourceEntry entry) { 7796 void put(Source source, SourceEntry entry) {
7804 (entry as SourceEntryImpl).fixExceptionState(); 7797 entry.fixExceptionState();
7805 _sourceMap[source] = entry; 7798 _sourceMap[source] = entry;
7806 } 7799 }
7807 7800
7808 /** 7801 /**
7809 * Remove all information related to the given source from this cache. 7802 * Remove all information related to the given source from this cache.
7810 * 7803 *
7811 * @param source the source to be removed 7804 * @param source the source to be removed
7812 */ 7805 */
7813 void remove(Source source) { 7806 void remove(Source source) {
7814 _recentlyUsed.remove(source); 7807 _recentlyUsed.remove(source);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
7867 * 7860 *
7868 * @return `true` if a structure was flushed 7861 * @return `true` if a structure was flushed
7869 */ 7862 */
7870 bool _flushAstFromCache() { 7863 bool _flushAstFromCache() {
7871 Source removedSource = _removeAstToFlush(); 7864 Source removedSource = _removeAstToFlush();
7872 if (removedSource == null) { 7865 if (removedSource == null) {
7873 return false; 7866 return false;
7874 } 7867 }
7875 SourceEntry sourceEntry = _sourceMap[removedSource]; 7868 SourceEntry sourceEntry = _sourceMap[removedSource];
7876 if (sourceEntry is HtmlEntry) { 7869 if (sourceEntry is HtmlEntry) {
7877 HtmlEntryImpl htmlEntry = sourceEntry; 7870 HtmlEntry htmlEntry = sourceEntry;
7878 htmlEntry.flushAstStructures(); 7871 htmlEntry.flushAstStructures();
7879 } else if (sourceEntry is DartEntry) { 7872 } else if (sourceEntry is DartEntry) {
7880 DartEntryImpl dartEntry = sourceEntry; 7873 DartEntry dartEntry = sourceEntry;
7881 dartEntry.flushAstStructures(); 7874 dartEntry.flushAstStructures();
7882 } 7875 }
7883 return true; 7876 return true;
7884 } 7877 }
7885 7878
7886 /** 7879 /**
7887 * Remove and return one source from the list of recently used sources whose A ST structure can be 7880 * Remove and return one source from the list of recently used sources whose A ST structure can be
7888 * flushed from the cache. The source that will be returned will be the source that has been 7881 * flushed from the cache. The source that will be returned will be the source that has been
7889 * unreferenced for the longest period of time but that is not a priority for analysis. 7882 * unreferenced for the longest period of time but that is not a priority for analysis.
7890 * 7883 *
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
8385 * 8378 *
8386 * @param source the source associated with the entry 8379 * @param source the source associated with the entry
8387 * @param entry the entry associated with the source 8380 * @param entry the entry associated with the source
8388 */ 8381 */
8389 CycleBuilder_SourceEntryPair(Source source, DartEntry entry) { 8382 CycleBuilder_SourceEntryPair(Source source, DartEntry entry) {
8390 this.source = source; 8383 this.source = source;
8391 this.entry = entry; 8384 this.entry = entry;
8392 } 8385 }
8393 } 8386 }
8394 8387
8388
8395 /** 8389 /**
8396 * The interface `DartEntry` defines the behavior of objects that maintain the i nformation 8390 * A `DartEntry` maintains the information cached by an analysis context about
8397 * cached by an analysis context about an individual Dart file. 8391 * an individual Dart file.
8398 */ 8392 */
8399 abstract class DartEntry implements SourceEntry { 8393 class DartEntry extends SourceEntry {
8400 /** 8394 /**
8401 * The data descriptor representing the errors reported during Angular resolut ion. 8395 * The state of the cached token stream.
8402 */ 8396 */
8403 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS = new DataDesc riptor<List<AnalysisError>>("DartEntry.ANGULAR_ERRORS"); 8397 CacheState _tokenStreamState = CacheState.INVALID;
8404 8398
8405 /** 8399 /**
8406 * The data descriptor representing the list of libraries that contain this co mpilation unit. 8400 * The head of the token stream, or `null` if the token stream is not
8407 */ 8401 * currently cached.
8408 static final DataDescriptor<List<Source>> CONTAINING_LIBRARIES = new DataDescr iptor<List<Source>>("DartEntry.CONTAINING_LIBRARIES"); 8402 */
8409 8403 Token _tokenStream;
8410 /** 8404
8411 * The data descriptor representing the library element for the library. This data is only 8405 /**
8412 * available for Dart files that are the defining compilation unit of a librar y. 8406 * The state of the cached scan errors.
8413 */ 8407 */
8414 static final DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<Libra ryElement>("DartEntry.ELEMENT"); 8408 CacheState _scanErrorsState = CacheState.INVALID;
8415 8409
8416 /** 8410 /**
8417 * The data descriptor representing the list of exported libraries. This data is only available 8411 * The errors produced while scanning the compilation unit, or an empty array
8418 * for Dart files that are the defining compilation unit of a library. 8412 * if the errors are not currently cached.
8419 */ 8413 */
8420 static final DataDescriptor<List<Source>> EXPORTED_LIBRARIES = new DataDescrip tor<List<Source>>("DartEntry.EXPORTED_LIBRARIES"); 8414 List<AnalysisError> _scanErrors = AnalysisError.NO_ERRORS;
8421 8415
8422 /** 8416 /**
8423 * The data descriptor representing the hints resulting from auditing the sour ce. 8417 * The state of the cached source kind.
8424 */ 8418 */
8425 static final DataDescriptor<List<AnalysisError>> HINTS = new DataDescriptor<Li st<AnalysisError>>("DartEntry.HINTS"); 8419 CacheState _sourceKindState = CacheState.INVALID;
8426 8420
8427 /** 8421 /**
8428 * The data descriptor representing the list of imported libraries. This data is only available 8422 * The kind of this source.
8429 * for Dart files that are the defining compilation unit of a library. 8423 */
8430 */ 8424 SourceKind _sourceKind = SourceKind.UNKNOWN;
8431 static final DataDescriptor<List<Source>> IMPORTED_LIBRARIES = new DataDescrip tor<List<Source>>("DartEntry.IMPORTED_LIBRARIES"); 8425
8432 8426 /**
8433 /** 8427 * The state of the cached parsed compilation unit.
8434 * The data descriptor representing the list of included parts. This data is o nly available for 8428 */
8435 * Dart files that are the defining compilation unit of a library. 8429 CacheState _parsedUnitState = CacheState.INVALID;
8436 */ 8430
8437 static final DataDescriptor<List<Source>> INCLUDED_PARTS = new DataDescriptor< List<Source>>("DartEntry.INCLUDED_PARTS"); 8431 /**
8438 8432 * A flag indicating whether the parsed AST structure has been accessed since
8439 /** 8433 * it was set. This is used to determine whether the structure needs to be
8440 * The data descriptor representing the client flag. This data is only availab le for Dart files 8434 * copied before it is resolved.
8441 * that are the defining compilation unit of a library. 8435 */
8442 */ 8436 bool _parsedUnitAccessed = false;
8443 static final DataDescriptor<bool> IS_CLIENT = new DataDescriptor<bool>("DartEn try.IS_CLIENT"); 8437
8444 8438 /**
8445 /** 8439 * The parsed compilation unit, or `null` if the parsed compilation unit is
8446 * The data descriptor representing the launchable flag. This data is only ava ilable for Dart 8440 * not currently cached.
8447 * files that are the defining compilation unit of a library. 8441 */
8448 */ 8442 CompilationUnit _parsedUnit;
8449 static final DataDescriptor<bool> IS_LAUNCHABLE = new DataDescriptor<bool>("Da rtEntry.IS_LAUNCHABLE"); 8443
8450 8444 /**
8451 /** 8445 * The state of the cached parse errors.
8452 * The data descriptor representing the errors resulting from parsing the sour ce. 8446 */
8453 */ 8447 CacheState _parseErrorsState = CacheState.INVALID;
8454 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS = new DataDescri ptor<List<AnalysisError>>("DartEntry.PARSE_ERRORS"); 8448
8449 /**
8450 * The errors produced while parsing the compilation unit, or an empty array
8451 * if the errors are not currently cached.
8452 */
8453 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS;
8454
8455 /**
8456 * The state of the cached list of imported libraries.
8457 */
8458 CacheState _importedLibrariesState = CacheState.INVALID;
8459
8460 /**
8461 * The list of libraries imported by the library, or an empty array if the
8462 * list is not currently cached. The list will be empty if the Dart file is a
8463 * part rather than a library.
8464 */
8465 List<Source> _importedLibraries = Source.EMPTY_ARRAY;
8466
8467 /**
8468 * The state of the cached list of exported libraries.
8469 */
8470 CacheState _exportedLibrariesState = CacheState.INVALID;
8471
8472 /**
8473 * The list of libraries exported by the library, or an empty array if the
8474 * list is not currently cached. The list will be empty if the Dart file is a
8475 * part rather than a library.
8476 */
8477 List<Source> _exportedLibraries = Source.EMPTY_ARRAY;
8478
8479 /**
8480 * The state of the cached list of included parts.
8481 */
8482 CacheState _includedPartsState = CacheState.INVALID;
8483
8484 /**
8485 * The list of parts included in the library, or an empty array if the list is
8486 * not currently cached. The list will be empty if the Dart file is a part
8487 * rather than a library.
8488 */
8489 List<Source> _includedParts = Source.EMPTY_ARRAY;
8490
8491 /**
8492 * The list of libraries that contain this compilation unit. The list will be
8493 * empty if there are no known libraries that contain this compilation unit.
8494 */
8495 List<Source> _containingLibraries = new List<Source>();
8496
8497 /**
8498 * The information known as a result of resolving this compilation unit as
8499 * part of the library that contains this unit. This field will never be
8500 * `null`.
8501 */
8502 ResolutionState _resolutionState
8503 = new ResolutionState();
8504
8505 /**
8506 * The state of the cached library element.
8507 */
8508 CacheState _elementState = CacheState.INVALID;
8509
8510 /**
8511 * The element representing the library, or `null` if the element is not
8512 * currently cached.
8513 */
8514 LibraryElement _element;
8515
8516 /**
8517 * The state of the cached public namespace.
8518 */
8519 CacheState _publicNamespaceState = CacheState.INVALID;
8520
8521 /**
8522 * The public namespace of the library, or `null` if the namespace is not
8523 * currently cached.
8524 */
8525 Namespace _publicNamespace;
8526
8527 /**
8528 * The state of the cached client/ server flag.
8529 */
8530 CacheState _clientServerState = CacheState.INVALID;
8531
8532 /**
8533 * The state of the cached launchable flag.
8534 */
8535 CacheState _launchableState = CacheState.INVALID;
8536
8537 /**
8538 * The error produced while performing Angular resolution, or an empty array
8539 * if there are no errors if the error are not currently cached.
8540 */
8541 List<AnalysisError> _angularErrors = AnalysisError.NO_ERRORS;
8542
8543 /**
8544 * The data descriptor representing the errors reported during Angular
8545 * resolution.
8546 */
8547 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS
8548 = new DataDescriptor<List<AnalysisError>>("DartEntry.ANGULAR_ERRORS");
8549
8550 /**
8551 * The data descriptor representing the list of libraries that contain this
8552 * compilation unit.
8553 */
8554 static final DataDescriptor<List<Source>> CONTAINING_LIBRARIES
8555 = new DataDescriptor<List<Source>>("DartEntry.CONTAINING_LIBRARIES");
8556
8557 /**
8558 * The data descriptor representing the library element for the library. This
8559 * data is only available for Dart files that are the defining compilation
8560 * unit of a library.
8561 */
8562 static final DataDescriptor<LibraryElement> ELEMENT
8563 = new DataDescriptor<LibraryElement>("DartEntry.ELEMENT");
8564
8565 /**
8566 * The data descriptor representing the list of exported libraries. This data
8567 * is only available for Dart files that are the defining compilation unit of
8568 * a library.
8569 */
8570 static final DataDescriptor<List<Source>> EXPORTED_LIBRARIES
8571 = new DataDescriptor<List<Source>>("DartEntry.EXPORTED_LIBRARIES");
8572
8573 /**
8574 * The data descriptor representing the hints resulting from auditing the
8575 * source.
8576 */
8577 static final DataDescriptor<List<AnalysisError>> HINTS
8578 = new DataDescriptor<List<AnalysisError>>("DartEntry.HINTS");
8579
8580 /**
8581 * The data descriptor representing the list of imported libraries. This data
8582 * is only available for Dart files that are the defining compilation unit of
8583 * a library.
8584 */
8585 static final DataDescriptor<List<Source>> IMPORTED_LIBRARIES
8586 = new DataDescriptor<List<Source>>("DartEntry.IMPORTED_LIBRARIES");
8587
8588 /**
8589 * The data descriptor representing the list of included parts. This data is
8590 * only available for Dart files that are the defining compilation unit of a
8591 * library.
8592 */
8593 static final DataDescriptor<List<Source>> INCLUDED_PARTS
8594 = new DataDescriptor<List<Source>>("DartEntry.INCLUDED_PARTS");
8595
8596 /**
8597 * The data descriptor representing the client flag. This data is only
8598 * available for Dart files that are the defining compilation unit of a
8599 * library.
8600 */
8601 static final DataDescriptor<bool> IS_CLIENT
8602 = new DataDescriptor<bool>("DartEntry.IS_CLIENT");
8603
8604 /**
8605 * The data descriptor representing the launchable flag. This data is only
8606 * available for Dart files that are the defining compilation unit of a
8607 * library.
8608 */
8609 static final DataDescriptor<bool> IS_LAUNCHABLE
8610 = new DataDescriptor<bool>("DartEntry.IS_LAUNCHABLE");
8611
8612 /**
8613 * The data descriptor representing the errors resulting from parsing the
8614 * source.
8615 */
8616 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS
8617 = new DataDescriptor<List<AnalysisError>>("DartEntry.PARSE_ERRORS");
8455 8618
8456 /** 8619 /**
8457 * The data descriptor representing the parsed AST structure. 8620 * The data descriptor representing the parsed AST structure.
8458 */ 8621 */
8459 static final DataDescriptor<CompilationUnit> PARSED_UNIT = new DataDescriptor< CompilationUnit>("DartEntry.PARSED_UNIT"); 8622 static final DataDescriptor<CompilationUnit> PARSED_UNIT
8460 8623 = new DataDescriptor<CompilationUnit>("DartEntry.PARSED_UNIT");
8461 /** 8624
8462 * The data descriptor representing the public namespace of the library. This data is only 8625 /**
8463 * available for Dart files that are the defining compilation unit of a librar y. 8626 * The data descriptor representing the public namespace of the library. This
8464 */ 8627 * data is only available for Dart files that are the defining compilation
8465 static final DataDescriptor<Namespace> PUBLIC_NAMESPACE = new DataDescriptor<N amespace>("DartEntry.PUBLIC_NAMESPACE"); 8628 * unit of a library.
8466 8629 */
8467 /** 8630 static final DataDescriptor<Namespace> PUBLIC_NAMESPACE
8468 * The data descriptor representing the errors resulting from resolving the so urce. 8631 = new DataDescriptor<Namespace>("DartEntry.PUBLIC_NAMESPACE");
8469 */ 8632
8470 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataD escriptor<List<AnalysisError>>("DartEntry.RESOLUTION_ERRORS"); 8633 /**
8634 * The data descriptor representing the errors resulting from resolving the
8635 * source.
8636 */
8637 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS
8638 = new DataDescriptor<List<AnalysisError>>("DartEntry.RESOLUTION_ERRORS");
8471 8639
8472 /** 8640 /**
8473 * The data descriptor representing the resolved AST structure. 8641 * The data descriptor representing the resolved AST structure.
8474 */ 8642 */
8475 static final DataDescriptor<CompilationUnit> RESOLVED_UNIT = new DataDescripto r<CompilationUnit>("DartEntry.RESOLVED_UNIT"); 8643 static final DataDescriptor<CompilationUnit> RESOLVED_UNIT
8644 = new DataDescriptor<CompilationUnit>("DartEntry.RESOLVED_UNIT");
8476 8645
8477 /** 8646 /**
8478 * The data descriptor representing the token stream. 8647 * The data descriptor representing the token stream.
8479 */ 8648 */
8480 static final DataDescriptor<List<AnalysisError>> SCAN_ERRORS = new DataDescrip tor<List<AnalysisError>>("DartEntry.SCAN_ERRORS"); 8649 static final DataDescriptor<List<AnalysisError>> SCAN_ERRORS
8650 = new DataDescriptor<List<AnalysisError>>("DartEntry.SCAN_ERRORS");
8481 8651
8482 /** 8652 /**
8483 * The data descriptor representing the source kind. 8653 * The data descriptor representing the source kind.
8484 */ 8654 */
8485 static final DataDescriptor<SourceKind> SOURCE_KIND = new DataDescriptor<Sourc eKind>("DartEntry.SOURCE_KIND"); 8655 static final DataDescriptor<SourceKind> SOURCE_KIND
8656 = new DataDescriptor<SourceKind>("DartEntry.SOURCE_KIND");
8486 8657
8487 /** 8658 /**
8488 * The data descriptor representing the token stream. 8659 * The data descriptor representing the token stream.
8489 */ 8660 */
8490 static final DataDescriptor<Token> TOKEN_STREAM = new DataDescriptor<Token>("D artEntry.TOKEN_STREAM"); 8661 static final DataDescriptor<Token> TOKEN_STREAM
8491 8662 = new DataDescriptor<Token>("DartEntry.TOKEN_STREAM");
8492 /** 8663
8493 * The data descriptor representing the errors resulting from verifying the so urce. 8664 /**
8494 */ 8665 * The data descriptor representing the errors resulting from verifying the
8495 static final DataDescriptor<List<AnalysisError>> VERIFICATION_ERRORS = new Dat aDescriptor<List<AnalysisError>>("DartEntry.VERIFICATION_ERRORS"); 8666 * source.
8496 8667 */
8497 /** 8668 static final DataDescriptor<List<AnalysisError>> VERIFICATION_ERRORS
8498 * Return all of the errors associated with the compilation unit that are curr ently cached. 8669 = new DataDescriptor<List<AnalysisError>>("DartEntry.VERIFICATION_ERRORS") ;
8499 * 8670
8500 * @return all of the errors associated with the compilation unit 8671 /**
8501 */ 8672 * The index of the flag indicating whether this library is launchable
8502 List<AnalysisError> get allErrors; 8673 * (whether the file has a main method).
8503
8504 /**
8505 * Return a valid parsed compilation unit, either an unresolved AST structure or the result of
8506 * resolving the AST structure in the context of some library, or `null` if th ere is no
8507 * parsed compilation unit available.
8508 *
8509 * @return a valid parsed compilation unit
8510 */
8511 CompilationUnit get anyParsedCompilationUnit;
8512
8513 /**
8514 * Return the result of resolving the compilation unit as part of any library, or `null` if
8515 * there is no cached resolved compilation unit.
8516 *
8517 * @return any resolved compilation unit
8518 */
8519 CompilationUnit get anyResolvedCompilationUnit;
8520
8521 /**
8522 * Return the state of the data represented by the given descriptor in the con text of the given
8523 * library.
8524 *
8525 * @param descriptor the descriptor representing the data whose state is to be returned
8526 * @param librarySource the source of the defining compilation unit of the lib rary that is the
8527 * context for the data
8528 * @return the value of the data represented by the given descriptor and libra ry
8529 */
8530 CacheState getStateInLibrary(DataDescriptor descriptor, Source librarySource);
8531
8532 /**
8533 * Return the value of the data represented by the given descriptor in the con text of the given
8534 * library, or `null` if the data represented by the descriptor is not in the cache.
8535 *
8536 * @param descriptor the descriptor representing which data is to be returned
8537 * @param librarySource the source of the defining compilation unit of the lib rary that is the
8538 * context for the data
8539 * @return the value of the data represented by the given descriptor and libra ry
8540 */
8541 Object getValueInLibrary(DataDescriptor descriptor, Source librarySource);
8542
8543 /**
8544 * Return `true` if the data represented by the given descriptor is marked as being invalid.
8545 * If the descriptor represents library-specific data then this method will re turn `true` if
8546 * the data associated with any library it marked as invalid.
8547 *
8548 * @param descriptor the descriptor representing which data is being tested
8549 * @return `true` if the data is marked as being invalid
8550 */
8551 bool hasInvalidData(DataDescriptor descriptor);
8552
8553 /**
8554 * Return `true` if this entry has an AST structure that can be resolved (even if it needs
8555 * to be copied).
8556 *
8557 * @return `true` if the method [DartEntryImpl#getResolvableCompilationUnit] w ill
8558 * return a non-`null` result
8559 */
8560 bool get hasResolvableCompilationUnit;
8561
8562 /**
8563 * Return `true` if this data is safe to use in refactoring.
8564 */
8565 bool get isRefactoringSafe;
8566 }
8567
8568 /**
8569 * Instances of the class `DartEntryImpl` implement a [DartEntry].
8570 */
8571 class DartEntryImpl extends SourceEntryImpl implements DartEntry {
8572 /**
8573 * The state of the cached token stream.
8574 */
8575 CacheState _tokenStreamState = CacheState.INVALID;
8576
8577 /**
8578 * The head of the token stream, or `null` if the token stream is not currentl y cached.
8579 */
8580 Token _tokenStream;
8581
8582 /**
8583 * The state of the cached scan errors.
8584 */
8585 CacheState _scanErrorsState = CacheState.INVALID;
8586
8587 /**
8588 * The errors produced while scanning the compilation unit, or an empty array if the errors are
8589 * not currently cached.
8590 */
8591 List<AnalysisError> _scanErrors = AnalysisError.NO_ERRORS;
8592
8593 /**
8594 * The state of the cached source kind.
8595 */
8596 CacheState _sourceKindState = CacheState.INVALID;
8597
8598 /**
8599 * The kind of this source.
8600 */
8601 SourceKind _sourceKind = SourceKind.UNKNOWN;
8602
8603 /**
8604 * The state of the cached parsed compilation unit.
8605 */
8606 CacheState _parsedUnitState = CacheState.INVALID;
8607
8608 /**
8609 * A flag indicating whether the parsed AST structure has been accessed since it was set. This is
8610 * used to determine whether the structure needs to be copied before it is res olved.
8611 */
8612 bool _parsedUnitAccessed = false;
8613
8614 /**
8615 * The parsed compilation unit, or `null` if the parsed compilation unit is no t currently
8616 * cached.
8617 */
8618 CompilationUnit _parsedUnit;
8619
8620 /**
8621 * The state of the cached parse errors.
8622 */
8623 CacheState _parseErrorsState = CacheState.INVALID;
8624
8625 /**
8626 * The errors produced while parsing the compilation unit, or an empty array i f the errors are not
8627 * currently cached.
8628 */
8629 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS;
8630
8631 /**
8632 * The state of the cached list of imported libraries.
8633 */
8634 CacheState _importedLibrariesState = CacheState.INVALID;
8635
8636 /**
8637 * The list of libraries imported by the library, or an empty array if the lis t is not currently
8638 * cached. The list will be empty if the Dart file is a part rather than a lib rary.
8639 */
8640 List<Source> _importedLibraries = Source.EMPTY_ARRAY;
8641
8642 /**
8643 * The state of the cached list of exported libraries.
8644 */
8645 CacheState _exportedLibrariesState = CacheState.INVALID;
8646
8647 /**
8648 * The list of libraries exported by the library, or an empty array if the lis t is not currently
8649 * cached. The list will be empty if the Dart file is a part rather than a lib rary.
8650 */
8651 List<Source> _exportedLibraries = Source.EMPTY_ARRAY;
8652
8653 /**
8654 * The state of the cached list of included parts.
8655 */
8656 CacheState _includedPartsState = CacheState.INVALID;
8657
8658 /**
8659 * The list of parts included in the library, or an empty array if the list is not currently
8660 * cached. The list will be empty if the Dart file is a part rather than a lib rary.
8661 */
8662 List<Source> _includedParts = Source.EMPTY_ARRAY;
8663
8664 /**
8665 * The list of libraries that contain this compilation unit. The list will be empty if there are
8666 * no known libraries that contain this compilation unit.
8667 */
8668 List<Source> _containingLibraries = new List<Source>();
8669
8670 /**
8671 * The information known as a result of resolving this compilation unit as par t of the library
8672 * that contains this unit. This field will never be `null`.
8673 */
8674 DartEntryImpl_ResolutionState _resolutionState = new DartEntryImpl_ResolutionS tate();
8675
8676 /**
8677 * The state of the cached library element.
8678 */
8679 CacheState _elementState = CacheState.INVALID;
8680
8681 /**
8682 * The element representing the library, or `null` if the element is not curre ntly cached.
8683 */
8684 LibraryElement _element;
8685
8686 /**
8687 * The state of the cached public namespace.
8688 */
8689 CacheState _publicNamespaceState = CacheState.INVALID;
8690
8691 /**
8692 * The public namespace of the library, or `null` if the namespace is not curr ently cached.
8693 */
8694 Namespace _publicNamespace;
8695
8696 /**
8697 * The state of the cached client/ server flag.
8698 */
8699 CacheState _clientServerState = CacheState.INVALID;
8700
8701 /**
8702 * The state of the cached launchable flag.
8703 */
8704 CacheState _launchableState = CacheState.INVALID;
8705
8706 /**
8707 * The error produced while performing Angular resolution, or an empty array i f there are no
8708 * errors if the error are not currently cached.
8709 */
8710 List<AnalysisError> _angularErrors = AnalysisError.NO_ERRORS;
8711
8712 /**
8713 * The index of the flag indicating whether this library is launchable (whethe r the file has a
8714 * main method).
8715 */ 8674 */
8716 static int _LAUNCHABLE_INDEX = 1; 8675 static int _LAUNCHABLE_INDEX = 1;
8717 8676
8718 /** 8677 /**
8719 * The index of the flag indicating whether the library is client code (whethe r the library 8678 * The index of the flag indicating whether the library is client code
8720 * depends on the html library). If the library is not "client code", then it is referred to as 8679 * (whether the library depends on the html library). If the library is not
8721 * "server code". 8680 * "client code", then it is referred to as "server code".
8722 */ 8681 */
8723 static int _CLIENT_CODE_INDEX = 2; 8682 static int _CLIENT_CODE_INDEX = 2;
8724 8683
8725 /** 8684 /**
8726 * Add the given library to the list of libraries that contain this part. This method should only 8685 * Add the given [librarySource] to the list of libraries that contain this
8727 * be invoked on entries that represent a part. 8686 * part. This method should only be invoked on entries that represent a part.
8728 *
8729 * @param librarySource the source of the library to be added
8730 */ 8687 */
8731 void addContainingLibrary(Source librarySource) { 8688 void addContainingLibrary(Source librarySource) {
8732 _containingLibraries.add(librarySource); 8689 _containingLibraries.add(librarySource);
8733 } 8690 }
8734 8691
8735 /** 8692 /**
8736 * Flush any AST structures being maintained by this entry. 8693 * Flush any AST structures being maintained by this entry.
8737 */ 8694 */
8738 void flushAstStructures() { 8695 void flushAstStructures() {
8739 if (_tokenStreamState == CacheState.VALID) { 8696 if (_tokenStreamState == CacheState.VALID) {
8740 _tokenStreamState = CacheState.FLUSHED; 8697 _tokenStreamState = CacheState.FLUSHED;
8741 _tokenStream = null; 8698 _tokenStream = null;
8742 } 8699 }
8743 if (_parsedUnitState == CacheState.VALID) { 8700 if (_parsedUnitState == CacheState.VALID) {
8744 _parsedUnitState = CacheState.FLUSHED; 8701 _parsedUnitState = CacheState.FLUSHED;
8745 _parsedUnitAccessed = false; 8702 _parsedUnitAccessed = false;
8746 _parsedUnit = null; 8703 _parsedUnit = null;
8747 } 8704 }
8748 _resolutionState.flushAstStructures(); 8705 _resolutionState.flushAstStructures();
8749 } 8706 }
8750 8707
8751 @override 8708 /**
8709 * Return all of the errors associated with the compilation unit that are
8710 * currently cached.
8711 */
8752 List<AnalysisError> get allErrors { 8712 List<AnalysisError> get allErrors {
8753 List<AnalysisError> errors = new List<AnalysisError>(); 8713 List<AnalysisError> errors = new List<AnalysisError>();
8754 ListUtilities.addAll(errors, _scanErrors); 8714 ListUtilities.addAll(errors, _scanErrors);
8755 ListUtilities.addAll(errors, _parseErrors); 8715 ListUtilities.addAll(errors, _parseErrors);
8756 DartEntryImpl_ResolutionState state = _resolutionState; 8716 ResolutionState state = _resolutionState;
8757 while (state != null) { 8717 while (state != null) {
8758 ListUtilities.addAll(errors, state._buildElementErrors); 8718 ListUtilities.addAll(errors, state._buildElementErrors);
8759 ListUtilities.addAll(errors, state._resolutionErrors); 8719 ListUtilities.addAll(errors, state._resolutionErrors);
8760 ListUtilities.addAll(errors, state._verificationErrors); 8720 ListUtilities.addAll(errors, state._verificationErrors);
8761 ListUtilities.addAll(errors, state._hints); 8721 ListUtilities.addAll(errors, state._hints);
8762 state = state._nextState; 8722 state = state._nextState;
8763 } 8723 }
8764 ListUtilities.addAll(errors, _angularErrors); 8724 ListUtilities.addAll(errors, _angularErrors);
8765 if (errors.length == 0) { 8725 if (errors.length == 0) {
8766 return AnalysisError.NO_ERRORS; 8726 return AnalysisError.NO_ERRORS;
8767 } 8727 }
8768 return new List.from(errors); 8728 return new List.from(errors);
8769 } 8729 }
8770 8730
8771 @override 8731 /**
8732 * Return a valid parsed compilation unit, either an unresolved AST structure
8733 * or the result of resolving the AST structure in the context of some library ,
8734 * or `null` if there is no parsed compilation unit available.
8735 */
8772 CompilationUnit get anyParsedCompilationUnit { 8736 CompilationUnit get anyParsedCompilationUnit {
8773 if (_parsedUnitState == CacheState.VALID) { 8737 if (_parsedUnitState == CacheState.VALID) {
8774 _parsedUnitAccessed = true; 8738 _parsedUnitAccessed = true;
8775 return _parsedUnit; 8739 return _parsedUnit;
8776 } 8740 }
8777 DartEntryImpl_ResolutionState state = _resolutionState; 8741 ResolutionState state = _resolutionState;
8778 while (state != null) { 8742 while (state != null) {
8779 if (state._builtUnitState == CacheState.VALID) { 8743 if (state._builtUnitState == CacheState.VALID) {
8780 return state._builtUnit; 8744 return state._builtUnit;
8781 } 8745 }
8782 state = state._nextState; 8746 state = state._nextState;
8783 } 8747 }
8784 ; 8748 ;
8785 return anyResolvedCompilationUnit; 8749 return anyResolvedCompilationUnit;
8786 } 8750 }
8787 8751
8788 @override 8752 /**
8753 * Return the result of resolving the compilation unit as part of any library,
8754 * or `null` if there is no cached resolved compilation unit.
8755 */
8789 CompilationUnit get anyResolvedCompilationUnit { 8756 CompilationUnit get anyResolvedCompilationUnit {
8790 DartEntryImpl_ResolutionState state = _resolutionState; 8757 ResolutionState state = _resolutionState;
8791 while (state != null) { 8758 while (state != null) {
8792 if (state._resolvedUnitState == CacheState.VALID) { 8759 if (state._resolvedUnitState == CacheState.VALID) {
8793 return state._resolvedUnit; 8760 return state._resolvedUnit;
8794 } 8761 }
8795 state = state._nextState; 8762 state = state._nextState;
8796 } 8763 }
8797 ; 8764 ;
8798 return null; 8765 return null;
8799 } 8766 }
8800 8767
8801 /** 8768 /**
8802 * Return a list containing the libraries that are known to contain this part. 8769 * The libraries that are known to contain this part.
8803 *
8804 * @return a list containing the libraries that are known to contain this part
8805 */ 8770 */
8806 List<Source> get containingLibraries => _containingLibraries; 8771 List<Source> get containingLibraries => _containingLibraries;
8807 8772
8808 @override 8773 @override
8809 SourceKind get kind => _sourceKind; 8774 SourceKind get kind => _sourceKind;
8810 8775
8811 /** 8776 /**
8812 * Answer an array of library sources containing the receiver's source. 8777 * The library sources containing the receiver's source.
8813 */ 8778 */
8814 List<Source> get librariesContaining { 8779 List<Source> get librariesContaining {
8815 DartEntryImpl_ResolutionState state = _resolutionState; 8780 ResolutionState state = _resolutionState;
8816 List<Source> result = new List<Source>(); 8781 List<Source> result = new List<Source>();
8817 while (state != null) { 8782 while (state != null) {
8818 if (state._librarySource != null) { 8783 if (state._librarySource != null) {
8819 result.add(state._librarySource); 8784 result.add(state._librarySource);
8820 } 8785 }
8821 state = state._nextState; 8786 state = state._nextState;
8822 } 8787 }
8823 return new List.from(result); 8788 return new List.from(result);
8824 } 8789 }
8825 8790
8826 /** 8791 /**
8827 * Return a compilation unit that has not been accessed by any other client an d can therefore 8792 * A compilation unit that has not been accessed by any other client and can
8828 * safely be modified by the reconciler, or `null` if the source has not been parsed. 8793 * therefore safely be modified by the reconciler, or `null` if the source has
8829 * 8794 * not been parsed.
8830 * @return a compilation unit that can be modified by the reconciler
8831 */ 8795 */
8832 CompilationUnit get resolvableCompilationUnit { 8796 CompilationUnit get resolvableCompilationUnit {
8833 if (_parsedUnitState == CacheState.VALID) { 8797 if (_parsedUnitState == CacheState.VALID) {
8834 if (_parsedUnitAccessed) { 8798 if (_parsedUnitAccessed) {
8835 return _parsedUnit.accept(new AstCloner()) as CompilationUnit; 8799 return _parsedUnit.accept(new AstCloner()) as CompilationUnit;
8836 } 8800 }
8837 CompilationUnit unit = _parsedUnit; 8801 CompilationUnit unit = _parsedUnit;
8838 _parsedUnitState = CacheState.FLUSHED; 8802 _parsedUnitState = CacheState.FLUSHED;
8839 _parsedUnitAccessed = false; 8803 _parsedUnitAccessed = false;
8840 _parsedUnit = null; 8804 _parsedUnit = null;
8841 return unit; 8805 return unit;
8842 } 8806 }
8843 DartEntryImpl_ResolutionState state = _resolutionState; 8807 ResolutionState state = _resolutionState;
8844 while (state != null) { 8808 while (state != null) {
8845 if (state._builtUnitState == CacheState.VALID) { 8809 if (state._builtUnitState == CacheState.VALID) {
8846 // TODO(brianwilkerson) We're cloning the structure to remove any previo us resolution data, 8810 // TODO(brianwilkerson) We're cloning the structure to remove any
8847 // but I'm not sure that's necessary. 8811 // previous resolution data, but I'm not sure that's necessary.
8848 return state._builtUnit.accept(new AstCloner()) as CompilationUnit; 8812 return state._builtUnit.accept(new AstCloner()) as CompilationUnit;
8849 } 8813 }
8850 if (state._resolvedUnitState == CacheState.VALID) { 8814 if (state._resolvedUnitState == CacheState.VALID) {
8851 return state._resolvedUnit.accept(new AstCloner()) as CompilationUnit; 8815 return state._resolvedUnit.accept(new AstCloner()) as CompilationUnit;
8852 } 8816 }
8853 state = state._nextState; 8817 state = state._nextState;
8854 } 8818 }
8855 ; 8819 ;
8856 return null; 8820 return null;
8857 } 8821 }
(...skipping 22 matching lines...) Expand all
8880 return _scanErrorsState; 8844 return _scanErrorsState;
8881 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { 8845 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
8882 return _sourceKindState; 8846 return _sourceKindState;
8883 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) { 8847 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) {
8884 return _tokenStreamState; 8848 return _tokenStreamState;
8885 } else { 8849 } else {
8886 return super.getState(descriptor); 8850 return super.getState(descriptor);
8887 } 8851 }
8888 } 8852 }
8889 8853
8890 @override 8854 /**
8855 * Return the state of the data represented by the given [descriptor] in the
8856 * context of the given [librarySource].
8857 */
8891 CacheState getStateInLibrary(DataDescriptor descriptor, Source librarySource) { 8858 CacheState getStateInLibrary(DataDescriptor descriptor, Source librarySource) {
8892 DartEntryImpl_ResolutionState state = _resolutionState; 8859 ResolutionState state = _resolutionState;
8893 while (state != null) { 8860 while (state != null) {
8894 if (librarySource == state._librarySource) { 8861 if (librarySource == state._librarySource) {
8895 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { 8862 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
8896 return state._resolutionErrorsState; 8863 return state._resolutionErrorsState;
8897 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 8864 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
8898 return state._resolvedUnitState; 8865 return state._resolvedUnitState;
8899 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 8866 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
8900 return state._verificationErrorsState; 8867 return state._verificationErrorsState;
8901 } else if (identical(descriptor, DartEntry.HINTS)) { 8868 } else if (identical(descriptor, DartEntry.HINTS)) {
8902 return state._hintsState; 8869 return state._hintsState;
8903 } else { 8870 } else {
8904 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" ); 8871 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" );
8905 } 8872 }
8906 } 8873 }
8907 state = state._nextState; 8874 state = state._nextState;
8908 } 8875 }
8909 ; 8876 ;
8910 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript or, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICATION_ERR ORS) || identical(descriptor, DartEntry.HINTS)) { 8877 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)
8878 || identical(descriptor, DartEntry.RESOLVED_UNIT)
8879 || identical(descriptor, DartEntry.VERIFICATION_ERRORS)
8880 || identical(descriptor, DartEntry.HINTS)) {
8911 return CacheState.INVALID; 8881 return CacheState.INVALID;
8912 } else { 8882 } else {
8913 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 8883 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
8914 } 8884 }
8915 } 8885 }
8916 8886
8917 @override 8887 @override
8918 Object getValue(DataDescriptor descriptor) { 8888 Object getValue(DataDescriptor descriptor) {
8919 if (identical(descriptor, DartEntry.ANGULAR_ERRORS)) { 8889 if (identical(descriptor, DartEntry.ANGULAR_ERRORS)) {
8920 return _angularErrors; 8890 return _angularErrors;
(...skipping 21 matching lines...) Expand all
8942 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) { 8912 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) {
8943 return _scanErrors; 8913 return _scanErrors;
8944 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { 8914 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
8945 return _sourceKind; 8915 return _sourceKind;
8946 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) { 8916 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) {
8947 return _tokenStream; 8917 return _tokenStream;
8948 } 8918 }
8949 return super.getValue(descriptor); 8919 return super.getValue(descriptor);
8950 } 8920 }
8951 8921
8952 @override 8922 /**
8923 * Return the value of the data represented by the given [descriptor] in the
8924 * context of the given [librarySource], or `null` if the data represented by
8925 * the descriptor is not in the cache.
8926 */
8953 Object getValueInLibrary(DataDescriptor descriptor, Source librarySource) { 8927 Object getValueInLibrary(DataDescriptor descriptor, Source librarySource) {
8954 DartEntryImpl_ResolutionState state = _resolutionState; 8928 ResolutionState state = _resolutionState;
8955 while (state != null) { 8929 while (state != null) {
8956 if (librarySource == state._librarySource) { 8930 if (librarySource == state._librarySource) {
8957 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { 8931 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
8958 return state._resolutionErrors; 8932 return state._resolutionErrors;
8959 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 8933 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
8960 return state._resolvedUnit; 8934 return state._resolvedUnit;
8961 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 8935 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
8962 return state._verificationErrors; 8936 return state._verificationErrors;
8963 } else if (identical(descriptor, DartEntry.HINTS)) { 8937 } else if (identical(descriptor, DartEntry.HINTS)) {
8964 return state._hints; 8938 return state._hints;
8965 } else { 8939 } else {
8966 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" ); 8940 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" );
8967 } 8941 }
8968 } 8942 }
8969 state = state._nextState; 8943 state = state._nextState;
8970 } 8944 }
8971 ; 8945 ;
8972 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript or, DartEntry.VERIFICATION_ERRORS) || identical(descriptor, DartEntry.HINTS)) { 8946 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)
8947 || identical(descriptor, DartEntry.VERIFICATION_ERRORS)
8948 || identical(descriptor, DartEntry.HINTS)) {
8973 return AnalysisError.NO_ERRORS; 8949 return AnalysisError.NO_ERRORS;
8974 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 8950 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
8975 return null; 8951 return null;
8976 } else { 8952 } else {
8977 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 8953 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
8978 } 8954 }
8979 } 8955 }
8980 8956
8981 @override 8957 /**
8958 * Return `true` if the data represented by the given [descriptor] is marked
8959 * as being invalid. If the descriptor represents library-specific data then
8960 * this method will return `true` if the data associated with any library it
8961 * marked as invalid.
8962 */
8982 bool hasInvalidData(DataDescriptor descriptor) { 8963 bool hasInvalidData(DataDescriptor descriptor) {
8983 if (identical(descriptor, DartEntry.ELEMENT)) { 8964 if (identical(descriptor, DartEntry.ELEMENT)) {
8984 return _elementState == CacheState.INVALID; 8965 return _elementState == CacheState.INVALID;
8985 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { 8966 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) {
8986 return _exportedLibrariesState == CacheState.INVALID; 8967 return _exportedLibrariesState == CacheState.INVALID;
8987 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { 8968 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) {
8988 return _importedLibrariesState == CacheState.INVALID; 8969 return _importedLibrariesState == CacheState.INVALID;
8989 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { 8970 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) {
8990 return _includedPartsState == CacheState.INVALID; 8971 return _includedPartsState == CacheState.INVALID;
8991 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { 8972 } else if (identical(descriptor, DartEntry.IS_CLIENT)) {
8992 return _clientServerState == CacheState.INVALID; 8973 return _clientServerState == CacheState.INVALID;
8993 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { 8974 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) {
8994 return _launchableState == CacheState.INVALID; 8975 return _launchableState == CacheState.INVALID;
8995 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { 8976 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) {
8996 return _parseErrorsState == CacheState.INVALID; 8977 return _parseErrorsState == CacheState.INVALID;
8997 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { 8978 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) {
8998 return _parsedUnitState == CacheState.INVALID; 8979 return _parsedUnitState == CacheState.INVALID;
8999 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { 8980 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) {
9000 return _publicNamespaceState == CacheState.INVALID; 8981 return _publicNamespaceState == CacheState.INVALID;
9001 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) { 8982 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) {
9002 return _scanErrorsState == CacheState.INVALID; 8983 return _scanErrorsState == CacheState.INVALID;
9003 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { 8984 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
9004 return _sourceKindState == CacheState.INVALID; 8985 return _sourceKindState == CacheState.INVALID;
9005 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) { 8986 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) {
9006 return _tokenStreamState == CacheState.INVALID; 8987 return _tokenStreamState == CacheState.INVALID;
9007 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(d escriptor, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICAT ION_ERRORS) || identical(descriptor, DartEntry.HINTS)) { 8988 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)
9008 DartEntryImpl_ResolutionState state = _resolutionState; 8989 || identical(descriptor, DartEntry.RESOLVED_UNIT)
8990 || identical(descriptor, DartEntry.VERIFICATION_ERRORS)
8991 || identical(descriptor, DartEntry.HINTS)) {
8992 ResolutionState state = _resolutionState;
9009 while (state != null) { 8993 while (state != null) {
9010 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { 8994 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
9011 return state._resolutionErrorsState == CacheState.INVALID; 8995 return state._resolutionErrorsState == CacheState.INVALID;
9012 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 8996 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
9013 return state._resolvedUnitState == CacheState.INVALID; 8997 return state._resolvedUnitState == CacheState.INVALID;
9014 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 8998 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
9015 return state._verificationErrorsState == CacheState.INVALID; 8999 return state._verificationErrorsState == CacheState.INVALID;
9016 } else if (identical(descriptor, DartEntry.HINTS)) { 9000 } else if (identical(descriptor, DartEntry.HINTS)) {
9017 return state._hintsState == CacheState.INVALID; 9001 return state._hintsState == CacheState.INVALID;
9018 } 9002 }
9019 } 9003 }
9020 return false; 9004 return false;
9021 } else { 9005 } else {
9022 return super.getState(descriptor) == CacheState.INVALID; 9006 return super.getState(descriptor) == CacheState.INVALID;
9023 } 9007 }
9024 } 9008 }
9025 9009
9026 @override 9010 /**
9011 * Return `true` if this entry has an AST structure that can be resolved, even
9012 * if it needs to be copied. Returning `true` implies that the method
9013 * [resolvableCompilationUnit] will return a non-`null` result.
9014 */
9027 bool get hasResolvableCompilationUnit { 9015 bool get hasResolvableCompilationUnit {
9028 if (_parsedUnitState == CacheState.VALID) { 9016 if (_parsedUnitState == CacheState.VALID) {
9029 return true; 9017 return true;
9030 } 9018 }
9031 DartEntryImpl_ResolutionState state = _resolutionState; 9019 ResolutionState state = _resolutionState;
9032 while (state != null) { 9020 while (state != null) {
9033 if (state._builtUnitState == CacheState.VALID || state._resolvedUnitState == CacheState.VALID) { 9021 if (state._builtUnitState == CacheState.VALID
9022 || state._resolvedUnitState == CacheState.VALID) {
9034 return true; 9023 return true;
9035 } 9024 }
9036 state = state._nextState; 9025 state = state._nextState;
9037 } 9026 }
9038 ; 9027 ;
9039 return false; 9028 return false;
9040 } 9029 }
9041 9030
9042 @override 9031 @override
9043 void invalidateAllInformation() { 9032 void invalidateAllInformation() {
9044 super.invalidateAllInformation(); 9033 super.invalidateAllInformation();
9045 _scanErrors = AnalysisError.NO_ERRORS; 9034 _scanErrors = AnalysisError.NO_ERRORS;
9046 _scanErrorsState = CacheState.INVALID; 9035 _scanErrorsState = CacheState.INVALID;
9047 _tokenStream = null; 9036 _tokenStream = null;
9048 _tokenStreamState = CacheState.INVALID; 9037 _tokenStreamState = CacheState.INVALID;
9049 _sourceKind = SourceKind.UNKNOWN; 9038 _sourceKind = SourceKind.UNKNOWN;
9050 _sourceKindState = CacheState.INVALID; 9039 _sourceKindState = CacheState.INVALID;
9051 _parseErrors = AnalysisError.NO_ERRORS; 9040 _parseErrors = AnalysisError.NO_ERRORS;
9052 _parseErrorsState = CacheState.INVALID; 9041 _parseErrorsState = CacheState.INVALID;
9053 _parsedUnit = null; 9042 _parsedUnit = null;
9054 _parsedUnitAccessed = false; 9043 _parsedUnitAccessed = false;
9055 _parsedUnitState = CacheState.INVALID; 9044 _parsedUnitState = CacheState.INVALID;
9056 _discardCachedResolutionInformation(true); 9045 _discardCachedResolutionInformation(true);
9057 } 9046 }
9058 9047
9059 /** 9048 /**
9060 * Invalidate all of the resolution information associated with the compilatio n unit. 9049 * Invalidate all of the resolution information associated with the
9061 * 9050 * compilation unit. The flag [invalidateUris] should be `true` if the cached
9062 * @param invalidateUris true if the cached results of converting URIs to sour ce files should also 9051 * results of converting URIs to source files should also be invalidated.
9063 * be invalidated.
9064 */ 9052 */
9065 void invalidateAllResolutionInformation(bool invalidateUris) { 9053 void invalidateAllResolutionInformation(bool invalidateUris) {
9066 if (_parsedUnitState == CacheState.FLUSHED) { 9054 if (_parsedUnitState == CacheState.FLUSHED) {
9067 DartEntryImpl_ResolutionState state = _resolutionState; 9055 ResolutionState state = _resolutionState;
9068 while (state != null) { 9056 while (state != null) {
9069 if (state._builtUnitState == CacheState.VALID) { 9057 if (state._builtUnitState == CacheState.VALID) {
9070 _parsedUnit = state._builtUnit; 9058 _parsedUnit = state._builtUnit;
9071 _parsedUnitAccessed = true; 9059 _parsedUnitAccessed = true;
9072 _parsedUnitState = CacheState.VALID; 9060 _parsedUnitState = CacheState.VALID;
9073 break; 9061 break;
9074 } else if (state._resolvedUnitState == CacheState.VALID) { 9062 } else if (state._resolvedUnitState == CacheState.VALID) {
9075 _parsedUnit = state._resolvedUnit; 9063 _parsedUnit = state._resolvedUnit;
9076 _parsedUnitAccessed = true; 9064 _parsedUnitAccessed = true;
9077 _parsedUnitState = CacheState.VALID; 9065 _parsedUnitState = CacheState.VALID;
9078 break; 9066 break;
9079 } 9067 }
9080 state = state._nextState; 9068 state = state._nextState;
9081 } 9069 }
9082 } 9070 }
9083 _discardCachedResolutionInformation(invalidateUris); 9071 _discardCachedResolutionInformation(invalidateUris);
9084 } 9072 }
9085 9073
9086 @override 9074 /**
9075 * Return `true` if this data is safe to use in refactoring.
9076 */
9087 bool get isRefactoringSafe { 9077 bool get isRefactoringSafe {
9088 DartEntryImpl_ResolutionState state = _resolutionState; 9078 ResolutionState state = _resolutionState;
9089 while (state != null) { 9079 while (state != null) {
9090 CacheState resolvedState = state._resolvedUnitState; 9080 CacheState resolvedState = state._resolvedUnitState;
9091 if (resolvedState != CacheState.VALID && resolvedState != CacheState.FLUSH ED) { 9081 if (resolvedState != CacheState.VALID
9082 && resolvedState != CacheState.FLUSHED) {
9092 return false; 9083 return false;
9093 } 9084 }
9094 state = state._nextState; 9085 state = state._nextState;
9095 } 9086 }
9096 return true; 9087 return true;
9097 } 9088 }
9098 9089
9099 /** 9090 /**
9100 * Record that an error occurred while attempting to build the element model f or the source 9091 * Record that an error occurred while attempting to build the element model
9101 * represented by this entry. This will set the state of all resolution-based information as being 9092 * for the source represented by this entry. This will set the state of all
9102 * in error, but will not change the state of any parse results. 9093 * resolution-based information as being in error, but will not change the
9094 * state of any parse results.
9103 * 9095 *
9104 * @param librarySource the source of the library in which the element model w as being built 9096 * @param librarySource the source of the library in which the element model w as being built
9105 * @param exception the exception that shows where the error occurred 9097 * @param exception the exception that shows where the error occurred
9106 */ 9098 */
9107 void recordBuildElementErrorInLibrary(Source librarySource, CaughtException ex ception) { 9099 void recordBuildElementErrorInLibrary(Source librarySource, CaughtException ex ception) {
9108 this.exception = exception; 9100 this.exception = exception;
9109 _element = null; 9101 _element = null;
9110 _elementState = CacheState.ERROR; 9102 _elementState = CacheState.ERROR;
9111 clearFlags([_LAUNCHABLE_INDEX, _CLIENT_CODE_INDEX]); 9103 clearFlags([_LAUNCHABLE_INDEX, _CLIENT_CODE_INDEX]);
9112 _clientServerState = CacheState.ERROR; 9104 _clientServerState = CacheState.ERROR;
9113 _launchableState = CacheState.ERROR; 9105 _launchableState = CacheState.ERROR;
9114 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou rce); 9106 ResolutionState state = _getOrCreateResolutionState(librarySource);
9115 state.recordBuildElementError(); 9107 state.recordBuildElementError();
9116 } 9108 }
9117 9109
9118 /** 9110 /**
9119 * Record that an in-process model build has stopped without recording results because the results 9111 * Record that an in-process model build has stopped without recording results
9120 * were invalidated before they could be recorded. 9112 * because the results were invalidated before they could be recorded.
9121 */ 9113 */
9122 void recordBuildElementNotInProcess() { 9114 void recordBuildElementNotInProcess() {
9123 if (_elementState == CacheState.IN_PROCESS) { 9115 if (_elementState == CacheState.IN_PROCESS) {
9124 _elementState = CacheState.INVALID; 9116 _elementState = CacheState.INVALID;
9125 } 9117 }
9126 if (_clientServerState == CacheState.IN_PROCESS) { 9118 if (_clientServerState == CacheState.IN_PROCESS) {
9127 _clientServerState = CacheState.INVALID; 9119 _clientServerState = CacheState.INVALID;
9128 } 9120 }
9129 if (_launchableState == CacheState.IN_PROCESS) { 9121 if (_launchableState == CacheState.IN_PROCESS) {
9130 _launchableState = CacheState.INVALID; 9122 _launchableState = CacheState.INVALID;
9131 } 9123 }
9132 } 9124 }
9133 9125
9134 @override 9126 @override
9135 void recordContentError(CaughtException exception) { 9127 void recordContentError(CaughtException exception) {
9136 super.recordContentError(exception); 9128 super.recordContentError(exception);
9137 recordScanError(exception); 9129 recordScanError(exception);
9138 } 9130 }
9139 9131
9140 /** 9132 /**
9141 * Record that an error occurred while attempting to generate hints for the so urce represented by 9133 * Record that an error occurred while attempting to generate hints for the
9142 * this entry. This will set the state of all verification information as bein g in error. 9134 * source represented by this entry. This will set the state of all
9135 * verification information as being in error.
9143 * 9136 *
9144 * @param librarySource the source of the library in which hints were being ge nerated 9137 * @param librarySource the source of the library in which hints were being ge nerated
9145 * @param exception the exception that shows where the error occurred 9138 * @param exception the exception that shows where the error occurred
9146 */ 9139 */
9147 void recordHintErrorInLibrary(Source librarySource, CaughtException exception) { 9140 void recordHintErrorInLibrary(Source librarySource, CaughtException exception) {
9148 this.exception = exception; 9141 this.exception = exception;
9149 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou rce); 9142 ResolutionState state = _getOrCreateResolutionState(librarySource);
9150 state.recordHintError(); 9143 state.recordHintError();
9151 } 9144 }
9152 9145
9153 /** 9146 /**
9154 * Record that an error occurred while attempting to scan or parse the entry r epresented by this 9147 * Record that an [exception] occurred while attempting to scan or parse the
9155 * entry. This will set the state of all information, including any resolution -based information, 9148 * entry represented by this entry. This will set the state of all information ,
9156 * as being in error. 9149 * including any resolution-based information, as being in error.
9157 *
9158 * @param exception the exception that shows where the error occurred
9159 */ 9150 */
9160 void recordParseError(CaughtException exception) { 9151 void recordParseError(CaughtException exception) {
9161 _sourceKind = SourceKind.UNKNOWN; 9152 _sourceKind = SourceKind.UNKNOWN;
9162 _sourceKindState = CacheState.ERROR; 9153 _sourceKindState = CacheState.ERROR;
9163 _parseErrors = AnalysisError.NO_ERRORS; 9154 _parseErrors = AnalysisError.NO_ERRORS;
9164 _parseErrorsState = CacheState.ERROR; 9155 _parseErrorsState = CacheState.ERROR;
9165 _parsedUnit = null; 9156 _parsedUnit = null;
9166 _parsedUnitAccessed = false; 9157 _parsedUnitAccessed = false;
9167 _parsedUnitState = CacheState.ERROR; 9158 _parsedUnitState = CacheState.ERROR;
9168 _exportedLibraries = Source.EMPTY_ARRAY; 9159 _exportedLibraries = Source.EMPTY_ARRAY;
9169 _exportedLibrariesState = CacheState.ERROR; 9160 _exportedLibrariesState = CacheState.ERROR;
9170 _importedLibraries = Source.EMPTY_ARRAY; 9161 _importedLibraries = Source.EMPTY_ARRAY;
9171 _importedLibrariesState = CacheState.ERROR; 9162 _importedLibrariesState = CacheState.ERROR;
9172 _includedParts = Source.EMPTY_ARRAY; 9163 _includedParts = Source.EMPTY_ARRAY;
9173 _includedPartsState = CacheState.ERROR; 9164 _includedPartsState = CacheState.ERROR;
9174 recordResolutionError(exception); 9165 recordResolutionError(exception);
9175 } 9166 }
9176 9167
9177 /** 9168 /**
9178 * Record that the parse-related information for the associated source is abou t to be computed by 9169 * Record that the parse-related information for the associated source is
9179 * the current thread. 9170 * about to be computed by the current thread.
9180 */ 9171 */
9181 void recordParseInProcess() { 9172 void recordParseInProcess() {
9182 if (_sourceKindState != CacheState.VALID) { 9173 if (_sourceKindState != CacheState.VALID) {
9183 _sourceKindState = CacheState.IN_PROCESS; 9174 _sourceKindState = CacheState.IN_PROCESS;
9184 } 9175 }
9185 if (_parseErrorsState != CacheState.VALID) { 9176 if (_parseErrorsState != CacheState.VALID) {
9186 _parseErrorsState = CacheState.IN_PROCESS; 9177 _parseErrorsState = CacheState.IN_PROCESS;
9187 } 9178 }
9188 if (_parsedUnitState != CacheState.VALID) { 9179 if (_parsedUnitState != CacheState.VALID) {
9189 _parsedUnitState = CacheState.IN_PROCESS; 9180 _parsedUnitState = CacheState.IN_PROCESS;
9190 } 9181 }
9191 if (_exportedLibrariesState != CacheState.VALID) { 9182 if (_exportedLibrariesState != CacheState.VALID) {
9192 _exportedLibrariesState = CacheState.IN_PROCESS; 9183 _exportedLibrariesState = CacheState.IN_PROCESS;
9193 } 9184 }
9194 if (_importedLibrariesState != CacheState.VALID) { 9185 if (_importedLibrariesState != CacheState.VALID) {
9195 _importedLibrariesState = CacheState.IN_PROCESS; 9186 _importedLibrariesState = CacheState.IN_PROCESS;
9196 } 9187 }
9197 if (_includedPartsState != CacheState.VALID) { 9188 if (_includedPartsState != CacheState.VALID) {
9198 _includedPartsState = CacheState.IN_PROCESS; 9189 _includedPartsState = CacheState.IN_PROCESS;
9199 } 9190 }
9200 } 9191 }
9201 9192
9202 /** 9193 /**
9203 * Record that an in-process parse has stopped without recording results becau se the results were 9194 * Record that an in-process parse has stopped without recording results
9204 * invalidated before they could be recorded. 9195 * because the results were invalidated before they could be recorded.
9205 */ 9196 */
9206 void recordParseNotInProcess() { 9197 void recordParseNotInProcess() {
9207 if (getState(SourceEntry.LINE_INFO) == CacheState.IN_PROCESS) { 9198 if (getState(SourceEntry.LINE_INFO) == CacheState.IN_PROCESS) {
9208 setState(SourceEntry.LINE_INFO, CacheState.INVALID); 9199 setState(SourceEntry.LINE_INFO, CacheState.INVALID);
9209 } 9200 }
9210 if (_sourceKindState == CacheState.IN_PROCESS) { 9201 if (_sourceKindState == CacheState.IN_PROCESS) {
9211 _sourceKindState = CacheState.INVALID; 9202 _sourceKindState = CacheState.INVALID;
9212 } 9203 }
9213 if (_parseErrorsState == CacheState.IN_PROCESS) { 9204 if (_parseErrorsState == CacheState.IN_PROCESS) {
9214 _parseErrorsState = CacheState.INVALID; 9205 _parseErrorsState = CacheState.INVALID;
9215 } 9206 }
9216 if (_parsedUnitState == CacheState.IN_PROCESS) { 9207 if (_parsedUnitState == CacheState.IN_PROCESS) {
9217 _parsedUnitState = CacheState.INVALID; 9208 _parsedUnitState = CacheState.INVALID;
9218 } 9209 }
9219 if (_exportedLibrariesState == CacheState.IN_PROCESS) { 9210 if (_exportedLibrariesState == CacheState.IN_PROCESS) {
9220 _exportedLibrariesState = CacheState.INVALID; 9211 _exportedLibrariesState = CacheState.INVALID;
9221 } 9212 }
9222 if (_importedLibrariesState == CacheState.IN_PROCESS) { 9213 if (_importedLibrariesState == CacheState.IN_PROCESS) {
9223 _importedLibrariesState = CacheState.INVALID; 9214 _importedLibrariesState = CacheState.INVALID;
9224 } 9215 }
9225 if (_includedPartsState == CacheState.IN_PROCESS) { 9216 if (_includedPartsState == CacheState.IN_PROCESS) {
9226 _includedPartsState = CacheState.INVALID; 9217 _includedPartsState = CacheState.INVALID;
9227 } 9218 }
9228 } 9219 }
9229 9220
9230 /** 9221 /**
9231 * Record that an error occurred while attempting to resolve the source repres ented by this entry. 9222 * Record that an [exception] occurred while attempting to resolve the source
9232 * This will set the state of all resolution-based information as being in err or, but will not 9223 * represented by this entry. This will set the state of all resolution-based
9233 * change the state of any parse results. 9224 * information as being in error, but will not change the state of any parse
9225 * results.
9234 * 9226 *
9235 * @param exception the exception that shows where the error occurred 9227 * @param exception the exception that shows where the error occurred
9236 */ 9228 */
9237 void recordResolutionError(CaughtException exception) { 9229 void recordResolutionError(CaughtException exception) {
9238 this.exception = exception; 9230 this.exception = exception;
9239 _element = null; 9231 _element = null;
9240 _elementState = CacheState.ERROR; 9232 _elementState = CacheState.ERROR;
9241 clearFlags([_LAUNCHABLE_INDEX, _CLIENT_CODE_INDEX]); 9233 clearFlags([_LAUNCHABLE_INDEX, _CLIENT_CODE_INDEX]);
9242 _clientServerState = CacheState.ERROR; 9234 _clientServerState = CacheState.ERROR;
9243 _launchableState = CacheState.ERROR; 9235 _launchableState = CacheState.ERROR;
(...skipping 12 matching lines...) Expand all
9256 */ 9248 */
9257 void recordResolutionErrorInLibrary(Source librarySource, CaughtException exce ption) { 9249 void recordResolutionErrorInLibrary(Source librarySource, CaughtException exce ption) {
9258 this.exception = exception; 9250 this.exception = exception;
9259 _element = null; 9251 _element = null;
9260 _elementState = CacheState.ERROR; 9252 _elementState = CacheState.ERROR;
9261 clearFlags([_LAUNCHABLE_INDEX, _CLIENT_CODE_INDEX]); 9253 clearFlags([_LAUNCHABLE_INDEX, _CLIENT_CODE_INDEX]);
9262 _clientServerState = CacheState.ERROR; 9254 _clientServerState = CacheState.ERROR;
9263 _launchableState = CacheState.ERROR; 9255 _launchableState = CacheState.ERROR;
9264 _publicNamespace = null; 9256 _publicNamespace = null;
9265 _publicNamespaceState = CacheState.ERROR; 9257 _publicNamespaceState = CacheState.ERROR;
9266 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou rce); 9258 ResolutionState state = _getOrCreateResolutionState(librarySource);
9267 state.recordResolutionError(); 9259 state.recordResolutionError();
9268 } 9260 }
9269 9261
9270 /** 9262 /**
9271 * Record that an in-process resolution has stopped without recording results because the results 9263 * Record that an in-process resolution has stopped without recording results because the results
9272 * were invalidated before they could be recorded. 9264 * were invalidated before they could be recorded.
9273 */ 9265 */
9274 void recordResolutionNotInProcess() { 9266 void recordResolutionNotInProcess() {
9275 if (_elementState == CacheState.IN_PROCESS) { 9267 if (_elementState == CacheState.IN_PROCESS) {
9276 _elementState = CacheState.INVALID; 9268 _elementState = CacheState.INVALID;
9277 } 9269 }
9278 if (_clientServerState == CacheState.IN_PROCESS) { 9270 if (_clientServerState == CacheState.IN_PROCESS) {
9279 _clientServerState = CacheState.INVALID; 9271 _clientServerState = CacheState.INVALID;
9280 } 9272 }
9281 if (_launchableState == CacheState.IN_PROCESS) { 9273 if (_launchableState == CacheState.IN_PROCESS) {
9282 _launchableState = CacheState.INVALID; 9274 _launchableState = CacheState.INVALID;
9283 } 9275 }
9284 // TODO(brianwilkerson) Remove the code above this line after resolution and element building 9276 // TODO(brianwilkerson) Remove the code above this line after resolution and element building
9285 // are separated. 9277 // are separated.
9286 if (_publicNamespaceState == CacheState.IN_PROCESS) { 9278 if (_publicNamespaceState == CacheState.IN_PROCESS) {
9287 _publicNamespaceState = CacheState.INVALID; 9279 _publicNamespaceState = CacheState.INVALID;
9288 } 9280 }
9289 _resolutionState.recordResolutionNotInProcess(); 9281 _resolutionState.recordResolutionNotInProcess();
9290 } 9282 }
9291 9283
9292 /** 9284 /**
9293 * Record that an error occurred while attempting to scan or parse the entry r epresented by this 9285 * Record that an [exception] occurred while attempting to scan or parse the
9294 * entry. This will set the state of all information, including any resolution -based information, 9286 * entry represented by this entry. This will set the state of all information ,
9295 * as being in error. 9287 * including any resolution-based information, as being in error.
9296 *
9297 * @param exception the exception that shows where the error occurred
9298 */ 9288 */
9299 @override 9289 @override
9300 void recordScanError(CaughtException exception) { 9290 void recordScanError(CaughtException exception) {
9301 super.recordScanError(exception); 9291 super.recordScanError(exception);
9302 _scanErrors = AnalysisError.NO_ERRORS; 9292 _scanErrors = AnalysisError.NO_ERRORS;
9303 _scanErrorsState = CacheState.ERROR; 9293 _scanErrorsState = CacheState.ERROR;
9304 _tokenStream = null; 9294 _tokenStream = null;
9305 _tokenStreamState = CacheState.ERROR; 9295 _tokenStreamState = CacheState.ERROR;
9306 recordParseError(exception); 9296 recordParseError(exception);
9307 } 9297 }
9308 9298
9309 /** 9299 /**
9310 * Record that the scan-related information for the associated source is about to be computed by 9300 * Record that the scan-related information for the associated source is about
9311 * the current thread. 9301 * to be computed by the current thread.
9312 */ 9302 */
9313 void recordScanInProcess() { 9303 void recordScanInProcess() {
9314 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) { 9304 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) {
9315 setState(SourceEntry.LINE_INFO, CacheState.IN_PROCESS); 9305 setState(SourceEntry.LINE_INFO, CacheState.IN_PROCESS);
9316 } 9306 }
9317 if (_scanErrorsState != CacheState.VALID) { 9307 if (_scanErrorsState != CacheState.VALID) {
9318 _scanErrorsState = CacheState.IN_PROCESS; 9308 _scanErrorsState = CacheState.IN_PROCESS;
9319 } 9309 }
9320 if (_tokenStreamState != CacheState.VALID) { 9310 if (_tokenStreamState != CacheState.VALID) {
9321 _tokenStreamState = CacheState.IN_PROCESS; 9311 _tokenStreamState = CacheState.IN_PROCESS;
9322 } 9312 }
9323 } 9313 }
9324 9314
9325 /** 9315 /**
9326 * Record that an in-process scan has stopped without recording results becaus e the results were 9316 * Record that an in-process scan has stopped without recording results
9327 * invalidated before they could be recorded. 9317 * because the results were invalidated before they could be recorded.
9328 */ 9318 */
9329 void recordScanNotInProcess() { 9319 void recordScanNotInProcess() {
9330 if (getState(SourceEntry.LINE_INFO) == CacheState.IN_PROCESS) { 9320 if (getState(SourceEntry.LINE_INFO) == CacheState.IN_PROCESS) {
9331 setState(SourceEntry.LINE_INFO, CacheState.INVALID); 9321 setState(SourceEntry.LINE_INFO, CacheState.INVALID);
9332 } 9322 }
9333 if (_scanErrorsState == CacheState.IN_PROCESS) { 9323 if (_scanErrorsState == CacheState.IN_PROCESS) {
9334 _scanErrorsState = CacheState.INVALID; 9324 _scanErrorsState = CacheState.INVALID;
9335 } 9325 }
9336 if (_tokenStreamState == CacheState.IN_PROCESS) { 9326 if (_tokenStreamState == CacheState.IN_PROCESS) {
9337 _tokenStreamState = CacheState.INVALID; 9327 _tokenStreamState = CacheState.INVALID;
9338 } 9328 }
9339 } 9329 }
9340 9330
9341 /** 9331 /**
9342 * Record that an error occurred while attempting to generate errors and warni ngs for the source 9332 * Record that an [exception] occurred while attempting to generate errors and
9343 * represented by this entry. This will set the state of all verification info rmation as being in 9333 * warnings for the source represented by this entry. This will set the state
9344 * error. 9334 * of all verification information as being in error.
9345 * 9335 *
9346 * @param librarySource the source of the library in which verification was be ing performed 9336 * @param librarySource the source of the library in which verification was be ing performed
9347 * @param exception the exception that shows where the error occurred 9337 * @param exception the exception that shows where the error occurred
9348 */ 9338 */
9349 void recordVerificationErrorInLibrary(Source librarySource, CaughtException ex ception) { 9339 void recordVerificationErrorInLibrary(Source librarySource, CaughtException ex ception) {
9350 this.exception = exception; 9340 this.exception = exception;
9351 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou rce); 9341 ResolutionState state = _getOrCreateResolutionState(librarySource);
9352 state.recordVerificationError(); 9342 state.recordVerificationError();
9353 } 9343 }
9354 9344
9355 /** 9345 /**
9356 * Remove the given library from the list of libraries that contain this part. This method should 9346 * Remove the given [library] from the list of libraries that contain this
9357 * only be invoked on entries that represent a part. 9347 * part. This method should only be invoked on entries that represent a part.
9358 * 9348 *
9359 * @param librarySource the source of the library to be removed 9349 * @param librarySource the source of the library to be removed
9360 */ 9350 */
9361 void removeContainingLibrary(Source librarySource) { 9351 void removeContainingLibrary(Source library) {
9362 _containingLibraries.remove(librarySource); 9352 _containingLibraries.remove(library);
9363 } 9353 }
9364 9354
9365 /** 9355 /**
9366 * Remove any resolution information associated with this compilation unit bei ng part of the given 9356 * Remove any resolution information associated with this compilation unit
9367 * library, presumably because it is no longer part of the library. 9357 * being part of the given [library], presumably because it is no longer part
9368 * 9358 * of the library.
9369 * @param librarySource the source of the defining compilation unit of the lib rary that used to
9370 * contain this part but no longer does
9371 */ 9359 */
9372 void removeResolution(Source librarySource) { 9360 void removeResolution(Source library) {
9373 if (librarySource != null) { 9361 if (library != null) {
9374 if (librarySource == _resolutionState._librarySource) { 9362 if (library == _resolutionState._librarySource) {
9375 if (_resolutionState._nextState == null) { 9363 if (_resolutionState._nextState == null) {
9376 _resolutionState.invalidateAllResolutionInformation(); 9364 _resolutionState.invalidateAllResolutionInformation();
9377 } else { 9365 } else {
9378 _resolutionState = _resolutionState._nextState; 9366 _resolutionState = _resolutionState._nextState;
9379 } 9367 }
9380 } else { 9368 } else {
9381 DartEntryImpl_ResolutionState priorState = _resolutionState; 9369 ResolutionState priorState = _resolutionState;
9382 DartEntryImpl_ResolutionState state = _resolutionState._nextState; 9370 ResolutionState state = _resolutionState._nextState;
9383 while (state != null) { 9371 while (state != null) {
9384 if (librarySource == state._librarySource) { 9372 if (library == state._librarySource) {
9385 priorState._nextState = state._nextState; 9373 priorState._nextState = state._nextState;
9386 break; 9374 break;
9387 } 9375 }
9388 priorState = state; 9376 priorState = state;
9389 state = state._nextState; 9377 state = state._nextState;
9390 } 9378 }
9391 } 9379 }
9392 } 9380 }
9393 } 9381 }
9394 9382
9395 /** 9383 /**
9396 * Set the list of libraries that contain this compilation unit to contain onl y the given source. 9384 * Set the list of libraries that contain this compilation unit to contain
9397 * This method should only be invoked on entries that represent a library. 9385 * only the given source. This method should only be invoked on entries that
9386 * represent a library.
9398 * 9387 *
9399 * @param librarySource the source of the single library that the list should contain 9388 * @param librarySource the source of the single library that the list should contain
9400 */ 9389 */
9401 void set containingLibrary(Source librarySource) { 9390 void set containingLibrary(Source librarySource) {
9402 _containingLibraries.clear(); 9391 _containingLibraries.clear();
9403 _containingLibraries.add(librarySource); 9392 _containingLibraries.add(librarySource);
9404 } 9393 }
9405 9394
9406 @override 9395 @override
9407 void setState(DataDescriptor descriptor, CacheState state) { 9396 void setState(DataDescriptor descriptor, CacheState state) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
9453 /** 9442 /**
9454 * Set the state of the data represented by the given descriptor in the contex t of the given 9443 * Set the state of the data represented by the given descriptor in the contex t of the given
9455 * library to the given state. 9444 * library to the given state.
9456 * 9445 *
9457 * @param descriptor the descriptor representing the data whose state is to be set 9446 * @param descriptor the descriptor representing the data whose state is to be set
9458 * @param librarySource the source of the defining compilation unit of the lib rary that is the 9447 * @param librarySource the source of the defining compilation unit of the lib rary that is the
9459 * context for the data 9448 * context for the data
9460 * @param cacheState the new state of the data represented by the given descri ptor 9449 * @param cacheState the new state of the data represented by the given descri ptor
9461 */ 9450 */
9462 void setStateInLibrary(DataDescriptor descriptor, Source librarySource, CacheS tate cacheState) { 9451 void setStateInLibrary(DataDescriptor descriptor, Source librarySource, CacheS tate cacheState) {
9463 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou rce); 9452 ResolutionState state = _getOrCreateResolutionState(librarySource);
9464 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { 9453 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
9465 state._resolutionErrors = updatedValue(cacheState, state._resolutionErrors , AnalysisError.NO_ERRORS); 9454 state._resolutionErrors = updatedValue(cacheState, state._resolutionErrors , AnalysisError.NO_ERRORS);
9466 state._resolutionErrorsState = cacheState; 9455 state._resolutionErrorsState = cacheState;
9467 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 9456 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
9468 state._resolvedUnit = updatedValue(cacheState, state._resolvedUnit, null); 9457 state._resolvedUnit = updatedValue(cacheState, state._resolvedUnit, null);
9469 state._resolvedUnitState = cacheState; 9458 state._resolvedUnitState = cacheState;
9470 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 9459 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
9471 state._verificationErrors = updatedValue(cacheState, state._verificationEr rors, AnalysisError.NO_ERRORS); 9460 state._verificationErrors = updatedValue(cacheState, state._verificationEr rors, AnalysisError.NO_ERRORS);
9472 state._verificationErrorsState = cacheState; 9461 state._verificationErrorsState = cacheState;
9473 } else if (identical(descriptor, DartEntry.HINTS)) { 9462 } else if (identical(descriptor, DartEntry.HINTS)) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
9519 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) { 9508 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) {
9520 _tokenStream = value as Token; 9509 _tokenStream = value as Token;
9521 _tokenStreamState = CacheState.VALID; 9510 _tokenStreamState = CacheState.VALID;
9522 } else { 9511 } else {
9523 super.setValue(descriptor, value); 9512 super.setValue(descriptor, value);
9524 } 9513 }
9525 } 9514 }
9526 9515
9527 /** 9516 /**
9528 * Set the value of the data represented by the given descriptor in the contex t of the given 9517 * Set the value of the data represented by the given descriptor in the contex t of the given
9529 * library to the given value, and set the state of that data to [CacheState#V ALID]. 9518 * library to the given value, and set the state of that data to [CacheState.V ALID].
9530 * 9519 *
9531 * @param descriptor the descriptor representing which data is to have its val ue set 9520 * @param descriptor the descriptor representing which data is to have its val ue set
9532 * @param librarySource the source of the defining compilation unit of the lib rary that is the 9521 * @param librarySource the source of the defining compilation unit of the lib rary that is the
9533 * context for the data 9522 * context for the data
9534 * @param value the new value of the data represented by the given descriptor and library 9523 * @param value the new value of the data represented by the given descriptor and library
9535 */ 9524 */
9536 void setValueInLibrary(DataDescriptor descriptor, Source librarySource, Object value) { 9525 void setValueInLibrary(DataDescriptor descriptor, Source librarySource, Object value) {
9537 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou rce); 9526 ResolutionState state = _getOrCreateResolutionState(librarySource);
9538 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { 9527 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
9539 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<AnalysisError>); 9528 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<AnalysisError>);
9540 state._resolutionErrorsState = CacheState.VALID; 9529 state._resolutionErrorsState = CacheState.VALID;
9541 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 9530 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
9542 state._resolvedUnit = value as CompilationUnit; 9531 state._resolvedUnit = value as CompilationUnit;
9543 state._resolvedUnitState = CacheState.VALID; 9532 state._resolvedUnitState = CacheState.VALID;
9544 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 9533 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
9545 state._verificationErrors = value == null ? AnalysisError.NO_ERRORS : (val ue as List<AnalysisError>); 9534 state._verificationErrors = value == null ? AnalysisError.NO_ERRORS : (val ue as List<AnalysisError>);
9546 state._verificationErrorsState = CacheState.VALID; 9535 state._verificationErrorsState = CacheState.VALID;
9547 } else if (identical(descriptor, DartEntry.HINTS)) { 9536 } else if (identical(descriptor, DartEntry.HINTS)) {
9548 state._hints = value == null ? AnalysisError.NO_ERRORS : (value as List<An alysisError>); 9537 state._hints = value == null ? AnalysisError.NO_ERRORS : (value as List<An alysisError>);
9549 state._hintsState = CacheState.VALID; 9538 state._hintsState = CacheState.VALID;
9550 } 9539 }
9551 } 9540 }
9552 9541
9553 @override 9542 @override
9554 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; 9543 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;
9555 9544
9556 @override 9545 @override
9557 bool writeDiffOn(JavaStringBuilder builder, SourceEntry oldEntry) { 9546 bool writeDiffOn(JavaStringBuilder builder, SourceEntry oldEntry) {
9558 bool needsSeparator = super.writeDiffOn(builder, oldEntry); 9547 bool needsSeparator = super.writeDiffOn(builder, oldEntry);
9559 if (oldEntry is! DartEntryImpl) { 9548 if (oldEntry is! DartEntry) {
9560 if (needsSeparator) { 9549 if (needsSeparator) {
9561 builder.append("; "); 9550 builder.append("; ");
9562 } 9551 }
9563 builder.append("entry type changed; was ${oldEntry.runtimeType.toString()} "); 9552 builder.append("entry type changed; was ${oldEntry.runtimeType.toString()} ");
9564 return true; 9553 return true;
9565 } 9554 }
9566 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.TOKEN_STREAM, "tokenStream"); 9555 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.TOKEN_STREAM, "tokenStream");
9567 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.SCAN_ERRORS, "scanErrors"); 9556 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.SCAN_ERRORS, "scanErrors");
9568 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.SOURCE_KIND, "sourceKind"); 9557 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.SOURCE_KIND, "sourceKind");
9569 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.PARSED_UNIT, "parsedUnit"); 9558 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.PARSED_UNIT, "parsedUnit");
9570 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.PARSE_ERRORS, "parseErrors"); 9559 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.PARSE_ERRORS, "parseErrors");
9571 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.IMPORTED_LIBRARIES, "importedLibraries"); 9560 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.IMPORTED_LIBRARIES, "importedLibraries");
9572 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.EXPORTED_LIBRARIES, "exportedLibraries"); 9561 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.EXPORTED_LIBRARIES, "exportedLibraries");
9573 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.INCLUDED_PARTS, "includedParts"); 9562 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.INCLUDED_PARTS, "includedParts");
9574 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.ELEMENT, "element"); 9563 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.ELEMENT, "element");
9575 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.PUBLIC_NAMESPACE, "publicNamespace"); 9564 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.PUBLIC_NAMESPACE, "publicNamespace");
9576 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.IS_CLIENT, "clientServer"); 9565 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.IS_CLIENT, "clientServer");
9577 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.IS_LAUNCHABLE, "launchable"); 9566 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.IS_LAUNCHABLE, "launchable");
9578 // TODO(brianwilkerson) Add better support for containingLibraries. It would be nice to be able 9567 // TODO(brianwilkerson) Add better support for containingLibraries. It would be nice to be able
9579 // to report on size-preserving changes. 9568 // to report on size-preserving changes.
9580 int oldLibraryCount = (oldEntry as DartEntryImpl)._containingLibraries.lengt h; 9569 int oldLibraryCount = (oldEntry as DartEntry)._containingLibraries.length;
9581 int libraryCount = _containingLibraries.length; 9570 int libraryCount = _containingLibraries.length;
9582 if (oldLibraryCount != libraryCount) { 9571 if (oldLibraryCount != libraryCount) {
9583 if (needsSeparator) { 9572 if (needsSeparator) {
9584 builder.append("; "); 9573 builder.append("; ");
9585 } 9574 }
9586 builder.append("containingLibraryCount = "); 9575 builder.append("containingLibraryCount = ");
9587 builder.append(oldLibraryCount); 9576 builder.append(oldLibraryCount);
9588 builder.append(" -> "); 9577 builder.append(" -> ");
9589 builder.append(libraryCount); 9578 builder.append(libraryCount);
9590 needsSeparator = true; 9579 needsSeparator = true;
9591 } 9580 }
9592 // 9581 //
9593 // Report change to the per-library state. 9582 // Report change to the per-library state.
9594 // 9583 //
9595 HashMap<Source, DartEntryImpl_ResolutionState> oldStateMap = new HashMap<Sou rce, DartEntryImpl_ResolutionState>(); 9584 HashMap<Source, ResolutionState> oldStateMap = new HashMap<Source, Resolutio nState>();
9596 DartEntryImpl_ResolutionState state = (oldEntry as DartEntryImpl)._resolutio nState; 9585 ResolutionState state = (oldEntry as DartEntry)._resolutionState;
9597 while (state != null) { 9586 while (state != null) {
9598 Source librarySource = state._librarySource; 9587 Source librarySource = state._librarySource;
9599 if (librarySource != null) { 9588 if (librarySource != null) {
9600 oldStateMap[librarySource] = state; 9589 oldStateMap[librarySource] = state;
9601 } 9590 }
9602 state = state._nextState; 9591 state = state._nextState;
9603 } 9592 }
9604 state = _resolutionState; 9593 state = _resolutionState;
9605 while (state != null) { 9594 while (state != null) {
9606 Source librarySource = state._librarySource; 9595 Source librarySource = state._librarySource;
9607 if (librarySource != null) { 9596 if (librarySource != null) {
9608 DartEntryImpl_ResolutionState oldState = oldStateMap.remove(librarySourc e); 9597 ResolutionState oldState = oldStateMap.remove(librarySource);
9609 if (oldState == null) { 9598 if (oldState == null) {
9610 if (needsSeparator) { 9599 if (needsSeparator) {
9611 builder.append("; "); 9600 builder.append("; ");
9612 } 9601 }
9613 builder.append("added resolution for "); 9602 builder.append("added resolution for ");
9614 builder.append(librarySource.fullName); 9603 builder.append(librarySource.fullName);
9615 needsSeparator = true; 9604 needsSeparator = true;
9616 } else { 9605 } else {
9617 needsSeparator = oldState.writeDiffOn(builder, needsSeparator, oldEntr y as DartEntry); 9606 needsSeparator = oldState.writeDiffOn(builder, needsSeparator, oldEntr y as DartEntry);
9618 } 9607 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
9688 _includedPartsState = CacheState.INVALID; 9677 _includedPartsState = CacheState.INVALID;
9689 } 9678 }
9690 } 9679 }
9691 9680
9692 /** 9681 /**
9693 * Return a resolution state for the specified library, creating one as necess ary. 9682 * Return a resolution state for the specified library, creating one as necess ary.
9694 * 9683 *
9695 * @param librarySource the library source (not `null`) 9684 * @param librarySource the library source (not `null`)
9696 * @return the resolution state (not `null`) 9685 * @return the resolution state (not `null`)
9697 */ 9686 */
9698 DartEntryImpl_ResolutionState _getOrCreateResolutionState(Source librarySource ) { 9687 ResolutionState _getOrCreateResolutionState(Source librarySource) {
9699 DartEntryImpl_ResolutionState state = _resolutionState; 9688 ResolutionState state = _resolutionState;
9700 if (state._librarySource == null) { 9689 if (state._librarySource == null) {
9701 state._librarySource = librarySource; 9690 state._librarySource = librarySource;
9702 return state; 9691 return state;
9703 } 9692 }
9704 while (state._librarySource != librarySource) { 9693 while (state._librarySource != librarySource) {
9705 if (state._nextState == null) { 9694 if (state._nextState == null) {
9706 DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionSta te(); 9695 ResolutionState newState = new ResolutionState();
9707 newState._librarySource = librarySource; 9696 newState._librarySource = librarySource;
9708 state._nextState = newState; 9697 state._nextState = newState;
9709 return newState; 9698 return newState;
9710 } 9699 }
9711 state = state._nextState; 9700 state = state._nextState;
9712 } 9701 }
9713 return state; 9702 return state;
9714 } 9703 }
9715 9704
9716 /** 9705 /**
(...skipping 10 matching lines...) Expand all
9727 // 9716 //
9728 // If the value is in process, we can leave the current value in the cache for any 'get' 9717 // If the value is in process, we can leave the current value in the cache for any 'get'
9729 // methods to access. 9718 // methods to access.
9730 // 9719 //
9731 setFlag(index, false); 9720 setFlag(index, false);
9732 } 9721 }
9733 } 9722 }
9734 } 9723 }
9735 9724
9736 /** 9725 /**
9737 * Instances of the class `ResolutionState` represent the information produced b y resolving
9738 * a compilation unit as part of a specific library.
9739 */
9740 class DartEntryImpl_ResolutionState {
9741 /**
9742 * The next resolution state or `null` if none.
9743 */
9744 DartEntryImpl_ResolutionState _nextState;
9745
9746 /**
9747 * The source for the defining compilation unit of the library that contains t his unit. If this
9748 * unit is the defining compilation unit for it's library, then this will be t he source for this
9749 * unit.
9750 */
9751 Source _librarySource;
9752
9753 /**
9754 * The state of the cached compilation unit that contains references to the bu ilt element model.
9755 */
9756 CacheState _builtUnitState = CacheState.INVALID;
9757
9758 /**
9759 * The compilation unit that contains references to the built element model, o r `null` if
9760 * that compilation unit is not currently cached.
9761 */
9762 CompilationUnit _builtUnit;
9763
9764 /**
9765 * The state of the cached errors reported while building an element model.
9766 */
9767 CacheState _buildElementErrorsState = CacheState.INVALID;
9768
9769 /**
9770 * The errors produced while building an element model, or an empty array if t he errors are not
9771 * currently cached.
9772 */
9773 List<AnalysisError> _buildElementErrors = AnalysisError.NO_ERRORS;
9774
9775 /**
9776 * The state of the cached resolved compilation unit.
9777 */
9778 CacheState _resolvedUnitState = CacheState.INVALID;
9779
9780 /**
9781 * The resolved compilation unit, or `null` if the resolved compilation unit i s not
9782 * currently cached.
9783 */
9784 CompilationUnit _resolvedUnit;
9785
9786 /**
9787 * The state of the cached resolution errors.
9788 */
9789 CacheState _resolutionErrorsState = CacheState.INVALID;
9790
9791 /**
9792 * The errors produced while resolving the compilation unit, or an empty array if the errors are
9793 * not currently cached.
9794 */
9795 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS;
9796
9797 /**
9798 * The state of the cached verification errors.
9799 */
9800 CacheState _verificationErrorsState = CacheState.INVALID;
9801
9802 /**
9803 * The errors produced while verifying the compilation unit, or an empty array if the errors are
9804 * not currently cached.
9805 */
9806 List<AnalysisError> _verificationErrors = AnalysisError.NO_ERRORS;
9807
9808 /**
9809 * The state of the cached hints.
9810 */
9811 CacheState _hintsState = CacheState.INVALID;
9812
9813 /**
9814 * The hints produced while auditing the compilation unit, or an empty array i f the hints are
9815 * not currently cached.
9816 */
9817 List<AnalysisError> _hints = AnalysisError.NO_ERRORS;
9818
9819 /**
9820 * Flush any AST structures being maintained by this state.
9821 */
9822 void flushAstStructures() {
9823 if (_builtUnitState == CacheState.VALID) {
9824 _builtUnitState = CacheState.FLUSHED;
9825 _builtUnit = null;
9826 }
9827 if (_resolvedUnitState == CacheState.VALID) {
9828 _resolvedUnitState = CacheState.FLUSHED;
9829 _resolvedUnit = null;
9830 }
9831 if (_nextState != null) {
9832 _nextState.flushAstStructures();
9833 }
9834 }
9835
9836 bool get hasErrorState => _builtUnitState == CacheState.ERROR || _buildElement ErrorsState == CacheState.ERROR || _resolvedUnitState == CacheState.ERROR || _re solutionErrorsState == CacheState.ERROR || _verificationErrorsState == CacheStat e.ERROR || _hintsState == CacheState.ERROR || (_nextState != null && _nextState. hasErrorState);
9837
9838 /**
9839 * Invalidate all of the resolution information associated with the compilatio n unit.
9840 */
9841 void invalidateAllResolutionInformation() {
9842 _nextState = null;
9843 _librarySource = null;
9844 _builtUnitState = CacheState.INVALID;
9845 _builtUnit = null;
9846 _buildElementErrorsState = CacheState.INVALID;
9847 _buildElementErrors = AnalysisError.NO_ERRORS;
9848 _resolvedUnitState = CacheState.INVALID;
9849 _resolvedUnit = null;
9850 _resolutionErrorsState = CacheState.INVALID;
9851 _resolutionErrors = AnalysisError.NO_ERRORS;
9852 _verificationErrorsState = CacheState.INVALID;
9853 _verificationErrors = AnalysisError.NO_ERRORS;
9854 _hintsState = CacheState.INVALID;
9855 _hints = AnalysisError.NO_ERRORS;
9856 }
9857
9858 /**
9859 * Record that an error occurred while attempting to build the element model f or the source
9860 * represented by this state.
9861 */
9862 void recordBuildElementError() {
9863 _builtUnitState = CacheState.ERROR;
9864 _builtUnit = null;
9865 _buildElementErrorsState = CacheState.ERROR;
9866 _buildElementErrors = AnalysisError.NO_ERRORS;
9867 recordResolutionError();
9868 }
9869
9870 /**
9871 * Record that an error occurred while attempting to generate hints for the so urce represented
9872 * by this entry. This will set the state of all verification information as b eing in error.
9873 */
9874 void recordHintError() {
9875 _hints = AnalysisError.NO_ERRORS;
9876 _hintsState = CacheState.ERROR;
9877 }
9878
9879 /**
9880 * Record that an error occurred while attempting to resolve the source repres ented by this
9881 * state.
9882 */
9883 void recordResolutionError() {
9884 _resolvedUnitState = CacheState.ERROR;
9885 _resolvedUnit = null;
9886 _resolutionErrorsState = CacheState.ERROR;
9887 _resolutionErrors = AnalysisError.NO_ERRORS;
9888 recordVerificationError();
9889 }
9890
9891 /**
9892 * Record that an error occurred while attempting to scan or parse the entry r epresented by this
9893 * entry. This will set the state of all resolution-based information as being in error, but
9894 * will not change the state of any parse results.
9895 */
9896 void recordResolutionErrorsInAllLibraries() {
9897 _builtUnitState = CacheState.ERROR;
9898 _builtUnit = null;
9899 _buildElementErrorsState = CacheState.ERROR;
9900 _buildElementErrors = AnalysisError.NO_ERRORS;
9901 _resolvedUnitState = CacheState.ERROR;
9902 _resolvedUnit = null;
9903 _resolutionErrorsState = CacheState.ERROR;
9904 _resolutionErrors = AnalysisError.NO_ERRORS;
9905 recordVerificationError();
9906 if (_nextState != null) {
9907 _nextState.recordResolutionErrorsInAllLibraries();
9908 }
9909 }
9910
9911 /**
9912 * Record that an in-process parse has stopped without recording results becau se the results
9913 * were invalidated before they could be recorded.
9914 */
9915 void recordResolutionNotInProcess() {
9916 if (_resolvedUnitState == CacheState.IN_PROCESS) {
9917 _resolvedUnitState = CacheState.INVALID;
9918 }
9919 if (_resolutionErrorsState == CacheState.IN_PROCESS) {
9920 _resolutionErrorsState = CacheState.INVALID;
9921 }
9922 if (_verificationErrorsState == CacheState.IN_PROCESS) {
9923 _verificationErrorsState = CacheState.INVALID;
9924 }
9925 if (_hintsState == CacheState.IN_PROCESS) {
9926 _hintsState = CacheState.INVALID;
9927 }
9928 if (_nextState != null) {
9929 _nextState.recordResolutionNotInProcess();
9930 }
9931 }
9932
9933 /**
9934 * Record that an error occurred while attempting to generate errors and warni ngs for the source
9935 * represented by this entry. This will set the state of all verification info rmation as being
9936 * in error.
9937 */
9938 void recordVerificationError() {
9939 _verificationErrors = AnalysisError.NO_ERRORS;
9940 _verificationErrorsState = CacheState.ERROR;
9941 recordHintError();
9942 }
9943
9944 /**
9945 * Write a textual representation of the difference between the old entry and this entry to the
9946 * given string builder.
9947 *
9948 * @param builder the string builder to which the difference is to be written
9949 * @param oldEntry the entry that was replaced by this entry
9950 * @return `true` if some difference was written
9951 */
9952 bool writeDiffOn(JavaStringBuilder builder, bool needsSeparator, DartEntry old Entry) {
9953 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.RESOLVED_UNIT, _resolvedUnitState, "resolvedUnit");
9954 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.RESOLUTION_ERRORS, _resolutionErrorsState, "resolutionErrors");
9955 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.VERIFICATION_ERRORS, _verificationErrorsState, "verificationErrors");
9956 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.HINTS, _hintsState, "hints");
9957 return needsSeparator;
9958 }
9959
9960 /**
9961 * Write a textual representation of this state to the given builder. The resu lt will only be
9962 * used for debugging purposes.
9963 *
9964 * @param builder the builder to which the text should be written
9965 */
9966 void writeOn(JavaStringBuilder builder) {
9967 if (_librarySource != null) {
9968 builder.append("; builtUnit = ");
9969 builder.append(_builtUnitState);
9970 builder.append("; buildElementErrors = ");
9971 builder.append(_buildElementErrorsState);
9972 builder.append("; resolvedUnit = ");
9973 builder.append(_resolvedUnitState);
9974 builder.append("; resolutionErrors = ");
9975 builder.append(_resolutionErrorsState);
9976 builder.append("; verificationErrors = ");
9977 builder.append(_verificationErrorsState);
9978 builder.append("; hints = ");
9979 builder.append(_hintsState);
9980 if (_nextState != null) {
9981 _nextState.writeOn(builder);
9982 }
9983 }
9984 }
9985
9986 /**
9987 * Write a textual representation of the difference between the state of the s pecified data
9988 * between the old entry and this entry to the given string builder.
9989 *
9990 * @param builder the string builder to which the difference is to be written
9991 * @param needsSeparator `true` if any data that is written
9992 * @param oldEntry the entry that was replaced by this entry
9993 * @param descriptor the descriptor defining the data whose state is being com pared
9994 * @param label the label used to describe the state
9995 * @return `true` if some difference was written
9996 */
9997 bool writeStateDiffOn(JavaStringBuilder builder, bool needsSeparator, SourceEn try oldEntry, DataDescriptor descriptor, CacheState newState, String label) {
9998 CacheState oldState = (oldEntry as DartEntryImpl).getStateInLibrary(descript or, _librarySource);
9999 if (oldState != newState) {
10000 if (needsSeparator) {
10001 builder.append("; ");
10002 }
10003 builder.append(label);
10004 builder.append(" = ");
10005 builder.append(oldState);
10006 builder.append(" -> ");
10007 builder.append(newState);
10008 return true;
10009 }
10010 return needsSeparator;
10011 }
10012 }
10013
10014 /**
10015 * Instances of the class `DataDescriptor` are immutable constants representing data that can 9726 * Instances of the class `DataDescriptor` are immutable constants representing data that can
10016 * be stored in the cache. 9727 * be stored in the cache.
10017 */ 9728 */
10018 class DataDescriptor<E> { 9729 class DataDescriptor<E> {
10019 /** 9730 /**
10020 * The name of the descriptor, used for debugging purposes. 9731 * The name of the descriptor, used for debugging purposes.
10021 */ 9732 */
10022 final String _name; 9733 final String _name;
10023 9734
10024 /** 9735 /**
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
10138 * @param directive the directive to be verified 9849 * @param directive the directive to be verified
10139 * @param errorListener the error listener to which errors should be reported 9850 * @param errorListener the error listener to which errors should be reported
10140 */ 9851 */
10141 static void validateReferencedSource(AnalysisContext context, Source librarySo urce, UriBasedDirective directive, AnalysisErrorListener errorListener) { 9852 static void validateReferencedSource(AnalysisContext context, Source librarySo urce, UriBasedDirective directive, AnalysisErrorListener errorListener) {
10142 Source source = directive.source; 9853 Source source = directive.source;
10143 if (source != null) { 9854 if (source != null) {
10144 if (context.exists(source)) { 9855 if (context.exists(source)) {
10145 return; 9856 return;
10146 } 9857 }
10147 } else { 9858 } else {
10148 // Don't report errors already reported by ParseDartTask#resolveDirective 9859 // Don't report errors already reported by ParseDartTask.resolveDirective
10149 if (directive.validate() != null) { 9860 if (directive.validate() != null) {
10150 return; 9861 return;
10151 } 9862 }
10152 } 9863 }
10153 StringLiteral uriLiteral = directive.uri; 9864 StringLiteral uriLiteral = directive.uri;
10154 errorListener.onError(new AnalysisError.con2(librarySource, uriLiteral.offse t, uriLiteral.length, CompileTimeErrorCode.URI_DOES_NOT_EXIST, [directive.uriCon tent])); 9865 errorListener.onError(new AnalysisError.con2(librarySource, uriLiteral.offse t, uriLiteral.length, CompileTimeErrorCode.URI_DOES_NOT_EXIST, [directive.uriCon tent]));
10155 } 9866 }
10156 9867
10157 /** 9868 /**
10158 * The source for which errors and warnings are to be produced. 9869 * The source for which errors and warnings are to be produced.
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
10366 * Return the time at which the contents of the source that was parsed were la st modified, or a 10077 * Return the time at which the contents of the source that was parsed were la st modified, or a
10367 * negative value if the task has not yet been performed or if an exception oc curred. 10078 * negative value if the task has not yet been performed or if an exception oc curred.
10368 * 10079 *
10369 * @return the time at which the contents of the source that was parsed were l ast modified 10080 * @return the time at which the contents of the source that was parsed were l ast modified
10370 */ 10081 */
10371 int get modificationTime => _modificationTime; 10082 int get modificationTime => _modificationTime;
10372 10083
10373 /** 10084 /**
10374 * Return `true` if this task is complete. Unlike most tasks, this task is all owed to be 10085 * Return `true` if this task is complete. Unlike most tasks, this task is all owed to be
10375 * visited more than once in order to support asynchronous IO. If the task is not complete when it 10086 * visited more than once in order to support asynchronous IO. If the task is not complete when it
10376 * is visited synchronously as part of the [AnalysisTask#perform] 10087 * is visited synchronously as part of the [AnalysisTask.perform]
10377 * method, it will be visited again, using the same visitor, when the IO opera tion has been 10088 * method, it will be visited again, using the same visitor, when the IO opera tion has been
10378 * performed. 10089 * performed.
10379 * 10090 *
10380 * @return `true` if this task is complete 10091 * @return `true` if this task is complete
10381 */ 10092 */
10382 bool get isComplete => _complete; 10093 bool get isComplete => _complete;
10383 10094
10384 @override 10095 @override
10385 String get taskDescription => "get contents of ${source.fullName}"; 10096 String get taskDescription => "get contents of ${source.fullName}";
10386 10097
10387 @override 10098 @override
10388 void internalPerform() { 10099 void internalPerform() {
10389 _complete = true; 10100 _complete = true;
10390 try { 10101 try {
10391 TimestampedData<String> data = context.getContents(source); 10102 TimestampedData<String> data = context.getContents(source);
10392 _content = data.data; 10103 _content = data.data;
10393 _modificationTime = data.modificationTime; 10104 _modificationTime = data.modificationTime;
10394 } catch (exception, stackTrace) { 10105 } catch (exception, stackTrace) {
10395 throw new AnalysisException("Could not get contents of ${source}", new Cau ghtException(exception, stackTrace)); 10106 throw new AnalysisException("Could not get contents of ${source}", new Cau ghtException(exception, stackTrace));
10396 } 10107 }
10397 } 10108 }
10398 } 10109 }
10399 10110
10400 /** 10111 /**
10401 * The interface `HtmlEntry` defines the behavior of objects that maintain the i nformation 10112 * An `HtmlEntry` maintains the information cached by an analysis context about
10402 * cached by an analysis context about an individual HTML file. 10113 * an individual HTML file.
10403 */ 10114 */
10404 abstract class HtmlEntry implements SourceEntry { 10115 class HtmlEntry extends SourceEntry {
10405 /**
10406 * The data descriptor representing the information about an Angular applicati on this source is
10407 * used in.
10408 */
10409 static final DataDescriptor<AngularApplication> ANGULAR_APPLICATION = new Data Descriptor<AngularApplication>("HtmlEntry.ANGULAR_APPLICATION");
10410
10411 /**
10412 * The data descriptor representing the information about an Angular component this source is used
10413 * as template for.
10414 */
10415 static final DataDescriptor<AngularComponentElement> ANGULAR_COMPONENT = new D ataDescriptor<AngularComponentElement>("HtmlEntry.ANGULAR_COMPONENT");
10416
10417 /**
10418 * The data descriptor representing the information about an Angular applicati on this source is
10419 * entry point for.
10420 */
10421 static final DataDescriptor<AngularApplication> ANGULAR_ENTRY = new DataDescri ptor<AngularApplication>("HtmlEntry.ANGULAR_ENTRY");
10422
10423 /**
10424 * The data descriptor representing the errors reported during Angular resolut ion.
10425 */
10426 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS = new DataDesc riptor<List<AnalysisError>>("HtmlEntry.ANGULAR_ERRORS");
10427
10428 /**
10429 * The data descriptor representing the HTML element.
10430 */
10431 static final DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElem ent>("HtmlEntry.ELEMENT");
10432
10433 /**
10434 * The data descriptor representing the hints resulting from auditing the sour ce.
10435 */
10436 static final DataDescriptor<List<AnalysisError>> HINTS = new DataDescriptor<Li st<AnalysisError>>("HtmlEntry.HINTS");
10437
10438 /**
10439 * The data descriptor representing the errors resulting from parsing the sour ce.
10440 */
10441 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS = new DataDescri ptor<List<AnalysisError>>("HtmlEntry.PARSE_ERRORS");
10442
10443 /**
10444 * The data descriptor representing the parsed AST structure.
10445 */
10446 static final DataDescriptor<ht.HtmlUnit> PARSED_UNIT = new DataDescriptor<ht.H tmlUnit>("HtmlEntry.PARSED_UNIT");
10447
10448 /**
10449 * The data descriptor representing the resolved AST structure.
10450 */
10451 static final DataDescriptor<ht.HtmlUnit> RESOLVED_UNIT = new DataDescriptor<ht .HtmlUnit>("HtmlEntry.RESOLVED_UNIT");
10452
10453 /**
10454 * The data descriptor representing the list of referenced libraries.
10455 */
10456 static final DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescr iptor<List<Source>>("HtmlEntry.REFERENCED_LIBRARIES");
10457
10458 /**
10459 * The data descriptor representing the errors resulting from resolving the so urce.
10460 */
10461 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataD escriptor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS");
10462
10463 /**
10464 * The data descriptor representing the status of Polymer elements in the sour ce.
10465 */
10466 static final DataDescriptor<List<AnalysisError>> POLYMER_BUILD_ERRORS = new Da taDescriptor<List<AnalysisError>>("HtmlEntry.POLYMER_BUILD_ERRORS");
10467
10468 /**
10469 * The data descriptor representing the errors reported during Polymer resolut ion.
10470 */
10471 static final DataDescriptor<List<AnalysisError>> POLYMER_RESOLUTION_ERRORS = n ew DataDescriptor<List<AnalysisError>>("HtmlEntry.POLYMER_RESOLUTION_ERRORS");
10472
10473 /**
10474 * Return all of the errors associated with the compilation unit that are curr ently cached.
10475 *
10476 * @return all of the errors associated with the compilation unit
10477 */
10478 List<AnalysisError> get allErrors;
10479
10480 /**
10481 * Return a valid parsed unit, either an unresolved AST structure or the resul t of resolving the
10482 * AST structure, or `null` if there is no parsed unit available.
10483 *
10484 * @return a valid parsed unit
10485 */
10486 ht.HtmlUnit get anyParsedUnit;
10487 }
10488
10489 /**
10490 * Instances of the class `HtmlEntryImpl` implement an [HtmlEntry].
10491 */
10492 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry {
10493 /** 10116 /**
10494 * The state of the cached parsed (but not resolved) HTML unit. 10117 * The state of the cached parsed (but not resolved) HTML unit.
10495 */ 10118 */
10496 CacheState _parsedUnitState = CacheState.INVALID; 10119 CacheState _parsedUnitState = CacheState.INVALID;
10497 10120
10498 /** 10121 /**
10499 * The parsed HTML unit, or `null` if the parsed HTML unit is not currently ca ched. 10122 * The parsed HTML unit, or `null` if the parsed HTML unit is not currently ca ched.
10500 */ 10123 */
10501 ht.HtmlUnit _parsedUnit; 10124 ht.HtmlUnit _parsedUnit;
10502 10125
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
10621 */ 10244 */
10622 CacheState _polymerResolutionErrorsState = CacheState.INVALID; 10245 CacheState _polymerResolutionErrorsState = CacheState.INVALID;
10623 10246
10624 /** 10247 /**
10625 * The hints produced while performing Polymer resolution, or an empty array i f the error are not 10248 * The hints produced while performing Polymer resolution, or an empty array i f the error are not
10626 * currently cached. 10249 * currently cached.
10627 */ 10250 */
10628 List<AnalysisError> _polymerResolutionErrors = AnalysisError.NO_ERRORS; 10251 List<AnalysisError> _polymerResolutionErrors = AnalysisError.NO_ERRORS;
10629 10252
10630 /** 10253 /**
10254 * The data descriptor representing the information about an Angular
10255 * application this source is used in.
10256 */
10257 static final DataDescriptor<AngularApplication> ANGULAR_APPLICATION
10258 = new DataDescriptor<AngularApplication>("HtmlEntry.ANGULAR_APPLICATION");
10259
10260 /**
10261 * The data descriptor representing the information about an Angular component
10262 * this source is used as template for.
10263 */
10264 static final DataDescriptor<AngularComponentElement> ANGULAR_COMPONENT
10265 = new DataDescriptor<AngularComponentElement>("HtmlEntry.ANGULAR_COMPONENT ");
10266
10267 /**
10268 * The data descriptor representing the information about an Angular
10269 * application for which this source is an entry point.
10270 */
10271 static final DataDescriptor<AngularApplication> ANGULAR_ENTRY
10272 = new DataDescriptor<AngularApplication>("HtmlEntry.ANGULAR_ENTRY");
10273
10274 /**
10275 * The data descriptor representing the errors reported during Angular
10276 * resolution.
10277 */
10278 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS
10279 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.ANGULAR_ERRORS");
10280
10281 /**
10282 * The data descriptor representing the HTML element.
10283 */
10284 static final DataDescriptor<HtmlElement> ELEMENT
10285 = new DataDescriptor<HtmlElement>("HtmlEntry.ELEMENT");
10286
10287 /**
10288 * The data descriptor representing the hints resulting from auditing the
10289 * source.
10290 */
10291 static final DataDescriptor<List<AnalysisError>> HINTS
10292 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.HINTS");
10293
10294 /**
10295 * The data descriptor representing the errors resulting from parsing the
10296 * source.
10297 */
10298 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS
10299 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.PARSE_ERRORS");
10300
10301 /**
10302 * The data descriptor representing the parsed AST structure.
10303 */
10304 static final DataDescriptor<ht.HtmlUnit> PARSED_UNIT
10305 = new DataDescriptor<ht.HtmlUnit>("HtmlEntry.PARSED_UNIT");
10306
10307 /**
10308 * The data descriptor representing the resolved AST structure.
10309 */
10310 static final DataDescriptor<ht.HtmlUnit> RESOLVED_UNIT
10311 = new DataDescriptor<ht.HtmlUnit>("HtmlEntry.RESOLVED_UNIT");
10312
10313 /**
10314 * The data descriptor representing the list of referenced libraries.
10315 */
10316 static final DataDescriptor<List<Source>> REFERENCED_LIBRARIES
10317 = new DataDescriptor<List<Source>>("HtmlEntry.REFERENCED_LIBRARIES");
10318
10319 /**
10320 * The data descriptor representing the errors resulting from resolving the
10321 * source.
10322 */
10323 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS
10324 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS");
10325
10326 /**
10327 * The data descriptor representing the status of Polymer elements in the
10328 * source.
10329 */
10330 static final DataDescriptor<List<AnalysisError>> POLYMER_BUILD_ERRORS
10331 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.POLYMER_BUILD_ERRORS" );
10332
10333 /**
10334 * The data descriptor representing the errors reported during Polymer
10335 * resolution.
10336 */
10337 static final DataDescriptor<List<AnalysisError>> POLYMER_RESOLUTION_ERRORS
10338 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.POLYMER_RESOLUTION_ER RORS");
10339
10340 /**
10631 * Flush any AST structures being maintained by this entry. 10341 * Flush any AST structures being maintained by this entry.
10632 */ 10342 */
10633 void flushAstStructures() { 10343 void flushAstStructures() {
10634 if (_parsedUnitState == CacheState.VALID) { 10344 if (_parsedUnitState == CacheState.VALID) {
10635 _parsedUnitState = CacheState.FLUSHED; 10345 _parsedUnitState = CacheState.FLUSHED;
10636 _parsedUnit = null; 10346 _parsedUnit = null;
10637 } 10347 }
10638 if (_resolvedUnitState == CacheState.VALID) { 10348 if (_resolvedUnitState == CacheState.VALID) {
10639 _resolvedUnitState = CacheState.FLUSHED; 10349 _resolvedUnitState = CacheState.FLUSHED;
10640 _resolvedUnit = null; 10350 _resolvedUnit = null;
10641 } 10351 }
10642 if (_angularEntryState == CacheState.VALID) { 10352 if (_angularEntryState == CacheState.VALID) {
10643 _angularEntryState = CacheState.FLUSHED; 10353 _angularEntryState = CacheState.FLUSHED;
10644 } 10354 }
10645 if (_angularErrorsState == CacheState.VALID) { 10355 if (_angularErrorsState == CacheState.VALID) {
10646 _angularErrorsState = CacheState.FLUSHED; 10356 _angularErrorsState = CacheState.FLUSHED;
10647 } 10357 }
10648 } 10358 }
10649 10359
10650 @override 10360 /**
10361 * Return all of the errors associated with the compilation unit that are
10362 * currently cached.
10363 */
10651 List<AnalysisError> get allErrors { 10364 List<AnalysisError> get allErrors {
10652 List<AnalysisError> errors = new List<AnalysisError>(); 10365 List<AnalysisError> errors = new List<AnalysisError>();
10653 if (_parseErrors != null) { 10366 if (_parseErrors != null) {
10654 for (AnalysisError error in _parseErrors) { 10367 for (AnalysisError error in _parseErrors) {
10655 errors.add(error); 10368 errors.add(error);
10656 } 10369 }
10657 } 10370 }
10658 if (_resolutionErrors != null) { 10371 if (_resolutionErrors != null) {
10659 for (AnalysisError error in _resolutionErrors) { 10372 for (AnalysisError error in _resolutionErrors) {
10660 errors.add(error); 10373 errors.add(error);
(...skipping 18 matching lines...) Expand all
10679 for (AnalysisError error in _polymerResolutionErrors) { 10392 for (AnalysisError error in _polymerResolutionErrors) {
10680 errors.add(error); 10393 errors.add(error);
10681 } 10394 }
10682 } 10395 }
10683 if (errors.length == 0) { 10396 if (errors.length == 0) {
10684 return AnalysisError.NO_ERRORS; 10397 return AnalysisError.NO_ERRORS;
10685 } 10398 }
10686 return new List.from(errors); 10399 return new List.from(errors);
10687 } 10400 }
10688 10401
10689 @override 10402 /**
10403 * Return a valid parsed unit, either an unresolved AST structure or the
10404 * result of resolving the AST structure, or `null` if there is no parsed unit
10405 * available.
10406 */
10690 ht.HtmlUnit get anyParsedUnit { 10407 ht.HtmlUnit get anyParsedUnit {
10691 if (_parsedUnitState == CacheState.VALID) { 10408 if (_parsedUnitState == CacheState.VALID) {
10692 // parsedUnitAccessed = true; 10409 // parsedUnitAccessed = true;
10693 return _parsedUnit; 10410 return _parsedUnit;
10694 } 10411 }
10695 if (_resolvedUnitState == CacheState.VALID) { 10412 if (_resolvedUnitState == CacheState.VALID) {
10696 // resovledUnitAccessed = true; 10413 // resovledUnitAccessed = true;
10697 return _resolvedUnit; 10414 return _resolvedUnit;
10698 } 10415 }
10699 return null; 10416 return null;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
10944 super.setValue(descriptor, value); 10661 super.setValue(descriptor, value);
10945 } 10662 }
10946 } 10663 }
10947 10664
10948 @override 10665 @override
10949 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; 10666 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;
10950 10667
10951 @override 10668 @override
10952 bool writeDiffOn(JavaStringBuilder builder, SourceEntry oldEntry) { 10669 bool writeDiffOn(JavaStringBuilder builder, SourceEntry oldEntry) {
10953 bool needsSeparator = super.writeDiffOn(builder, oldEntry); 10670 bool needsSeparator = super.writeDiffOn(builder, oldEntry);
10954 if (oldEntry is! HtmlEntryImpl) { 10671 if (oldEntry is! HtmlEntry) {
10955 if (needsSeparator) { 10672 if (needsSeparator) {
10956 builder.append("; "); 10673 builder.append("; ");
10957 } 10674 }
10958 builder.append("entry type changed; was ${oldEntry.runtimeType.toString()} "); 10675 builder.append("entry type changed; was ${oldEntry.runtimeType.toString()} ");
10959 return true; 10676 return true;
10960 } 10677 }
10961 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt ry.PARSE_ERRORS, "parseErrors"); 10678 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt ry.PARSE_ERRORS, "parseErrors");
10962 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt ry.PARSED_UNIT, "parsedUnit"); 10679 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt ry.PARSED_UNIT, "parsedUnit");
10963 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt ry.RESOLVED_UNIT, "resolvedUnit"); 10680 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt ry.RESOLVED_UNIT, "resolvedUnit");
10964 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt ry.RESOLUTION_ERRORS, "resolutionErrors"); 10681 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt ry.RESOLUTION_ERRORS, "resolutionErrors");
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
11001 builder.append(_polymerBuildErrorsState); 10718 builder.append(_polymerBuildErrorsState);
11002 builder.append("; polymerResolutionErrors = "); 10719 builder.append("; polymerResolutionErrors = ");
11003 builder.append(_polymerResolutionErrorsState); 10720 builder.append(_polymerResolutionErrorsState);
11004 } 10721 }
11005 } 10722 }
11006 10723
11007 /** 10724 /**
11008 * Instances of the class `IncrementalAnalysisCache` hold information used to pe rform 10725 * Instances of the class `IncrementalAnalysisCache` hold information used to pe rform
11009 * incremental analysis. 10726 * incremental analysis.
11010 * 10727 *
11011 * @see AnalysisContextImpl#setChangedContents(Source, String, int, int, int) 10728 * @see AnalysisContextImpl.setChangedContents(Source, String, int, int, int)
11012 */ 10729 */
11013 class IncrementalAnalysisCache { 10730 class IncrementalAnalysisCache {
11014 /** 10731 /**
11015 * Determine if the incremental analysis result can be cached for the next inc remental analysis. 10732 * Determine if the incremental analysis result can be cached for the next inc remental analysis.
11016 * 10733 *
11017 * @param cache the prior incremental analysis cache 10734 * @param cache the prior incremental analysis cache
11018 * @param unit the incrementally updated compilation unit 10735 * @param unit the incrementally updated compilation unit
11019 * @return the cache used for incremental analysis or `null` if incremental an alysis results 10736 * @return the cache used for incremental analysis or `null` if incremental an alysis results
11020 * cannot be cached for the next incremental analysis 10737 * cannot be cached for the next incremental analysis
11021 */ 10738 */
(...skipping 30 matching lines...) Expand all
11052 * @param oldLength the length of the text being replaced 10769 * @param oldLength the length of the text being replaced
11053 * @param newLength the length of the replacement text 10770 * @param newLength the length of the replacement text
11054 * @param sourceEntry the cached entry for the given source or `null` if none 10771 * @param sourceEntry the cached entry for the given source or `null` if none
11055 * @return the cache used for incremental analysis or `null` if incremental an alysis cannot 10772 * @return the cache used for incremental analysis or `null` if incremental an alysis cannot
11056 * be performed 10773 * be performed
11057 */ 10774 */
11058 static IncrementalAnalysisCache update(IncrementalAnalysisCache cache, Source source, String oldContents, String newContents, int offset, int oldLength, int n ewLength, SourceEntry sourceEntry) { 10775 static IncrementalAnalysisCache update(IncrementalAnalysisCache cache, Source source, String oldContents, String newContents, int offset, int oldLength, int n ewLength, SourceEntry sourceEntry) {
11059 // Determine the cache resolved unit 10776 // Determine the cache resolved unit
11060 Source librarySource = null; 10777 Source librarySource = null;
11061 CompilationUnit unit = null; 10778 CompilationUnit unit = null;
11062 if (sourceEntry is DartEntryImpl) { 10779 if (sourceEntry is DartEntry) {
11063 DartEntryImpl dartEntry = sourceEntry; 10780 DartEntry dartEntry = sourceEntry;
11064 List<Source> librarySources = dartEntry.librariesContaining; 10781 List<Source> librarySources = dartEntry.librariesContaining;
11065 if (librarySources.length == 1) { 10782 if (librarySources.length == 1) {
11066 librarySource = librarySources[0]; 10783 librarySource = librarySources[0];
11067 if (librarySource != null) { 10784 if (librarySource != null) {
11068 unit = dartEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySou rce); 10785 unit = dartEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySou rce);
11069 } 10786 }
11070 } 10787 }
11071 } 10788 }
11072 // Create a new cache if there is not an existing cache or the source is dif ferent 10789 // Create a new cache if there is not an existing cache or the source is dif ferent
11073 // or a new resolved compilation unit is available 10790 // or a new resolved compilation unit is available
(...skipping 2627 matching lines...) Expand 10 before | Expand all | Expand 10 after
13701 return super.visitSimpleIdentifier(node); 13418 return super.visitSimpleIdentifier(node);
13702 } 13419 }
13703 13420
13704 @override 13421 @override
13705 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { 13422 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) {
13706 node.staticElement = null; 13423 node.staticElement = null;
13707 return super.visitSuperConstructorInvocation(node); 13424 return super.visitSuperConstructorInvocation(node);
13708 } 13425 }
13709 } 13426 }
13710 13427
13428 /**
13429 * A `ResolutionState` maintains the information produced by resolving a
13430 * compilation unit as part of a specific library.
13431 */
13432 class ResolutionState {
13433 /**
13434 * The next resolution state or `null` if none.
13435 */
13436 ResolutionState _nextState;
13437
13438 /**
13439 * The source for the defining compilation unit of the library that contains t his unit. If this
13440 * unit is the defining compilation unit for it's library, then this will be t he source for this
13441 * unit.
13442 */
13443 Source _librarySource;
13444
13445 /**
13446 * The state of the cached compilation unit that contains references to the bu ilt element model.
13447 */
13448 CacheState _builtUnitState = CacheState.INVALID;
13449
13450 /**
13451 * The compilation unit that contains references to the built element model, o r `null` if
13452 * that compilation unit is not currently cached.
13453 */
13454 CompilationUnit _builtUnit;
13455
13456 /**
13457 * The state of the cached errors reported while building an element model.
13458 */
13459 CacheState _buildElementErrorsState = CacheState.INVALID;
13460
13461 /**
13462 * The errors produced while building an element model, or an empty array if t he errors are not
13463 * currently cached.
13464 */
13465 List<AnalysisError> _buildElementErrors = AnalysisError.NO_ERRORS;
13466
13467 /**
13468 * The state of the cached resolved compilation unit.
13469 */
13470 CacheState _resolvedUnitState = CacheState.INVALID;
13471
13472 /**
13473 * The resolved compilation unit, or `null` if the resolved compilation unit i s not
13474 * currently cached.
13475 */
13476 CompilationUnit _resolvedUnit;
13477
13478 /**
13479 * The state of the cached resolution errors.
13480 */
13481 CacheState _resolutionErrorsState = CacheState.INVALID;
13482
13483 /**
13484 * The errors produced while resolving the compilation unit, or an empty array if the errors are
13485 * not currently cached.
13486 */
13487 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS;
13488
13489 /**
13490 * The state of the cached verification errors.
13491 */
13492 CacheState _verificationErrorsState = CacheState.INVALID;
13493
13494 /**
13495 * The errors produced while verifying the compilation unit, or an empty array if the errors are
13496 * not currently cached.
13497 */
13498 List<AnalysisError> _verificationErrors = AnalysisError.NO_ERRORS;
13499
13500 /**
13501 * The state of the cached hints.
13502 */
13503 CacheState _hintsState = CacheState.INVALID;
13504
13505 /**
13506 * The hints produced while auditing the compilation unit, or an empty array i f the hints are
13507 * not currently cached.
13508 */
13509 List<AnalysisError> _hints = AnalysisError.NO_ERRORS;
13510
13511 /**
13512 * Flush any AST structures being maintained by this state.
13513 */
13514 void flushAstStructures() {
13515 if (_builtUnitState == CacheState.VALID) {
13516 _builtUnitState = CacheState.FLUSHED;
13517 _builtUnit = null;
13518 }
13519 if (_resolvedUnitState == CacheState.VALID) {
13520 _resolvedUnitState = CacheState.FLUSHED;
13521 _resolvedUnit = null;
13522 }
13523 if (_nextState != null) {
13524 _nextState.flushAstStructures();
13525 }
13526 }
13527
13528 bool get hasErrorState => _builtUnitState == CacheState.ERROR || _buildElement ErrorsState == CacheState.ERROR || _resolvedUnitState == CacheState.ERROR || _re solutionErrorsState == CacheState.ERROR || _verificationErrorsState == CacheStat e.ERROR || _hintsState == CacheState.ERROR || (_nextState != null && _nextState. hasErrorState);
13529
13530 /**
13531 * Invalidate all of the resolution information associated with the compilatio n unit.
13532 */
13533 void invalidateAllResolutionInformation() {
13534 _nextState = null;
13535 _librarySource = null;
13536 _builtUnitState = CacheState.INVALID;
13537 _builtUnit = null;
13538 _buildElementErrorsState = CacheState.INVALID;
13539 _buildElementErrors = AnalysisError.NO_ERRORS;
13540 _resolvedUnitState = CacheState.INVALID;
13541 _resolvedUnit = null;
13542 _resolutionErrorsState = CacheState.INVALID;
13543 _resolutionErrors = AnalysisError.NO_ERRORS;
13544 _verificationErrorsState = CacheState.INVALID;
13545 _verificationErrors = AnalysisError.NO_ERRORS;
13546 _hintsState = CacheState.INVALID;
13547 _hints = AnalysisError.NO_ERRORS;
13548 }
13549
13550 /**
13551 * Record that an error occurred while attempting to build the element model f or the source
13552 * represented by this state.
13553 */
13554 void recordBuildElementError() {
13555 _builtUnitState = CacheState.ERROR;
13556 _builtUnit = null;
13557 _buildElementErrorsState = CacheState.ERROR;
13558 _buildElementErrors = AnalysisError.NO_ERRORS;
13559 recordResolutionError();
13560 }
13561
13562 /**
13563 * Record that an error occurred while attempting to generate hints for the so urce represented
13564 * by this entry. This will set the state of all verification information as b eing in error.
13565 */
13566 void recordHintError() {
13567 _hints = AnalysisError.NO_ERRORS;
13568 _hintsState = CacheState.ERROR;
13569 }
13570
13571 /**
13572 * Record that an error occurred while attempting to resolve the source repres ented by this
13573 * state.
13574 */
13575 void recordResolutionError() {
13576 _resolvedUnitState = CacheState.ERROR;
13577 _resolvedUnit = null;
13578 _resolutionErrorsState = CacheState.ERROR;
13579 _resolutionErrors = AnalysisError.NO_ERRORS;
13580 recordVerificationError();
13581 }
13582
13583 /**
13584 * Record that an error occurred while attempting to scan or parse the entry r epresented by this
13585 * entry. This will set the state of all resolution-based information as being in error, but
13586 * will not change the state of any parse results.
13587 */
13588 void recordResolutionErrorsInAllLibraries() {
13589 _builtUnitState = CacheState.ERROR;
13590 _builtUnit = null;
13591 _buildElementErrorsState = CacheState.ERROR;
13592 _buildElementErrors = AnalysisError.NO_ERRORS;
13593 _resolvedUnitState = CacheState.ERROR;
13594 _resolvedUnit = null;
13595 _resolutionErrorsState = CacheState.ERROR;
13596 _resolutionErrors = AnalysisError.NO_ERRORS;
13597 recordVerificationError();
13598 if (_nextState != null) {
13599 _nextState.recordResolutionErrorsInAllLibraries();
13600 }
13601 }
13602
13603 /**
13604 * Record that an in-process parse has stopped without recording results becau se the results
13605 * were invalidated before they could be recorded.
13606 */
13607 void recordResolutionNotInProcess() {
13608 if (_resolvedUnitState == CacheState.IN_PROCESS) {
13609 _resolvedUnitState = CacheState.INVALID;
13610 }
13611 if (_resolutionErrorsState == CacheState.IN_PROCESS) {
13612 _resolutionErrorsState = CacheState.INVALID;
13613 }
13614 if (_verificationErrorsState == CacheState.IN_PROCESS) {
13615 _verificationErrorsState = CacheState.INVALID;
13616 }
13617 if (_hintsState == CacheState.IN_PROCESS) {
13618 _hintsState = CacheState.INVALID;
13619 }
13620 if (_nextState != null) {
13621 _nextState.recordResolutionNotInProcess();
13622 }
13623 }
13624
13625 /**
13626 * Record that an error occurred while attempting to generate errors and warni ngs for the source
13627 * represented by this entry. This will set the state of all verification info rmation as being
13628 * in error.
13629 */
13630 void recordVerificationError() {
13631 _verificationErrors = AnalysisError.NO_ERRORS;
13632 _verificationErrorsState = CacheState.ERROR;
13633 recordHintError();
13634 }
13635
13636 /**
13637 * Write a textual representation of the difference between the old entry and this entry to the
13638 * given string builder.
13639 *
13640 * @param builder the string builder to which the difference is to be written
13641 * @param oldEntry the entry that was replaced by this entry
13642 * @return `true` if some difference was written
13643 */
13644 bool writeDiffOn(JavaStringBuilder builder, bool needsSeparator, DartEntry old Entry) {
13645 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.RESOLVED_UNIT, _resolvedUnitState, "resolvedUnit");
13646 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.RESOLUTION_ERRORS, _resolutionErrorsState, "resolutionErrors");
13647 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.VERIFICATION_ERRORS, _verificationErrorsState, "verificationErrors");
13648 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.HINTS, _hintsState, "hints");
13649 return needsSeparator;
13650 }
13651
13652 /**
13653 * Write a textual representation of this state to the given builder. The resu lt will only be
13654 * used for debugging purposes.
13655 *
13656 * @param builder the builder to which the text should be written
13657 */
13658 void writeOn(JavaStringBuilder builder) {
13659 if (_librarySource != null) {
13660 builder.append("; builtUnit = ");
13661 builder.append(_builtUnitState);
13662 builder.append("; buildElementErrors = ");
13663 builder.append(_buildElementErrorsState);
13664 builder.append("; resolvedUnit = ");
13665 builder.append(_resolvedUnitState);
13666 builder.append("; resolutionErrors = ");
13667 builder.append(_resolutionErrorsState);
13668 builder.append("; verificationErrors = ");
13669 builder.append(_verificationErrorsState);
13670 builder.append("; hints = ");
13671 builder.append(_hintsState);
13672 if (_nextState != null) {
13673 _nextState.writeOn(builder);
13674 }
13675 }
13676 }
13677
13678 /**
13679 * Write a textual representation of the difference between the state of the s pecified data
13680 * between the old entry and this entry to the given string builder.
13681 *
13682 * @param builder the string builder to which the difference is to be written
13683 * @param needsSeparator `true` if any data that is written
13684 * @param oldEntry the entry that was replaced by this entry
13685 * @param descriptor the descriptor defining the data whose state is being com pared
13686 * @param label the label used to describe the state
13687 * @return `true` if some difference was written
13688 */
13689 bool writeStateDiffOn(JavaStringBuilder builder, bool needsSeparator, SourceEn try oldEntry, DataDescriptor descriptor, CacheState newState, String label) {
13690 CacheState oldState = (oldEntry as DartEntry).getStateInLibrary(descriptor, _librarySource);
13691 if (oldState != newState) {
13692 if (needsSeparator) {
13693 builder.append("; ");
13694 }
13695 builder.append(label);
13696 builder.append(" = ");
13697 builder.append(oldState);
13698 builder.append(" -> ");
13699 builder.append(newState);
13700 return true;
13701 }
13702 return needsSeparator;
13703 }
13704 }
13705
13711 /** 13706 /**
13712 * Instances of the class `ResolvableCompilationUnit` represent a compilation un it that is not 13707 * Instances of the class `ResolvableCompilationUnit` represent a compilation un it that is not
13713 * referenced by any other objects and for which we have modification stamp info rmation. It is used 13708 * referenced by any other objects and for which we have modification stamp info rmation. It is used
13714 * by the [LibraryResolver] to resolve a library. 13709 * by the [LibraryResolver] to resolve a library.
13715 */ 13710 */
13716 class ResolvableCompilationUnit extends TimestampedData<CompilationUnit> { 13711 class ResolvableCompilationUnit extends TimestampedData<CompilationUnit> {
13717 /** 13712 /**
13718 * The source of the compilation unit. 13713 * The source of the compilation unit.
13719 */ 13714 */
13720 final Source source; 13715 final Source source;
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
14458 * @param maxCacheSize the maximum number of sources for which AST structures should be kept in 14453 * @param maxCacheSize the maximum number of sources for which AST structures should be kept in
14459 * the cache 14454 * the cache
14460 */ 14455 */
14461 SdkCachePartition(InternalAnalysisContext context, int maxCacheSize) : super(c ontext, maxCacheSize, DefaultRetentionPolicy.POLICY); 14456 SdkCachePartition(InternalAnalysisContext context, int maxCacheSize) : super(c ontext, maxCacheSize, DefaultRetentionPolicy.POLICY);
14462 14457
14463 @override 14458 @override
14464 bool contains(Source source) => source.isInSystemLibrary; 14459 bool contains(Source source) => source.isInSystemLibrary;
14465 } 14460 }
14466 14461
14467 /** 14462 /**
14468 * The interface `SourceEntry` defines the behavior of objects that maintain the information 14463 * A `SourceEntry` maintains the information cached by an analysis context about
14469 * cached by an analysis context about an individual source, no matter what kind of source it is. 14464 * an individual source, no matter what kind of source it is.
14470 *
14471 * Source entries should be treated as if they were immutable unless a writable copy of the entry
14472 * has been obtained and has not yet been made visible to other threads.
14473 */ 14465 */
14474 abstract class SourceEntry { 14466 abstract class SourceEntry {
14475 /** 14467 /**
14476 * The data descriptor representing the contents of the source. 14468 * The most recent time at which the state of the source matched the state
14477 */ 14469 * represented by this entry.
14478 static final DataDescriptor<String> CONTENT = new DataDescriptor<String>("Dart Entry.CONTENT");
14479
14480 /**
14481 * The data descriptor representing the line information.
14482 */
14483 static final DataDescriptor<LineInfo> LINE_INFO = new DataDescriptor<LineInfo> ("SourceEntry.LINE_INFO");
14484
14485 /**
14486 * Return the exception that caused one or more values to have a state of [Cac heState#ERROR]
14487 * .
14488 *
14489 * @return the exception that caused one or more values to be uncomputable
14490 */
14491 CaughtException get exception;
14492
14493 /**
14494 * Return `true` if the source was explicitly added to the context or `false` if the
14495 * source was implicitly added because it was referenced by another source.
14496 *
14497 * @return `true` if the source was explicitly added to the context
14498 */
14499 bool get explicitlyAdded;
14500
14501 /**
14502 * Return the kind of the source, or `null` if the kind is not currently cache d.
14503 *
14504 * @return the kind of the source
14505 */
14506 SourceKind get kind;
14507
14508 /**
14509 * Return the most recent time at which the state of the source matched the st ate represented by
14510 * this entry.
14511 *
14512 * @return the modification time of this entry
14513 */
14514 int get modificationTime;
14515
14516 /**
14517 * Return the state of the data represented by the given descriptor.
14518 *
14519 * @param descriptor the descriptor representing the data whose state is to be returned
14520 * @return the state of the data represented by the given descriptor
14521 */
14522 CacheState getState(DataDescriptor descriptor);
14523
14524 /**
14525 * Return the value of the data represented by the given descriptor, or `null` if the data
14526 * represented by the descriptor is not in the cache.
14527 *
14528 * @param descriptor the descriptor representing which data is to be returned
14529 * @return the value of the data represented by the given descriptor
14530 */
14531 Object getValue(DataDescriptor descriptor);
14532 }
14533
14534 /**
14535 * Instances of the abstract class `SourceEntryImpl` implement the behavior comm on to all
14536 * [SourceEntry].
14537 */
14538 abstract class SourceEntryImpl implements SourceEntry {
14539 /**
14540 * The most recent time at which the state of the source matched the state rep resented by this
14541 * entry.
14542 */ 14470 */
14543 int _modificationTime = 0; 14471 int _modificationTime = 0;
14544 14472
14545 /** 14473 /**
14546 * A bit-encoding of boolean flags associated with this element. 14474 * A bit-encoding of boolean flags associated with this element.
14547 */ 14475 */
14548 int _flags = 0; 14476 int _flags = 0;
14549 14477
14550 /** 14478 /**
14551 * The exception that caused one or more values to have a state of [CacheState #ERROR]. 14479 * The exception that caused one or more values to have a state of
14480 * [CacheState.ERROR].
14552 */ 14481 */
14553 CaughtException _exception; 14482 CaughtException _exception;
14554 14483
14555 /** 14484 /**
14556 * The state of the cached content. 14485 * The state of the cached content.
14557 */ 14486 */
14558 CacheState _contentState = CacheState.INVALID; 14487 CacheState _contentState = CacheState.INVALID;
14559 14488
14560 /** 14489 /**
14561 * The content of the source, or `null` if the content is not currently cached . 14490 * The content of the source, or `null` if the content is not currently cached .
14562 */ 14491 */
14563 String _content; 14492 String _content;
14564 14493
14565 /** 14494 /**
14566 * The state of the cached line information. 14495 * The state of the cached line information.
14567 */ 14496 */
14568 CacheState _lineInfoState = CacheState.INVALID; 14497 CacheState _lineInfoState = CacheState.INVALID;
14569 14498
14570 /** 14499 /**
14571 * The line information computed for the source, or `null` if the line informa tion is not 14500 * The line information computed for the source, or `null` if the line
14572 * currently cached. 14501 * information is not currently cached.
14573 */ 14502 */
14574 LineInfo _lineInfo; 14503 LineInfo _lineInfo;
14575 14504
14576 /** 14505 /**
14577 * The index of the flag indicating whether the source was explicitly added to the context or 14506 * The data descriptor representing the contents of the source.
14578 * whether the source was implicitly added because it was referenced by anothe r source. 14507 */
14508 static final DataDescriptor<String> CONTENT
14509 = new DataDescriptor<String>("SourceEntry.CONTENT");
14510
14511 /**
14512 * The data descriptor representing the line information.
14513 */
14514 static final DataDescriptor<LineInfo> LINE_INFO
14515 = new DataDescriptor<LineInfo>("SourceEntry.LINE_INFO");
14516
14517 /**
14518 * The index of the flag indicating whether the source was explicitly added to
14519 * the context or whether the source was implicitly added because it was
14520 * referenced by another source.
14579 */ 14521 */
14580 static int _EXPLICITLY_ADDED_FLAG = 0; 14522 static int _EXPLICITLY_ADDED_FLAG = 0;
14581 14523
14582 /** 14524 /**
14583 * Fix the state of the [exception] to match the current state of the entry. 14525 * Fix the state of the [exception] to match the current state of the entry.
14584 */ 14526 */
14585 void fixExceptionState() { 14527 void fixExceptionState() {
14586 if (hasErrorState) { 14528 if (hasErrorState) {
14587 if (_exception == null) { 14529 if (_exception == null) {
14588 // 14530 //
(...skipping 15 matching lines...) Expand all
14604 * @param oldEntry the entry being diff'd with this entry 14546 * @param oldEntry the entry being diff'd with this entry
14605 * @return a textual representation of the difference 14547 * @return a textual representation of the difference
14606 */ 14548 */
14607 String getDiff(SourceEntry oldEntry) { 14549 String getDiff(SourceEntry oldEntry) {
14608 JavaStringBuilder builder = new JavaStringBuilder(); 14550 JavaStringBuilder builder = new JavaStringBuilder();
14609 writeDiffOn(builder, oldEntry); 14551 writeDiffOn(builder, oldEntry);
14610 return builder.toString(); 14552 return builder.toString();
14611 } 14553 }
14612 14554
14613 /** 14555 /**
14614 * Return the exception that caused one or more values to have a state of [Cac heState#ERROR] 14556 * Return the exception that caused one or more values to have a state of
14615 * . 14557 * [CacheState.ERROR].
14616 *
14617 * @return the exception that caused one or more values to be uncomputable
14618 */ 14558 */
14619 @override
14620 CaughtException get exception => _exception; 14559 CaughtException get exception => _exception;
14621 14560
14622 /** 14561 /**
14623 * Return `true` if the source was explicitly added to the context or `false` if the 14562 * Return `true` if the source was explicitly added to the context or `false`
14624 * source was implicitly added because it was referenced by another source. 14563 * if the source was implicitly added because it was referenced by another
14625 * 14564 * source.
14626 * @return `true` if the source was explicitly added to the context
14627 */ 14565 */
14628 @override
14629 bool get explicitlyAdded => getFlag(_EXPLICITLY_ADDED_FLAG); 14566 bool get explicitlyAdded => getFlag(_EXPLICITLY_ADDED_FLAG);
14630 14567
14631 @override 14568 /**
14569 * Return the kind of the source, or `null` if the kind is not currently
14570 * cached.
14571 */
14572 SourceKind get kind;
14573
14574 /**
14575 * Return the most recent time at which the state of the source matched the
14576 * state represented by this entry.
14577 */
14632 int get modificationTime => _modificationTime; 14578 int get modificationTime => _modificationTime;
14633 14579
14634 @override 14580 /**
14581 * Return the state of the data represented by the given [descriptor].
14582 */
14635 CacheState getState(DataDescriptor descriptor) { 14583 CacheState getState(DataDescriptor descriptor) {
14636 if (identical(descriptor, SourceEntry.CONTENT)) { 14584 if (identical(descriptor, SourceEntry.CONTENT)) {
14637 return _contentState; 14585 return _contentState;
14638 } else if (identical(descriptor, SourceEntry.LINE_INFO)) { 14586 } else if (identical(descriptor, SourceEntry.LINE_INFO)) {
14639 return _lineInfoState; 14587 return _lineInfoState;
14640 } else { 14588 } else {
14641 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 14589 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
14642 } 14590 }
14643 } 14591 }
14644 14592
14645 @override 14593 /**
14594 * Return the value of the data represented by the given [descriptor], or
14595 * `null` if the data represented by the descriptor is not in the cache.
14596 */
14646 Object getValue(DataDescriptor descriptor) { 14597 Object getValue(DataDescriptor descriptor) {
14647 if (identical(descriptor, SourceEntry.CONTENT)) { 14598 if (identical(descriptor, SourceEntry.CONTENT)) {
14648 return _content; 14599 return _content;
14649 } else if (identical(descriptor, SourceEntry.LINE_INFO)) { 14600 } else if (identical(descriptor, SourceEntry.LINE_INFO)) {
14650 return _lineInfo; 14601 return _lineInfo;
14651 } else { 14602 } else {
14652 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 14603 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
14653 } 14604 }
14654 } 14605 }
14655 14606
(...skipping 27 matching lines...) Expand all
14683 * 14634 *
14684 * @param exception the exception that shows where the error occurred 14635 * @param exception the exception that shows where the error occurred
14685 */ 14636 */
14686 void recordScanError(CaughtException exception) { 14637 void recordScanError(CaughtException exception) {
14687 this.exception = exception; 14638 this.exception = exception;
14688 _lineInfo = null; 14639 _lineInfo = null;
14689 _lineInfoState = CacheState.ERROR; 14640 _lineInfoState = CacheState.ERROR;
14690 } 14641 }
14691 14642
14692 /** 14643 /**
14693 * Set whether the source was explicitly added to the context to match the giv en value. 14644 * Set whether the source was explicitly added to the context to match the
14694 * 14645 * given value.
14695 * @param explicitlyAdded `true` if the source was explicitly added to the con text
14696 */ 14646 */
14697 void set explicitlyAdded(bool explicitlyAdded) { 14647 void set explicitlyAdded(bool explicitlyAdded) {
14698 setFlag(_EXPLICITLY_ADDED_FLAG, explicitlyAdded); 14648 setFlag(_EXPLICITLY_ADDED_FLAG, explicitlyAdded);
14699 } 14649 }
14700 14650
14701 /** 14651 /**
14702 * Set the most recent time at which the state of the source matched the state represented by this 14652 * Set the most recent time at which the state of the source matched the state
14703 * entry to the given time. 14653 * represented by this entry to the given time.
14704 *
14705 * @param time the new modification time of this entry
14706 */ 14654 */
14707 void set modificationTime(int time) { 14655 void set modificationTime(int time) {
14708 _modificationTime = time; 14656 _modificationTime = time;
14709 } 14657 }
14710 14658
14711 /** 14659 /**
14712 * Set the state of the data represented by the given descriptor to the given state. 14660 * Set the state of the data represented by the given descriptor to the given state.
14713 * 14661 *
14714 * @param descriptor the descriptor representing the data whose state is to be set 14662 * @param descriptor the descriptor representing the data whose state is to be set
14715 * @param the new state of the data represented by the given descriptor 14663 * @param the new state of the data represented by the given descriptor
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
14764 14712
14765 /** 14713 /**
14766 * Return the value of the flag with the given index. 14714 * Return the value of the flag with the given index.
14767 * 14715 *
14768 * @param index the index of the flag whose value is to be returned 14716 * @param index the index of the flag whose value is to be returned
14769 * @return the value of the flag with the given index 14717 * @return the value of the flag with the given index
14770 */ 14718 */
14771 bool getFlag(int index) => BooleanArray.get(_flags, index); 14719 bool getFlag(int index) => BooleanArray.get(_flags, index);
14772 14720
14773 /** 14721 /**
14774 * Return `true` if the state of any data value is [CacheState#ERROR]. 14722 * Return `true` if the state of any data value is [CacheState.ERROR].
14775 * 14723 *
14776 * @return `true` if the state of any data value is [CacheState#ERROR] 14724 * @return `true` if the state of any data value is [CacheState.ERROR]
14777 */ 14725 */
14778 bool get hasErrorState => _contentState == CacheState.ERROR || _lineInfoState == CacheState.ERROR; 14726 bool get hasErrorState => _contentState == CacheState.ERROR || _lineInfoState == CacheState.ERROR;
14779 14727
14780 /** 14728 /**
14781 * Set the exception that caused one or more values to have a state of [CacheS tate#ERROR] to 14729 * Set the exception that caused one or more values to have a state of
14782 * the given exception. 14730 * [CacheState.ERROR] to the given [exception].
14783 *
14784 * @param exception the exception that caused one or more values to be uncompu table
14785 */ 14731 */
14786 void set exception(CaughtException exception) { 14732 void set exception(CaughtException exception) {
14787 if (exception == null) { 14733 if (exception == null) {
14788 throw new IllegalArgumentException("exception cannot be null"); 14734 throw new IllegalArgumentException("exception cannot be null");
14789 } 14735 }
14790 this._exception = exception; 14736 this._exception = exception;
14791 } 14737 }
14792 14738
14793 /** 14739 /**
14794 * Set the value of the flag with the given index to the given value. 14740 * Set the value of the flag with the given index to the given value.
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
15208 _index++; 15154 _index++;
15209 if (_index >= _manager._workQueues[_queueIndex].length) { 15155 if (_index >= _manager._workQueues[_queueIndex].length) {
15210 _index = 0; 15156 _index = 0;
15211 _queueIndex++; 15157 _queueIndex++;
15212 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_ queueIndex].isEmpty) { 15158 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_ queueIndex].isEmpty) {
15213 _queueIndex++; 15159 _queueIndex++;
15214 } 15160 }
15215 } 15161 }
15216 } 15162 }
15217 } 15163 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/engine_test.dart » ('j') | pkg/analyzer/test/generated/engine_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698