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

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

Issue 647033002: Remove more multi-thread support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add missed methods Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine; 8 library engine;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 DartSdk sdk = factory.dartSdk; 1935 DartSdk sdk = factory.dartSdk;
1936 if (sdk == null) { 1936 if (sdk == null) {
1937 return new AnalysisCache(<CachePartition> [_privatePartition]); 1937 return new AnalysisCache(<CachePartition> [_privatePartition]);
1938 } 1938 }
1939 return new AnalysisCache(<CachePartition> [ 1939 return new AnalysisCache(<CachePartition> [
1940 AnalysisEngine.instance.partitionManager.forSdk(sdk), 1940 AnalysisEngine.instance.partitionManager.forSdk(sdk),
1941 _privatePartition]); 1941 _privatePartition]);
1942 } 1942 }
1943 1943
1944 /** 1944 /**
1945 * Record the results produced by performing a [ResolveDartLibraryCycleTask]. If the results 1945 * Record the results produced by performing a [task] and return the cache
1946 * were computed from data that is now out-of-date, then the results will not be recorded. 1946 * entry associated with the results.
1947 *
1948 * @param task the task that was performed
1949 * @return an entry containing the computed results
1950 * @throws AnalysisException if the results could not be recorded
1951 */ 1947 */
1952 DartEntry recordResolveDartLibraryCycleTaskResults(ResolveDartLibraryCycleTask task) { 1948 DartEntry recordResolveDartLibraryCycleTaskResults(ResolveDartLibraryCycleTask task) {
1953 LibraryResolver2 resolver = task.libraryResolver; 1949 LibraryResolver2 resolver = task.libraryResolver;
1954 CaughtException thrownException = task.exception; 1950 CaughtException thrownException = task.exception;
1955 DartEntry unitEntry = null;
1956 Source unitSource = task.unitSource; 1951 Source unitSource = task.unitSource;
1952 DartEntry unitEntry = _getReadableDartEntry(unitSource);
1957 if (resolver != null) { 1953 if (resolver != null) {
1958 // 1954 //
1959 // The resolver should only be null if an exception was thrown before (or while) it was 1955 // The resolver should only be null if an exception was thrown before (or
1960 // being created. 1956 // while) it was being created.
1961 // 1957 //
1962 List<ResolvableLibrary> resolvedLibraries = resolver.resolvedLibraries; 1958 List<ResolvableLibrary> resolvedLibraries = resolver.resolvedLibraries;
1963 if (resolvedLibraries == null) { 1959 if (resolvedLibraries == null) {
1964 // 1960 //
1965 // The resolved libraries should only be null if an exception was thrown during resolution. 1961 // The resolved libraries should only be null if an exception was thrown
1962 // during resolution.
1966 // 1963 //
1967 unitEntry = _getReadableDartEntry(unitSource);
1968 if (unitEntry == null) {
1969 throw new AnalysisException("A Dart file became a non-Dart file: ${uni tSource.fullName}");
1970 }
1971 if (thrownException == null) { 1964 if (thrownException == null) {
1972 unitEntry.recordResolutionError(new CaughtException(new AnalysisExcept ion("In recordResolveDartLibraryCycleTaskResults, resolvedLibraries was null and there was no thrown exception"), null)); 1965 var message = "In recordResolveDartLibraryCycleTaskResults, "
1966 "resolvedLibraries was null and there was no thrown exception";
1967 unitEntry.recordResolutionError(new CaughtException(
1968 new AnalysisException(message),
1969 null));
1973 } else { 1970 } else {
1974 unitEntry.recordResolutionError(thrownException); 1971 unitEntry.recordResolutionError(thrownException);
1975 } 1972 }
1976 _cache.remove(unitSource); 1973 _cache.remove(unitSource);
1977 if (thrownException != null) { 1974 if (thrownException != null) {
1978 throw new AnalysisException('<rethrow>', thrownException); 1975 throw new AnalysisException('<rethrow>', thrownException);
1979 } 1976 }
1980 return unitEntry; 1977 return unitEntry;
1981 } 1978 }
1982 if (_allModificationTimesMatch(resolvedLibraries)) { 1979 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
1983 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); 1980 RecordingErrorListener errorListener = resolver.errorListener;
1984 RecordingErrorListener errorListener = resolver.errorListener; 1981 for (ResolvableLibrary library in resolvedLibraries) {
1985 for (ResolvableLibrary library in resolvedLibraries) { 1982 Source librarySource = library.librarySource;
1986 Source librarySource = library.librarySource; 1983 for (Source source in library.compilationUnitSources) {
1987 for (Source source in library.compilationUnitSources) { 1984 CompilationUnit unit = library.getAST(source);
1988 CompilationUnit unit = library.getAST(source); 1985 List<AnalysisError> errors = errorListener.getErrorsForSource(source);
1989 List<AnalysisError> errors = errorListener.getErrorsForSource(source ); 1986 LineInfo lineInfo = getLineInfo(source);
1990 LineInfo lineInfo = getLineInfo(source); 1987 DartEntry dartEntry = _cache.get(source);
1991 DartEntry dartEntry = _cache.get(source); 1988 if (thrownException == null) {
1992 if (thrownException == null) { 1989 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
1993 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); 1990 dartEntry.setValueInLibrary(
1994 dartEntry.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource , unit); 1991 DartEntry.RESOLVED_UNIT,
1995 dartEntry.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySo urce, errors); 1992 librarySource,
1996 if (source == librarySource) { 1993 unit);
1997 _recordElementData(dartEntry, library.libraryElement, librarySou rce, htmlSource); 1994 dartEntry.setValueInLibrary(
1998 } 1995 DartEntry.RESOLUTION_ERRORS,
1999 _cache.storedAst(source); 1996 librarySource,
2000 } else { 1997 errors);
2001 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownExce ption); 1998 if (source == librarySource) {
2002 _cache.remove(source); 1999 _recordElementData(
2000 dartEntry,
2001 library.libraryElement,
2002 librarySource, htmlSource);
2003 } 2003 }
2004 if (source != librarySource) { 2004 _cache.storedAst(source);
2005 _workManager.add(source, SourcePriority.PRIORITY_PART); 2005 } else {
2006 } 2006 dartEntry.recordResolutionErrorInLibrary(
2007 if (source == unitSource) { 2007 librarySource,
2008 unitEntry = dartEntry; 2008 thrownException);
2009 } 2009 _cache.remove(source);
2010 ChangeNoticeImpl notice = _getNotice(source);
2011 notice.compilationUnit = unit;
2012 notice.setErrors(dartEntry.allErrors, lineInfo);
2013 } 2010 }
2011 if (source != librarySource) {
2012 _workManager.add(source, SourcePriority.PRIORITY_PART);
2013 }
2014 ChangeNoticeImpl notice = _getNotice(source);
2015 notice.compilationUnit = unit;
2016 notice.setErrors(dartEntry.allErrors, lineInfo);
2014 } 2017 }
2015 } else {
2016 PrintStringWriter writer = new PrintStringWriter();
2017 writer.println("Library resolution results discarded for");
2018 for (ResolvableLibrary library in resolvedLibraries) {
2019 for (Source source in library.compilationUnitSources) {
2020 DartEntry dartEntry = _getReadableDartEntry(source);
2021 if (dartEntry != null) {
2022 int resultTime = library.getModificationTime(source);
2023 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.m odificationTime}");
2024 if (thrownException == null || resultTime >= 0) {
2025 //
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.
2028 //
2029 dartEntry.recordResolutionNotInProcess();
2030 } else {
2031 //
2032 // We could not determine whether the sources were up-to-date or out-of-date. Mark
2033 // the cache so that we won't attempt to re-analyze the sources until there's a
2034 // good chance that we'll be able to do so without error.
2035 //
2036 dartEntry.recordResolutionError(thrownException);
2037 _cache.remove(source);
2038 }
2039 if (source == unitSource) {
2040 unitEntry = dartEntry;
2041 }
2042 } else {
2043 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, no entry");
2044 }
2045 }
2046 }
2047 _logInformation(writer.toString());
2048 } 2018 }
2049 } 2019 }
2050 if (thrownException != null) { 2020 if (thrownException != null) {
2051 throw new AnalysisException('<rethrow>', thrownException); 2021 throw new AnalysisException('<rethrow>', thrownException);
2052 } 2022 }
2053 if (unitEntry == null) {
2054 unitEntry = _getReadableDartEntry(unitSource);
2055 if (unitEntry == null) {
2056 throw new AnalysisException("A Dart file became a non-Dart file: ${unitS ource.fullName}");
2057 }
2058 }
2059 return unitEntry; 2023 return unitEntry;
2060 } 2024 }
2061 2025
2026 /**
2027 * Record the results produced by performing a [task] and return the cache
2028 * entry associated with the results.
2029 */
2062 DartEntry recordResolveDartLibraryTaskResults(ResolveDartLibraryTask task) { 2030 DartEntry recordResolveDartLibraryTaskResults(ResolveDartLibraryTask task) {
2063 LibraryResolver resolver = task.libraryResolver; 2031 LibraryResolver resolver = task.libraryResolver;
2064 CaughtException thrownException = task.exception; 2032 CaughtException thrownException = task.exception;
2065 DartEntry unitEntry = null;
2066 Source unitSource = task.unitSource; 2033 Source unitSource = task.unitSource;
2034 DartEntry unitEntry = _getReadableDartEntry(unitSource);
2067 if (resolver != null) { 2035 if (resolver != null) {
2068 // 2036 //
2069 // The resolver should only be null if an exception was thrown before (or while) it was 2037 // The resolver should only be null if an exception was thrown before (or
2070 // being created. 2038 // while) it was being created.
2071 // 2039 //
2072 Set<Library> resolvedLibraries = resolver.resolvedLibraries; 2040 Set<Library> resolvedLibraries = resolver.resolvedLibraries;
2073 if (resolvedLibraries == null) { 2041 if (resolvedLibraries == null) {
2074 // 2042 //
2075 // The resolved libraries should only be null if an exception was thrown during resolution. 2043 // The resolved libraries should only be null if an exception was thrown
2044 // during resolution.
2076 // 2045 //
2077 unitEntry = _getReadableDartEntry(unitSource);
2078 if (unitEntry == null) {
2079 throw new AnalysisException("A Dart file became a non-Dart file: ${uni tSource.fullName}");
2080 }
2081 if (thrownException == null) { 2046 if (thrownException == null) {
2082 unitEntry.recordResolutionError(new CaughtException(new AnalysisExcept ion("In recordResolveDartLibraryTaskResults, resolvedLibraries was null and ther e was no thrown exception"), null)); 2047 String message = "In recordResolveDartLibraryTaskResults, "
2048 "resolvedLibraries was null and there was no thrown exception";
2049 unitEntry.recordResolutionError(new CaughtException(
2050 new AnalysisException(message),
2051 null));
2083 } else { 2052 } else {
2084 unitEntry.recordResolutionError(thrownException); 2053 unitEntry.recordResolutionError(thrownException);
2085 } 2054 }
2086 _cache.remove(unitSource); 2055 _cache.remove(unitSource);
2087 if (thrownException != null) { 2056 if (thrownException != null) {
2088 throw new AnalysisException('<rethrow>', thrownException); 2057 throw new AnalysisException('<rethrow>', thrownException);
2089 } 2058 }
2090 return unitEntry; 2059 return unitEntry;
2091 } 2060 }
2092 if (_allModificationTimesMatch2(resolvedLibraries)) { 2061 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
2093 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); 2062 RecordingErrorListener errorListener = resolver.errorListener;
2094 RecordingErrorListener errorListener = resolver.errorListener; 2063 for (Library library in resolvedLibraries) {
2095 for (Library library in resolvedLibraries) { 2064 Source librarySource = library.librarySource;
2096 Source librarySource = library.librarySource; 2065 for (Source source in library.compilationUnitSources) {
2097 for (Source source in library.compilationUnitSources) { 2066 CompilationUnit unit = library.getAST(source);
2098 CompilationUnit unit = library.getAST(source); 2067 List<AnalysisError> errors = errorListener.getErrorsForSource(source);
2099 List<AnalysisError> errors = errorListener.getErrorsForSource(source ); 2068 LineInfo lineInfo = getLineInfo(source);
2100 LineInfo lineInfo = getLineInfo(source); 2069 DartEntry dartEntry = _cache.get(source);
2101 DartEntry dartEntry = _cache.get(source); 2070 if (thrownException == null) {
2102 int sourceTime = getModificationStamp(source); 2071 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo);
2103 if (dartEntry.modificationTime != sourceTime) { 2072 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
2104 // The source has changed without the context being notified. Simu late notification. 2073 dartEntry.setValueInLibrary(
2105 _sourceChanged(source); 2074 DartEntry.RESOLVED_UNIT,
2106 dartEntry = _getReadableDartEntry(source); 2075 librarySource,
2107 if (dartEntry == null) { 2076 unit);
2108 throw new AnalysisException("A Dart file became a non-Dart file: ${source.fullName}"); 2077 dartEntry.setValueInLibrary(
2109 } 2078 DartEntry.RESOLUTION_ERRORS,
2079 librarySource,
2080 errors);
2081 if (source == librarySource) {
2082 _recordElementData(
2083 dartEntry,
2084 library.libraryElement,
2085 librarySource, htmlSource);
2110 } 2086 }
2111 if (thrownException == null) { 2087 _cache.storedAst(source);
2112 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); 2088 } else {
2113 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); 2089 dartEntry.recordResolutionErrorInLibrary(
2114 dartEntry.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource , unit); 2090 librarySource,
2115 dartEntry.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySo urce, errors); 2091 thrownException);
2116 if (source == librarySource) { 2092 _cache.remove(source);
2117 _recordElementData(dartEntry, library.libraryElement, librarySou rce, htmlSource);
2118 }
2119 _cache.storedAst(source);
2120 } else {
2121 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownExce ption);
2122 _cache.remove(source);
2123 }
2124 if (source != librarySource) {
2125 _workManager.add(source, SourcePriority.PRIORITY_PART);
2126 }
2127 if (source == unitSource) {
2128 unitEntry = dartEntry;
2129 }
2130 ChangeNoticeImpl notice = _getNotice(source);
2131 notice.compilationUnit = unit;
2132 notice.setErrors(dartEntry.allErrors, lineInfo);
2133 } 2093 }
2094 if (source != librarySource) {
2095 _workManager.add(source, SourcePriority.PRIORITY_PART);
2096 }
2097 ChangeNoticeImpl notice = _getNotice(source);
2098 notice.compilationUnit = unit;
2099 notice.setErrors(dartEntry.allErrors, lineInfo);
2134 } 2100 }
2135 } else {
2136 PrintStringWriter writer = new PrintStringWriter();
2137 writer.println("Library resolution results discarded for");
2138 for (Library library in resolvedLibraries) {
2139 for (Source source in library.compilationUnitSources) {
2140 DartEntry dartEntry = _getReadableDartEntry(source);
2141 if (dartEntry != null) {
2142 int resultTime = library.getModificationTime(source);
2143 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.m odificationTime}");
2144 if (thrownException == null || resultTime >= 0) {
2145 //
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.
2148 //
2149 dartEntry.recordResolutionNotInProcess();
2150 } else {
2151 //
2152 // We could not determine whether the sources were up-to-date or out-of-date. Mark
2153 // the cache so that we won't attempt to re-analyze the sources until there's a
2154 // good chance that we'll be able to do so without error.
2155 //
2156 dartEntry.recordResolutionError(thrownException);
2157 _cache.remove(source);
2158 }
2159 if (source == unitSource) {
2160 unitEntry = dartEntry;
2161 }
2162 } else {
2163 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM odificationStamp(source)}, no entry");
2164 }
2165 }
2166 }
2167 _logInformation(writer.toString());
2168 } 2101 }
2169 } 2102 }
2170 if (thrownException != null) { 2103 if (thrownException != null) {
2171 throw new AnalysisException('<rethrow>', thrownException); 2104 throw new AnalysisException('<rethrow>', thrownException);
2172 } 2105 }
2173 if (unitEntry == null) {
2174 unitEntry = _getReadableDartEntry(unitSource);
2175 if (unitEntry == null) {
2176 throw new AnalysisException("A Dart file became a non-Dart file: ${unitS ource.fullName}");
2177 }
2178 }
2179 return unitEntry; 2106 return unitEntry;
2180 } 2107 }
2181 2108
2182 /** 2109 /**
2183 * Record that we have accessed the AST structure associated with the given so urce. At the moment, 2110 * Record that we have accessed the AST structure associated with the given so urce. At the moment,
2184 * there is no differentiation between the parsed and resolved forms of the AS T. 2111 * there is no differentiation between the parsed and resolved forms of the AS T.
2185 * 2112 *
2186 * @param source the source whose AST structure was accessed 2113 * @param source the source whose AST structure was accessed
2187 */ 2114 */
2188 void _accessedAst(Source source) { 2115 void _accessedAst(Source source) {
(...skipping 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after
3953 * @param librarySource the source for the library used to record information 3880 * @param librarySource the source for the library used to record information
3954 * @param htmlSource the source for the HTML library 3881 * @param htmlSource the source for the HTML library
3955 */ 3882 */
3956 void _recordElementData(DartEntry dartEntry, LibraryElement library, Source li brarySource, Source htmlSource) { 3883 void _recordElementData(DartEntry dartEntry, LibraryElement library, Source li brarySource, Source htmlSource) {
3957 dartEntry.setValue(DartEntry.ELEMENT, library); 3884 dartEntry.setValue(DartEntry.ELEMENT, library);
3958 dartEntry.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); 3885 dartEntry.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null);
3959 dartEntry.setValue(DartEntry.IS_CLIENT, _isClient(library, htmlSource, new H ashSet<LibraryElement>())); 3886 dartEntry.setValue(DartEntry.IS_CLIENT, _isClient(library, htmlSource, new H ashSet<LibraryElement>()));
3960 } 3887 }
3961 3888
3962 /** 3889 /**
3963 * Record the results produced by performing a [GenerateDartErrorsTask]. If th e results were 3890 * Record the results produced by performing a [task] and return the cache
3964 * computed from data that is now out-of-date, then the results will not be re corded. 3891 * entry associated with the results.
3965 *
3966 * @param task the task that was performed
3967 * @return an entry containing the computed results
3968 * @throws AnalysisException if the results could not be recorded
3969 */ 3892 */
3970 DartEntry _recordGenerateDartErrorsTask(GenerateDartErrorsTask task) { 3893 DartEntry _recordGenerateDartErrorsTask(GenerateDartErrorsTask task) {
3971 Source source = task.source; 3894 Source source = task.source;
3895 DartEntry dartEntry = _cache.get(source);
3972 Source librarySource = task.libraryElement.source; 3896 Source librarySource = task.libraryElement.source;
3973 CaughtException thrownException = task.exception; 3897 CaughtException thrownException = task.exception;
3974 SourceEntry sourceEntry = _cache.get(source);
3975 if (sourceEntry == null) {
3976 throw new ObsoleteSourceAnalysisException(source);
3977 } else if (sourceEntry is! DartEntry) {
3978 // This shouldn't be possible because we should never have performed the t ask if the source
3979 // didn't represent a Dart file, but check to be safe.
3980 throw new AnalysisException("Internal error: attempting to verify non-Dart file as a Dart file: ${source.fullName}");
3981 }
3982 DartEntry dartEntry = sourceEntry;
3983 int sourceTime = getModificationStamp(source);
3984 int resultTime = task.modificationTime;
3985 if (sourceTime == resultTime) {
3986 if (dartEntry.modificationTime != sourceTime) {
3987 // The source has changed without the context being notified. Simulate n otification.
3988 _sourceChanged(source);
3989 dartEntry = _getReadableDartEntry(source);
3990 if (dartEntry == null) {
3991 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}");
3992 }
3993 }
3994 if (thrownException == null) {
3995 dartEntry.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource , task.errors);
3996 ChangeNoticeImpl notice = _getNotice(source);
3997 notice.setErrors(dartEntry.allErrors, dartEntry.getValue(SourceEntry.LIN E_INFO));
3998 } else {
3999 dartEntry.recordVerificationErrorInLibrary(librarySource, thrownExceptio n);
4000 }
4001 } else {
4002 _logInformation2("Generated errors discarded for ${_debuggingString(source )}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEn try.modificationTime}", thrownException);
4003 if (thrownException == null || resultTime >= 0) {
4004 //
4005 // The analysis was performed on out-of-date sources. Mark the cache so that the source
4006 // will be re-verified using the up-to-date sources.
4007 //
4008 // dartCopy.setState(DartEntry.VERIFICATION_ERRORS, librarySour ce, CacheState.INVALID);
4009 _removeFromParts(source, dartEntry);
4010 dartEntry.invalidateAllInformation();
4011 dartEntry.modificationTime = sourceTime;
4012 _cache.removedAst(source);
4013 _workManager.add(source, SourcePriority.UNKNOWN);
4014 } else {
4015 //
4016 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4017 // cache so that we won't attempt to re-verify the source until there's a good chance
4018 // that we'll be able to do so without error.
4019 //
4020 dartEntry.recordVerificationErrorInLibrary(librarySource, thrownExceptio n);
4021 }
4022 }
4023 if (thrownException != null) { 3898 if (thrownException != null) {
3899 dartEntry.recordVerificationErrorInLibrary(librarySource, thrownException) ;
4024 throw new AnalysisException('<rethrow>', thrownException); 3900 throw new AnalysisException('<rethrow>', thrownException);
4025 } 3901 }
3902 dartEntry.setValueInLibrary(
3903 DartEntry.VERIFICATION_ERRORS,
3904 librarySource,
3905 task.errors);
3906 ChangeNoticeImpl notice = _getNotice(source);
3907 LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO);
3908 notice.setErrors(dartEntry.allErrors, lineInfo);
4026 return dartEntry; 3909 return dartEntry;
4027 } 3910 }
4028 3911
4029 /** 3912 /**
4030 * Record the results produced by performing a [GenerateDartHintsTask]. If the results were 3913 * Record the results produced by performing a [task] and return the cache
4031 * computed from data that is now out-of-date, then the results will not be re corded. 3914 * entry associated with the results.
4032 *
4033 * @param task the task that was performed
4034 * @return an entry containing the computed results
4035 * @throws AnalysisException if the results could not be recorded
4036 */ 3915 */
4037 DartEntry _recordGenerateDartHintsTask(GenerateDartHintsTask task) { 3916 DartEntry _recordGenerateDartHintsTask(GenerateDartHintsTask task) {
4038 Source librarySource = task.libraryElement.source; 3917 Source librarySource = task.libraryElement.source;
4039 CaughtException thrownException = task.exception; 3918 CaughtException thrownException = task.exception;
4040 DartEntry libraryEntry = null; 3919 DartEntry libraryEntry = null;
4041 HashMap<Source, TimestampedData<List<AnalysisError>>> hintMap = task.hintMap ; 3920 HashMap<Source, TimestampedData<List<AnalysisError>>> hintMap = task.hintMap ;
4042 if (hintMap == null) { 3921 if (hintMap == null) {
4043 // We don't have any information about which sources to mark as invalid ot her than the library 3922 // We don't have any information about which sources to mark as invalid
4044 // source. 3923 // other than the library source.
4045 SourceEntry sourceEntry = _cache.get(librarySource); 3924 DartEntry libraryEntry = _cache.get(librarySource);
4046 if (sourceEntry == null) { 3925 if (thrownException == null) {
4047 throw new ObsoleteSourceAnalysisException(librarySource); 3926 String message = "GenerateDartHintsTask returned a null hint map "
4048 } else if (sourceEntry is! DartEntry) { 3927 "without throwing an exception: ${librarySource.fullName}";
4049 // This shouldn't be possible because we should never have performed the task if the source 3928 thrownException = new CaughtException(new AnalysisException(message), nu ll);
4050 // didn't represent a Dart file, but check to be safe.
4051 throw new AnalysisException("Internal error: attempting to generate hint s for non-Dart file as a Dart file: ${librarySource.fullName}");
4052 } 3929 }
4053 if (thrownException == null) { 3930 libraryEntry.recordHintErrorInLibrary(librarySource, thrownException);
4054 thrownException = new CaughtException(new AnalysisException("GenerateDar tHintsTask returned a null hint map without throwing an exception: ${librarySour ce.fullName}"), null);
4055 }
4056 (sourceEntry as DartEntry).recordHintErrorInLibrary(librarySource, thrownE xception);
4057 throw new AnalysisException('<rethrow>', thrownException); 3931 throw new AnalysisException('<rethrow>', thrownException);
4058 } 3932 }
4059 for (MapEntry<Source, TimestampedData<List<AnalysisError>>> entry in getMapE ntrySet(hintMap)) { 3933 hintMap.forEach((Source unitSource, TimestampedData<List<AnalysisError>> res ults) {
4060 Source unitSource = entry.getKey(); 3934 DartEntry dartEntry = _cache.get(unitSource);
4061 TimestampedData<List<AnalysisError>> results = entry.getValue();
4062 SourceEntry sourceEntry = _cache.get(unitSource);
4063 if (sourceEntry is! DartEntry) {
4064 // This shouldn't be possible because we should never have performed the task if the source
4065 // didn't represent a Dart file, but check to be safe.
4066 throw new AnalysisException("Internal error: attempting to parse non-Dar t file as a Dart file: ${unitSource.fullName}");
4067 }
4068 DartEntry dartEntry = sourceEntry;
4069 if (unitSource == librarySource) { 3935 if (unitSource == librarySource) {
4070 libraryEntry = dartEntry; 3936 libraryEntry = dartEntry;
4071 } 3937 }
4072 int sourceTime = getModificationStamp(unitSource); 3938 if (thrownException == null) {
4073 int resultTime = results.modificationTime; 3939 dartEntry.setValueInLibrary(DartEntry.HINTS, librarySource, results.data );
4074 if (sourceTime == resultTime) { 3940 ChangeNoticeImpl notice = _getNotice(unitSource);
4075 if (dartEntry.modificationTime != sourceTime) { 3941 LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO);
4076 // The source has changed without the context being notified. Simulate notification. 3942 notice.setErrors(dartEntry.allErrors, lineInfo);
4077 _sourceChanged(unitSource);
4078 dartEntry = _getReadableDartEntry(unitSource);
4079 if (dartEntry == null) {
4080 throw new AnalysisException("A Dart file became a non-Dart file: ${u nitSource.fullName}");
4081 }
4082 }
4083 if (thrownException == null) {
4084 dartEntry.setValueInLibrary(DartEntry.HINTS, librarySource, results.da ta);
4085 ChangeNoticeImpl notice = _getNotice(unitSource);
4086 notice.setErrors(dartEntry.allErrors, dartEntry.getValue(SourceEntry.L INE_INFO));
4087 } else {
4088 dartEntry.recordHintErrorInLibrary(librarySource, thrownException);
4089 }
4090 } else { 3943 } else {
4091 _logInformation2("Generated hints discarded for ${_debuggingString(unitS ource)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${d artEntry.modificationTime}", thrownException); 3944 dartEntry.recordHintErrorInLibrary(librarySource, thrownException);
4092 if (dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource) == Cache State.IN_PROCESS) {
4093 if (thrownException == null || resultTime >= 0) {
4094 //
4095 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4096 // will be re-analyzed using the up-to-date sources.
4097 //
4098 // dartCopy.setState(DartEntry.HINTS, librarySource, Ca cheState.INVALID);
4099 _removeFromParts(unitSource, dartEntry);
4100 dartEntry.invalidateAllInformation();
4101 dartEntry.modificationTime = sourceTime;
4102 _cache.removedAst(unitSource);
4103 _workManager.add(unitSource, SourcePriority.UNKNOWN);
4104 } else {
4105 //
4106 // We could not determine whether the sources were up-to-date or out -of-date. Mark the
4107 // cache so that we won't attempt to re-analyze the sources until th ere's a good chance
4108 // that we'll be able to do so without error.
4109 //
4110 dartEntry.recordHintErrorInLibrary(librarySource, thrownException);
4111 }
4112 }
4113 } 3945 }
4114 } 3946 });
4115 if (thrownException != null) { 3947 if (thrownException != null) {
4116 throw new AnalysisException('<rethrow>', thrownException); 3948 throw new AnalysisException('<rethrow>', thrownException);
4117 } 3949 }
4118 return libraryEntry; 3950 return libraryEntry;
4119 } 3951 }
4120 3952
4121 /** 3953 /**
4122 * Record the results produced by performing a [GetContentTask]. 3954 * Record the results produced by performing a [task] and return the cache
4123 * 3955 * entry associated with the results.
4124 * @param task the task that was performed
4125 * @return an entry containing the computed results
4126 * @throws AnalysisException if the results could not be recorded
4127 */ 3956 */
4128 SourceEntry _recordGetContentsTask(GetContentTask task) { 3957 SourceEntry _recordGetContentsTask(GetContentTask task) {
4129 if (!task.isComplete) { 3958 if (!task.isComplete) {
4130 return null; 3959 return null;
4131 } 3960 }
4132 Source source = task.source; 3961 Source source = task.source;
3962 SourceEntry sourceEntry = _cache.get(source);
4133 CaughtException thrownException = task.exception; 3963 CaughtException thrownException = task.exception;
4134 SourceEntry sourceEntry = _cache.get(source); 3964 if (thrownException != null) {
4135 if (sourceEntry == null) {
4136 throw new ObsoleteSourceAnalysisException(source);
4137 }
4138 if (thrownException == null) {
4139 sourceEntry.modificationTime = task.modificationTime;
4140 sourceEntry.setValue(SourceEntry.CONTENT, task.content);
4141 } else {
4142 sourceEntry.recordContentError(thrownException); 3965 sourceEntry.recordContentError(thrownException);
4143 _workManager.remove(source); 3966 _workManager.remove(source);
4144 }
4145 if (thrownException != null) {
4146 throw new AnalysisException('<rethrow>', thrownException); 3967 throw new AnalysisException('<rethrow>', thrownException);
4147 } 3968 }
3969 sourceEntry.modificationTime = task.modificationTime;
3970 sourceEntry.setValue(SourceEntry.CONTENT, task.content);
4148 return sourceEntry; 3971 return sourceEntry;
4149 } 3972 }
4150 3973
4151 /** 3974 /**
4152 * Record the results produced by performing a [IncrementalAnalysisTask]. 3975 * Record the results produced by performing a [IncrementalAnalysisTask].
4153 * 3976 *
4154 * @param task the task that was performed 3977 * @param task the task that was performed
4155 * @return an entry containing the computed results 3978 * @return an entry containing the computed results
4156 * @throws AnalysisException if the results could not be recorded 3979 * @throws AnalysisException if the results could not be recorded
4157 */ 3980 */
4158 DartEntry _recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task) { 3981 DartEntry _recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task) {
4159 CompilationUnit unit = task.compilationUnit; 3982 CompilationUnit unit = task.compilationUnit;
4160 if (unit != null) { 3983 if (unit != null) {
4161 ChangeNoticeImpl notice = _getNotice(task.source); 3984 ChangeNoticeImpl notice = _getNotice(task.source);
4162 notice.compilationUnit = unit; 3985 notice.compilationUnit = unit;
4163 _incrementalAnalysisCache = IncrementalAnalysisCache.cacheResult(task.cach e, unit); 3986 _incrementalAnalysisCache = IncrementalAnalysisCache.cacheResult(
3987 task.cache,
3988 unit);
4164 } 3989 }
4165 return null; 3990 return null;
4166 } 3991 }
4167 3992
4168 /** 3993 /**
4169 * Record the results produced by performing a [ParseDartTask]. If the results were computed 3994 * Record the results produced by performing a [task] and return the cache
4170 * from data that is now out-of-date, then the results will not be recorded. 3995 * entry associated with the results.
4171 *
4172 * @param task the task that was performed
4173 * @return an entry containing the computed results
4174 * @throws AnalysisException if the results could not be recorded
4175 */ 3996 */
4176 DartEntry _recordParseDartTaskResults(ParseDartTask task) { 3997 DartEntry _recordParseDartTaskResults(ParseDartTask task) {
4177 Source source = task.source; 3998 Source source = task.source;
4178 CaughtException thrownException = task.exception; 3999 DartEntry dartEntry = _cache.get(source);
4179 SourceEntry sourceEntry = _cache.get(source); 4000 _removeFromParts(source, dartEntry);
4180 if (sourceEntry == null) { 4001 CaughtException thrownException = task.exception;
4181 throw new ObsoleteSourceAnalysisException(source); 4002 if (thrownException != null) {
4182 } else if (sourceEntry is! DartEntry) { 4003 _removeFromParts(source, dartEntry);
4183 // This shouldn't be possible because we should never have performed the t ask if the source 4004 dartEntry.recordParseError(thrownException);
4184 // didn't represent a Dart file, but check to be safe. 4005 _cache.removedAst(source);
4185 throw new AnalysisException("Internal error: attempting to parse non-Dart file as a Dart file: ${source.fullName}"); 4006 throw new AnalysisException('<rethrow>', thrownException);
4186 } 4007 }
4187 DartEntry dartEntry = sourceEntry as DartEntry; 4008 if (task.hasNonPartOfDirective) {
4188 int sourceTime = getModificationStamp(source); 4009 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
4189 int resultTime = task.modificationTime; 4010 dartEntry.containingLibrary = source;
4190 if (sourceTime == resultTime) { 4011 _workManager.add(source, SourcePriority.LIBRARY);
4191 if (dartEntry.modificationTime != sourceTime) { 4012 } else if (task.hasPartOfDirective) {
4192 // The source has changed without the context being notified. Simulate n otification. 4013 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
4193 _sourceChanged(source); 4014 dartEntry.removeContainingLibrary(source);
4194 dartEntry = _getReadableDartEntry(source); 4015 _workManager.add(source, SourcePriority.NORMAL_PART);
4195 if (dartEntry == null) { 4016 } else {
4196 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}"); 4017 // The file contains no directives.
4197 } 4018 List<Source> containingLibraries = dartEntry.containingLibraries;
4019 if (containingLibraries.length > 1
4020 || (containingLibraries.length == 1
4021 && containingLibraries[0] != source)) {
4022 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
4023 dartEntry.removeContainingLibrary(source);
4024 _workManager.add(source, SourcePriority.NORMAL_PART);
4025 } else {
4026 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
4027 dartEntry.containingLibrary = source;
4028 _workManager.add(source, SourcePriority.LIBRARY);
4198 } 4029 }
4199 _removeFromParts(source, dartEntry); 4030 }
4200 if (thrownException == null) { 4031 List<Source> newParts = task.includedSources;
4201 if (task.hasNonPartOfDirective) { 4032 for (int i = 0; i < newParts.length; i++) {
4202 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); 4033 Source partSource = newParts[i];
4203 dartEntry.containingLibrary = source; 4034 DartEntry partEntry = _getReadableDartEntry(partSource);
4204 _workManager.add(source, SourcePriority.LIBRARY); 4035 if (partEntry != null && !identical(partEntry, dartEntry)) {
4205 } else if (task.hasPartOfDirective) { 4036 // TODO(brianwilkerson) Change the kind of the "part" if it was marked
4206 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); 4037 // as a library and it has no directives.
4207 dartEntry.removeContainingLibrary(source); 4038 partEntry.addContainingLibrary(source);
4208 _workManager.add(source, SourcePriority.NORMAL_PART);
4209 } else {
4210 // The file contains no directives.
4211 List<Source> containingLibraries = dartEntry.containingLibraries;
4212 if (containingLibraries.length > 1 || (containingLibraries.length == 1 && containingLibraries[0] != source)) {
4213 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
4214 dartEntry.removeContainingLibrary(source);
4215 _workManager.add(source, SourcePriority.NORMAL_PART);
4216 } else {
4217 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
4218 dartEntry.containingLibrary = source;
4219 _workManager.add(source, SourcePriority.LIBRARY);
4220 }
4221 }
4222 List<Source> newParts = task.includedSources;
4223 for (int i = 0; i < newParts.length; i++) {
4224 Source partSource = newParts[i];
4225 DartEntry partEntry = _getReadableDartEntry(partSource);
4226 if (partEntry != null && !identical(partEntry, dartEntry)) {
4227 // TODO(brianwilkerson) Change the kind of the "part" if it was mark ed as a library
4228 // and it has no directives.
4229 partEntry.addContainingLibrary(source);
4230 }
4231 }
4232 dartEntry.setValue(DartEntry.PARSED_UNIT, task.compilationUnit);
4233 dartEntry.setValue(DartEntry.PARSE_ERRORS, task.errors);
4234 dartEntry.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources);
4235 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources);
4236 dartEntry.setValue(DartEntry.INCLUDED_PARTS, newParts);
4237 _cache.storedAst(source);
4238 ChangeNoticeImpl notice = _getNotice(source);
4239 notice.setErrors(dartEntry.allErrors, task.lineInfo);
4240 // Verify that the incrementally parsed and resolved unit in the increme ntal cache
4241 // is structurally equivalent to the fully parsed unit
4242 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_in crementalAnalysisCache, source, task.compilationUnit);
4243 } else {
4244 _removeFromParts(source, dartEntry);
4245 dartEntry.recordParseError(thrownException);
4246 _cache.removedAst(source);
4247 } 4039 }
4248 } else { 4040 }
4249 _logInformation2("Parse results discarded for ${_debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry .modificationTime}", thrownException); 4041 dartEntry.setValue(DartEntry.PARSED_UNIT, task.compilationUnit);
4250 if (thrownException == null || resultTime >= 0) { 4042 dartEntry.setValue(DartEntry.PARSE_ERRORS, task.errors);
4251 // 4043 dartEntry.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources);
4252 // The analysis was performed on out-of-date sources. Mark the cache so that the sources 4044 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources);
4253 // will be re-analyzed using the up-to-date sources. 4045 dartEntry.setValue(DartEntry.INCLUDED_PARTS, newParts);
4254 // 4046 _cache.storedAst(source);
4255 // dartCopy.recordParseNotInProcess(); 4047 ChangeNoticeImpl notice = _getNotice(source);
4256 _removeFromParts(source, dartEntry); 4048 notice.setErrors(dartEntry.allErrors, task.lineInfo);
4257 dartEntry.invalidateAllInformation(); 4049 // Verify that the incrementally parsed and resolved unit in the incremental
4258 dartEntry.modificationTime = sourceTime; 4050 // cache is structurally equivalent to the fully parsed unit
4259 _cache.removedAst(source); 4051 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(
4260 _workManager.add(source, SourcePriority.UNKNOWN); 4052 _incrementalAnalysisCache,
4261 } else { 4053 source,
4262 // 4054 task.compilationUnit);
4263 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4264 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4265 // that we'll be able to do so without error.
4266 //
4267 dartEntry.recordParseError(thrownException);
4268 }
4269 }
4270 if (thrownException != null) {
4271 throw new AnalysisException('<rethrow>', thrownException);
4272 }
4273 return dartEntry; 4055 return dartEntry;
4274 } 4056 }
4275 4057
4276 /** 4058 /**
4277 * Record the results produced by performing a [ParseHtmlTask]. If the results were computed 4059 * Record the results produced by performing a [task] and return the cache
4278 * from data that is now out-of-date, then the results will not be recorded. 4060 * entry associated with the results.
4279 *
4280 * @param task the task that was performed
4281 * @return an entry containing the computed results
4282 * @throws AnalysisException if the results could not be recorded
4283 */ 4061 */
4284 HtmlEntry _recordParseHtmlTaskResults(ParseHtmlTask task) { 4062 HtmlEntry _recordParseHtmlTaskResults(ParseHtmlTask task) {
4285 Source source = task.source; 4063 Source source = task.source;
4286 CaughtException thrownException = task.exception; 4064 HtmlEntry htmlEntry = _cache.get(source);
4287 SourceEntry sourceEntry = _cache.get(source); 4065 CaughtException thrownException = task.exception;
4288 if (sourceEntry == null) { 4066 if (thrownException != null) {
4289 throw new ObsoleteSourceAnalysisException(source); 4067 htmlEntry.recordParseError(thrownException);
4290 } else if (sourceEntry is! HtmlEntry) { 4068 _cache.removedAst(source);
4291 // This shouldn't be possible because we should never have performed the t ask if the source 4069 throw new AnalysisException('<rethrow>', thrownException);
4292 // didn't represent an HTML file, but check to be safe. 4070 }
4293 throw new AnalysisException("Internal error: attempting to parse non-HTML file as a HTML file: ${source.fullName}"); 4071 LineInfo lineInfo = task.lineInfo;
4294 } 4072 htmlEntry.setValue(SourceEntry.LINE_INFO, lineInfo);
4295 HtmlEntry htmlEntry = sourceEntry; 4073 htmlEntry.setValue(HtmlEntry.PARSED_UNIT, task.htmlUnit);
4296 int sourceTime = getModificationStamp(source); 4074 htmlEntry.setValue(HtmlEntry.PARSE_ERRORS, task.errors);
4297 int resultTime = task.modificationTime; 4075 htmlEntry.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibraries) ;
4298 if (sourceTime == resultTime) { 4076 _cache.storedAst(source);
4299 if (htmlEntry.modificationTime != sourceTime) { 4077 ChangeNoticeImpl notice = _getNotice(source);
4300 // The source has changed without the context being notified. Simulate n otification. 4078 notice.setErrors(htmlEntry.allErrors, lineInfo);
4301 _sourceChanged(source); 4079 return htmlEntry;
4302 htmlEntry = _getReadableHtmlEntry(source); 4080 }
4303 if (htmlEntry == null) { 4081
4304 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4082 /**
4305 } 4083 * Record the results produced by performing a [task] and return the cache
4306 } 4084 * entry associated with the results.
4307 if (thrownException == null) {
4308 LineInfo lineInfo = task.lineInfo;
4309 ht.HtmlUnit unit = task.htmlUnit;
4310 htmlEntry.setValue(SourceEntry.LINE_INFO, lineInfo);
4311 htmlEntry.setValue(HtmlEntry.PARSED_UNIT, unit);
4312 htmlEntry.setValue(HtmlEntry.PARSE_ERRORS, task.errors);
4313 htmlEntry.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibrar ies);
4314 _cache.storedAst(source);
4315 ChangeNoticeImpl notice = _getNotice(source);
4316 notice.setErrors(htmlEntry.allErrors, lineInfo);
4317 } else {
4318 htmlEntry.recordParseError(thrownException);
4319 _cache.removedAst(source);
4320 }
4321 } else {
4322 _logInformation2("Parse results discarded for ${_debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry .modificationTime}", thrownException);
4323 if (thrownException == null || resultTime >= 0) {
4324 //
4325 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4326 // will be re-analyzed using the up-to-date sources.
4327 //
4328 // if (htmlCopy.getState(SourceEntry.LINE_INFO) == CacheState.I N_PROCESS) {
4329 // htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALI D);
4330 // }
4331 // if (htmlCopy.getState(HtmlEntry.PARSED_UNIT) == CacheState.I N_PROCESS) {
4332 // htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALI D);
4333 // }
4334 // if (htmlCopy.getState(HtmlEntry.REFERENCED_LIBRARIES) == Cac heState.IN_PROCESS) {
4335 // htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheSta te.INVALID);
4336 // }
4337 htmlEntry.invalidateAllInformation();
4338 htmlEntry.modificationTime = sourceTime;
4339 _cache.removedAst(source);
4340 } else {
4341 //
4342 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4343 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4344 // that we'll be able to do so without error.
4345 //
4346 htmlEntry.recordParseError(thrownException);
4347 }
4348 }
4349 if (thrownException != null) {
4350 throw new AnalysisException('<rethrow>', thrownException);
4351 }
4352 return htmlEntry;
4353 }
4354
4355 /**
4356 * Record the results produced by performing a [PolymerBuildHtmlTask]. If the results were
4357 * computed from data that is now out-of-date, then the results will not be re corded.
4358 *
4359 * @param task the task that was performed
4360 * @throws AnalysisException if the results could not be recorded
4361 */ 4085 */
4362 HtmlEntry _recordPolymerBuildHtmlTaskResults(PolymerBuildHtmlTask task) { 4086 HtmlEntry _recordPolymerBuildHtmlTaskResults(PolymerBuildHtmlTask task) {
4363 Source source = task.source; 4087 Source source = task.source;
4364 CaughtException thrownException = task.exception; 4088 HtmlEntry htmlEntry = _cache.get(source);
4365 SourceEntry sourceEntry = _cache.get(source); 4089 CaughtException thrownException = task.exception;
4366 if (sourceEntry == null) { 4090 if (thrownException != null) {
4367 throw new ObsoleteSourceAnalysisException(source); 4091 htmlEntry.recordResolutionError(thrownException);
4368 } else if (sourceEntry is! HtmlEntry) { 4092 throw new AnalysisException('<rethrow>', thrownException);
4369 // This shouldn't be possible because we should never have performed the t ask if the source 4093 }
4370 // didn't represent an HTML file, but check to be safe. 4094 htmlEntry.setValue(HtmlEntry.POLYMER_BUILD_ERRORS, task.errors);
4371 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4095 // notify about errors
4372 } 4096 ChangeNoticeImpl notice = _getNotice(source);
4373 HtmlEntry htmlEntry = sourceEntry; 4097 LineInfo lineInfo = htmlEntry.getValue(SourceEntry.LINE_INFO);
4374 int sourceTime = getModificationStamp(source); 4098 notice.setErrors(htmlEntry.allErrors, lineInfo);
4375 int resultTime = task.modificationTime; 4099 return htmlEntry;
4376 if (sourceTime == resultTime) { 4100 }
4377 if (htmlEntry.modificationTime != sourceTime) { 4101
4378 // The source has changed without the context being notified. Simulate n otification. 4102 /**
4379 _sourceChanged(source); 4103 * Record the results produced by performing a [task] and return the cache
4380 htmlEntry = _getReadableHtmlEntry(source); 4104 * entry associated with the results.
4381 if (htmlEntry == null) {
4382 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4383 }
4384 }
4385 if (thrownException == null) {
4386 htmlEntry.setValue(HtmlEntry.POLYMER_BUILD_ERRORS, task.errors);
4387 // notify about errors
4388 ChangeNoticeImpl notice = _getNotice(source);
4389 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LIN E_INFO));
4390 } else {
4391 htmlEntry.recordResolutionError(thrownException);
4392 }
4393 } else {
4394 if (thrownException == null || resultTime >= 0) {
4395 //
4396 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4397 // will be re-analyzed using the up-to-date sources.
4398 //
4399 htmlEntry.invalidateAllInformation();
4400 htmlEntry.modificationTime = sourceTime;
4401 _cache.removedAst(source);
4402 } else {
4403 //
4404 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4405 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4406 // that we'll be able to do so without error.
4407 //
4408 htmlEntry.recordResolutionError(thrownException);
4409 }
4410 }
4411 if (thrownException != null) {
4412 throw new AnalysisException('<rethrow>', thrownException);
4413 }
4414 return htmlEntry;
4415 }
4416
4417 /**
4418 * Record the results produced by performing a [PolymerResolveHtmlTask]. If th e results were
4419 * computed from data that is now out-of-date, then the results will not be re corded.
4420 *
4421 * @param task the task that was performed
4422 * @throws AnalysisException if the results could not be recorded
4423 */ 4105 */
4424 HtmlEntry _recordPolymerResolveHtmlTaskResults(PolymerResolveHtmlTask task) { 4106 HtmlEntry _recordPolymerResolveHtmlTaskResults(PolymerResolveHtmlTask task) {
4425 Source source = task.source; 4107 Source source = task.source;
4426 CaughtException thrownException = task.exception; 4108 HtmlEntry htmlEntry = _cache.get(source);
4427 SourceEntry sourceEntry = _cache.get(source); 4109 CaughtException thrownException = task.exception;
4428 if (sourceEntry == null) { 4110 if (thrownException != null) {
4429 throw new ObsoleteSourceAnalysisException(source); 4111 htmlEntry.recordResolutionError(thrownException);
4430 } else if (sourceEntry is! HtmlEntry) { 4112 throw new AnalysisException('<rethrow>', thrownException);
4431 // This shouldn't be possible because we should never have performed the t ask if the source 4113 }
4432 // didn't represent an HTML file, but check to be safe. 4114 htmlEntry.setValue(HtmlEntry.POLYMER_RESOLUTION_ERRORS, task.errors);
4433 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4115 // notify about errors
4434 } 4116 ChangeNoticeImpl notice = _getNotice(source);
4435 HtmlEntry htmlEntry = sourceEntry; 4117 LineInfo lineInfo = htmlEntry.getValue(SourceEntry.LINE_INFO);
4436 int sourceTime = getModificationStamp(source); 4118 notice.setErrors(htmlEntry.allErrors, lineInfo);
4437 int resultTime = task.modificationTime; 4119 return htmlEntry;
4438 if (sourceTime == resultTime) { 4120 }
4439 if (htmlEntry.modificationTime != sourceTime) { 4121
4440 // The source has changed without the context being notified. Simulate n otification. 4122 /**
4441 _sourceChanged(source); 4123 * Record the results produced by performing a [task] and return the cache
4442 htmlEntry = _getReadableHtmlEntry(source); 4124 * entry associated with the results.
4443 if (htmlEntry == null) {
4444 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4445 }
4446 }
4447 if (thrownException == null) {
4448 htmlEntry.setValue(HtmlEntry.POLYMER_RESOLUTION_ERRORS, task.errors);
4449 // notify about errors
4450 ChangeNoticeImpl notice = _getNotice(source);
4451 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LIN E_INFO));
4452 } else {
4453 htmlEntry.recordResolutionError(thrownException);
4454 }
4455 } else {
4456 if (thrownException == null || resultTime >= 0) {
4457 //
4458 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4459 // will be re-analyzed using the up-to-date sources.
4460 //
4461 htmlEntry.invalidateAllInformation();
4462 htmlEntry.modificationTime = sourceTime;
4463 _cache.removedAst(source);
4464 } else {
4465 //
4466 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4467 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4468 // that we'll be able to do so without error.
4469 //
4470 htmlEntry.recordResolutionError(thrownException);
4471 }
4472 }
4473 if (thrownException != null) {
4474 throw new AnalysisException('<rethrow>', thrownException);
4475 }
4476 return htmlEntry;
4477 }
4478
4479 /**
4480 * Record the results produced by performing a [ResolveAngularComponentTemplat eTask]. If the
4481 * results were computed from data that is now out-of-date, then the results w ill not be recorded.
4482 *
4483 * @param task the task that was performed
4484 * @throws AnalysisException if the results could not be recorded
4485 */ 4125 */
4486 HtmlEntry _recordResolveAngularComponentTemplateTaskResults(ResolveAngularComp onentTemplateTask task) { 4126 HtmlEntry _recordResolveAngularComponentTemplateTaskResults(ResolveAngularComp onentTemplateTask task) {
4487 Source source = task.source; 4127 Source source = task.source;
4488 CaughtException thrownException = task.exception; 4128 HtmlEntry htmlEntry = _cache.get(source);
4489 SourceEntry sourceEntry = _cache.get(source); 4129 CaughtException thrownException = task.exception;
4490 if (sourceEntry == null) { 4130 if (thrownException != null) {
4491 throw new ObsoleteSourceAnalysisException(source); 4131 htmlEntry.recordResolutionError(thrownException);
4492 } else if (sourceEntry is! HtmlEntry) { 4132 throw new AnalysisException('<rethrow>', thrownException);
4493 // This shouldn't be possible because we should never have performed the t ask if the source 4133 }
4494 // didn't represent an HTML file, but check to be safe. 4134 htmlEntry.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors);
4495 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4135 // notify about errors
4496 } 4136 ChangeNoticeImpl notice = _getNotice(source);
4497 HtmlEntry htmlEntry = sourceEntry; 4137 notice.htmlUnit = task.resolvedUnit;
4498 int sourceTime = getModificationStamp(source); 4138 LineInfo lineInfo = htmlEntry.getValue(SourceEntry.LINE_INFO);
4499 int resultTime = task.modificationTime; 4139 notice.setErrors(htmlEntry.allErrors, lineInfo);
4500 if (sourceTime == resultTime) { 4140 return htmlEntry;
4501 if (htmlEntry.modificationTime != sourceTime) { 4141 }
4502 // The source has changed without the context being notified. Simulate n otification. 4142
4503 _sourceChanged(source); 4143 /**
4504 htmlEntry = _getReadableHtmlEntry(source); 4144 * Record the results produced by performing a [task] and return the cache
4505 if (htmlEntry == null) { 4145 * entry associated with the results.
4506 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}");
4507 }
4508 }
4509 if (thrownException == null) {
4510 htmlEntry.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors);
4511 // notify about errors
4512 ChangeNoticeImpl notice = _getNotice(source);
4513 notice.htmlUnit = task.resolvedUnit;
4514 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LIN E_INFO));
4515 } else {
4516 htmlEntry.recordResolutionError(thrownException);
4517 }
4518 } else {
4519 if (thrownException == null || resultTime >= 0) {
4520 //
4521 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4522 // will be re-analyzed using the up-to-date sources.
4523 //
4524 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheStat e.IN_PROCESS) {
4525 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INV ALID);
4526 // }
4527 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) {
4528 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
4529 // }
4530 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) {
4531 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID);
4532 // }
4533 htmlEntry.invalidateAllInformation();
4534 htmlEntry.modificationTime = sourceTime;
4535 _cache.removedAst(source);
4536 } else {
4537 //
4538 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4539 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4540 // that we'll be able to do so without error.
4541 //
4542 htmlEntry.recordResolutionError(thrownException);
4543 }
4544 }
4545 if (thrownException != null) {
4546 throw new AnalysisException('<rethrow>', thrownException);
4547 }
4548 return htmlEntry;
4549 }
4550
4551 /**
4552 * Record the results produced by performing a [ResolveAngularEntryHtmlTask]. If the results
4553 * were computed from data that is now out-of-date, then the results will not be recorded.
4554 *
4555 * @param task the task that was performed
4556 * @throws AnalysisException if the results could not be recorded
4557 */ 4146 */
4558 HtmlEntry _recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTas k task) { 4147 HtmlEntry _recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTas k task) {
4559 Source source = task.source; 4148 Source source = task.source;
4560 CaughtException thrownException = task.exception; 4149 HtmlEntry htmlEntry = _cache.get(source);
4561 SourceEntry sourceEntry = _cache.get(source); 4150 CaughtException thrownException = task.exception;
4562 if (sourceEntry == null) { 4151 if (thrownException != null) {
4563 throw new ObsoleteSourceAnalysisException(source); 4152 htmlEntry.recordResolutionError(thrownException);
4564 } else if (sourceEntry is! HtmlEntry) { 4153 throw new AnalysisException('<rethrow>', thrownException);
4565 // This shouldn't be possible because we should never have performed the t ask if the source 4154 }
4566 // didn't represent an HTML file, but check to be safe. 4155 htmlEntry.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit);
4567 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4156 _recordAngularEntryPoint(htmlEntry, task);
4568 } 4157 _cache.storedAst(source);
4569 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; 4158 ChangeNoticeImpl notice = _getNotice(source);
4570 int sourceTime = getModificationStamp(source); 4159 notice.htmlUnit = task.resolvedUnit;
4571 int resultTime = task.modificationTime; 4160 LineInfo lineInfo = htmlEntry.getValue(SourceEntry.LINE_INFO);
4572 if (sourceTime == resultTime) { 4161 notice.setErrors(htmlEntry.allErrors, lineInfo);
4573 if (htmlEntry.modificationTime != sourceTime) { 4162 return htmlEntry;
4574 // The source has changed without the context being notified. Simulate n otification. 4163 }
4575 _sourceChanged(source); 4164
4576 htmlEntry = _getReadableHtmlEntry(source); 4165 /**
4577 if (htmlEntry == null) { 4166 * Record the results produced by performing a [task] and return the cache
4578 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4167 * entry associated with the results.
4579 }
4580 }
4581 if (thrownException == null) {
4582 htmlEntry.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit);
4583 _recordAngularEntryPoint(htmlEntry, task);
4584 _cache.storedAst(source);
4585 ChangeNoticeImpl notice = _getNotice(source);
4586 notice.htmlUnit = task.resolvedUnit;
4587 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LIN E_INFO));
4588 } else {
4589 htmlEntry.recordResolutionError(thrownException);
4590 }
4591 } else {
4592 if (thrownException == null || resultTime >= 0) {
4593 //
4594 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4595 // will be re-analyzed using the up-to-date sources.
4596 //
4597 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheStat e.IN_PROCESS) {
4598 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INV ALID);
4599 // }
4600 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) {
4601 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
4602 // }
4603 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) {
4604 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID);
4605 // }
4606 htmlEntry.invalidateAllInformation();
4607 htmlEntry.modificationTime = sourceTime;
4608 _cache.removedAst(source);
4609 } else {
4610 //
4611 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4612 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4613 // that we'll be able to do so without error.
4614 //
4615 htmlEntry.recordResolutionError(thrownException);
4616 }
4617 }
4618 if (thrownException != null) {
4619 throw new AnalysisException('<rethrow>', thrownException);
4620 }
4621 return htmlEntry;
4622 }
4623
4624 /**
4625 * Record the results produced by performing a [ResolveDartUnitTask]. If the r esults were
4626 * computed from data that is now out-of-date, then the results will not be re corded.
4627 *
4628 * @param task the task that was performed
4629 * @return an entry containing the computed results
4630 * @throws AnalysisException if the results could not be recorded
4631 */ 4168 */
4632 DartEntry _recordResolveDartUnitTaskResults(ResolveDartUnitTask task) { 4169 DartEntry _recordResolveDartUnitTaskResults(ResolveDartUnitTask task) {
4633 Source unitSource = task.source; 4170 Source unitSource = task.source;
4171 DartEntry dartEntry = _cache.get(unitSource);
4634 Source librarySource = task.librarySource; 4172 Source librarySource = task.librarySource;
4635 CaughtException thrownException = task.exception; 4173 CaughtException thrownException = task.exception;
4636 SourceEntry sourceEntry = _cache.get(unitSource); 4174 if (thrownException != null) {
4637 if (sourceEntry == null) { 4175 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownException);
4638 throw new ObsoleteSourceAnalysisException(unitSource); 4176 _cache.removedAst(unitSource);
4639 } else if (sourceEntry is! DartEntry) { 4177 throw new AnalysisException('<rethrow>', thrownException);
4640 // This shouldn't be possible because we should never have performed the t ask if the source 4178 }
4641 // didn't represent a Dart file, but check to be safe. 4179 dartEntry.setValueInLibrary(
4642 throw new AnalysisException("Internal error: attempting to resolve non-Dar t file as a Dart file: ${unitSource.fullName}"); 4180 DartEntry.RESOLVED_UNIT,
4643 } 4181 librarySource,
4644 DartEntry dartEntry = sourceEntry as DartEntry; 4182 task.resolvedUnit);
4645 int sourceTime = getModificationStamp(unitSource); 4183 _cache.storedAst(unitSource);
4646 int resultTime = task.modificationTime;
4647 if (sourceTime == resultTime) {
4648 if (dartEntry.modificationTime != sourceTime) {
4649 // The source has changed without the context being notified. Simulate n otification.
4650 _sourceChanged(unitSource);
4651 dartEntry = _getReadableDartEntry(unitSource);
4652 if (dartEntry == null) {
4653 throw new AnalysisException("A Dart file became a non-Dart file: ${uni tSource.fullName}");
4654 }
4655 }
4656 if (thrownException == null) {
4657 dartEntry.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, task .resolvedUnit);
4658 _cache.storedAst(unitSource);
4659 } else {
4660 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownException) ;
4661 _cache.removedAst(unitSource);
4662 }
4663 } else {
4664 _logInformation2("Resolution results discarded for ${_debuggingString(unit Source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${ dartEntry.modificationTime}", thrownException);
4665 if (thrownException == null || resultTime >= 0) {
4666 //
4667 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4668 // will be re-analyzed using the up-to-date sources.
4669 //
4670 // if (dartCopy.getState(DartEntry.RESOLVED_UNIT) == CacheState .IN_PROCESS) {
4671 // dartCopy.setState(DartEntry.RESOLVED_UNIT, librarySource, CacheState.INVALID);
4672 // }
4673 _removeFromParts(unitSource, dartEntry);
4674 dartEntry.invalidateAllInformation();
4675 dartEntry.modificationTime = sourceTime;
4676 _cache.removedAst(unitSource);
4677 _workManager.add(unitSource, SourcePriority.UNKNOWN);
4678 } else {
4679 //
4680 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4681 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4682 // that we'll be able to do so without error.
4683 //
4684 dartEntry.recordResolutionErrorInLibrary(librarySource, thrownException) ;
4685 }
4686 }
4687 if (thrownException != null) {
4688 throw new AnalysisException('<rethrow>', thrownException);
4689 }
4690 return dartEntry; 4184 return dartEntry;
4691 } 4185 }
4692 4186
4693 /** 4187 /**
4694 * Record the results produced by performing a [ResolveHtmlTask]. If the resul ts were 4188 * Record the results produced by performing a [task] and return the cache
4695 * computed from data that is now out-of-date, then the results will not be re corded. 4189 * entry associated with the results.
4696 *
4697 * @param task the task that was performed
4698 * @return an entry containing the computed results
4699 * @throws AnalysisException if the results could not be recorded
4700 */ 4190 */
4701 HtmlEntry _recordResolveHtmlTaskResults(ResolveHtmlTask task) { 4191 HtmlEntry _recordResolveHtmlTaskResults(ResolveHtmlTask task) {
4702 Source source = task.source; 4192 Source source = task.source;
4703 CaughtException thrownException = task.exception; 4193 HtmlEntry htmlEntry = _cache.get(source);
4704 SourceEntry sourceEntry = _cache.get(source); 4194 CaughtException thrownException = task.exception;
4705 if (sourceEntry == null) { 4195 if (thrownException != null) {
4706 throw new ObsoleteSourceAnalysisException(source); 4196 htmlEntry.recordResolutionError(thrownException);
4707 } else if (sourceEntry is! HtmlEntry) { 4197 _cache.removedAst(source);
4708 // This shouldn't be possible because we should never have performed the t ask if the source 4198 throw new AnalysisException('<rethrow>', thrownException);
4709 // didn't represent an HTML file, but check to be safe. 4199 }
4710 throw new AnalysisException("Internal error: attempting to resolve non-HTM L file as an HTML file: ${source.fullName}"); 4200 htmlEntry.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED);
4711 } 4201 htmlEntry.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit);
4712 HtmlEntry htmlEntry = sourceEntry; 4202 htmlEntry.setValue(HtmlEntry.ELEMENT, task.element);
4713 int sourceTime = getModificationStamp(source); 4203 htmlEntry.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors);
4714 int resultTime = task.modificationTime; 4204 _cache.storedAst(source);
4715 if (sourceTime == resultTime) { 4205 ChangeNoticeImpl notice = _getNotice(source);
4716 if (htmlEntry.modificationTime != sourceTime) { 4206 notice.htmlUnit = task.resolvedUnit;
4717 // The source has changed without the context being notified. Simulate n otification. 4207 LineInfo lineInfo = htmlEntry.getValue(SourceEntry.LINE_INFO);
4718 _sourceChanged(source); 4208 notice.setErrors(htmlEntry.allErrors, lineInfo);
4719 htmlEntry = _getReadableHtmlEntry(source); 4209 return htmlEntry;
4720 if (htmlEntry == null) { 4210 }
4721 throw new AnalysisException("An HTML file became a non-HTML file: ${so urce.fullName}"); 4211
4722 } 4212 /**
4723 } 4213 * Record the results produced by performing a [task] and return the cache
4724 if (thrownException == null) { 4214 * entry associated with the results.
4725 htmlEntry.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED);
4726 htmlEntry.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit);
4727 htmlEntry.setValue(HtmlEntry.ELEMENT, task.element);
4728 htmlEntry.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors);
4729 _cache.storedAst(source);
4730 ChangeNoticeImpl notice = _getNotice(source);
4731 notice.htmlUnit = task.resolvedUnit;
4732 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LIN E_INFO));
4733 } else {
4734 htmlEntry.recordResolutionError(thrownException);
4735 _cache.removedAst(source);
4736 }
4737 } else {
4738 _logInformation2("Resolution results discarded for ${_debuggingString(sour ce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${html Entry.modificationTime}", thrownException);
4739 if (thrownException == null || resultTime >= 0) {
4740 //
4741 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4742 // will be re-analyzed using the up-to-date sources.
4743 //
4744 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR OCESS) {
4745 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
4746 // }
4747 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS tate.IN_PROCESS) {
4748 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState. INVALID);
4749 // }
4750 htmlEntry.invalidateAllInformation();
4751 htmlEntry.modificationTime = sourceTime;
4752 _cache.removedAst(source);
4753 } else {
4754 //
4755 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4756 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4757 // that we'll be able to do so without error.
4758 //
4759 htmlEntry.recordResolutionError(thrownException);
4760 }
4761 }
4762 if (thrownException != null) {
4763 throw new AnalysisException('<rethrow>', thrownException);
4764 }
4765 return htmlEntry;
4766 }
4767
4768 /**
4769 * Record the results produced by performing a [ScanDartTask]. If the results were computed
4770 * from data that is now out-of-date, then the results will not be recorded.
4771 *
4772 * @param task the task that was performed
4773 * @return an entry containing the computed results
4774 * @throws AnalysisException if the results could not be recorded
4775 */ 4215 */
4776 DartEntry _recordScanDartTaskResults(ScanDartTask task) { 4216 DartEntry _recordScanDartTaskResults(ScanDartTask task) {
4777 Source source = task.source; 4217 Source source = task.source;
4778 CaughtException thrownException = task.exception; 4218 DartEntry dartEntry = _cache.get(source);
4779 SourceEntry sourceEntry = _cache.get(source); 4219 CaughtException thrownException = task.exception;
4780 if (sourceEntry == null) { 4220 if (thrownException != null) {
4781 throw new ObsoleteSourceAnalysisException(source); 4221 _removeFromParts(source, dartEntry);
4782 } else if (sourceEntry is! DartEntry) { 4222 dartEntry.recordScanError(thrownException);
4783 // This shouldn't be possible because we should never have performed the t ask if the source 4223 _cache.removedAst(source);
4784 // didn't represent a Dart file, but check to be safe. 4224 throw new AnalysisException('<rethrow>', thrownException);
4785 throw new AnalysisException("Internal error: attempting to parse non-Dart file as a Dart file: ${source.fullName}"); 4225 }
4786 } 4226 LineInfo lineInfo = task.lineInfo;
4787 DartEntry dartEntry = sourceEntry; 4227 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo);
4788 int sourceTime = getModificationStamp(source); 4228 dartEntry.setValue(DartEntry.TOKEN_STREAM, task.tokenStream);
4789 int resultTime = task.modificationTime; 4229 dartEntry.setValue(DartEntry.SCAN_ERRORS, task.errors);
4790 if (sourceTime == resultTime) { 4230 _cache.storedAst(source);
4791 if (dartEntry.modificationTime != sourceTime) { 4231 ChangeNoticeImpl notice = _getNotice(source);
4792 // The source has changed without the context being notified. Simulate n otification. 4232 notice.setErrors(dartEntry.allErrors, lineInfo);
4793 _sourceChanged(source);
4794 dartEntry = _getReadableDartEntry(source);
4795 if (dartEntry == null) {
4796 throw new AnalysisException("A Dart file became a non-Dart file: ${sou rce.fullName}");
4797 }
4798 }
4799 if (thrownException == null) {
4800 LineInfo lineInfo = task.lineInfo;
4801 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo);
4802 dartEntry.setValue(DartEntry.TOKEN_STREAM, task.tokenStream);
4803 dartEntry.setValue(DartEntry.SCAN_ERRORS, task.errors);
4804 _cache.storedAst(source);
4805 ChangeNoticeImpl notice = _getNotice(source);
4806 notice.setErrors(dartEntry.allErrors, lineInfo);
4807 } else {
4808 _removeFromParts(source, dartEntry);
4809 dartEntry.recordScanError(thrownException);
4810 _cache.removedAst(source);
4811 }
4812 } else {
4813 _logInformation2("Scan results discarded for ${_debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry. modificationTime}", thrownException);
4814 if (thrownException == null || resultTime >= 0) {
4815 //
4816 // The analysis was performed on out-of-date sources. Mark the cache so that the sources
4817 // will be re-analyzed using the up-to-date sources.
4818 //
4819 // dartCopy.recordScanNotInProcess();
4820 _removeFromParts(source, dartEntry);
4821 dartEntry.invalidateAllInformation();
4822 dartEntry.modificationTime = sourceTime;
4823 _cache.removedAst(source);
4824 _workManager.add(source, SourcePriority.UNKNOWN);
4825 } else {
4826 //
4827 // We could not determine whether the sources were up-to-date or out-of- date. Mark the
4828 // cache so that we won't attempt to re-analyze the sources until there' s a good chance
4829 // that we'll be able to do so without error.
4830 //
4831 dartEntry.recordScanError(thrownException);
4832 }
4833 }
4834 if (thrownException != null) {
4835 throw new AnalysisException('<rethrow>', thrownException);
4836 }
4837 return dartEntry; 4233 return dartEntry;
4838 } 4234 }
4839 4235
4840 /** 4236 /**
4841 * Remove the given library from the list of containing libraries for all of t he parts referenced 4237 * Remove the given library from the list of containing libraries for all of t he parts referenced
4842 * by the given entry. 4238 * by the given entry.
4843 * 4239 *
4844 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4240 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
4845 * 4241 *
4846 * @param librarySource the library to be removed 4242 * @param librarySource the library to be removed
(...skipping 10307 matching lines...) Expand 10 before | Expand all | Expand 10 after
15154 _index++; 14550 _index++;
15155 if (_index >= _manager._workQueues[_queueIndex].length) { 14551 if (_index >= _manager._workQueues[_queueIndex].length) {
15156 _index = 0; 14552 _index = 0;
15157 _queueIndex++; 14553 _queueIndex++;
15158 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_ queueIndex].isEmpty) { 14554 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_ queueIndex].isEmpty) {
15159 _queueIndex++; 14555 _queueIndex++;
15160 } 14556 }
15161 } 14557 }
15162 } 14558 }
15163 } 14559 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698