| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine; | 8 library engine; |
| 9 | 9 |
| 10 import 'java_core.dart'; | 10 import 'java_core.dart'; |
| (...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 * @param source the source that was removed | 1008 * @param source the source that was removed |
| 1009 */ | 1009 */ |
| 1010 void removedSource(Source source) { | 1010 void removedSource(Source source) { |
| 1011 if (source != null) { | 1011 if (source != null) { |
| 1012 _removed.add(source); | 1012 _removed.add(source); |
| 1013 } | 1013 } |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 String toString() { | 1016 String toString() { |
| 1017 JavaStringBuilder builder = new JavaStringBuilder(); | 1017 JavaStringBuilder builder = new JavaStringBuilder(); |
| 1018 bool needsSeparator = appendSources(builder, _added, false, "added"); | 1018 bool needsSeparator = _appendSources(builder, _added, false, "added"); |
| 1019 needsSeparator = appendSources(builder, _changed, needsSeparator, "changed")
; | 1019 needsSeparator = _appendSources(builder, _changed, needsSeparator, "changed"
); |
| 1020 appendSources(builder, _removed, needsSeparator, "removed"); | 1020 _appendSources(builder, _removed, needsSeparator, "removed"); |
| 1021 int count = removedContainers.length; | 1021 int count = removedContainers.length; |
| 1022 if (count > 0) { | 1022 if (count > 0) { |
| 1023 if (_removed.isEmpty) { | 1023 if (_removed.isEmpty) { |
| 1024 if (needsSeparator) { | 1024 if (needsSeparator) { |
| 1025 builder.append("; "); | 1025 builder.append("; "); |
| 1026 } | 1026 } |
| 1027 builder.append("removed: from "); | 1027 builder.append("removed: from "); |
| 1028 builder.append(count); | 1028 builder.append(count); |
| 1029 builder.append(" containers"); | 1029 builder.append(" containers"); |
| 1030 } else { | 1030 } else { |
| 1031 builder.append(", and more from "); | 1031 builder.append(", and more from "); |
| 1032 builder.append(count); | 1032 builder.append(count); |
| 1033 builder.append(" containers"); | 1033 builder.append(" containers"); |
| 1034 } | 1034 } |
| 1035 } | 1035 } |
| 1036 return builder.toString(); | 1036 return builder.toString(); |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 /** | 1039 /** |
| 1040 * Append the given sources to the given builder, prefixed with the given labe
l and possibly a | 1040 * Append the given sources to the given builder, prefixed with the given labe
l and possibly a |
| 1041 * separator. | 1041 * separator. |
| 1042 * | 1042 * |
| 1043 * @param builder the builder to which the sources are to be appended | 1043 * @param builder the builder to which the sources are to be appended |
| 1044 * @param sources the sources to be appended | 1044 * @param sources the sources to be appended |
| 1045 * @param needsSeparator `true` if a separator is needed before the label | 1045 * @param needsSeparator `true` if a separator is needed before the label |
| 1046 * @param label the label used to prefix the sources | 1046 * @param label the label used to prefix the sources |
| 1047 * @return `true` if future lists of sources will need a separator | 1047 * @return `true` if future lists of sources will need a separator |
| 1048 */ | 1048 */ |
| 1049 bool appendSources(JavaStringBuilder builder, List<Source> sources, bool needs
Separator, String label) { | 1049 bool _appendSources(JavaStringBuilder builder, List<Source> sources, bool need
sSeparator, String label) { |
| 1050 if (sources.isEmpty) { | 1050 if (sources.isEmpty) { |
| 1051 return needsSeparator; | 1051 return needsSeparator; |
| 1052 } | 1052 } |
| 1053 if (needsSeparator) { | 1053 if (needsSeparator) { |
| 1054 builder.append("; "); | 1054 builder.append("; "); |
| 1055 } | 1055 } |
| 1056 builder.append(label); | 1056 builder.append(label); |
| 1057 String prefix = " "; | 1057 String prefix = " "; |
| 1058 for (Source source in sources) { | 1058 for (Source source in sources) { |
| 1059 builder.append(prefix); | 1059 builder.append(prefix); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 * Record that the AST associated with the given source was just read from the
cache. | 1138 * Record that the AST associated with the given source was just read from the
cache. |
| 1139 * | 1139 * |
| 1140 * @param source the source whose AST was accessed | 1140 * @param source the source whose AST was accessed |
| 1141 */ | 1141 */ |
| 1142 void accessedAst(Source source) { | 1142 void accessedAst(Source source) { |
| 1143 if (_recentlyUsed.remove(source)) { | 1143 if (_recentlyUsed.remove(source)) { |
| 1144 _recentlyUsed.add(source); | 1144 _recentlyUsed.add(source); |
| 1145 return; | 1145 return; |
| 1146 } | 1146 } |
| 1147 while (_recentlyUsed.length >= _maxCacheSize) { | 1147 while (_recentlyUsed.length >= _maxCacheSize) { |
| 1148 if (!flushAstFromCache()) { | 1148 if (!_flushAstFromCache()) { |
| 1149 break; | 1149 break; |
| 1150 } | 1150 } |
| 1151 } | 1151 } |
| 1152 _recentlyUsed.add(source); | 1152 _recentlyUsed.add(source); |
| 1153 } | 1153 } |
| 1154 | 1154 |
| 1155 /** | 1155 /** |
| 1156 * Return a collection containing all of the map entries mapping sources to ca
che entries. Clients | 1156 * Return a collection containing all of the map entries mapping sources to ca
che entries. Clients |
| 1157 * should not modify the returned collection. | 1157 * should not modify the returned collection. |
| 1158 * | 1158 * |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 } | 1199 } |
| 1200 | 1200 |
| 1201 /** | 1201 /** |
| 1202 * Set the maximum size of the cache to the given size. | 1202 * Set the maximum size of the cache to the given size. |
| 1203 * | 1203 * |
| 1204 * @param size the maximum number of sources for which AST structures should b
e kept in the cache | 1204 * @param size the maximum number of sources for which AST structures should b
e kept in the cache |
| 1205 */ | 1205 */ |
| 1206 void set maxCacheSize(int size) { | 1206 void set maxCacheSize(int size) { |
| 1207 _maxCacheSize = size; | 1207 _maxCacheSize = size; |
| 1208 while (_recentlyUsed.length > _maxCacheSize) { | 1208 while (_recentlyUsed.length > _maxCacheSize) { |
| 1209 if (!flushAstFromCache()) { | 1209 if (!_flushAstFromCache()) { |
| 1210 break; | 1210 break; |
| 1211 } | 1211 } |
| 1212 } | 1212 } |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 /** | 1215 /** |
| 1216 * Return the number of sources that are mapped to cache entries. | 1216 * Return the number of sources that are mapped to cache entries. |
| 1217 * | 1217 * |
| 1218 * @return the number of sources that are mapped to cache entries | 1218 * @return the number of sources that are mapped to cache entries |
| 1219 */ | 1219 */ |
| 1220 int size() => _sourceMap.length; | 1220 int size() => _sourceMap.length; |
| 1221 | 1221 |
| 1222 /** | 1222 /** |
| 1223 * Record that the AST associated with the given source was just stored to the
cache. | 1223 * Record that the AST associated with the given source was just stored to the
cache. |
| 1224 * | 1224 * |
| 1225 * @param source the source whose AST was stored | 1225 * @param source the source whose AST was stored |
| 1226 */ | 1226 */ |
| 1227 void storedAst(Source source) { | 1227 void storedAst(Source source) { |
| 1228 if (_recentlyUsed.contains(source)) { | 1228 if (_recentlyUsed.contains(source)) { |
| 1229 return; | 1229 return; |
| 1230 } | 1230 } |
| 1231 while (_recentlyUsed.length >= _maxCacheSize) { | 1231 while (_recentlyUsed.length >= _maxCacheSize) { |
| 1232 if (!flushAstFromCache()) { | 1232 if (!_flushAstFromCache()) { |
| 1233 break; | 1233 break; |
| 1234 } | 1234 } |
| 1235 } | 1235 } |
| 1236 _recentlyUsed.add(source); | 1236 _recentlyUsed.add(source); |
| 1237 } | 1237 } |
| 1238 | 1238 |
| 1239 /** | 1239 /** |
| 1240 * Attempt to flush one AST structure from the cache. | 1240 * Attempt to flush one AST structure from the cache. |
| 1241 * | 1241 * |
| 1242 * @return `true` if a structure was flushed | 1242 * @return `true` if a structure was flushed |
| 1243 */ | 1243 */ |
| 1244 bool flushAstFromCache() { | 1244 bool _flushAstFromCache() { |
| 1245 Source removedSource = removeAstToFlush(); | 1245 Source removedSource = _removeAstToFlush(); |
| 1246 if (removedSource == null) { | 1246 if (removedSource == null) { |
| 1247 return false; | 1247 return false; |
| 1248 } | 1248 } |
| 1249 SourceEntry sourceEntry = _sourceMap[removedSource]; | 1249 SourceEntry sourceEntry = _sourceMap[removedSource]; |
| 1250 if (sourceEntry is HtmlEntry) { | 1250 if (sourceEntry is HtmlEntry) { |
| 1251 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; | 1251 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; |
| 1252 htmlCopy.flushAstStructures(); | 1252 htmlCopy.flushAstStructures(); |
| 1253 _sourceMap[removedSource] = htmlCopy; | 1253 _sourceMap[removedSource] = htmlCopy; |
| 1254 } else if (sourceEntry is DartEntry) { | 1254 } else if (sourceEntry is DartEntry) { |
| 1255 DartEntryImpl dartCopy = sourceEntry.writableCopy; | 1255 DartEntryImpl dartCopy = sourceEntry.writableCopy; |
| 1256 dartCopy.flushAstStructures(); | 1256 dartCopy.flushAstStructures(); |
| 1257 _sourceMap[removedSource] = dartCopy; | 1257 _sourceMap[removedSource] = dartCopy; |
| 1258 } | 1258 } |
| 1259 return true; | 1259 return true; |
| 1260 } | 1260 } |
| 1261 | 1261 |
| 1262 /** | 1262 /** |
| 1263 * Remove and return one source from the list of recently used sources whose A
ST structure can be | 1263 * Remove and return one source from the list of recently used sources whose A
ST structure can be |
| 1264 * flushed from the cache. The source that will be returned will be the source
that has been | 1264 * flushed from the cache. The source that will be returned will be the source
that has been |
| 1265 * unreferenced for the longest period of time but that is not a priority for
analysis. | 1265 * unreferenced for the longest period of time but that is not a priority for
analysis. |
| 1266 * | 1266 * |
| 1267 * @return the source that was removed | 1267 * @return the source that was removed |
| 1268 */ | 1268 */ |
| 1269 Source removeAstToFlush() { | 1269 Source _removeAstToFlush() { |
| 1270 int sourceToRemove = -1; | 1270 int sourceToRemove = -1; |
| 1271 for (int i = 0; i < _recentlyUsed.length; i++) { | 1271 for (int i = 0; i < _recentlyUsed.length; i++) { |
| 1272 Source source = _recentlyUsed[i]; | 1272 Source source = _recentlyUsed[i]; |
| 1273 RetentionPriority priority = _retentionPolicy.getAstPriority(source, _sour
ceMap[source]); | 1273 RetentionPriority priority = _retentionPolicy.getAstPriority(source, _sour
ceMap[source]); |
| 1274 if (identical(priority, RetentionPriority.LOW)) { | 1274 if (identical(priority, RetentionPriority.LOW)) { |
| 1275 return _recentlyUsed.removeAt(i); | 1275 return _recentlyUsed.removeAt(i); |
| 1276 } else if (identical(priority, RetentionPriority.MEDIUM) && sourceToRemove
< 0) { | 1276 } else if (identical(priority, RetentionPriority.MEDIUM) && sourceToRemove
< 0) { |
| 1277 sourceToRemove = i; | 1277 sourceToRemove = i; |
| 1278 } | 1278 } |
| 1279 } | 1279 } |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1965 _scanErrorsState = CacheState.INVALID; | 1965 _scanErrorsState = CacheState.INVALID; |
| 1966 _tokenStream = null; | 1966 _tokenStream = null; |
| 1967 _tokenStreamState = CacheState.INVALID; | 1967 _tokenStreamState = CacheState.INVALID; |
| 1968 _sourceKind = SourceKind.UNKNOWN; | 1968 _sourceKind = SourceKind.UNKNOWN; |
| 1969 _sourceKindState = CacheState.INVALID; | 1969 _sourceKindState = CacheState.INVALID; |
| 1970 _parseErrors = AnalysisError.NO_ERRORS; | 1970 _parseErrors = AnalysisError.NO_ERRORS; |
| 1971 _parseErrorsState = CacheState.INVALID; | 1971 _parseErrorsState = CacheState.INVALID; |
| 1972 _parsedUnit = null; | 1972 _parsedUnit = null; |
| 1973 _parsedUnitAccessed = false; | 1973 _parsedUnitAccessed = false; |
| 1974 _parsedUnitState = CacheState.INVALID; | 1974 _parsedUnitState = CacheState.INVALID; |
| 1975 discardCachedResolutionInformation(); | 1975 _discardCachedResolutionInformation(); |
| 1976 } | 1976 } |
| 1977 | 1977 |
| 1978 /** | 1978 /** |
| 1979 * Invalidate all of the resolution information associated with the compilatio
n unit. | 1979 * Invalidate all of the resolution information associated with the compilatio
n unit. |
| 1980 */ | 1980 */ |
| 1981 void invalidateAllResolutionInformation() { | 1981 void invalidateAllResolutionInformation() { |
| 1982 if (identical(_parsedUnitState, CacheState.FLUSHED)) { | 1982 if (identical(_parsedUnitState, CacheState.FLUSHED)) { |
| 1983 DartEntryImpl_ResolutionState state = _resolutionState; | 1983 DartEntryImpl_ResolutionState state = _resolutionState; |
| 1984 while (state != null) { | 1984 while (state != null) { |
| 1985 if (identical(state._resolvedUnitState, CacheState.VALID)) { | 1985 if (identical(state._resolvedUnitState, CacheState.VALID)) { |
| 1986 _parsedUnit = state._resolvedUnit; | 1986 _parsedUnit = state._resolvedUnit; |
| 1987 _parsedUnitAccessed = true; | 1987 _parsedUnitAccessed = true; |
| 1988 _parsedUnitState = CacheState.VALID; | 1988 _parsedUnitState = CacheState.VALID; |
| 1989 break; | 1989 break; |
| 1990 } | 1990 } |
| 1991 state = state._nextState; | 1991 state = state._nextState; |
| 1992 } | 1992 } |
| 1993 } | 1993 } |
| 1994 discardCachedResolutionInformation(); | 1994 _discardCachedResolutionInformation(); |
| 1995 } | 1995 } |
| 1996 | 1996 |
| 1997 bool get isRefactoringSafe { | 1997 bool get isRefactoringSafe { |
| 1998 DartEntryImpl_ResolutionState state = _resolutionState; | 1998 DartEntryImpl_ResolutionState state = _resolutionState; |
| 1999 while (state != null) { | 1999 while (state != null) { |
| 2000 CacheState resolvedState = state._resolvedUnitState; | 2000 CacheState resolvedState = state._resolvedUnitState; |
| 2001 if (resolvedState != CacheState.VALID && resolvedState != CacheState.FLUSH
ED) { | 2001 if (resolvedState != CacheState.VALID && resolvedState != CacheState.FLUSH
ED) { |
| 2002 return false; | 2002 return false; |
| 2003 } | 2003 } |
| 2004 state = state._nextState; | 2004 state = state._nextState; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2248 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { | 2248 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { |
| 2249 _exportedLibraries = updatedValue(state, _exportedLibraries, Source.EMPTY_
ARRAY); | 2249 _exportedLibraries = updatedValue(state, _exportedLibraries, Source.EMPTY_
ARRAY); |
| 2250 _exportedLibrariesState = state; | 2250 _exportedLibrariesState = state; |
| 2251 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { | 2251 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { |
| 2252 _importedLibraries = updatedValue(state, _importedLibraries, Source.EMPTY_
ARRAY); | 2252 _importedLibraries = updatedValue(state, _importedLibraries, Source.EMPTY_
ARRAY); |
| 2253 _importedLibrariesState = state; | 2253 _importedLibrariesState = state; |
| 2254 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 2254 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 2255 _includedParts = updatedValue(state, _includedParts, Source.EMPTY_ARRAY); | 2255 _includedParts = updatedValue(state, _includedParts, Source.EMPTY_ARRAY); |
| 2256 _includedPartsState = state; | 2256 _includedPartsState = state; |
| 2257 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | 2257 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
| 2258 _bitmask = updatedValueOfFlag(state, _bitmask, _CLIENT_CODE_INDEX); | 2258 _bitmask = _updatedValueOfFlag(state, _bitmask, _CLIENT_CODE_INDEX); |
| 2259 _clientServerState = state; | 2259 _clientServerState = state; |
| 2260 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | 2260 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
| 2261 _bitmask = updatedValueOfFlag(state, _bitmask, _LAUNCHABLE_INDEX); | 2261 _bitmask = _updatedValueOfFlag(state, _bitmask, _LAUNCHABLE_INDEX); |
| 2262 _launchableState = state; | 2262 _launchableState = state; |
| 2263 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | 2263 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
| 2264 _parseErrors = updatedValue(state, _parseErrors, AnalysisError.NO_ERRORS); | 2264 _parseErrors = updatedValue(state, _parseErrors, AnalysisError.NO_ERRORS); |
| 2265 _parseErrorsState = state; | 2265 _parseErrorsState = state; |
| 2266 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 2266 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 2267 CompilationUnit newUnit = updatedValue(state, _parsedUnit, null); | 2267 CompilationUnit newUnit = updatedValue(state, _parsedUnit, null); |
| 2268 if (newUnit != _parsedUnit) { | 2268 if (newUnit != _parsedUnit) { |
| 2269 _parsedUnitAccessed = false; | 2269 _parsedUnitAccessed = false; |
| 2270 } | 2270 } |
| 2271 _parsedUnit = newUnit; | 2271 _parsedUnit = newUnit; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2290 /** | 2290 /** |
| 2291 * Set the state of the data represented by the given descriptor in the contex
t of the given | 2291 * Set the state of the data represented by the given descriptor in the contex
t of the given |
| 2292 * library to the given state. | 2292 * library to the given state. |
| 2293 * | 2293 * |
| 2294 * @param descriptor the descriptor representing the data whose state is to be
set | 2294 * @param descriptor the descriptor representing the data whose state is to be
set |
| 2295 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 2295 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
| 2296 * context for the data | 2296 * context for the data |
| 2297 * @param cacheState the new state of the data represented by the given descri
ptor | 2297 * @param cacheState the new state of the data represented by the given descri
ptor |
| 2298 */ | 2298 */ |
| 2299 void setStateInLibrary(DataDescriptor descriptor, Source librarySource, CacheS
tate cacheState) { | 2299 void setStateInLibrary(DataDescriptor descriptor, Source librarySource, CacheS
tate cacheState) { |
| 2300 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour
ce); | 2300 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou
rce); |
| 2301 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 2301 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 2302 state._resolutionErrors = updatedValue(cacheState, state._resolutionErrors
, AnalysisError.NO_ERRORS); | 2302 state._resolutionErrors = updatedValue(cacheState, state._resolutionErrors
, AnalysisError.NO_ERRORS); |
| 2303 state._resolutionErrorsState = cacheState; | 2303 state._resolutionErrorsState = cacheState; |
| 2304 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 2304 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 2305 state._resolvedUnit = updatedValue(cacheState, state._resolvedUnit, null); | 2305 state._resolvedUnit = updatedValue(cacheState, state._resolvedUnit, null); |
| 2306 state._resolvedUnitState = cacheState; | 2306 state._resolvedUnitState = cacheState; |
| 2307 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { | 2307 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { |
| 2308 state._verificationErrors = updatedValue(cacheState, state._verificationEr
rors, AnalysisError.NO_ERRORS); | 2308 state._verificationErrors = updatedValue(cacheState, state._verificationEr
rors, AnalysisError.NO_ERRORS); |
| 2309 state._verificationErrorsState = cacheState; | 2309 state._verificationErrorsState = cacheState; |
| 2310 } else if (identical(descriptor, DartEntry.HINTS)) { | 2310 } else if (identical(descriptor, DartEntry.HINTS)) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2363 /** | 2363 /** |
| 2364 * Set the value of the data represented by the given descriptor in the contex
t of the given | 2364 * Set the value of the data represented by the given descriptor in the contex
t of the given |
| 2365 * library to the given value, and set the state of that data to [CacheState#V
ALID]. | 2365 * library to the given value, and set the state of that data to [CacheState#V
ALID]. |
| 2366 * | 2366 * |
| 2367 * @param descriptor the descriptor representing which data is to have its val
ue set | 2367 * @param descriptor the descriptor representing which data is to have its val
ue set |
| 2368 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 2368 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
| 2369 * context for the data | 2369 * context for the data |
| 2370 * @param value the new value of the data represented by the given descriptor
and library | 2370 * @param value the new value of the data represented by the given descriptor
and library |
| 2371 */ | 2371 */ |
| 2372 void setValueInLibrary(DataDescriptor descriptor, Source librarySource, Object
value) { | 2372 void setValueInLibrary(DataDescriptor descriptor, Source librarySource, Object
value) { |
| 2373 DartEntryImpl_ResolutionState state = getOrCreateResolutionState(librarySour
ce); | 2373 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou
rce); |
| 2374 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 2374 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 2375 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value
as List<AnalysisError>); | 2375 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value
as List<AnalysisError>); |
| 2376 state._resolutionErrorsState = CacheState.VALID; | 2376 state._resolutionErrorsState = CacheState.VALID; |
| 2377 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 2377 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 2378 state._resolvedUnit = value as CompilationUnit; | 2378 state._resolvedUnit = value as CompilationUnit; |
| 2379 state._resolvedUnitState = CacheState.VALID; | 2379 state._resolvedUnitState = CacheState.VALID; |
| 2380 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { | 2380 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { |
| 2381 state._verificationErrors = value == null ? AnalysisError.NO_ERRORS : (val
ue as List<AnalysisError>); | 2381 state._verificationErrors = value == null ? AnalysisError.NO_ERRORS : (val
ue as List<AnalysisError>); |
| 2382 state._verificationErrorsState = CacheState.VALID; | 2382 state._verificationErrorsState = CacheState.VALID; |
| 2383 } else if (identical(descriptor, DartEntry.HINTS)) { | 2383 } else if (identical(descriptor, DartEntry.HINTS)) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2449 builder.append(_clientServerState); | 2449 builder.append(_clientServerState); |
| 2450 builder.append("; launchable = "); | 2450 builder.append("; launchable = "); |
| 2451 builder.append(_launchableState); | 2451 builder.append(_launchableState); |
| 2452 // builder.append("; angularElements = "); | 2452 // builder.append("; angularElements = "); |
| 2453 _resolutionState.writeOn(builder); | 2453 _resolutionState.writeOn(builder); |
| 2454 } | 2454 } |
| 2455 | 2455 |
| 2456 /** | 2456 /** |
| 2457 * Invalidate all of the resolution information associated with the compilatio
n unit. | 2457 * Invalidate all of the resolution information associated with the compilatio
n unit. |
| 2458 */ | 2458 */ |
| 2459 void discardCachedResolutionInformation() { | 2459 void _discardCachedResolutionInformation() { |
| 2460 _element = null; | 2460 _element = null; |
| 2461 _elementState = CacheState.INVALID; | 2461 _elementState = CacheState.INVALID; |
| 2462 _includedParts = Source.EMPTY_ARRAY; | 2462 _includedParts = Source.EMPTY_ARRAY; |
| 2463 _includedPartsState = CacheState.INVALID; | 2463 _includedPartsState = CacheState.INVALID; |
| 2464 _exportedLibraries = Source.EMPTY_ARRAY; | 2464 _exportedLibraries = Source.EMPTY_ARRAY; |
| 2465 _exportedLibrariesState = CacheState.INVALID; | 2465 _exportedLibrariesState = CacheState.INVALID; |
| 2466 _importedLibraries = Source.EMPTY_ARRAY; | 2466 _importedLibraries = Source.EMPTY_ARRAY; |
| 2467 _importedLibrariesState = CacheState.INVALID; | 2467 _importedLibrariesState = CacheState.INVALID; |
| 2468 _bitmask = 0; | 2468 _bitmask = 0; |
| 2469 _clientServerState = CacheState.INVALID; | 2469 _clientServerState = CacheState.INVALID; |
| 2470 _launchableState = CacheState.INVALID; | 2470 _launchableState = CacheState.INVALID; |
| 2471 _publicNamespace = null; | 2471 _publicNamespace = null; |
| 2472 _publicNamespaceState = CacheState.INVALID; | 2472 _publicNamespaceState = CacheState.INVALID; |
| 2473 _resolutionState.invalidateAllResolutionInformation(); | 2473 _resolutionState.invalidateAllResolutionInformation(); |
| 2474 } | 2474 } |
| 2475 | 2475 |
| 2476 /** | 2476 /** |
| 2477 * Return a resolution state for the specified library, creating one as necess
ary. | 2477 * Return a resolution state for the specified library, creating one as necess
ary. |
| 2478 * | 2478 * |
| 2479 * @param librarySource the library source (not `null`) | 2479 * @param librarySource the library source (not `null`) |
| 2480 * @return the resolution state (not `null`) | 2480 * @return the resolution state (not `null`) |
| 2481 */ | 2481 */ |
| 2482 DartEntryImpl_ResolutionState getOrCreateResolutionState(Source librarySource)
{ | 2482 DartEntryImpl_ResolutionState _getOrCreateResolutionState(Source librarySource
) { |
| 2483 DartEntryImpl_ResolutionState state = _resolutionState; | 2483 DartEntryImpl_ResolutionState state = _resolutionState; |
| 2484 if (state._librarySource == null) { | 2484 if (state._librarySource == null) { |
| 2485 state._librarySource = librarySource; | 2485 state._librarySource = librarySource; |
| 2486 return state; | 2486 return state; |
| 2487 } | 2487 } |
| 2488 while (state._librarySource != librarySource) { | 2488 while (state._librarySource != librarySource) { |
| 2489 if (state._nextState == null) { | 2489 if (state._nextState == null) { |
| 2490 DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionSta
te(); | 2490 DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionSta
te(); |
| 2491 newState._librarySource = librarySource; | 2491 newState._librarySource = librarySource; |
| 2492 state._nextState = newState; | 2492 state._nextState = newState; |
| 2493 return newState; | 2493 return newState; |
| 2494 } | 2494 } |
| 2495 state = state._nextState; | 2495 state = state._nextState; |
| 2496 } | 2496 } |
| 2497 return state; | 2497 return state; |
| 2498 } | 2498 } |
| 2499 | 2499 |
| 2500 /** | 2500 /** |
| 2501 * Given that one of the flags is being transitioned to the given state, retur
n the value of the | 2501 * Given that one of the flags is being transitioned to the given state, retur
n the value of the |
| 2502 * flags that should be kept in the cache. | 2502 * flags that should be kept in the cache. |
| 2503 * | 2503 * |
| 2504 * @param state the state to which the data is being transitioned | 2504 * @param state the state to which the data is being transitioned |
| 2505 * @param currentValue the value of the flags before the transition | 2505 * @param currentValue the value of the flags before the transition |
| 2506 * @param bitMask the mask used to access the bit whose state is being set | 2506 * @param bitMask the mask used to access the bit whose state is being set |
| 2507 * @return the value of the data that should be kept in the cache | 2507 * @return the value of the data that should be kept in the cache |
| 2508 */ | 2508 */ |
| 2509 int updatedValueOfFlag(CacheState state, int currentValue, int bitIndex) { | 2509 int _updatedValueOfFlag(CacheState state, int currentValue, int bitIndex) { |
| 2510 if (identical(state, CacheState.VALID)) { | 2510 if (identical(state, CacheState.VALID)) { |
| 2511 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); | 2511 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); |
| 2512 } else if (identical(state, CacheState.IN_PROCESS)) { | 2512 } else if (identical(state, CacheState.IN_PROCESS)) { |
| 2513 // | 2513 // |
| 2514 // We can leave the current value in the cache for any 'get' methods to ac
cess. | 2514 // We can leave the current value in the cache for any 'get' methods to ac
cess. |
| 2515 // | 2515 // |
| 2516 return currentValue; | 2516 return currentValue; |
| 2517 } | 2517 } |
| 2518 return BooleanArray.set(currentValue, bitIndex, false); | 2518 return BooleanArray.set(currentValue, bitIndex, false); |
| 2519 } | 2519 } |
| (...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3545 List<AnalysisContentStatistics_CacheRow> get cacheRows { | 3545 List<AnalysisContentStatistics_CacheRow> get cacheRows { |
| 3546 Iterable<AnalysisContentStatistics_CacheRow> items = _dataMap.values; | 3546 Iterable<AnalysisContentStatistics_CacheRow> items = _dataMap.values; |
| 3547 return new List.from(items); | 3547 return new List.from(items); |
| 3548 } | 3548 } |
| 3549 | 3549 |
| 3550 List<AnalysisException> get exceptions => new List.from(_exceptions); | 3550 List<AnalysisException> get exceptions => new List.from(_exceptions); |
| 3551 | 3551 |
| 3552 List<Source> get sources => new List.from(_sources); | 3552 List<Source> get sources => new List.from(_sources); |
| 3553 | 3553 |
| 3554 void putCacheItem(SourceEntry dartEntry, DataDescriptor descriptor) { | 3554 void putCacheItem(SourceEntry dartEntry, DataDescriptor descriptor) { |
| 3555 internalPutCacheItem(dartEntry, descriptor, dartEntry.getState(descriptor)); | 3555 _internalPutCacheItem(dartEntry, descriptor, dartEntry.getState(descriptor))
; |
| 3556 } | 3556 } |
| 3557 | 3557 |
| 3558 void putCacheItemInLibrary(DartEntry dartEntry, Source librarySource, DataDesc
riptor descriptor) { | 3558 void putCacheItemInLibrary(DartEntry dartEntry, Source librarySource, DataDesc
riptor descriptor) { |
| 3559 internalPutCacheItem(dartEntry, descriptor, dartEntry.getStateInLibrary(desc
riptor, librarySource)); | 3559 _internalPutCacheItem(dartEntry, descriptor, dartEntry.getStateInLibrary(des
criptor, librarySource)); |
| 3560 } | 3560 } |
| 3561 | 3561 |
| 3562 void internalPutCacheItem(SourceEntry dartEntry, DataDescriptor rowDesc, Cache
State state) { | 3562 void _internalPutCacheItem(SourceEntry dartEntry, DataDescriptor rowDesc, Cach
eState state) { |
| 3563 String rowName = rowDesc.toString(); | 3563 String rowName = rowDesc.toString(); |
| 3564 AnalysisContentStatisticsImpl_CacheRowImpl row = _dataMap[rowName] as Analys
isContentStatisticsImpl_CacheRowImpl; | 3564 AnalysisContentStatisticsImpl_CacheRowImpl row = _dataMap[rowName] as Analys
isContentStatisticsImpl_CacheRowImpl; |
| 3565 if (row == null) { | 3565 if (row == null) { |
| 3566 row = new AnalysisContentStatisticsImpl_CacheRowImpl(rowName); | 3566 row = new AnalysisContentStatisticsImpl_CacheRowImpl(rowName); |
| 3567 _dataMap[rowName] = row; | 3567 _dataMap[rowName] = row; |
| 3568 } | 3568 } |
| 3569 row.incState(state); | 3569 row._incState(state); |
| 3570 if (identical(state, CacheState.ERROR)) { | 3570 if (identical(state, CacheState.ERROR)) { |
| 3571 AnalysisException exception = dartEntry.exception; | 3571 AnalysisException exception = dartEntry.exception; |
| 3572 if (exception != null) { | 3572 if (exception != null) { |
| 3573 _exceptions.add(exception); | 3573 _exceptions.add(exception); |
| 3574 } | 3574 } |
| 3575 } | 3575 } |
| 3576 } | 3576 } |
| 3577 } | 3577 } |
| 3578 | 3578 |
| 3579 class AnalysisContentStatisticsImpl_CacheRowImpl implements AnalysisContentStati
stics_CacheRow { | 3579 class AnalysisContentStatisticsImpl_CacheRowImpl implements AnalysisContentStati
stics_CacheRow { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3598 int get flushedCount => _flushedCount; | 3598 int get flushedCount => _flushedCount; |
| 3599 | 3599 |
| 3600 int get inProcessCount => _inProcessCount; | 3600 int get inProcessCount => _inProcessCount; |
| 3601 | 3601 |
| 3602 int get invalidCount => _invalidCount; | 3602 int get invalidCount => _invalidCount; |
| 3603 | 3603 |
| 3604 int get validCount => _validCount; | 3604 int get validCount => _validCount; |
| 3605 | 3605 |
| 3606 int get hashCode => name.hashCode; | 3606 int get hashCode => name.hashCode; |
| 3607 | 3607 |
| 3608 void incState(CacheState state) { | 3608 void _incState(CacheState state) { |
| 3609 if (identical(state, CacheState.ERROR)) { | 3609 if (identical(state, CacheState.ERROR)) { |
| 3610 _errorCount++; | 3610 _errorCount++; |
| 3611 } | 3611 } |
| 3612 if (identical(state, CacheState.FLUSHED)) { | 3612 if (identical(state, CacheState.FLUSHED)) { |
| 3613 _flushedCount++; | 3613 _flushedCount++; |
| 3614 } | 3614 } |
| 3615 if (identical(state, CacheState.IN_PROCESS)) { | 3615 if (identical(state, CacheState.IN_PROCESS)) { |
| 3616 _inProcessCount++; | 3616 _inProcessCount++; |
| 3617 } | 3617 } |
| 3618 if (identical(state, CacheState.INVALID)) { | 3618 if (identical(state, CacheState.INVALID)) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3721 void applyChanges(ChangeSet changeSet) { | 3721 void applyChanges(ChangeSet changeSet) { |
| 3722 if (changeSet.isEmpty) { | 3722 if (changeSet.isEmpty) { |
| 3723 return; | 3723 return; |
| 3724 } | 3724 } |
| 3725 _recentTasks.clear(); | 3725 _recentTasks.clear(); |
| 3726 // | 3726 // |
| 3727 // First, compute the list of sources that have been removed. | 3727 // First, compute the list of sources that have been removed. |
| 3728 // | 3728 // |
| 3729 List<Source> removedSources = new List<Source>.from(changeSet.removedSources
); | 3729 List<Source> removedSources = new List<Source>.from(changeSet.removedSources
); |
| 3730 for (SourceContainer container in changeSet.removedContainers) { | 3730 for (SourceContainer container in changeSet.removedContainers) { |
| 3731 addSourcesInContainer(removedSources, container); | 3731 _addSourcesInContainer(removedSources, container); |
| 3732 } | 3732 } |
| 3733 // | 3733 // |
| 3734 // Then determine which cached results are no longer valid. | 3734 // Then determine which cached results are no longer valid. |
| 3735 // | 3735 // |
| 3736 bool addedDartSource = false; | 3736 bool addedDartSource = false; |
| 3737 for (Source source in changeSet.addedSources) { | 3737 for (Source source in changeSet.addedSources) { |
| 3738 if (sourceAvailable(source)) { | 3738 if (_sourceAvailable(source)) { |
| 3739 addedDartSource = true; | 3739 addedDartSource = true; |
| 3740 } | 3740 } |
| 3741 } | 3741 } |
| 3742 for (Source source in changeSet.changedSources) { | 3742 for (Source source in changeSet.changedSources) { |
| 3743 sourceChanged(source); | 3743 _sourceChanged(source); |
| 3744 } | 3744 } |
| 3745 for (Source source in removedSources) { | 3745 for (Source source in removedSources) { |
| 3746 sourceRemoved(source); | 3746 _sourceRemoved(source); |
| 3747 } | 3747 } |
| 3748 if (addedDartSource) { | 3748 if (addedDartSource) { |
| 3749 // TODO(brianwilkerson) This is hugely inefficient, but we need to re-anal
yze any libraries | 3749 // TODO(brianwilkerson) This is hugely inefficient, but we need to re-anal
yze any libraries |
| 3750 // that might have been referencing the not-yet-existing source that was j
ust added. Longer | 3750 // that might have been referencing the not-yet-existing source that was j
ust added. Longer |
| 3751 // term we need to keep track of which libraries are referencing non-exist
ing sources and | 3751 // term we need to keep track of which libraries are referencing non-exist
ing sources and |
| 3752 // only re-analyze those libraries. | 3752 // only re-analyze those libraries. |
| 3753 logInformation("Added Dart sources, invalidating all resolution informatio
n"); | 3753 _logInformation("Added Dart sources, invalidating all resolution informati
on"); |
| 3754 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { | 3754 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { |
| 3755 Source source = mapEntry.getKey(); | 3755 Source source = mapEntry.getKey(); |
| 3756 SourceEntry sourceEntry = mapEntry.getValue(); | 3756 SourceEntry sourceEntry = mapEntry.getValue(); |
| 3757 if (!source.isInSystemLibrary && sourceEntry is DartEntry) { | 3757 if (!source.isInSystemLibrary && sourceEntry is DartEntry) { |
| 3758 DartEntry dartEntry = sourceEntry; | 3758 DartEntry dartEntry = sourceEntry; |
| 3759 DartEntryImpl dartCopy = dartEntry.writableCopy; | 3759 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 3760 removeFromParts(source, dartEntry); | 3760 _removeFromParts(source, dartEntry); |
| 3761 dartCopy.invalidateAllResolutionInformation(); | 3761 dartCopy.invalidateAllResolutionInformation(); |
| 3762 mapEntry.setValue(dartCopy); | 3762 mapEntry.setValue(dartCopy); |
| 3763 SourcePriority priority = SourcePriority.UNKNOWN; | 3763 SourcePriority priority = SourcePriority.UNKNOWN; |
| 3764 SourceKind kind = dartCopy.kind; | 3764 SourceKind kind = dartCopy.kind; |
| 3765 if (identical(kind, SourceKind.LIBRARY)) { | 3765 if (identical(kind, SourceKind.LIBRARY)) { |
| 3766 priority = SourcePriority.LIBRARY; | 3766 priority = SourcePriority.LIBRARY; |
| 3767 } else if (identical(kind, SourceKind.PART)) { | 3767 } else if (identical(kind, SourceKind.PART)) { |
| 3768 priority = SourcePriority.NORMAL_PART; | 3768 priority = SourcePriority.NORMAL_PART; |
| 3769 } | 3769 } |
| 3770 _workManager.add(source, priority); | 3770 _workManager.add(source, priority); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3803 } | 3803 } |
| 3804 return builder.toString(); | 3804 return builder.toString(); |
| 3805 } | 3805 } |
| 3806 nameNode = nameNode.parent; | 3806 nameNode = nameNode.parent; |
| 3807 } | 3807 } |
| 3808 return null; | 3808 return null; |
| 3809 } | 3809 } |
| 3810 | 3810 |
| 3811 List<AnalysisError> computeErrors(Source source) { | 3811 List<AnalysisError> computeErrors(Source source) { |
| 3812 bool enableHints = _options.hint; | 3812 bool enableHints = _options.hint; |
| 3813 SourceEntry sourceEntry = getReadableSourceEntry(source); | 3813 SourceEntry sourceEntry = _getReadableSourceEntry(source); |
| 3814 if (sourceEntry is DartEntry) { | 3814 if (sourceEntry is DartEntry) { |
| 3815 List<AnalysisError> errors = new List<AnalysisError>(); | 3815 List<AnalysisError> errors = new List<AnalysisError>(); |
| 3816 try { | 3816 try { |
| 3817 DartEntry dartEntry = sourceEntry; | 3817 DartEntry dartEntry = sourceEntry; |
| 3818 ListUtilities.addAll(errors, getDartScanData(source, dartEntry, DartEntr
y.SCAN_ERRORS)); | 3818 ListUtilities.addAll(errors, _getDartScanData(source, dartEntry, DartEnt
ry.SCAN_ERRORS)); |
| 3819 dartEntry = getReadableDartEntry(source); | 3819 dartEntry = _getReadableDartEntry(source); |
| 3820 ListUtilities.addAll(errors, getDartParseData(source, dartEntry, DartEnt
ry.PARSE_ERRORS)); | 3820 ListUtilities.addAll(errors, _getDartParseData(source, dartEntry, DartEn
try.PARSE_ERRORS)); |
| 3821 dartEntry = getReadableDartEntry(source); | 3821 dartEntry = _getReadableDartEntry(source); |
| 3822 if (identical(dartEntry.getValue(DartEntry.SOURCE_KIND), SourceKind.LIBR
ARY)) { | 3822 if (identical(dartEntry.getValue(DartEntry.SOURCE_KIND), SourceKind.LIBR
ARY)) { |
| 3823 ListUtilities.addAll(errors, getDartResolutionData(source, source, dar
tEntry, DartEntry.RESOLUTION_ERRORS)); | 3823 ListUtilities.addAll(errors, _getDartResolutionData(source, source, da
rtEntry, DartEntry.RESOLUTION_ERRORS)); |
| 3824 dartEntry = getReadableDartEntry(source); | 3824 dartEntry = _getReadableDartEntry(source); |
| 3825 ListUtilities.addAll(errors, getDartVerificationData(source, source, d
artEntry, DartEntry.VERIFICATION_ERRORS)); | 3825 ListUtilities.addAll(errors, _getDartVerificationData(source, source,
dartEntry, DartEntry.VERIFICATION_ERRORS)); |
| 3826 if (enableHints) { | 3826 if (enableHints) { |
| 3827 dartEntry = getReadableDartEntry(source); | 3827 dartEntry = _getReadableDartEntry(source); |
| 3828 ListUtilities.addAll(errors, getDartHintData(source, source, dartEnt
ry, DartEntry.HINTS)); | 3828 ListUtilities.addAll(errors, _getDartHintData(source, source, dartEn
try, DartEntry.HINTS)); |
| 3829 } | 3829 } |
| 3830 } else { | 3830 } else { |
| 3831 List<Source> libraries = getLibrariesContaining(source); | 3831 List<Source> libraries = getLibrariesContaining(source); |
| 3832 for (Source librarySource in libraries) { | 3832 for (Source librarySource in libraries) { |
| 3833 ListUtilities.addAll(errors, getDartResolutionData(source, librarySo
urce, dartEntry, DartEntry.RESOLUTION_ERRORS)); | 3833 ListUtilities.addAll(errors, _getDartResolutionData(source, libraryS
ource, dartEntry, DartEntry.RESOLUTION_ERRORS)); |
| 3834 dartEntry = getReadableDartEntry(source); | 3834 dartEntry = _getReadableDartEntry(source); |
| 3835 ListUtilities.addAll(errors, getDartVerificationData(source, library
Source, dartEntry, DartEntry.VERIFICATION_ERRORS)); | 3835 ListUtilities.addAll(errors, _getDartVerificationData(source, librar
ySource, dartEntry, DartEntry.VERIFICATION_ERRORS)); |
| 3836 if (enableHints) { | 3836 if (enableHints) { |
| 3837 dartEntry = getReadableDartEntry(source); | 3837 dartEntry = _getReadableDartEntry(source); |
| 3838 ListUtilities.addAll(errors, getDartHintData(source, librarySource
, dartEntry, DartEntry.HINTS)); | 3838 ListUtilities.addAll(errors, _getDartHintData(source, librarySourc
e, dartEntry, DartEntry.HINTS)); |
| 3839 } | 3839 } |
| 3840 } | 3840 } |
| 3841 } | 3841 } |
| 3842 } on ObsoleteSourceAnalysisException catch (exception) { | 3842 } on ObsoleteSourceAnalysisException catch (exception) { |
| 3843 AnalysisEngine.instance.logger.logInformation3("Could not compute errors
", exception); | 3843 AnalysisEngine.instance.logger.logInformation2("Could not compute errors
", exception); |
| 3844 } | 3844 } |
| 3845 if (errors.isEmpty) { | 3845 if (errors.isEmpty) { |
| 3846 return AnalysisError.NO_ERRORS; | 3846 return AnalysisError.NO_ERRORS; |
| 3847 } | 3847 } |
| 3848 return new List.from(errors); | 3848 return new List.from(errors); |
| 3849 } else if (sourceEntry is HtmlEntry) { | 3849 } else if (sourceEntry is HtmlEntry) { |
| 3850 HtmlEntry htmlEntry = sourceEntry; | 3850 HtmlEntry htmlEntry = sourceEntry; |
| 3851 try { | 3851 try { |
| 3852 return getHtmlResolutionData2(source, htmlEntry, HtmlEntry.RESOLUTION_ER
RORS); | 3852 return _getHtmlResolutionData2(source, htmlEntry, HtmlEntry.RESOLUTION_E
RRORS); |
| 3853 } on ObsoleteSourceAnalysisException catch (exception) { | 3853 } on ObsoleteSourceAnalysisException catch (exception) { |
| 3854 AnalysisEngine.instance.logger.logInformation3("Could not compute errors
", exception); | 3854 AnalysisEngine.instance.logger.logInformation2("Could not compute errors
", exception); |
| 3855 } | 3855 } |
| 3856 } | 3856 } |
| 3857 return AnalysisError.NO_ERRORS; | 3857 return AnalysisError.NO_ERRORS; |
| 3858 } | 3858 } |
| 3859 | 3859 |
| 3860 List<Source> computeExportedLibraries(Source source) => getDartDependencyData2
(source, DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY); | 3860 List<Source> computeExportedLibraries(Source source) => _getDartDependencyData
2(source, DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY); |
| 3861 | 3861 |
| 3862 HtmlElement computeHtmlElement(Source source) => getHtmlResolutionData(source,
HtmlEntry.ELEMENT, null); | 3862 HtmlElement computeHtmlElement(Source source) => _getHtmlResolutionData(source
, HtmlEntry.ELEMENT, null); |
| 3863 | 3863 |
| 3864 List<Source> computeImportedLibraries(Source source) => getDartDependencyData2
(source, DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY); | 3864 List<Source> computeImportedLibraries(Source source) => _getDartDependencyData
2(source, DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY); |
| 3865 | 3865 |
| 3866 SourceKind computeKindOf(Source source) { | 3866 SourceKind computeKindOf(Source source) { |
| 3867 SourceEntry sourceEntry = getReadableSourceEntry(source); | 3867 SourceEntry sourceEntry = _getReadableSourceEntry(source); |
| 3868 if (sourceEntry == null) { | 3868 if (sourceEntry == null) { |
| 3869 return SourceKind.UNKNOWN; | 3869 return SourceKind.UNKNOWN; |
| 3870 } else if (sourceEntry is DartEntry) { | 3870 } else if (sourceEntry is DartEntry) { |
| 3871 try { | 3871 try { |
| 3872 return getDartParseData(source, sourceEntry, DartEntry.SOURCE_KIND); | 3872 return _getDartParseData(source, sourceEntry, DartEntry.SOURCE_KIND); |
| 3873 } on AnalysisException catch (exception) { | 3873 } on AnalysisException catch (exception) { |
| 3874 return SourceKind.UNKNOWN; | 3874 return SourceKind.UNKNOWN; |
| 3875 } | 3875 } |
| 3876 } | 3876 } |
| 3877 return sourceEntry.kind; | 3877 return sourceEntry.kind; |
| 3878 } | 3878 } |
| 3879 | 3879 |
| 3880 LibraryElement computeLibraryElement(Source source) => getDartResolutionData2(
source, source, DartEntry.ELEMENT, null); | 3880 LibraryElement computeLibraryElement(Source source) => _getDartResolutionData2
(source, source, DartEntry.ELEMENT, null); |
| 3881 | 3881 |
| 3882 LineInfo computeLineInfo(Source source) { | 3882 LineInfo computeLineInfo(Source source) { |
| 3883 SourceEntry sourceEntry = getReadableSourceEntry(source); | 3883 SourceEntry sourceEntry = _getReadableSourceEntry(source); |
| 3884 try { | 3884 try { |
| 3885 if (sourceEntry is HtmlEntry) { | 3885 if (sourceEntry is HtmlEntry) { |
| 3886 return getHtmlParseData(source, SourceEntry.LINE_INFO, null); | 3886 return _getHtmlParseData(source, SourceEntry.LINE_INFO, null); |
| 3887 } else if (sourceEntry is DartEntry) { | 3887 } else if (sourceEntry is DartEntry) { |
| 3888 return getDartScanData2(source, SourceEntry.LINE_INFO, null); | 3888 return _getDartScanData2(source, SourceEntry.LINE_INFO, null); |
| 3889 } | 3889 } |
| 3890 } on ObsoleteSourceAnalysisException catch (exception) { | 3890 } on ObsoleteSourceAnalysisException catch (exception) { |
| 3891 AnalysisEngine.instance.logger.logInformation3("Could not compute ${Source
Entry.LINE_INFO.toString()}", exception); | 3891 AnalysisEngine.instance.logger.logInformation2("Could not compute ${Source
Entry.LINE_INFO.toString()}", exception); |
| 3892 } | 3892 } |
| 3893 return null; | 3893 return null; |
| 3894 } | 3894 } |
| 3895 | 3895 |
| 3896 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) { | 3896 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) { |
| 3897 DartEntry dartEntry = getReadableDartEntry(source); | 3897 DartEntry dartEntry = _getReadableDartEntry(source); |
| 3898 if (dartEntry == null) { | 3898 if (dartEntry == null) { |
| 3899 throw new AnalysisException.con1("computeResolvableCompilationUnit for non
-Dart: ${source.fullName}"); | 3899 throw new AnalysisException.con1("computeResolvableCompilationUnit for non
-Dart: ${source.fullName}"); |
| 3900 } | 3900 } |
| 3901 dartEntry = cacheDartParseData(source, dartEntry, DartEntry.PARSED_UNIT); | 3901 dartEntry = _cacheDartParseData(source, dartEntry, DartEntry.PARSED_UNIT); |
| 3902 DartEntryImpl dartCopy = dartEntry.writableCopy; | 3902 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 3903 CompilationUnit unit = dartCopy.resolvableCompilationUnit; | 3903 CompilationUnit unit = dartCopy.resolvableCompilationUnit; |
| 3904 if (unit == null) { | 3904 if (unit == null) { |
| 3905 throw new AnalysisException.con2("Internal error: computeResolvableCompila
tionUnit could not parse ${source.fullName}", dartEntry.exception); | 3905 throw new AnalysisException.con2("Internal error: computeResolvableCompila
tionUnit could not parse ${source.fullName}", dartEntry.exception); |
| 3906 } | 3906 } |
| 3907 _cache.put(source, dartCopy); | 3907 _cache.put(source, dartCopy); |
| 3908 return new ResolvableCompilationUnit(dartCopy.modificationTime, unit); | 3908 return new ResolvableCompilationUnit(dartCopy.modificationTime, unit); |
| 3909 } | 3909 } |
| 3910 | 3910 |
| 3911 bool exists(Source source) { | 3911 bool exists(Source source) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3967 receiver.accept(contents, _contentCache.getModificationStamp(source)); | 3967 receiver.accept(contents, _contentCache.getModificationStamp(source)); |
| 3968 return; | 3968 return; |
| 3969 } | 3969 } |
| 3970 source.getContentsToReceiver(receiver); | 3970 source.getContentsToReceiver(receiver); |
| 3971 } | 3971 } |
| 3972 | 3972 |
| 3973 Element getElement(ElementLocation location) { | 3973 Element getElement(ElementLocation location) { |
| 3974 // TODO(brianwilkerson) This should not be a "get" method. | 3974 // TODO(brianwilkerson) This should not be a "get" method. |
| 3975 try { | 3975 try { |
| 3976 List<String> components = (location as ElementLocationImpl).components; | 3976 List<String> components = (location as ElementLocationImpl).components; |
| 3977 Source librarySource = computeSourceFromEncoding(components[0]); | 3977 Source librarySource = _computeSourceFromEncoding(components[0]); |
| 3978 ElementImpl element = computeLibraryElement(librarySource) as ElementImpl; | 3978 ElementImpl element = computeLibraryElement(librarySource) as ElementImpl; |
| 3979 for (int i = 1; i < components.length; i++) { | 3979 for (int i = 1; i < components.length; i++) { |
| 3980 if (element == null) { | 3980 if (element == null) { |
| 3981 return null; | 3981 return null; |
| 3982 } | 3982 } |
| 3983 element = element.getChild(components[i]); | 3983 element = element.getChild(components[i]); |
| 3984 } | 3984 } |
| 3985 return element; | 3985 return element; |
| 3986 } on AnalysisException catch (exception) { | 3986 } on AnalysisException catch (exception) { |
| 3987 return null; | 3987 return null; |
| 3988 } | 3988 } |
| 3989 } | 3989 } |
| 3990 | 3990 |
| 3991 AnalysisErrorInfo getErrors(Source source) { | 3991 AnalysisErrorInfo getErrors(Source source) { |
| 3992 SourceEntry sourceEntry = getReadableSourceEntry(source); | 3992 SourceEntry sourceEntry = _getReadableSourceEntry(source); |
| 3993 if (sourceEntry is DartEntry) { | 3993 if (sourceEntry is DartEntry) { |
| 3994 DartEntry dartEntry = sourceEntry; | 3994 DartEntry dartEntry = sourceEntry; |
| 3995 return new AnalysisErrorInfoImpl(dartEntry.allErrors, dartEntry.getValue(S
ourceEntry.LINE_INFO)); | 3995 return new AnalysisErrorInfoImpl(dartEntry.allErrors, dartEntry.getValue(S
ourceEntry.LINE_INFO)); |
| 3996 } else if (sourceEntry is HtmlEntry) { | 3996 } else if (sourceEntry is HtmlEntry) { |
| 3997 HtmlEntry htmlEntry = sourceEntry; | 3997 HtmlEntry htmlEntry = sourceEntry; |
| 3998 return new AnalysisErrorInfoImpl(htmlEntry.allErrors, htmlEntry.getValue(S
ourceEntry.LINE_INFO)); | 3998 return new AnalysisErrorInfoImpl(htmlEntry.allErrors, htmlEntry.getValue(S
ourceEntry.LINE_INFO)); |
| 3999 } | 3999 } |
| 4000 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, null); | 4000 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, null); |
| 4001 } | 4001 } |
| 4002 | 4002 |
| 4003 HtmlElement getHtmlElement(Source source) { | 4003 HtmlElement getHtmlElement(Source source) { |
| 4004 SourceEntry sourceEntry = getReadableSourceEntry(source); | 4004 SourceEntry sourceEntry = _getReadableSourceEntry(source); |
| 4005 if (sourceEntry is HtmlEntry) { | 4005 if (sourceEntry is HtmlEntry) { |
| 4006 return sourceEntry.getValue(HtmlEntry.ELEMENT); | 4006 return sourceEntry.getValue(HtmlEntry.ELEMENT); |
| 4007 } | 4007 } |
| 4008 return null; | 4008 return null; |
| 4009 } | 4009 } |
| 4010 | 4010 |
| 4011 List<Source> getHtmlFilesReferencing(Source source) { | 4011 List<Source> getHtmlFilesReferencing(Source source) { |
| 4012 SourceKind sourceKind = getKindOf(source); | 4012 SourceKind sourceKind = getKindOf(source); |
| 4013 if (sourceKind == null) { | 4013 if (sourceKind == null) { |
| 4014 return Source.EMPTY_ARRAY; | 4014 return Source.EMPTY_ARRAY; |
| 4015 } | 4015 } |
| 4016 List<Source> htmlSources = new List<Source>(); | 4016 List<Source> htmlSources = new List<Source>(); |
| 4017 while (true) { | 4017 while (true) { |
| 4018 if (sourceKind == SourceKind.LIBRARY) { | 4018 if (sourceKind == SourceKind.LIBRARY) { |
| 4019 } else if (sourceKind == SourceKind.PART) { | 4019 } else if (sourceKind == SourceKind.PART) { |
| 4020 List<Source> librarySources = getLibrariesContaining(source); | 4020 List<Source> librarySources = getLibrariesContaining(source); |
| 4021 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4021 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4022 SourceEntry sourceEntry = entry.getValue(); | 4022 SourceEntry sourceEntry = entry.getValue(); |
| 4023 if (identical(sourceEntry.kind, SourceKind.HTML)) { | 4023 if (identical(sourceEntry.kind, SourceKind.HTML)) { |
| 4024 List<Source> referencedLibraries = (sourceEntry as HtmlEntry).getVal
ue(HtmlEntry.REFERENCED_LIBRARIES); | 4024 List<Source> referencedLibraries = (sourceEntry as HtmlEntry).getVal
ue(HtmlEntry.REFERENCED_LIBRARIES); |
| 4025 if (containsAny(referencedLibraries, librarySources)) { | 4025 if (_containsAny(referencedLibraries, librarySources)) { |
| 4026 htmlSources.add(entry.getKey()); | 4026 htmlSources.add(entry.getKey()); |
| 4027 } | 4027 } |
| 4028 } | 4028 } |
| 4029 } | 4029 } |
| 4030 } | 4030 } |
| 4031 break; | 4031 break; |
| 4032 } | 4032 } |
| 4033 if (htmlSources.isEmpty) { | 4033 if (htmlSources.isEmpty) { |
| 4034 return Source.EMPTY_ARRAY; | 4034 return Source.EMPTY_ARRAY; |
| 4035 } | 4035 } |
| 4036 return new List.from(htmlSources); | 4036 return new List.from(htmlSources); |
| 4037 } | 4037 } |
| 4038 | 4038 |
| 4039 List<Source> get htmlSources => getSources(SourceKind.HTML); | 4039 List<Source> get htmlSources => _getSources(SourceKind.HTML); |
| 4040 | 4040 |
| 4041 SourceKind getKindOf(Source source) { | 4041 SourceKind getKindOf(Source source) { |
| 4042 SourceEntry sourceEntry = getReadableSourceEntry(source); | 4042 SourceEntry sourceEntry = _getReadableSourceEntry(source); |
| 4043 if (sourceEntry == null) { | 4043 if (sourceEntry == null) { |
| 4044 return SourceKind.UNKNOWN; | 4044 return SourceKind.UNKNOWN; |
| 4045 } | 4045 } |
| 4046 return sourceEntry.kind; | 4046 return sourceEntry.kind; |
| 4047 } | 4047 } |
| 4048 | 4048 |
| 4049 List<Source> get launchableClientLibrarySources { | 4049 List<Source> get launchableClientLibrarySources { |
| 4050 // TODO(brianwilkerson) This needs to filter out libraries that do not refer
ence dart:html, | 4050 // TODO(brianwilkerson) This needs to filter out libraries that do not refer
ence dart:html, |
| 4051 // either directly or indirectly. | 4051 // either directly or indirectly. |
| 4052 List<Source> sources = new List<Source>(); | 4052 List<Source> sources = new List<Source>(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4072 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSystemL
ibrary) { | 4072 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSystemL
ibrary) { |
| 4073 // DartEntry dartEntry = (DartEntry) sourceEntry; | 4073 // DartEntry dartEntry = (DartEntry) sourceEntry; |
| 4074 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && !dartEntr
y.getValue(DartEntry.IS_CLIENT)) { | 4074 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && !dartEntr
y.getValue(DartEntry.IS_CLIENT)) { |
| 4075 sources.add(source); | 4075 sources.add(source); |
| 4076 } | 4076 } |
| 4077 } | 4077 } |
| 4078 return new List.from(sources); | 4078 return new List.from(sources); |
| 4079 } | 4079 } |
| 4080 | 4080 |
| 4081 List<Source> getLibrariesContaining(Source source) { | 4081 List<Source> getLibrariesContaining(Source source) { |
| 4082 DartEntry dartEntry = getReadableDartEntry(source); | 4082 DartEntry dartEntry = _getReadableDartEntry(source); |
| 4083 if (dartEntry == null) { | 4083 if (dartEntry == null) { |
| 4084 return Source.EMPTY_ARRAY; | 4084 return Source.EMPTY_ARRAY; |
| 4085 } | 4085 } |
| 4086 return dartEntry.getValue(DartEntry.CONTAINING_LIBRARIES); | 4086 return dartEntry.getValue(DartEntry.CONTAINING_LIBRARIES); |
| 4087 } | 4087 } |
| 4088 | 4088 |
| 4089 List<Source> getLibrariesDependingOn(Source librarySource) { | 4089 List<Source> getLibrariesDependingOn(Source librarySource) { |
| 4090 List<Source> dependentLibraries = new List<Source>(); | 4090 List<Source> dependentLibraries = new List<Source>(); |
| 4091 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4091 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4092 SourceEntry sourceEntry = entry.getValue(); | 4092 SourceEntry sourceEntry = entry.getValue(); |
| 4093 if (identical(sourceEntry.kind, SourceKind.LIBRARY)) { | 4093 if (identical(sourceEntry.kind, SourceKind.LIBRARY)) { |
| 4094 if (contains((sourceEntry as DartEntry).getValue(DartEntry.EXPORTED_LIBR
ARIES), librarySource)) { | 4094 if (_contains((sourceEntry as DartEntry).getValue(DartEntry.EXPORTED_LIB
RARIES), librarySource)) { |
| 4095 dependentLibraries.add(entry.getKey()); | 4095 dependentLibraries.add(entry.getKey()); |
| 4096 } | 4096 } |
| 4097 if (contains((sourceEntry as DartEntry).getValue(DartEntry.IMPORTED_LIBR
ARIES), librarySource)) { | 4097 if (_contains((sourceEntry as DartEntry).getValue(DartEntry.IMPORTED_LIB
RARIES), librarySource)) { |
| 4098 dependentLibraries.add(entry.getKey()); | 4098 dependentLibraries.add(entry.getKey()); |
| 4099 } | 4099 } |
| 4100 } | 4100 } |
| 4101 } | 4101 } |
| 4102 if (dependentLibraries.isEmpty) { | 4102 if (dependentLibraries.isEmpty) { |
| 4103 return Source.EMPTY_ARRAY; | 4103 return Source.EMPTY_ARRAY; |
| 4104 } | 4104 } |
| 4105 return new List.from(dependentLibraries); | 4105 return new List.from(dependentLibraries); |
| 4106 } | 4106 } |
| 4107 | 4107 |
| 4108 LibraryElement getLibraryElement(Source source) { | 4108 LibraryElement getLibraryElement(Source source) { |
| 4109 SourceEntry sourceEntry = getReadableSourceEntry(source); | 4109 SourceEntry sourceEntry = _getReadableSourceEntry(source); |
| 4110 if (sourceEntry is DartEntry) { | 4110 if (sourceEntry is DartEntry) { |
| 4111 return sourceEntry.getValue(DartEntry.ELEMENT); | 4111 return sourceEntry.getValue(DartEntry.ELEMENT); |
| 4112 } | 4112 } |
| 4113 return null; | 4113 return null; |
| 4114 } | 4114 } |
| 4115 | 4115 |
| 4116 List<Source> get librarySources => getSources(SourceKind.LIBRARY); | 4116 List<Source> get librarySources => _getSources(SourceKind.LIBRARY); |
| 4117 | 4117 |
| 4118 LineInfo getLineInfo(Source source) { | 4118 LineInfo getLineInfo(Source source) { |
| 4119 SourceEntry sourceEntry = getReadableSourceEntry(source); | 4119 SourceEntry sourceEntry = _getReadableSourceEntry(source); |
| 4120 if (sourceEntry != null) { | 4120 if (sourceEntry != null) { |
| 4121 return sourceEntry.getValue(SourceEntry.LINE_INFO); | 4121 return sourceEntry.getValue(SourceEntry.LINE_INFO); |
| 4122 } | 4122 } |
| 4123 return null; | 4123 return null; |
| 4124 } | 4124 } |
| 4125 | 4125 |
| 4126 int getModificationStamp(Source source) { | 4126 int getModificationStamp(Source source) { |
| 4127 int stamp = _contentCache.getModificationStamp(source); | 4127 int stamp = _contentCache.getModificationStamp(source); |
| 4128 if (stamp != null) { | 4128 if (stamp != null) { |
| 4129 return stamp; | 4129 return stamp; |
| 4130 } | 4130 } |
| 4131 return source.modificationStamp; | 4131 return source.modificationStamp; |
| 4132 } | 4132 } |
| 4133 | 4133 |
| 4134 Namespace getPublicNamespace(LibraryElement library) { | 4134 Namespace getPublicNamespace(LibraryElement library) { |
| 4135 // TODO(brianwilkerson) Rename this to not start with 'get'. Note that this
is not part of the | 4135 // TODO(brianwilkerson) Rename this to not start with 'get'. Note that this
is not part of the |
| 4136 // API of the interface. | 4136 // API of the interface. |
| 4137 Source source = library.definingCompilationUnit.source; | 4137 Source source = library.definingCompilationUnit.source; |
| 4138 DartEntry dartEntry = getReadableDartEntry(source); | 4138 DartEntry dartEntry = _getReadableDartEntry(source); |
| 4139 if (dartEntry == null) { | 4139 if (dartEntry == null) { |
| 4140 return null; | 4140 return null; |
| 4141 } | 4141 } |
| 4142 Namespace namespace = null; | 4142 Namespace namespace = null; |
| 4143 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { | 4143 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { |
| 4144 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); | 4144 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); |
| 4145 } | 4145 } |
| 4146 if (namespace == null) { | 4146 if (namespace == null) { |
| 4147 NamespaceBuilder builder = new NamespaceBuilder(); | 4147 NamespaceBuilder builder = new NamespaceBuilder(); |
| 4148 namespace = builder.createPublicNamespaceForLibrary(library); | 4148 namespace = builder.createPublicNamespaceForLibrary(library); |
| 4149 dartEntry = getReadableDartEntry(source); | 4149 dartEntry = _getReadableDartEntry(source); |
| 4150 if (dartEntry == null) { | 4150 if (dartEntry == null) { |
| 4151 AnalysisEngine.instance.logger.logError2("Could not compute the public n
amespace for ${library.source.fullName}", new AnalysisException.con1("A Dart fil
e became a non-Dart file: ${source.fullName}")); | 4151 AnalysisEngine.instance.logger.logError2("Could not compute the public n
amespace for ${library.source.fullName}", new AnalysisException.con1("A Dart fil
e became a non-Dart file: ${source.fullName}")); |
| 4152 return null; | 4152 return null; |
| 4153 } | 4153 } |
| 4154 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { | 4154 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { |
| 4155 DartEntryImpl dartCopy = getReadableDartEntry(source).writableCopy; | 4155 DartEntryImpl dartCopy = _getReadableDartEntry(source).writableCopy; |
| 4156 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); | 4156 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); |
| 4157 _cache.put(source, dartCopy); | 4157 _cache.put(source, dartCopy); |
| 4158 } | 4158 } |
| 4159 } | 4159 } |
| 4160 return namespace; | 4160 return namespace; |
| 4161 } | 4161 } |
| 4162 | 4162 |
| 4163 Namespace getPublicNamespace2(Source source) { | 4163 Namespace getPublicNamespace2(Source source) { |
| 4164 // TODO(brianwilkerson) Rename this to not start with 'get'. Note that this
is not part of the | 4164 // TODO(brianwilkerson) Rename this to not start with 'get'. Note that this
is not part of the |
| 4165 // API of the interface. | 4165 // API of the interface. |
| 4166 DartEntry dartEntry = getReadableDartEntry(source); | 4166 DartEntry dartEntry = _getReadableDartEntry(source); |
| 4167 if (dartEntry == null) { | 4167 if (dartEntry == null) { |
| 4168 return null; | 4168 return null; |
| 4169 } | 4169 } |
| 4170 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); | 4170 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); |
| 4171 if (namespace == null) { | 4171 if (namespace == null) { |
| 4172 LibraryElement library = computeLibraryElement(source); | 4172 LibraryElement library = computeLibraryElement(source); |
| 4173 if (library == null) { | 4173 if (library == null) { |
| 4174 return null; | 4174 return null; |
| 4175 } | 4175 } |
| 4176 NamespaceBuilder builder = new NamespaceBuilder(); | 4176 NamespaceBuilder builder = new NamespaceBuilder(); |
| 4177 namespace = builder.createPublicNamespaceForLibrary(library); | 4177 namespace = builder.createPublicNamespaceForLibrary(library); |
| 4178 dartEntry = getReadableDartEntry(source); | 4178 dartEntry = _getReadableDartEntry(source); |
| 4179 if (dartEntry == null) { | 4179 if (dartEntry == null) { |
| 4180 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${
source.fullName}"); | 4180 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${
source.fullName}"); |
| 4181 } | 4181 } |
| 4182 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { | 4182 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { |
| 4183 DartEntryImpl dartCopy = getReadableDartEntry(source).writableCopy; | 4183 DartEntryImpl dartCopy = _getReadableDartEntry(source).writableCopy; |
| 4184 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); | 4184 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); |
| 4185 _cache.put(source, dartCopy); | 4185 _cache.put(source, dartCopy); |
| 4186 } | 4186 } |
| 4187 } | 4187 } |
| 4188 return namespace; | 4188 return namespace; |
| 4189 } | 4189 } |
| 4190 | 4190 |
| 4191 List<Source> get refactoringUnsafeSources { | 4191 List<Source> get refactoringUnsafeSources { |
| 4192 List<Source> sources = new List<Source>(); | 4192 List<Source> sources = new List<Source>(); |
| 4193 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4193 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4194 SourceEntry sourceEntry = entry.getValue(); | 4194 SourceEntry sourceEntry = entry.getValue(); |
| 4195 if (sourceEntry is DartEntry) { | 4195 if (sourceEntry is DartEntry) { |
| 4196 if (!sourceEntry.isRefactoringSafe) { | 4196 if (!sourceEntry.isRefactoringSafe) { |
| 4197 sources.add(entry.getKey()); | 4197 sources.add(entry.getKey()); |
| 4198 } | 4198 } |
| 4199 } | 4199 } |
| 4200 } | 4200 } |
| 4201 return new List.from(sources); | 4201 return new List.from(sources); |
| 4202 } | 4202 } |
| 4203 | 4203 |
| 4204 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary) { | 4204 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary) { |
| 4205 if (library == null) { | 4205 if (library == null) { |
| 4206 return null; | 4206 return null; |
| 4207 } | 4207 } |
| 4208 return getResolvedCompilationUnit2(unitSource, library.source); | 4208 return getResolvedCompilationUnit2(unitSource, library.source); |
| 4209 } | 4209 } |
| 4210 | 4210 |
| 4211 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS
ource) { | 4211 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS
ource) { |
| 4212 SourceEntry sourceEntry = getReadableSourceEntry(unitSource); | 4212 SourceEntry sourceEntry = _getReadableSourceEntry(unitSource); |
| 4213 if (sourceEntry is DartEntry) { | 4213 if (sourceEntry is DartEntry) { |
| 4214 return sourceEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySourc
e); | 4214 return sourceEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySourc
e); |
| 4215 } | 4215 } |
| 4216 return null; | 4216 return null; |
| 4217 } | 4217 } |
| 4218 | 4218 |
| 4219 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { | 4219 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { |
| 4220 SourceEntry sourceEntry = getReadableSourceEntry(htmlSource); | 4220 SourceEntry sourceEntry = _getReadableSourceEntry(htmlSource); |
| 4221 if (sourceEntry is HtmlEntry) { | 4221 if (sourceEntry is HtmlEntry) { |
| 4222 HtmlEntry htmlEntry = sourceEntry; | 4222 HtmlEntry htmlEntry = sourceEntry; |
| 4223 return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); | 4223 return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
| 4224 } | 4224 } |
| 4225 return null; | 4225 return null; |
| 4226 } | 4226 } |
| 4227 | 4227 |
| 4228 SourceFactory get sourceFactory => _sourceFactory; | 4228 SourceFactory get sourceFactory => _sourceFactory; |
| 4229 | 4229 |
| 4230 /** | 4230 /** |
| 4231 * Return a list of the sources that would be processed by [performAnalysisTas
k]. This | 4231 * Return a list of the sources that would be processed by [performAnalysisTas
k]. This |
| 4232 * method duplicates, and must therefore be kept in sync with, [getNextAnalysi
sTask]. | 4232 * method duplicates, and must therefore be kept in sync with, [getNextAnalysi
sTask]. |
| 4233 * This method is intended to be used for testing purposes only. | 4233 * This method is intended to be used for testing purposes only. |
| 4234 * | 4234 * |
| 4235 * @return a list of the sources that would be processed by [performAnalysisTa
sk] | 4235 * @return a list of the sources that would be processed by [performAnalysisTa
sk] |
| 4236 */ | 4236 */ |
| 4237 List<Source> get sourcesNeedingProcessing { | 4237 List<Source> get sourcesNeedingProcessing { |
| 4238 Set<Source> sources = new Set<Source>(); | 4238 Set<Source> sources = new Set<Source>(); |
| 4239 bool hintsEnabled = _options.hint; | 4239 bool hintsEnabled = _options.hint; |
| 4240 // | 4240 // |
| 4241 // Look for priority sources that need to be analyzed. | 4241 // Look for priority sources that need to be analyzed. |
| 4242 // | 4242 // |
| 4243 for (Source source in _priorityOrder) { | 4243 for (Source source in _priorityOrder) { |
| 4244 getSourcesNeedingProcessing2(source, _cache.get(source), true, hintsEnable
d, sources); | 4244 _getSourcesNeedingProcessing(source, _cache.get(source), true, hintsEnable
d, sources); |
| 4245 } | 4245 } |
| 4246 // | 4246 // |
| 4247 // Look for non-priority sources that need to be analyzed. | 4247 // Look for non-priority sources that need to be analyzed. |
| 4248 // | 4248 // |
| 4249 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4249 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4250 getSourcesNeedingProcessing2(entry.getKey(), entry.getValue(), false, hint
sEnabled, sources); | 4250 _getSourcesNeedingProcessing(entry.getKey(), entry.getValue(), false, hint
sEnabled, sources); |
| 4251 } | 4251 } |
| 4252 return new List<Source>.from(sources); | 4252 return new List<Source>.from(sources); |
| 4253 } | 4253 } |
| 4254 | 4254 |
| 4255 AnalysisContentStatistics get statistics { | 4255 AnalysisContentStatistics get statistics { |
| 4256 AnalysisContentStatisticsImpl statistics = new AnalysisContentStatisticsImpl
(); | 4256 AnalysisContentStatisticsImpl statistics = new AnalysisContentStatisticsImpl
(); |
| 4257 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { | 4257 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { |
| 4258 statistics.addSource(mapEntry.getKey()); | 4258 statistics.addSource(mapEntry.getKey()); |
| 4259 SourceEntry entry = mapEntry.getValue(); | 4259 SourceEntry entry = mapEntry.getValue(); |
| 4260 if (entry is DartEntry) { | 4260 if (entry is DartEntry) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4293 } | 4293 } |
| 4294 return statistics; | 4294 return statistics; |
| 4295 } | 4295 } |
| 4296 | 4296 |
| 4297 TypeProvider get typeProvider { | 4297 TypeProvider get typeProvider { |
| 4298 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); | 4298 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); |
| 4299 return new TypeProviderImpl(computeLibraryElement(coreSource)); | 4299 return new TypeProviderImpl(computeLibraryElement(coreSource)); |
| 4300 } | 4300 } |
| 4301 | 4301 |
| 4302 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou
rce, LibraryElement libraryElement) { | 4302 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou
rce, LibraryElement libraryElement) { |
| 4303 DartEntry dartEntry = getReadableDartEntry(unitSource); | 4303 DartEntry dartEntry = _getReadableDartEntry(unitSource); |
| 4304 if (dartEntry == null) { | 4304 if (dartEntry == null) { |
| 4305 throw new AnalysisException.con1("internalResolveCompilationUnit invoked f
or non-Dart file: ${unitSource.fullName}"); | 4305 throw new AnalysisException.con1("internalResolveCompilationUnit invoked f
or non-Dart file: ${unitSource.fullName}"); |
| 4306 } | 4306 } |
| 4307 Source librarySource = libraryElement.source; | 4307 Source librarySource = libraryElement.source; |
| 4308 dartEntry = cacheDartResolutionData(unitSource, librarySource, dartEntry, Da
rtEntry.RESOLVED_UNIT); | 4308 dartEntry = _cacheDartResolutionData(unitSource, librarySource, dartEntry, D
artEntry.RESOLVED_UNIT); |
| 4309 return new TimestampedData<CompilationUnit>(dartEntry.modificationTime, dart
Entry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource)); | 4309 return new TimestampedData<CompilationUnit>(dartEntry.modificationTime, dart
Entry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource)); |
| 4310 } | 4310 } |
| 4311 | 4311 |
| 4312 bool isClientLibrary(Source librarySource) { | 4312 bool isClientLibrary(Source librarySource) { |
| 4313 SourceEntry sourceEntry = getReadableSourceEntry(librarySource); | 4313 SourceEntry sourceEntry = _getReadableSourceEntry(librarySource); |
| 4314 if (sourceEntry is DartEntry) { | 4314 if (sourceEntry is DartEntry) { |
| 4315 DartEntry dartEntry = sourceEntry; | 4315 DartEntry dartEntry = sourceEntry; |
| 4316 return dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(DartE
ntry.IS_LAUNCHABLE); | 4316 return dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(DartE
ntry.IS_LAUNCHABLE); |
| 4317 } | 4317 } |
| 4318 return false; | 4318 return false; |
| 4319 } | 4319 } |
| 4320 | 4320 |
| 4321 bool isServerLibrary(Source librarySource) { | 4321 bool isServerLibrary(Source librarySource) { |
| 4322 SourceEntry sourceEntry = getReadableSourceEntry(librarySource); | 4322 SourceEntry sourceEntry = _getReadableSourceEntry(librarySource); |
| 4323 if (sourceEntry is DartEntry) { | 4323 if (sourceEntry is DartEntry) { |
| 4324 DartEntry dartEntry = sourceEntry; | 4324 DartEntry dartEntry = sourceEntry; |
| 4325 return !dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(Dart
Entry.IS_LAUNCHABLE); | 4325 return !dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(Dart
Entry.IS_LAUNCHABLE); |
| 4326 } | 4326 } |
| 4327 return false; | 4327 return false; |
| 4328 } | 4328 } |
| 4329 | 4329 |
| 4330 void mergeContext(AnalysisContext context) { | 4330 void mergeContext(AnalysisContext context) { |
| 4331 if (context is InstrumentedAnalysisContextImpl) { | 4331 if (context is InstrumentedAnalysisContextImpl) { |
| 4332 context = (context as InstrumentedAnalysisContextImpl).basis; | 4332 context = (context as InstrumentedAnalysisContextImpl).basis; |
| 4333 } | 4333 } |
| 4334 if (context is! AnalysisContextImpl) { | 4334 if (context is! AnalysisContextImpl) { |
| 4335 return; | 4335 return; |
| 4336 } | 4336 } |
| 4337 // TODO(brianwilkerson) This does not lock against the other context's cache
Lock. | 4337 // TODO(brianwilkerson) This does not lock against the other context's cache
Lock. |
| 4338 for (MapEntry<Source, SourceEntry> entry in (context as AnalysisContextImpl)
._cache.entrySet()) { | 4338 for (MapEntry<Source, SourceEntry> entry in (context as AnalysisContextImpl)
._cache.entrySet()) { |
| 4339 Source newSource = entry.getKey(); | 4339 Source newSource = entry.getKey(); |
| 4340 SourceEntry existingEntry = getReadableSourceEntry(newSource); | 4340 SourceEntry existingEntry = _getReadableSourceEntry(newSource); |
| 4341 if (existingEntry == null) { | 4341 if (existingEntry == null) { |
| 4342 // TODO(brianwilkerson) Decide whether we really need to copy the info. | 4342 // TODO(brianwilkerson) Decide whether we really need to copy the info. |
| 4343 _cache.put(newSource, entry.getValue().writableCopy); | 4343 _cache.put(newSource, entry.getValue().writableCopy); |
| 4344 } else { | 4344 } else { |
| 4345 } | 4345 } |
| 4346 } | 4346 } |
| 4347 } | 4347 } |
| 4348 | 4348 |
| 4349 CompilationUnit parseCompilationUnit(Source source) => getDartParseData2(sourc
e, DartEntry.PARSED_UNIT, null); | 4349 CompilationUnit parseCompilationUnit(Source source) => _getDartParseData2(sour
ce, DartEntry.PARSED_UNIT, null); |
| 4350 | 4350 |
| 4351 ht.HtmlUnit parseHtmlUnit(Source source) => getHtmlParseData(source, HtmlEntry
.PARSED_UNIT, null); | 4351 ht.HtmlUnit parseHtmlUnit(Source source) => _getHtmlParseData(source, HtmlEntr
y.PARSED_UNIT, null); |
| 4352 | 4352 |
| 4353 AnalysisResult performAnalysisTask() { | 4353 AnalysisResult performAnalysisTask() { |
| 4354 int getStart = JavaSystem.currentTimeMillis(); | 4354 int getStart = JavaSystem.currentTimeMillis(); |
| 4355 AnalysisTask task = nextAnalysisTask; | 4355 AnalysisTask task = nextAnalysisTask; |
| 4356 int getEnd = JavaSystem.currentTimeMillis(); | 4356 int getEnd = JavaSystem.currentTimeMillis(); |
| 4357 if (task == null && validateCacheConsistency()) { | 4357 if (task == null && _validateCacheConsistency()) { |
| 4358 task = nextAnalysisTask; | 4358 task = nextAnalysisTask; |
| 4359 } | 4359 } |
| 4360 if (task == null) { | 4360 if (task == null) { |
| 4361 return new AnalysisResult(getChangeNotices(true), getEnd - getStart, null,
-1); | 4361 return new AnalysisResult(_getChangeNotices(true), getEnd - getStart, null
, -1); |
| 4362 } | 4362 } |
| 4363 String taskDescriptor = task.toString(); | 4363 String taskDescriptor = task.toString(); |
| 4364 if (_recentTasks.add(taskDescriptor)) { | 4364 if (_recentTasks.add(taskDescriptor)) { |
| 4365 logInformation("Performing task: ${taskDescriptor}"); | 4365 _logInformation("Performing task: ${taskDescriptor}"); |
| 4366 } else { | 4366 } else { |
| 4367 logInformation("*** Performing repeated task: ${taskDescriptor}"); | 4367 _logInformation("*** Performing repeated task: ${taskDescriptor}"); |
| 4368 } | 4368 } |
| 4369 int performStart = JavaSystem.currentTimeMillis(); | 4369 int performStart = JavaSystem.currentTimeMillis(); |
| 4370 try { | 4370 try { |
| 4371 task.perform(_resultRecorder); | 4371 task.perform(_resultRecorder); |
| 4372 } on ObsoleteSourceAnalysisException catch (exception) { | 4372 } on ObsoleteSourceAnalysisException catch (exception) { |
| 4373 AnalysisEngine.instance.logger.logInformation3("Could not perform analysis
task: ${taskDescriptor}", exception); | 4373 AnalysisEngine.instance.logger.logInformation2("Could not perform analysis
task: ${taskDescriptor}", exception); |
| 4374 } on AnalysisException catch (exception) { | 4374 } on AnalysisException catch (exception) { |
| 4375 if (exception.cause is! JavaIOException) { | 4375 if (exception.cause is! JavaIOException) { |
| 4376 AnalysisEngine.instance.logger.logError2("Internal error while performin
g the task: ${task}", exception); | 4376 AnalysisEngine.instance.logger.logError2("Internal error while performin
g the task: ${task}", exception); |
| 4377 } | 4377 } |
| 4378 } | 4378 } |
| 4379 int performEnd = JavaSystem.currentTimeMillis(); | 4379 int performEnd = JavaSystem.currentTimeMillis(); |
| 4380 return new AnalysisResult(getChangeNotices(false), getEnd - getStart, task.r
untimeType.toString(), performEnd - performStart); | 4380 return new AnalysisResult(_getChangeNotices(false), getEnd - getStart, task.
runtimeType.toString(), performEnd - performStart); |
| 4381 } | 4381 } |
| 4382 | 4382 |
| 4383 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { | 4383 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { |
| 4384 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); | 4384 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); |
| 4385 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap)) { | 4385 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap)) { |
| 4386 Source librarySource = entry.getKey(); | 4386 Source librarySource = entry.getKey(); |
| 4387 LibraryElement library = entry.getValue(); | 4387 LibraryElement library = entry.getValue(); |
| 4388 // | 4388 // |
| 4389 // Cache the element in the library's info. | 4389 // Cache the element in the library's info. |
| 4390 // | 4390 // |
| 4391 DartEntry dartEntry = getReadableDartEntry(librarySource); | 4391 DartEntry dartEntry = _getReadableDartEntry(librarySource); |
| 4392 if (dartEntry != null) { | 4392 if (dartEntry != null) { |
| 4393 DartEntryImpl dartCopy = dartEntry.writableCopy; | 4393 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 4394 recordElementData(dartEntry, dartCopy, library, library.source, htmlSour
ce); | 4394 _recordElementData(dartEntry, dartCopy, library, library.source, htmlSou
rce); |
| 4395 _cache.put(librarySource, dartCopy); | 4395 _cache.put(librarySource, dartCopy); |
| 4396 } | 4396 } |
| 4397 } | 4397 } |
| 4398 } | 4398 } |
| 4399 | 4399 |
| 4400 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry) { | 4400 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry) { |
| 4401 if (library == null) { | 4401 if (library == null) { |
| 4402 return null; | 4402 return null; |
| 4403 } | 4403 } |
| 4404 return resolveCompilationUnit2(unitSource, library.source); | 4404 return resolveCompilationUnit2(unitSource, library.source); |
| 4405 } | 4405 } |
| 4406 | 4406 |
| 4407 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) => getDartResolutionData2(unitSource, librarySource, DartEntry.RESOLVED_UNIT,
null); | 4407 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) => _getDartResolutionData2(unitSource, librarySource, DartEntry.RESOLVED_UNIT
, null); |
| 4408 | 4408 |
| 4409 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { | 4409 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { |
| 4410 computeHtmlElement(htmlSource); | 4410 computeHtmlElement(htmlSource); |
| 4411 return parseHtmlUnit(htmlSource); | 4411 return parseHtmlUnit(htmlSource); |
| 4412 } | 4412 } |
| 4413 | 4413 |
| 4414 void set analysisOptions(AnalysisOptions options) { | 4414 void set analysisOptions(AnalysisOptions options) { |
| 4415 bool needsRecompute = this._options.analyzeFunctionBodies != options.analyze
FunctionBodies || this._options.dart2jsHint != options.dart2jsHint || (this._opt
ions.hint && !options.hint) || this._options.preserveComments != options.preserv
eComments; | 4415 bool needsRecompute = this._options.analyzeFunctionBodies != options.analyze
FunctionBodies || this._options.dart2jsHint != options.dart2jsHint || (this._opt
ions.hint && !options.hint) || this._options.preserveComments != options.preserv
eComments; |
| 4416 int cacheSize = options.cacheSize; | 4416 int cacheSize = options.cacheSize; |
| 4417 if (this._options.cacheSize != cacheSize) { | 4417 if (this._options.cacheSize != cacheSize) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4428 JavaSystem.arraycopy(_priorityOrder, 0, newPriorityOrder, 0, maxPriority
OrderSize); | 4428 JavaSystem.arraycopy(_priorityOrder, 0, newPriorityOrder, 0, maxPriority
OrderSize); |
| 4429 _priorityOrder = newPriorityOrder; | 4429 _priorityOrder = newPriorityOrder; |
| 4430 } | 4430 } |
| 4431 } | 4431 } |
| 4432 this._options.analyzeFunctionBodies = options.analyzeFunctionBodies; | 4432 this._options.analyzeFunctionBodies = options.analyzeFunctionBodies; |
| 4433 this._options.dart2jsHint = options.dart2jsHint; | 4433 this._options.dart2jsHint = options.dart2jsHint; |
| 4434 this._options.hint = options.hint; | 4434 this._options.hint = options.hint; |
| 4435 this._options.incremental = options.incremental; | 4435 this._options.incremental = options.incremental; |
| 4436 this._options.preserveComments = options.preserveComments; | 4436 this._options.preserveComments = options.preserveComments; |
| 4437 if (needsRecompute) { | 4437 if (needsRecompute) { |
| 4438 invalidateAllResolutionInformation(); | 4438 _invalidateAllResolutionInformation(); |
| 4439 } | 4439 } |
| 4440 } | 4440 } |
| 4441 | 4441 |
| 4442 void set analysisPriorityOrder(List<Source> sources) { | 4442 void set analysisPriorityOrder(List<Source> sources) { |
| 4443 if (sources == null || sources.isEmpty) { | 4443 if (sources == null || sources.isEmpty) { |
| 4444 _priorityOrder = Source.EMPTY_ARRAY; | 4444 _priorityOrder = Source.EMPTY_ARRAY; |
| 4445 } else { | 4445 } else { |
| 4446 while (sources.remove(null)) { | 4446 while (sources.remove(null)) { |
| 4447 } | 4447 } |
| 4448 if (sources.isEmpty) { | 4448 if (sources.isEmpty) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4460 } | 4460 } |
| 4461 } | 4461 } |
| 4462 } | 4462 } |
| 4463 | 4463 |
| 4464 void setChangedContents(Source source, String contents, int offset, int oldLen
gth, int newLength) { | 4464 void setChangedContents(Source source, String contents, int offset, int oldLen
gth, int newLength) { |
| 4465 _recentTasks.clear(); | 4465 _recentTasks.clear(); |
| 4466 String originalContents = _contentCache.setContents(source, contents); | 4466 String originalContents = _contentCache.setContents(source, contents); |
| 4467 if (contents != null) { | 4467 if (contents != null) { |
| 4468 if (contents != originalContents) { | 4468 if (contents != originalContents) { |
| 4469 if (_options.incremental) { | 4469 if (_options.incremental) { |
| 4470 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increment
alAnalysisCache, source, originalContents, contents, offset, oldLength, newLengt
h, getReadableSourceEntry(source)); | 4470 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increment
alAnalysisCache, source, originalContents, contents, offset, oldLength, newLengt
h, _getReadableSourceEntry(source)); |
| 4471 } | 4471 } |
| 4472 sourceChanged(source); | 4472 _sourceChanged(source); |
| 4473 SourceEntry sourceEntry = _cache.get(source); | 4473 SourceEntry sourceEntry = _cache.get(source); |
| 4474 if (sourceEntry != null) { | 4474 if (sourceEntry != null) { |
| 4475 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; | 4475 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; |
| 4476 sourceCopy.modificationTime = _contentCache.getModificationStamp(sourc
e); | 4476 sourceCopy.modificationTime = _contentCache.getModificationStamp(sourc
e); |
| 4477 sourceCopy.setValue(SourceEntry.CONTENT, contents); | 4477 sourceCopy.setValue(SourceEntry.CONTENT, contents); |
| 4478 _cache.put(source, sourceCopy); | 4478 _cache.put(source, sourceCopy); |
| 4479 } | 4479 } |
| 4480 } | 4480 } |
| 4481 } else if (originalContents != null) { | 4481 } else if (originalContents != null) { |
| 4482 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna
lysisCache, source); | 4482 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna
lysisCache, source); |
| 4483 sourceChanged(source); | 4483 _sourceChanged(source); |
| 4484 } | 4484 } |
| 4485 } | 4485 } |
| 4486 | 4486 |
| 4487 void setContents(Source source, String contents) { | 4487 void setContents(Source source, String contents) { |
| 4488 _recentTasks.clear(); | 4488 _recentTasks.clear(); |
| 4489 String originalContents = _contentCache.setContents(source, contents); | 4489 String originalContents = _contentCache.setContents(source, contents); |
| 4490 if (contents != null) { | 4490 if (contents != null) { |
| 4491 if (contents != originalContents) { | 4491 if (contents != originalContents) { |
| 4492 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA
nalysisCache, source); | 4492 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA
nalysisCache, source); |
| 4493 sourceChanged(source); | 4493 _sourceChanged(source); |
| 4494 SourceEntry sourceEntry = _cache.get(source); | 4494 SourceEntry sourceEntry = _cache.get(source); |
| 4495 if (sourceEntry != null) { | 4495 if (sourceEntry != null) { |
| 4496 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; | 4496 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; |
| 4497 sourceCopy.modificationTime = _contentCache.getModificationStamp(sourc
e); | 4497 sourceCopy.modificationTime = _contentCache.getModificationStamp(sourc
e); |
| 4498 sourceCopy.setValue(SourceEntry.CONTENT, contents); | 4498 sourceCopy.setValue(SourceEntry.CONTENT, contents); |
| 4499 _cache.put(source, sourceCopy); | 4499 _cache.put(source, sourceCopy); |
| 4500 } | 4500 } |
| 4501 } | 4501 } |
| 4502 } else if (originalContents != null) { | 4502 } else if (originalContents != null) { |
| 4503 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna
lysisCache, source); | 4503 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalAna
lysisCache, source); |
| 4504 sourceChanged(source); | 4504 _sourceChanged(source); |
| 4505 } | 4505 } |
| 4506 } | 4506 } |
| 4507 | 4507 |
| 4508 void set sourceFactory(SourceFactory factory) { | 4508 void set sourceFactory(SourceFactory factory) { |
| 4509 if (identical(_sourceFactory, factory)) { | 4509 if (identical(_sourceFactory, factory)) { |
| 4510 return; | 4510 return; |
| 4511 } else if (factory.context != null) { | 4511 } else if (factory.context != null) { |
| 4512 throw new IllegalStateException("Source factories cannot be shared between
contexts"); | 4512 throw new IllegalStateException("Source factories cannot be shared between
contexts"); |
| 4513 } | 4513 } |
| 4514 if (_sourceFactory != null) { | 4514 if (_sourceFactory != null) { |
| 4515 _sourceFactory.context = null; | 4515 _sourceFactory.context = null; |
| 4516 } | 4516 } |
| 4517 factory.context = this; | 4517 factory.context = this; |
| 4518 _sourceFactory = factory; | 4518 _sourceFactory = factory; |
| 4519 invalidateAllResolutionInformation(); | 4519 _invalidateAllResolutionInformation(); |
| 4520 } | 4520 } |
| 4521 | 4521 |
| 4522 /** | 4522 /** |
| 4523 * Record the results produced by performing a [ResolveDartLibraryTask]. If th
e results were | 4523 * Record the results produced by performing a [ResolveDartLibraryTask]. If th
e results were |
| 4524 * computed from data that is now out-of-date, then the results will not be re
corded. | 4524 * computed from data that is now out-of-date, then the results will not be re
corded. |
| 4525 * | 4525 * |
| 4526 * @param task the task that was performed | 4526 * @param task the task that was performed |
| 4527 * @return an entry containing the computed results | 4527 * @return an entry containing the computed results |
| 4528 * @throws AnalysisException if the results could not be recorded | 4528 * @throws AnalysisException if the results could not be recorded |
| 4529 */ | 4529 */ |
| 4530 DartEntry recordResolveDartLibraryTaskResults(ResolveDartLibraryTask task) { | 4530 DartEntry recordResolveDartLibraryTaskResults(ResolveDartLibraryTask task) { |
| 4531 LibraryResolver resolver = task.libraryResolver; | 4531 LibraryResolver resolver = task.libraryResolver; |
| 4532 AnalysisException thrownException = task.exception; | 4532 AnalysisException thrownException = task.exception; |
| 4533 DartEntry unitEntry = null; | 4533 DartEntry unitEntry = null; |
| 4534 Source unitSource = task.unitSource; | 4534 Source unitSource = task.unitSource; |
| 4535 if (resolver != null) { | 4535 if (resolver != null) { |
| 4536 // | 4536 // |
| 4537 // The resolver should only be null if an exception was thrown before (or
while) it was | 4537 // The resolver should only be null if an exception was thrown before (or
while) it was |
| 4538 // being created. | 4538 // being created. |
| 4539 // | 4539 // |
| 4540 Set<Library> resolvedLibraries = resolver.resolvedLibraries; | 4540 Set<Library> resolvedLibraries = resolver.resolvedLibraries; |
| 4541 if (resolvedLibraries == null) { | 4541 if (resolvedLibraries == null) { |
| 4542 // | 4542 // |
| 4543 // The resolved libraries should only be null if an exception was thrown
during resolution. | 4543 // The resolved libraries should only be null if an exception was thrown
during resolution. |
| 4544 // | 4544 // |
| 4545 unitEntry = getReadableDartEntry(unitSource); | 4545 unitEntry = _getReadableDartEntry(unitSource); |
| 4546 if (unitEntry == null) { | 4546 if (unitEntry == null) { |
| 4547 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${unitSource.fullName}"); | 4547 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${unitSource.fullName}"); |
| 4548 } | 4548 } |
| 4549 DartEntryImpl dartCopy = unitEntry.writableCopy; | 4549 DartEntryImpl dartCopy = unitEntry.writableCopy; |
| 4550 dartCopy.recordResolutionError(); | 4550 dartCopy.recordResolutionError(); |
| 4551 dartCopy.exception = thrownException; | 4551 dartCopy.exception = thrownException; |
| 4552 _cache.put(unitSource, dartCopy); | 4552 _cache.put(unitSource, dartCopy); |
| 4553 _cache.remove(unitSource); | 4553 _cache.remove(unitSource); |
| 4554 if (thrownException != null) { | 4554 if (thrownException != null) { |
| 4555 throw thrownException; | 4555 throw thrownException; |
| 4556 } | 4556 } |
| 4557 return dartCopy; | 4557 return dartCopy; |
| 4558 } | 4558 } |
| 4559 if (allModificationTimesMatch(resolvedLibraries)) { | 4559 if (_allModificationTimesMatch(resolvedLibraries)) { |
| 4560 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); | 4560 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); |
| 4561 RecordingErrorListener errorListener = resolver.errorListener; | 4561 RecordingErrorListener errorListener = resolver.errorListener; |
| 4562 for (Library library in resolvedLibraries) { | 4562 for (Library library in resolvedLibraries) { |
| 4563 Source librarySource = library.librarySource; | 4563 Source librarySource = library.librarySource; |
| 4564 for (Source source in library.compilationUnitSources) { | 4564 for (Source source in library.compilationUnitSources) { |
| 4565 CompilationUnit unit = library.getAST(source); | 4565 CompilationUnit unit = library.getAST(source); |
| 4566 List<AnalysisError> errors = errorListener.getErrorsForSource(source
); | 4566 List<AnalysisError> errors = errorListener.getErrorsForSource(source
); |
| 4567 LineInfo lineInfo = getLineInfo(source); | 4567 LineInfo lineInfo = getLineInfo(source); |
| 4568 DartEntry dartEntry = _cache.get(source) as DartEntry; | 4568 DartEntry dartEntry = _cache.get(source) as DartEntry; |
| 4569 int sourceTime = getModificationStamp(source); | 4569 int sourceTime = getModificationStamp(source); |
| 4570 if (dartEntry.modificationTime != sourceTime) { | 4570 if (dartEntry.modificationTime != sourceTime) { |
| 4571 // The source has changed without the context being notified. Simu
late notification. | 4571 // The source has changed without the context being notified. Simu
late notification. |
| 4572 sourceChanged(source); | 4572 _sourceChanged(source); |
| 4573 dartEntry = getReadableDartEntry(source); | 4573 dartEntry = _getReadableDartEntry(source); |
| 4574 if (dartEntry == null) { | 4574 if (dartEntry == null) { |
| 4575 throw new AnalysisException.con1("A Dart file became a non-Dart
file: ${source.fullName}"); | 4575 throw new AnalysisException.con1("A Dart file became a non-Dart
file: ${source.fullName}"); |
| 4576 } | 4576 } |
| 4577 } | 4577 } |
| 4578 DartEntryImpl dartCopy = dartEntry.writableCopy; | 4578 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 4579 if (thrownException == null) { | 4579 if (thrownException == null) { |
| 4580 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | 4580 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 4581 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); | 4581 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 4582 dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource,
unit); | 4582 dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource,
unit); |
| 4583 dartCopy.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySou
rce, errors); | 4583 dartCopy.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySou
rce, errors); |
| 4584 if (source == librarySource) { | 4584 if (source == librarySource) { |
| 4585 recordElementData(dartEntry, dartCopy, library.libraryElement, l
ibrarySource, htmlSource); | 4585 _recordElementData(dartEntry, dartCopy, library.libraryElement,
librarySource, htmlSource); |
| 4586 } | 4586 } |
| 4587 _cache.storedAst(source); | 4587 _cache.storedAst(source); |
| 4588 } else { | 4588 } else { |
| 4589 dartCopy.recordResolutionError(); | 4589 dartCopy.recordResolutionError(); |
| 4590 _cache.remove(source); | 4590 _cache.remove(source); |
| 4591 } | 4591 } |
| 4592 dartCopy.exception = thrownException; | 4592 dartCopy.exception = thrownException; |
| 4593 _cache.put(source, dartCopy); | 4593 _cache.put(source, dartCopy); |
| 4594 if (source != librarySource) { | 4594 if (source != librarySource) { |
| 4595 _workManager.add(source, SourcePriority.PRIORITY_PART); | 4595 _workManager.add(source, SourcePriority.PRIORITY_PART); |
| 4596 } | 4596 } |
| 4597 if (source == unitSource) { | 4597 if (source == unitSource) { |
| 4598 unitEntry = dartCopy; | 4598 unitEntry = dartCopy; |
| 4599 } | 4599 } |
| 4600 ChangeNoticeImpl notice = getNotice(source); | 4600 ChangeNoticeImpl notice = _getNotice(source); |
| 4601 notice.compilationUnit = unit; | 4601 notice.compilationUnit = unit; |
| 4602 notice.setErrors(dartCopy.allErrors, lineInfo); | 4602 notice.setErrors(dartCopy.allErrors, lineInfo); |
| 4603 } | 4603 } |
| 4604 } | 4604 } |
| 4605 } else { | 4605 } else { |
| 4606 PrintStringWriter writer = new PrintStringWriter(); | 4606 PrintStringWriter writer = new PrintStringWriter(); |
| 4607 writer.println("Library resolution results discarded for"); | 4607 writer.println("Library resolution results discarded for"); |
| 4608 for (Library library in resolvedLibraries) { | 4608 for (Library library in resolvedLibraries) { |
| 4609 for (Source source in library.compilationUnitSources) { | 4609 for (Source source in library.compilationUnitSources) { |
| 4610 DartEntry dartEntry = getReadableDartEntry(source); | 4610 DartEntry dartEntry = _getReadableDartEntry(source); |
| 4611 if (dartEntry != null) { | 4611 if (dartEntry != null) { |
| 4612 int resultTime = library.getModificationTime(source); | 4612 int resultTime = library.getModificationTime(source); |
| 4613 writer.println(" ${debuggingString(source)}; sourceTime = ${getMo
dificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.mo
dificationTime}"); | 4613 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM
odificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.m
odificationTime}"); |
| 4614 DartEntryImpl dartCopy = dartEntry.writableCopy; | 4614 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 4615 if (thrownException == null || resultTime >= 0) { | 4615 if (thrownException == null || resultTime >= 0) { |
| 4616 // | 4616 // |
| 4617 // The analysis was performed on out-of-date sources. Mark the c
ache so that the | 4617 // The analysis was performed on out-of-date sources. Mark the c
ache so that the |
| 4618 // sources will be re-analyzed using the up-to-date sources. | 4618 // sources will be re-analyzed using the up-to-date sources. |
| 4619 // | 4619 // |
| 4620 dartCopy.recordResolutionNotInProcess(); | 4620 dartCopy.recordResolutionNotInProcess(); |
| 4621 } else { | 4621 } else { |
| 4622 // | 4622 // |
| 4623 // We could not determine whether the sources were up-to-date or
out-of-date. Mark | 4623 // We could not determine whether the sources were up-to-date or
out-of-date. Mark |
| 4624 // the cache so that we won't attempt to re-analyze the sources
until there's a | 4624 // the cache so that we won't attempt to re-analyze the sources
until there's a |
| 4625 // good chance that we'll be able to do so without error. | 4625 // good chance that we'll be able to do so without error. |
| 4626 // | 4626 // |
| 4627 dartCopy.recordResolutionError(); | 4627 dartCopy.recordResolutionError(); |
| 4628 _cache.remove(source); | 4628 _cache.remove(source); |
| 4629 } | 4629 } |
| 4630 dartCopy.exception = thrownException; | 4630 dartCopy.exception = thrownException; |
| 4631 _cache.put(source, dartCopy); | 4631 _cache.put(source, dartCopy); |
| 4632 if (source == unitSource) { | 4632 if (source == unitSource) { |
| 4633 unitEntry = dartCopy; | 4633 unitEntry = dartCopy; |
| 4634 } | 4634 } |
| 4635 } else { | 4635 } else { |
| 4636 writer.println(" ${debuggingString(source)}; sourceTime = ${getMo
dificationStamp(source)}, no entry"); | 4636 writer.println(" ${_debuggingString(source)}; sourceTime = ${getM
odificationStamp(source)}, no entry"); |
| 4637 } | 4637 } |
| 4638 } | 4638 } |
| 4639 } | 4639 } |
| 4640 logInformation(writer.toString()); | 4640 _logInformation(writer.toString()); |
| 4641 } | 4641 } |
| 4642 } | 4642 } |
| 4643 if (thrownException != null) { | 4643 if (thrownException != null) { |
| 4644 throw thrownException; | 4644 throw thrownException; |
| 4645 } | 4645 } |
| 4646 if (unitEntry == null) { | 4646 if (unitEntry == null) { |
| 4647 unitEntry = getReadableDartEntry(unitSource); | 4647 unitEntry = _getReadableDartEntry(unitSource); |
| 4648 if (unitEntry == null) { | 4648 if (unitEntry == null) { |
| 4649 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${
unitSource.fullName}"); | 4649 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${
unitSource.fullName}"); |
| 4650 } | 4650 } |
| 4651 } | 4651 } |
| 4652 return unitEntry; | 4652 return unitEntry; |
| 4653 } | 4653 } |
| 4654 | 4654 |
| 4655 /** | 4655 /** |
| 4656 * Record that we have accessed the AST structure associated with the given so
urce. At the moment, | 4656 * Record that we have accessed the AST structure associated with the given so
urce. At the moment, |
| 4657 * there is no differentiation between the parsed and resolved forms of the AS
T. | 4657 * there is no differentiation between the parsed and resolved forms of the AS
T. |
| 4658 * | 4658 * |
| 4659 * @param source the source whose AST structure was accessed | 4659 * @param source the source whose AST structure was accessed |
| 4660 */ | 4660 */ |
| 4661 void accessedAst(Source source) { | 4661 void _accessedAst(Source source) { |
| 4662 _cache.accessedAst(source); | 4662 _cache.accessedAst(source); |
| 4663 } | 4663 } |
| 4664 | 4664 |
| 4665 /** | 4665 /** |
| 4666 * Add all of the sources contained in the given source container to the given
list of sources. | 4666 * Add all of the sources contained in the given source container to the given
list of sources. |
| 4667 * | 4667 * |
| 4668 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. | 4668 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. |
| 4669 * | 4669 * |
| 4670 * @param sources the list to which sources are to be added | 4670 * @param sources the list to which sources are to be added |
| 4671 * @param container the source container containing the sources to be added to
the list | 4671 * @param container the source container containing the sources to be added to
the list |
| 4672 */ | 4672 */ |
| 4673 void addSourcesInContainer(List<Source> sources, SourceContainer container) { | 4673 void _addSourcesInContainer(List<Source> sources, SourceContainer container) { |
| 4674 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4674 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4675 Source source = entry.getKey(); | 4675 Source source = entry.getKey(); |
| 4676 if (container.contains(source)) { | 4676 if (container.contains(source)) { |
| 4677 sources.add(source); | 4677 sources.add(source); |
| 4678 } | 4678 } |
| 4679 } | 4679 } |
| 4680 } | 4680 } |
| 4681 | 4681 |
| 4682 /** | 4682 /** |
| 4683 * Return `true` if the modification times of the sources used by the given li
brary resolver | 4683 * Return `true` if the modification times of the sources used by the given li
brary resolver |
| 4684 * to resolve one or more libraries are consistent with the modification times
in the cache. | 4684 * to resolve one or more libraries are consistent with the modification times
in the cache. |
| 4685 * | 4685 * |
| 4686 * @param resolver the library resolver used to resolve one or more libraries | 4686 * @param resolver the library resolver used to resolve one or more libraries |
| 4687 * @return `true` if we should record the results of the resolution | 4687 * @return `true` if we should record the results of the resolution |
| 4688 * @throws AnalysisException if any of the modification times could not be det
ermined (this should | 4688 * @throws AnalysisException if any of the modification times could not be det
ermined (this should |
| 4689 * not happen) | 4689 * not happen) |
| 4690 */ | 4690 */ |
| 4691 bool allModificationTimesMatch(Set<Library> resolvedLibraries) { | 4691 bool _allModificationTimesMatch(Set<Library> resolvedLibraries) { |
| 4692 bool allTimesMatch = true; | 4692 bool allTimesMatch = true; |
| 4693 for (Library library in resolvedLibraries) { | 4693 for (Library library in resolvedLibraries) { |
| 4694 for (Source source in library.compilationUnitSources) { | 4694 for (Source source in library.compilationUnitSources) { |
| 4695 DartEntry dartEntry = getReadableDartEntry(source); | 4695 DartEntry dartEntry = _getReadableDartEntry(source); |
| 4696 if (dartEntry == null) { | 4696 if (dartEntry == null) { |
| 4697 // This shouldn't be possible because we should never have performed t
he task if the | 4697 // This shouldn't be possible because we should never have performed t
he task if the |
| 4698 // source didn't represent a Dart file, but check to be safe. | 4698 // source didn't represent a Dart file, but check to be safe. |
| 4699 throw new AnalysisException.con1("Internal error: attempting to resolv
e non-Dart file as a Dart file: ${source.fullName}"); | 4699 throw new AnalysisException.con1("Internal error: attempting to resolv
e non-Dart file as a Dart file: ${source.fullName}"); |
| 4700 } | 4700 } |
| 4701 int sourceTime = getModificationStamp(source); | 4701 int sourceTime = getModificationStamp(source); |
| 4702 int resultTime = library.getModificationTime(source); | 4702 int resultTime = library.getModificationTime(source); |
| 4703 if (sourceTime != resultTime) { | 4703 if (sourceTime != resultTime) { |
| 4704 // The source has changed without the context being notified. Simulate
notification. | 4704 // The source has changed without the context being notified. Simulate
notification. |
| 4705 sourceChanged(source); | 4705 _sourceChanged(source); |
| 4706 allTimesMatch = false; | 4706 allTimesMatch = false; |
| 4707 } | 4707 } |
| 4708 } | 4708 } |
| 4709 } | 4709 } |
| 4710 return allTimesMatch; | 4710 return allTimesMatch; |
| 4711 } | 4711 } |
| 4712 | 4712 |
| 4713 /** | 4713 /** |
| 4714 * Given a source for a Dart file, return a cache entry in which the state of
the data represented | 4714 * Given a source for a Dart file, return a cache entry in which the state of
the data represented |
| 4715 * by the given descriptor is either [CacheState#VALID] or [CacheState#ERROR].
This | 4715 * by the given descriptor is either [CacheState#VALID] or [CacheState#ERROR].
This |
| 4716 * method assumes that the data can be produced by resolving the directives in
the source if they | 4716 * method assumes that the data can be produced by resolving the directives in
the source if they |
| 4717 * are not already cached. | 4717 * are not already cached. |
| 4718 * | 4718 * |
| 4719 * <b>Note:</b> This method cannot be used in an async environment | 4719 * <b>Note:</b> This method cannot be used in an async environment |
| 4720 * | 4720 * |
| 4721 * @param source the source representing the Dart file | 4721 * @param source the source representing the Dart file |
| 4722 * @param dartEntry the cache entry associated with the Dart file | 4722 * @param dartEntry the cache entry associated with the Dart file |
| 4723 * @param descriptor the descriptor representing the data to be returned | 4723 * @param descriptor the descriptor representing the data to be returned |
| 4724 * @return a cache entry containing the required data | 4724 * @return a cache entry containing the required data |
| 4725 * @throws AnalysisException if data could not be returned because the source
could not be | 4725 * @throws AnalysisException if data could not be returned because the source
could not be |
| 4726 * resolved | 4726 * resolved |
| 4727 */ | 4727 */ |
| 4728 DartEntry cacheDartDependencyData(Source source, DartEntry dartEntry, DataDesc
riptor descriptor) { | 4728 DartEntry _cacheDartDependencyData(Source source, DartEntry dartEntry, DataDes
criptor descriptor) { |
| 4729 // | 4729 // |
| 4730 // Check to see whether we already have the information being requested. | 4730 // Check to see whether we already have the information being requested. |
| 4731 // | 4731 // |
| 4732 CacheState state = dartEntry.getState(descriptor); | 4732 CacheState state = dartEntry.getState(descriptor); |
| 4733 while (state != CacheState.ERROR && state != CacheState.VALID) { | 4733 while (state != CacheState.ERROR && state != CacheState.VALID) { |
| 4734 // | 4734 // |
| 4735 // If not, compute the information. Unless the modification date of the so
urce continues to | 4735 // If not, compute the information. Unless the modification date of the so
urce continues to |
| 4736 // change, this loop will eventually terminate. | 4736 // change, this loop will eventually terminate. |
| 4737 // | 4737 // |
| 4738 dartEntry = cacheDartParseData(source, dartEntry, DartEntry.PARSED_UNIT); | 4738 dartEntry = _cacheDartParseData(source, dartEntry, DartEntry.PARSED_UNIT); |
| 4739 dartEntry = new ResolveDartDependenciesTask(this, source, dartEntry.modifi
cationTime, dartEntry.anyParsedCompilationUnit).perform(_resultRecorder) as Dart
Entry; | 4739 dartEntry = new ResolveDartDependenciesTask(this, source, dartEntry.modifi
cationTime, dartEntry.anyParsedCompilationUnit).perform(_resultRecorder) as Dart
Entry; |
| 4740 state = dartEntry.getState(descriptor); | 4740 state = dartEntry.getState(descriptor); |
| 4741 } | 4741 } |
| 4742 return dartEntry; | 4742 return dartEntry; |
| 4743 } | 4743 } |
| 4744 | 4744 |
| 4745 /** | 4745 /** |
| 4746 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which | 4746 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which |
| 4747 * the state of the data represented by the given descriptor is either [CacheS
tate#VALID] or | 4747 * the state of the data represented by the given descriptor is either [CacheS
tate#VALID] or |
| 4748 * [CacheState#ERROR]. This method assumes that the data can be produced by ge
nerating hints | 4748 * [CacheState#ERROR]. This method assumes that the data can be produced by ge
nerating hints |
| 4749 * for the library if the data is not already cached. | 4749 * for the library if the data is not already cached. |
| 4750 * | 4750 * |
| 4751 * @param unitSource the source representing the Dart file | 4751 * @param unitSource the source representing the Dart file |
| 4752 * @param librarySource the source representing the library containing the Dar
t file | 4752 * @param librarySource the source representing the library containing the Dar
t file |
| 4753 * @param dartEntry the cache entry associated with the Dart file | 4753 * @param dartEntry the cache entry associated with the Dart file |
| 4754 * @param descriptor the descriptor representing the data to be returned | 4754 * @param descriptor the descriptor representing the data to be returned |
| 4755 * @return a cache entry containing the required data | 4755 * @return a cache entry containing the required data |
| 4756 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 4756 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
| 4757 */ | 4757 */ |
| 4758 DartEntry cacheDartHintData(Source unitSource, Source librarySource, DartEntry
dartEntry, DataDescriptor descriptor) { | 4758 DartEntry _cacheDartHintData(Source unitSource, Source librarySource, DartEntr
y dartEntry, DataDescriptor descriptor) { |
| 4759 // | 4759 // |
| 4760 // Check to see whether we already have the information being requested. | 4760 // Check to see whether we already have the information being requested. |
| 4761 // | 4761 // |
| 4762 CacheState state = dartEntry.getStateInLibrary(descriptor, librarySource); | 4762 CacheState state = dartEntry.getStateInLibrary(descriptor, librarySource); |
| 4763 while (state != CacheState.ERROR && state != CacheState.VALID) { | 4763 while (state != CacheState.ERROR && state != CacheState.VALID) { |
| 4764 // | 4764 // |
| 4765 // If not, compute the information. Unless the modification date of the so
urce continues to | 4765 // If not, compute the information. Unless the modification date of the so
urce continues to |
| 4766 // change, this loop will eventually terminate. | 4766 // change, this loop will eventually terminate. |
| 4767 // | 4767 // |
| 4768 dartEntry = new GenerateDartHintsTask(this, getLibraryElement(librarySourc
e)).perform(_resultRecorder) as DartEntry; | 4768 dartEntry = new GenerateDartHintsTask(this, getLibraryElement(librarySourc
e)).perform(_resultRecorder) as DartEntry; |
| 4769 state = dartEntry.getStateInLibrary(descriptor, librarySource); | 4769 state = dartEntry.getStateInLibrary(descriptor, librarySource); |
| 4770 } | 4770 } |
| 4771 return dartEntry; | 4771 return dartEntry; |
| 4772 } | 4772 } |
| 4773 | 4773 |
| 4774 /** | 4774 /** |
| 4775 * Given a source for a Dart file, return a cache entry in which the state of
the data represented | 4775 * Given a source for a Dart file, return a cache entry in which the state of
the data represented |
| 4776 * by the given descriptor is either [CacheState#VALID] or [CacheState#ERROR].
This | 4776 * by the given descriptor is either [CacheState#VALID] or [CacheState#ERROR].
This |
| 4777 * method assumes that the data can be produced by parsing the source if it is
not already cached. | 4777 * method assumes that the data can be produced by parsing the source if it is
not already cached. |
| 4778 * | 4778 * |
| 4779 * <b>Note:</b> This method cannot be used in an async environment | 4779 * <b>Note:</b> This method cannot be used in an async environment |
| 4780 * | 4780 * |
| 4781 * @param source the source representing the Dart file | 4781 * @param source the source representing the Dart file |
| 4782 * @param dartEntry the cache entry associated with the Dart file | 4782 * @param dartEntry the cache entry associated with the Dart file |
| 4783 * @param descriptor the descriptor representing the data to be returned | 4783 * @param descriptor the descriptor representing the data to be returned |
| 4784 * @return a cache entry containing the required data | 4784 * @return a cache entry containing the required data |
| 4785 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 4785 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
| 4786 */ | 4786 */ |
| 4787 DartEntry cacheDartParseData(Source source, DartEntry dartEntry, DataDescripto
r descriptor) { | 4787 DartEntry _cacheDartParseData(Source source, DartEntry dartEntry, DataDescript
or descriptor) { |
| 4788 if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 4788 if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 4789 CompilationUnit unit = dartEntry.anyParsedCompilationUnit; | 4789 CompilationUnit unit = dartEntry.anyParsedCompilationUnit; |
| 4790 if (unit != null) { | 4790 if (unit != null) { |
| 4791 return dartEntry; | 4791 return dartEntry; |
| 4792 } | 4792 } |
| 4793 } | 4793 } |
| 4794 // | 4794 // |
| 4795 // Check to see whether we already have the information being requested. | 4795 // Check to see whether we already have the information being requested. |
| 4796 // | 4796 // |
| 4797 CacheState state = dartEntry.getState(descriptor); | 4797 CacheState state = dartEntry.getState(descriptor); |
| 4798 while (state != CacheState.ERROR && state != CacheState.VALID) { | 4798 while (state != CacheState.ERROR && state != CacheState.VALID) { |
| 4799 // | 4799 // |
| 4800 // If not, compute the information. Unless the modification date of the so
urce continues to | 4800 // If not, compute the information. Unless the modification date of the so
urce continues to |
| 4801 // change, this loop will eventually terminate. | 4801 // change, this loop will eventually terminate. |
| 4802 // | 4802 // |
| 4803 dartEntry = cacheDartScanData(source, dartEntry, DartEntry.TOKEN_STREAM); | 4803 dartEntry = _cacheDartScanData(source, dartEntry, DartEntry.TOKEN_STREAM); |
| 4804 dartEntry = new ParseDartTask(this, source, dartEntry.modificationTime, da
rtEntry.getValue(DartEntry.TOKEN_STREAM)).perform(_resultRecorder) as DartEntry; | 4804 dartEntry = new ParseDartTask(this, source, dartEntry.modificationTime, da
rtEntry.getValue(DartEntry.TOKEN_STREAM)).perform(_resultRecorder) as DartEntry; |
| 4805 state = dartEntry.getState(descriptor); | 4805 state = dartEntry.getState(descriptor); |
| 4806 } | 4806 } |
| 4807 return dartEntry; | 4807 return dartEntry; |
| 4808 } | 4808 } |
| 4809 | 4809 |
| 4810 /** | 4810 /** |
| 4811 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which | 4811 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which |
| 4812 * the state of the data represented by the given descriptor is either [CacheS
tate#VALID] or | 4812 * the state of the data represented by the given descriptor is either [CacheS
tate#VALID] or |
| 4813 * [CacheState#ERROR]. This method assumes that the data can be produced by re
solving the | 4813 * [CacheState#ERROR]. This method assumes that the data can be produced by re
solving the |
| 4814 * source in the context of the library if it is not already cached. | 4814 * source in the context of the library if it is not already cached. |
| 4815 * | 4815 * |
| 4816 * @param unitSource the source representing the Dart file | 4816 * @param unitSource the source representing the Dart file |
| 4817 * @param librarySource the source representing the library containing the Dar
t file | 4817 * @param librarySource the source representing the library containing the Dar
t file |
| 4818 * @param dartEntry the cache entry associated with the Dart file | 4818 * @param dartEntry the cache entry associated with the Dart file |
| 4819 * @param descriptor the descriptor representing the data to be returned | 4819 * @param descriptor the descriptor representing the data to be returned |
| 4820 * @return a cache entry containing the required data | 4820 * @return a cache entry containing the required data |
| 4821 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 4821 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
| 4822 */ | 4822 */ |
| 4823 DartEntry cacheDartResolutionData(Source unitSource, Source librarySource, Dar
tEntry dartEntry, DataDescriptor descriptor) { | 4823 DartEntry _cacheDartResolutionData(Source unitSource, Source librarySource, Da
rtEntry dartEntry, DataDescriptor descriptor) { |
| 4824 // | 4824 // |
| 4825 // Check to see whether we already have the information being requested. | 4825 // Check to see whether we already have the information being requested. |
| 4826 // | 4826 // |
| 4827 CacheState state = (identical(descriptor, DartEntry.ELEMENT)) ? dartEntry.ge
tState(descriptor) : dartEntry.getStateInLibrary(descriptor, librarySource); | 4827 CacheState state = (identical(descriptor, DartEntry.ELEMENT)) ? dartEntry.ge
tState(descriptor) : dartEntry.getStateInLibrary(descriptor, librarySource); |
| 4828 while (state != CacheState.ERROR && state != CacheState.VALID) { | 4828 while (state != CacheState.ERROR && state != CacheState.VALID) { |
| 4829 // | 4829 // |
| 4830 // If not, compute the information. Unless the modification date of the so
urce continues to | 4830 // If not, compute the information. Unless the modification date of the so
urce continues to |
| 4831 // change, this loop will eventually terminate. | 4831 // change, this loop will eventually terminate. |
| 4832 // | 4832 // |
| 4833 // TODO(brianwilkerson) As an optimization, if we already have the element
model for the | 4833 // TODO(brianwilkerson) As an optimization, if we already have the element
model for the |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4845 * cached. | 4845 * cached. |
| 4846 * | 4846 * |
| 4847 * <b>Note:</b> This method cannot be used in an async environment | 4847 * <b>Note:</b> This method cannot be used in an async environment |
| 4848 * | 4848 * |
| 4849 * @param source the source representing the Dart file | 4849 * @param source the source representing the Dart file |
| 4850 * @param dartEntry the cache entry associated with the Dart file | 4850 * @param dartEntry the cache entry associated with the Dart file |
| 4851 * @param descriptor the descriptor representing the data to be returned | 4851 * @param descriptor the descriptor representing the data to be returned |
| 4852 * @return a cache entry containing the required data | 4852 * @return a cache entry containing the required data |
| 4853 * @throws AnalysisException if data could not be returned because the source
could not be scanned | 4853 * @throws AnalysisException if data could not be returned because the source
could not be scanned |
| 4854 */ | 4854 */ |
| 4855 DartEntry cacheDartScanData(Source source, DartEntry dartEntry, DataDescriptor
descriptor) { | 4855 DartEntry _cacheDartScanData(Source source, DartEntry dartEntry, DataDescripto
r descriptor) { |
| 4856 // | 4856 // |
| 4857 // Check to see whether we already have the information being requested. | 4857 // Check to see whether we already have the information being requested. |
| 4858 // | 4858 // |
| 4859 CacheState state = dartEntry.getState(descriptor); | 4859 CacheState state = dartEntry.getState(descriptor); |
| 4860 while (state != CacheState.ERROR && state != CacheState.VALID) { | 4860 while (state != CacheState.ERROR && state != CacheState.VALID) { |
| 4861 // | 4861 // |
| 4862 // If not, compute the information. Unless the modification date of the so
urce continues to | 4862 // If not, compute the information. Unless the modification date of the so
urce continues to |
| 4863 // change, this loop will eventually terminate. | 4863 // change, this loop will eventually terminate. |
| 4864 // | 4864 // |
| 4865 try { | 4865 try { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4883 * [CacheState#ERROR]. This method assumes that the data can be produced by ve
rifying the | 4883 * [CacheState#ERROR]. This method assumes that the data can be produced by ve
rifying the |
| 4884 * source in the given library if the data is not already cached. | 4884 * source in the given library if the data is not already cached. |
| 4885 * | 4885 * |
| 4886 * @param unitSource the source representing the Dart file | 4886 * @param unitSource the source representing the Dart file |
| 4887 * @param librarySource the source representing the library containing the Dar
t file | 4887 * @param librarySource the source representing the library containing the Dar
t file |
| 4888 * @param dartEntry the cache entry associated with the Dart file | 4888 * @param dartEntry the cache entry associated with the Dart file |
| 4889 * @param descriptor the descriptor representing the data to be returned | 4889 * @param descriptor the descriptor representing the data to be returned |
| 4890 * @return a cache entry containing the required data | 4890 * @return a cache entry containing the required data |
| 4891 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 4891 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
| 4892 */ | 4892 */ |
| 4893 DartEntry cacheDartVerificationData(Source unitSource, Source librarySource, D
artEntry dartEntry, DataDescriptor descriptor) { | 4893 DartEntry _cacheDartVerificationData(Source unitSource, Source librarySource,
DartEntry dartEntry, DataDescriptor descriptor) { |
| 4894 // | 4894 // |
| 4895 // Check to see whether we already have the information being requested. | 4895 // Check to see whether we already have the information being requested. |
| 4896 // | 4896 // |
| 4897 CacheState state = dartEntry.getStateInLibrary(descriptor, librarySource); | 4897 CacheState state = dartEntry.getStateInLibrary(descriptor, librarySource); |
| 4898 while (state != CacheState.ERROR && state != CacheState.VALID) { | 4898 while (state != CacheState.ERROR && state != CacheState.VALID) { |
| 4899 // | 4899 // |
| 4900 // If not, compute the information. Unless the modification date of the so
urce continues to | 4900 // If not, compute the information. Unless the modification date of the so
urce continues to |
| 4901 // change, this loop will eventually terminate. | 4901 // change, this loop will eventually terminate. |
| 4902 // | 4902 // |
| 4903 dartEntry = new GenerateDartErrorsTask(this, unitSource, getLibraryElement
(librarySource)).perform(_resultRecorder) as DartEntry; | 4903 dartEntry = new GenerateDartErrorsTask(this, unitSource, getLibraryElement
(librarySource)).perform(_resultRecorder) as DartEntry; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4914 * | 4914 * |
| 4915 * <b>Note:</b> This method cannot be used in an async environment | 4915 * <b>Note:</b> This method cannot be used in an async environment |
| 4916 * | 4916 * |
| 4917 * @param source the source representing the HTML file | 4917 * @param source the source representing the HTML file |
| 4918 * @param htmlEntry the cache entry associated with the HTML file | 4918 * @param htmlEntry the cache entry associated with the HTML file |
| 4919 * @param descriptor the descriptor representing the data to be returned | 4919 * @param descriptor the descriptor representing the data to be returned |
| 4920 * @return a cache entry containing the required data | 4920 * @return a cache entry containing the required data |
| 4921 * @throws AnalysisException if data could not be returned because the source
could not be | 4921 * @throws AnalysisException if data could not be returned because the source
could not be |
| 4922 * resolved | 4922 * resolved |
| 4923 */ | 4923 */ |
| 4924 HtmlEntry cacheHtmlParseData(Source source, HtmlEntry htmlEntry, DataDescripto
r descriptor) { | 4924 HtmlEntry _cacheHtmlParseData(Source source, HtmlEntry htmlEntry, DataDescript
or descriptor) { |
| 4925 if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | 4925 if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 4926 ht.HtmlUnit unit = htmlEntry.anyParsedUnit; | 4926 ht.HtmlUnit unit = htmlEntry.anyParsedUnit; |
| 4927 if (unit != null) { | 4927 if (unit != null) { |
| 4928 return htmlEntry; | 4928 return htmlEntry; |
| 4929 } | 4929 } |
| 4930 } | 4930 } |
| 4931 // | 4931 // |
| 4932 // Check to see whether we already have the information being requested. | 4932 // Check to see whether we already have the information being requested. |
| 4933 // | 4933 // |
| 4934 CacheState state = htmlEntry.getState(descriptor); | 4934 CacheState state = htmlEntry.getState(descriptor); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 4960 * | 4960 * |
| 4961 * <b>Note:</b> This method cannot be used in an async environment | 4961 * <b>Note:</b> This method cannot be used in an async environment |
| 4962 * | 4962 * |
| 4963 * @param source the source representing the HTML file | 4963 * @param source the source representing the HTML file |
| 4964 * @param dartEntry the cache entry associated with the HTML file | 4964 * @param dartEntry the cache entry associated with the HTML file |
| 4965 * @param descriptor the descriptor representing the data to be returned | 4965 * @param descriptor the descriptor representing the data to be returned |
| 4966 * @return a cache entry containing the required data | 4966 * @return a cache entry containing the required data |
| 4967 * @throws AnalysisException if data could not be returned because the source
could not be | 4967 * @throws AnalysisException if data could not be returned because the source
could not be |
| 4968 * resolved | 4968 * resolved |
| 4969 */ | 4969 */ |
| 4970 HtmlEntry cacheHtmlResolutionData(Source source, HtmlEntry htmlEntry, DataDesc
riptor descriptor) { | 4970 HtmlEntry _cacheHtmlResolutionData(Source source, HtmlEntry htmlEntry, DataDes
criptor descriptor) { |
| 4971 // | 4971 // |
| 4972 // Check to see whether we already have the information being requested. | 4972 // Check to see whether we already have the information being requested. |
| 4973 // | 4973 // |
| 4974 CacheState state = htmlEntry.getState(descriptor); | 4974 CacheState state = htmlEntry.getState(descriptor); |
| 4975 while (state != CacheState.ERROR && state != CacheState.VALID) { | 4975 while (state != CacheState.ERROR && state != CacheState.VALID) { |
| 4976 // | 4976 // |
| 4977 // If not, compute the information. Unless the modification date of the so
urce continues to | 4977 // If not, compute the information. Unless the modification date of the so
urce continues to |
| 4978 // change, this loop will eventually terminate. | 4978 // change, this loop will eventually terminate. |
| 4979 // | 4979 // |
| 4980 htmlEntry = cacheHtmlParseData(source, htmlEntry, HtmlEntry.PARSED_UNIT); | 4980 htmlEntry = _cacheHtmlParseData(source, htmlEntry, HtmlEntry.PARSED_UNIT); |
| 4981 htmlEntry = new ResolveHtmlTask(this, source, htmlEntry.modificationTime,
htmlEntry.getValue(HtmlEntry.PARSED_UNIT)).perform(_resultRecorder) as HtmlEntry
; | 4981 htmlEntry = new ResolveHtmlTask(this, source, htmlEntry.modificationTime,
htmlEntry.getValue(HtmlEntry.PARSED_UNIT)).perform(_resultRecorder) as HtmlEntry
; |
| 4982 state = htmlEntry.getState(descriptor); | 4982 state = htmlEntry.getState(descriptor); |
| 4983 } | 4983 } |
| 4984 return htmlEntry; | 4984 return htmlEntry; |
| 4985 } | 4985 } |
| 4986 | 4986 |
| 4987 /** | 4987 /** |
| 4988 * Given the encoded form of a source, use the source factory to reconstitute
the original source. | 4988 * Given the encoded form of a source, use the source factory to reconstitute
the original source. |
| 4989 * | 4989 * |
| 4990 * @param encoding the encoded form of a source | 4990 * @param encoding the encoded form of a source |
| 4991 * @return the source represented by the encoding | 4991 * @return the source represented by the encoding |
| 4992 */ | 4992 */ |
| 4993 Source computeSourceFromEncoding(String encoding) => _sourceFactory.fromEncodi
ng(encoding); | 4993 Source _computeSourceFromEncoding(String encoding) => _sourceFactory.fromEncod
ing(encoding); |
| 4994 | 4994 |
| 4995 /** | 4995 /** |
| 4996 * Return `true` if the given array of sources contains the given source. | 4996 * Return `true` if the given array of sources contains the given source. |
| 4997 * | 4997 * |
| 4998 * @param sources the sources being searched | 4998 * @param sources the sources being searched |
| 4999 * @param targetSource the source being searched for | 4999 * @param targetSource the source being searched for |
| 5000 * @return `true` if the given source is in the array | 5000 * @return `true` if the given source is in the array |
| 5001 */ | 5001 */ |
| 5002 bool contains(List<Source> sources, Source targetSource) { | 5002 bool _contains(List<Source> sources, Source targetSource) { |
| 5003 for (Source source in sources) { | 5003 for (Source source in sources) { |
| 5004 if (source == targetSource) { | 5004 if (source == targetSource) { |
| 5005 return true; | 5005 return true; |
| 5006 } | 5006 } |
| 5007 } | 5007 } |
| 5008 return false; | 5008 return false; |
| 5009 } | 5009 } |
| 5010 | 5010 |
| 5011 /** | 5011 /** |
| 5012 * Return `true` if the given array of sources contains any of the given targe
t sources. | 5012 * Return `true` if the given array of sources contains any of the given targe
t sources. |
| 5013 * | 5013 * |
| 5014 * @param sources the sources being searched | 5014 * @param sources the sources being searched |
| 5015 * @param targetSources the sources being searched for | 5015 * @param targetSources the sources being searched for |
| 5016 * @return `true` if any of the given target sources are in the array | 5016 * @return `true` if any of the given target sources are in the array |
| 5017 */ | 5017 */ |
| 5018 bool containsAny(List<Source> sources, List<Source> targetSources) { | 5018 bool _containsAny(List<Source> sources, List<Source> targetSources) { |
| 5019 for (Source targetSource in targetSources) { | 5019 for (Source targetSource in targetSources) { |
| 5020 if (contains(sources, targetSource)) { | 5020 if (_contains(sources, targetSource)) { |
| 5021 return true; | 5021 return true; |
| 5022 } | 5022 } |
| 5023 } | 5023 } |
| 5024 return false; | 5024 return false; |
| 5025 } | 5025 } |
| 5026 | 5026 |
| 5027 /** | 5027 /** |
| 5028 * Create a [GetContentTask] for the given source, marking the content as bein
g in-process. | 5028 * Create a [GetContentTask] for the given source, marking the content as bein
g in-process. |
| 5029 * | 5029 * |
| 5030 * @param source the source whose content is to be accessed | 5030 * @param source the source whose content is to be accessed |
| 5031 * @param sourceEntry the entry for the source | 5031 * @param sourceEntry the entry for the source |
| 5032 * @return task data representing the created task | 5032 * @return task data representing the created task |
| 5033 */ | 5033 */ |
| 5034 AnalysisContextImpl_TaskData createGetContentTask(Source source, SourceEntry s
ourceEntry) { | 5034 AnalysisContextImpl_TaskData _createGetContentTask(Source source, SourceEntry
sourceEntry) { |
| 5035 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; | 5035 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; |
| 5036 sourceCopy.setState(SourceEntry.CONTENT, CacheState.IN_PROCESS); | 5036 sourceCopy.setState(SourceEntry.CONTENT, CacheState.IN_PROCESS); |
| 5037 _cache.put(source, sourceCopy); | 5037 _cache.put(source, sourceCopy); |
| 5038 return new AnalysisContextImpl_TaskData(new GetContentTask(this, source), fa
lse, null); | 5038 return new AnalysisContextImpl_TaskData(new GetContentTask(this, source), fa
lse, null); |
| 5039 } | 5039 } |
| 5040 | 5040 |
| 5041 /** | 5041 /** |
| 5042 * Create a [ParseDartTask] for the given source, marking the parse errors as
being | 5042 * Create a [ParseDartTask] for the given source, marking the parse errors as
being |
| 5043 * in-process. | 5043 * in-process. |
| 5044 * | 5044 * |
| 5045 * @param source the source whose content is to be parsed | 5045 * @param source the source whose content is to be parsed |
| 5046 * @param dartEntry the entry for the source | 5046 * @param dartEntry the entry for the source |
| 5047 * @return task data representing the created task | 5047 * @return task data representing the created task |
| 5048 */ | 5048 */ |
| 5049 AnalysisContextImpl_TaskData createParseDartTask(Source source, DartEntry dart
Entry) { | 5049 AnalysisContextImpl_TaskData _createParseDartTask(Source source, DartEntry dar
tEntry) { |
| 5050 if (dartEntry.getState(DartEntry.TOKEN_STREAM) != CacheState.VALID) { | 5050 if (dartEntry.getState(DartEntry.TOKEN_STREAM) != CacheState.VALID) { |
| 5051 return createScanDartTask(source, dartEntry); | 5051 return _createScanDartTask(source, dartEntry); |
| 5052 } | 5052 } |
| 5053 Token tokenStream = dartEntry.getValue(DartEntry.TOKEN_STREAM); | 5053 Token tokenStream = dartEntry.getValue(DartEntry.TOKEN_STREAM); |
| 5054 DartEntryImpl dartCopy = dartEntry.writableCopy; | 5054 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5055 dartCopy.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED); | 5055 dartCopy.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED); |
| 5056 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.IN_PROCESS); | 5056 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.IN_PROCESS); |
| 5057 _cache.put(source, dartCopy); | 5057 _cache.put(source, dartCopy); |
| 5058 return new AnalysisContextImpl_TaskData(new ParseDartTask(this, source, dart
Copy.modificationTime, tokenStream), false, null); | 5058 return new AnalysisContextImpl_TaskData(new ParseDartTask(this, source, dart
Copy.modificationTime, tokenStream), false, null); |
| 5059 } | 5059 } |
| 5060 | 5060 |
| 5061 /** | 5061 /** |
| 5062 * Create a [ParseHtmlTask] for the given source, marking the parse errors as
being | 5062 * Create a [ParseHtmlTask] for the given source, marking the parse errors as
being |
| 5063 * in-process. | 5063 * in-process. |
| 5064 * | 5064 * |
| 5065 * @param source the source whose content is to be parsed | 5065 * @param source the source whose content is to be parsed |
| 5066 * @param htmlEntry the entry for the source | 5066 * @param htmlEntry the entry for the source |
| 5067 * @return task data representing the created task | 5067 * @return task data representing the created task |
| 5068 */ | 5068 */ |
| 5069 AnalysisContextImpl_TaskData createParseHtmlTask(Source source, HtmlEntry html
Entry) { | 5069 AnalysisContextImpl_TaskData _createParseHtmlTask(Source source, HtmlEntry htm
lEntry) { |
| 5070 if (htmlEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { | 5070 if (htmlEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { |
| 5071 return createGetContentTask(source, htmlEntry); | 5071 return _createGetContentTask(source, htmlEntry); |
| 5072 } | 5072 } |
| 5073 String content = htmlEntry.getValue(SourceEntry.CONTENT); | 5073 String content = htmlEntry.getValue(SourceEntry.CONTENT); |
| 5074 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 5074 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 5075 htmlCopy.setState(SourceEntry.CONTENT, CacheState.FLUSHED); | 5075 htmlCopy.setState(SourceEntry.CONTENT, CacheState.FLUSHED); |
| 5076 htmlCopy.setState(HtmlEntry.PARSE_ERRORS, CacheState.IN_PROCESS); | 5076 htmlCopy.setState(HtmlEntry.PARSE_ERRORS, CacheState.IN_PROCESS); |
| 5077 _cache.put(source, htmlCopy); | 5077 _cache.put(source, htmlCopy); |
| 5078 return new AnalysisContextImpl_TaskData(new ParseHtmlTask(this, source, html
Copy.modificationTime, content), false, null); | 5078 return new AnalysisContextImpl_TaskData(new ParseHtmlTask(this, source, html
Copy.modificationTime, content), false, null); |
| 5079 } | 5079 } |
| 5080 | 5080 |
| 5081 /** | 5081 /** |
| 5082 * Create a [ResolveDartDependenciesTask] for the given source, marking the ex
ported | 5082 * Create a [ResolveDartDependenciesTask] for the given source, marking the ex
ported |
| 5083 * libraries as being in-process. | 5083 * libraries as being in-process. |
| 5084 * | 5084 * |
| 5085 * @param source the source whose content is to be used to resolve dependencie
s | 5085 * @param source the source whose content is to be used to resolve dependencie
s |
| 5086 * @param dartEntry the entry for the source | 5086 * @param dartEntry the entry for the source |
| 5087 * @return task data representing the created task | 5087 * @return task data representing the created task |
| 5088 */ | 5088 */ |
| 5089 AnalysisContextImpl_TaskData createResolveDartDependenciesTask(Source source,
DartEntry dartEntry) { | 5089 AnalysisContextImpl_TaskData _createResolveDartDependenciesTask(Source source,
DartEntry dartEntry) { |
| 5090 CompilationUnit unit = dartEntry.anyParsedCompilationUnit; | 5090 CompilationUnit unit = dartEntry.anyParsedCompilationUnit; |
| 5091 if (unit == null) { | 5091 if (unit == null) { |
| 5092 return createParseDartTask(source, dartEntry); | 5092 return _createParseDartTask(source, dartEntry); |
| 5093 } | 5093 } |
| 5094 DartEntryImpl dartCopy = dartEntry.writableCopy; | 5094 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5095 dartCopy.setState(DartEntry.EXPORTED_LIBRARIES, CacheState.IN_PROCESS); | 5095 dartCopy.setState(DartEntry.EXPORTED_LIBRARIES, CacheState.IN_PROCESS); |
| 5096 _cache.put(source, dartCopy); | 5096 _cache.put(source, dartCopy); |
| 5097 return new AnalysisContextImpl_TaskData(new ResolveDartDependenciesTask(this
, source, dartCopy.modificationTime, unit), false, null); | 5097 return new AnalysisContextImpl_TaskData(new ResolveDartDependenciesTask(this
, source, dartCopy.modificationTime, unit), false, null); |
| 5098 } | 5098 } |
| 5099 | 5099 |
| 5100 /** | 5100 /** |
| 5101 * Create a [ResolveHtmlTask] for the given source, marking the resolved unit
as being | 5101 * Create a [ResolveHtmlTask] for the given source, marking the resolved unit
as being |
| 5102 * in-process. | 5102 * in-process. |
| 5103 * | 5103 * |
| 5104 * @param source the source whose content is to be resolved | 5104 * @param source the source whose content is to be resolved |
| 5105 * @param htmlEntry the entry for the source | 5105 * @param htmlEntry the entry for the source |
| 5106 * @return task data representing the created task | 5106 * @return task data representing the created task |
| 5107 */ | 5107 */ |
| 5108 AnalysisContextImpl_TaskData createResolveHtmlTask(Source source, HtmlEntry ht
mlEntry) { | 5108 AnalysisContextImpl_TaskData _createResolveHtmlTask(Source source, HtmlEntry h
tmlEntry) { |
| 5109 if (htmlEntry.getState(HtmlEntry.PARSED_UNIT) != CacheState.VALID) { | 5109 if (htmlEntry.getState(HtmlEntry.PARSED_UNIT) != CacheState.VALID) { |
| 5110 return createParseHtmlTask(source, htmlEntry); | 5110 return _createParseHtmlTask(source, htmlEntry); |
| 5111 } | 5111 } |
| 5112 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 5112 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 5113 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.IN_PROCESS); | 5113 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.IN_PROCESS); |
| 5114 _cache.put(source, htmlCopy); | 5114 _cache.put(source, htmlCopy); |
| 5115 return new AnalysisContextImpl_TaskData(new ResolveHtmlTask(this, source, ht
mlCopy.modificationTime, htmlCopy.getValue(HtmlEntry.PARSED_UNIT)), false, null)
; | 5115 return new AnalysisContextImpl_TaskData(new ResolveHtmlTask(this, source, ht
mlCopy.modificationTime, htmlCopy.getValue(HtmlEntry.PARSED_UNIT)), false, null)
; |
| 5116 } | 5116 } |
| 5117 | 5117 |
| 5118 /** | 5118 /** |
| 5119 * Create a [ScanDartTask] for the given source, marking the scan errors as be
ing | 5119 * Create a [ScanDartTask] for the given source, marking the scan errors as be
ing |
| 5120 * in-process. | 5120 * in-process. |
| 5121 * | 5121 * |
| 5122 * @param source the source whose content is to be scanned | 5122 * @param source the source whose content is to be scanned |
| 5123 * @param dartEntry the entry for the source | 5123 * @param dartEntry the entry for the source |
| 5124 * @return task data representing the created task | 5124 * @return task data representing the created task |
| 5125 */ | 5125 */ |
| 5126 AnalysisContextImpl_TaskData createScanDartTask(Source source, DartEntry dartE
ntry) { | 5126 AnalysisContextImpl_TaskData _createScanDartTask(Source source, DartEntry dart
Entry) { |
| 5127 if (dartEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { | 5127 if (dartEntry.getState(SourceEntry.CONTENT) != CacheState.VALID) { |
| 5128 return createGetContentTask(source, dartEntry); | 5128 return _createGetContentTask(source, dartEntry); |
| 5129 } | 5129 } |
| 5130 String content = dartEntry.getValue(SourceEntry.CONTENT); | 5130 String content = dartEntry.getValue(SourceEntry.CONTENT); |
| 5131 DartEntryImpl dartCopy = dartEntry.writableCopy; | 5131 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5132 dartCopy.setState(SourceEntry.CONTENT, CacheState.FLUSHED); | 5132 dartCopy.setState(SourceEntry.CONTENT, CacheState.FLUSHED); |
| 5133 dartCopy.setState(DartEntry.SCAN_ERRORS, CacheState.IN_PROCESS); | 5133 dartCopy.setState(DartEntry.SCAN_ERRORS, CacheState.IN_PROCESS); |
| 5134 _cache.put(source, dartCopy); | 5134 _cache.put(source, dartCopy); |
| 5135 return new AnalysisContextImpl_TaskData(new ScanDartTask(this, source, dartC
opy.modificationTime, content), false, null); | 5135 return new AnalysisContextImpl_TaskData(new ScanDartTask(this, source, dartC
opy.modificationTime, content), false, null); |
| 5136 } | 5136 } |
| 5137 | 5137 |
| 5138 /** | 5138 /** |
| 5139 * Create a source information object suitable for the given source. Return th
e source information | 5139 * Create a source information object suitable for the given source. Return th
e source information |
| 5140 * object that was created, or `null` if the source should not be tracked by t
his context. | 5140 * object that was created, or `null` if the source should not be tracked by t
his context. |
| 5141 * | 5141 * |
| 5142 * @param source the source for which an information object is being created | 5142 * @param source the source for which an information object is being created |
| 5143 * @return the source information object that was created | 5143 * @return the source information object that was created |
| 5144 */ | 5144 */ |
| 5145 SourceEntry createSourceEntry(Source source) { | 5145 SourceEntry _createSourceEntry(Source source) { |
| 5146 String name = source.shortName; | 5146 String name = source.shortName; |
| 5147 if (AnalysisEngine.isHtmlFileName(name)) { | 5147 if (AnalysisEngine.isHtmlFileName(name)) { |
| 5148 HtmlEntryImpl htmlEntry = new HtmlEntryImpl(); | 5148 HtmlEntryImpl htmlEntry = new HtmlEntryImpl(); |
| 5149 htmlEntry.modificationTime = getModificationStamp(source); | 5149 htmlEntry.modificationTime = getModificationStamp(source); |
| 5150 _cache.put(source, htmlEntry); | 5150 _cache.put(source, htmlEntry); |
| 5151 return htmlEntry; | 5151 return htmlEntry; |
| 5152 } else { | 5152 } else { |
| 5153 DartEntryImpl dartEntry = new DartEntryImpl(); | 5153 DartEntryImpl dartEntry = new DartEntryImpl(); |
| 5154 dartEntry.modificationTime = getModificationStamp(source); | 5154 dartEntry.modificationTime = getModificationStamp(source); |
| 5155 _cache.put(source, dartEntry); | 5155 _cache.put(source, dartEntry); |
| 5156 return dartEntry; | 5156 return dartEntry; |
| 5157 } | 5157 } |
| 5158 } | 5158 } |
| 5159 | 5159 |
| 5160 /** | 5160 /** |
| 5161 * Return a string with debugging information about the given source (the full
name and | 5161 * Return a string with debugging information about the given source (the full
name and |
| 5162 * modification stamp of the source). | 5162 * modification stamp of the source). |
| 5163 * | 5163 * |
| 5164 * @param source the source for which a debugging string is to be produced | 5164 * @param source the source for which a debugging string is to be produced |
| 5165 * @return debugging information about the given source | 5165 * @return debugging information about the given source |
| 5166 */ | 5166 */ |
| 5167 String debuggingString(Source source) => "'${source.fullName}' [${getModificat
ionStamp(source)}]"; | 5167 String _debuggingString(Source source) => "'${source.fullName}' [${getModifica
tionStamp(source)}]"; |
| 5168 | 5168 |
| 5169 /** | 5169 /** |
| 5170 * Return an array containing all of the change notices that are waiting to be
returned. If there | 5170 * Return an array containing all of the change notices that are waiting to be
returned. If there |
| 5171 * are no notices, then return either `null` or an empty array, depending on t
he value of | 5171 * are no notices, then return either `null` or an empty array, depending on t
he value of |
| 5172 * the argument. | 5172 * the argument. |
| 5173 * | 5173 * |
| 5174 * @param nullIfEmpty `true` if `null` should be returned when there are no no
tices | 5174 * @param nullIfEmpty `true` if `null` should be returned when there are no no
tices |
| 5175 * @return the change notices that are waiting to be returned | 5175 * @return the change notices that are waiting to be returned |
| 5176 */ | 5176 */ |
| 5177 List<ChangeNotice> getChangeNotices(bool nullIfEmpty) { | 5177 List<ChangeNotice> _getChangeNotices(bool nullIfEmpty) { |
| 5178 if (_pendingNotices.isEmpty) { | 5178 if (_pendingNotices.isEmpty) { |
| 5179 if (nullIfEmpty) { | 5179 if (nullIfEmpty) { |
| 5180 return null; | 5180 return null; |
| 5181 } | 5181 } |
| 5182 return ChangeNoticeImpl.EMPTY_ARRAY; | 5182 return ChangeNoticeImpl.EMPTY_ARRAY; |
| 5183 } | 5183 } |
| 5184 List<ChangeNotice> notices = new List.from(_pendingNotices.values); | 5184 List<ChangeNotice> notices = new List.from(_pendingNotices.values); |
| 5185 _pendingNotices.clear(); | 5185 _pendingNotices.clear(); |
| 5186 return notices; | 5186 return notices; |
| 5187 } | 5187 } |
| 5188 | 5188 |
| 5189 /** | 5189 /** |
| 5190 * Given a source for a Dart file, return the data represented by the given de
scriptor that is | 5190 * Given a source for a Dart file, return the data represented by the given de
scriptor that is |
| 5191 * associated with that source. This method assumes that the data can be produ
ced by resolving the | 5191 * associated with that source. This method assumes that the data can be produ
ced by resolving the |
| 5192 * directives in the source if they are not already cached. | 5192 * directives in the source if they are not already cached. |
| 5193 * | 5193 * |
| 5194 * @param source the source representing the Dart file | 5194 * @param source the source representing the Dart file |
| 5195 * @param dartEntry the cache entry associated with the Dart file | 5195 * @param dartEntry the cache entry associated with the Dart file |
| 5196 * @param descriptor the descriptor representing the data to be returned | 5196 * @param descriptor the descriptor representing the data to be returned |
| 5197 * @return the requested data about the given source | 5197 * @return the requested data about the given source |
| 5198 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 5198 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
| 5199 */ | 5199 */ |
| 5200 Object getDartDependencyData(Source source, DartEntry dartEntry, DataDescripto
r descriptor) { | 5200 Object _getDartDependencyData(Source source, DartEntry dartEntry, DataDescript
or descriptor) { |
| 5201 dartEntry = cacheDartDependencyData(source, dartEntry, descriptor); | 5201 dartEntry = _cacheDartDependencyData(source, dartEntry, descriptor); |
| 5202 return dartEntry.getValue(descriptor); | 5202 return dartEntry.getValue(descriptor); |
| 5203 } | 5203 } |
| 5204 | 5204 |
| 5205 /** | 5205 /** |
| 5206 * Given a source for a Dart file, return the data represented by the given de
scriptor that is | 5206 * Given a source for a Dart file, return the data represented by the given de
scriptor that is |
| 5207 * associated with that source, or the given default value if the source is no
t a Dart file. This | 5207 * associated with that source, or the given default value if the source is no
t a Dart file. This |
| 5208 * method assumes that the data can be produced by resolving the directives in
the source if they | 5208 * method assumes that the data can be produced by resolving the directives in
the source if they |
| 5209 * are not already cached. | 5209 * are not already cached. |
| 5210 * | 5210 * |
| 5211 * @param source the source representing the Dart file | 5211 * @param source the source representing the Dart file |
| 5212 * @param descriptor the descriptor representing the data to be returned | 5212 * @param descriptor the descriptor representing the data to be returned |
| 5213 * @param defaultValue the value to be returned if the source is not a Dart fi
le | 5213 * @param defaultValue the value to be returned if the source is not a Dart fi
le |
| 5214 * @return the requested data about the given source | 5214 * @return the requested data about the given source |
| 5215 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 5215 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
| 5216 */ | 5216 */ |
| 5217 Object getDartDependencyData2(Source source, DataDescriptor descriptor, Object
defaultValue) { | 5217 Object _getDartDependencyData2(Source source, DataDescriptor descriptor, Objec
t defaultValue) { |
| 5218 DartEntry dartEntry = getReadableDartEntry(source); | 5218 DartEntry dartEntry = _getReadableDartEntry(source); |
| 5219 if (dartEntry == null) { | 5219 if (dartEntry == null) { |
| 5220 return defaultValue; | 5220 return defaultValue; |
| 5221 } | 5221 } |
| 5222 try { | 5222 try { |
| 5223 return getDartDependencyData(source, dartEntry, descriptor); | 5223 return _getDartDependencyData(source, dartEntry, descriptor); |
| 5224 } on ObsoleteSourceAnalysisException catch (exception) { | 5224 } on ObsoleteSourceAnalysisException catch (exception) { |
| 5225 AnalysisEngine.instance.logger.logInformation3("Could not compute ${descri
ptor.toString()}", exception); | 5225 AnalysisEngine.instance.logger.logInformation2("Could not compute ${descri
ptor.toString()}", exception); |
| 5226 return defaultValue; | 5226 return defaultValue; |
| 5227 } | 5227 } |
| 5228 } | 5228 } |
| 5229 | 5229 |
| 5230 /** | 5230 /** |
| 5231 * Given a source for a Dart file and the library that contains it, return the
data represented by | 5231 * Given a source for a Dart file and the library that contains it, return the
data represented by |
| 5232 * the given descriptor that is associated with that source. This method assum
es that the data can | 5232 * the given descriptor that is associated with that source. This method assum
es that the data can |
| 5233 * be produced by generating hints for the library if it is not already cached
. | 5233 * be produced by generating hints for the library if it is not already cached
. |
| 5234 * | 5234 * |
| 5235 * @param unitSource the source representing the Dart file | 5235 * @param unitSource the source representing the Dart file |
| 5236 * @param librarySource the source representing the library containing the Dar
t file | 5236 * @param librarySource the source representing the library containing the Dar
t file |
| 5237 * @param dartEntry the entry representing the Dart file | 5237 * @param dartEntry the entry representing the Dart file |
| 5238 * @param descriptor the descriptor representing the data to be returned | 5238 * @param descriptor the descriptor representing the data to be returned |
| 5239 * @return the requested data about the given source | 5239 * @return the requested data about the given source |
| 5240 * @throws AnalysisException if data could not be returned because the source
could not be | 5240 * @throws AnalysisException if data could not be returned because the source
could not be |
| 5241 * resolved | 5241 * resolved |
| 5242 */ | 5242 */ |
| 5243 Object getDartHintData(Source unitSource, Source librarySource, DartEntry dart
Entry, DataDescriptor descriptor) { | 5243 Object _getDartHintData(Source unitSource, Source librarySource, DartEntry dar
tEntry, DataDescriptor descriptor) { |
| 5244 dartEntry = cacheDartHintData(unitSource, librarySource, dartEntry, descript
or); | 5244 dartEntry = _cacheDartHintData(unitSource, librarySource, dartEntry, descrip
tor); |
| 5245 if (identical(descriptor, DartEntry.ELEMENT)) { | 5245 if (identical(descriptor, DartEntry.ELEMENT)) { |
| 5246 return dartEntry.getValue(descriptor); | 5246 return dartEntry.getValue(descriptor); |
| 5247 } | 5247 } |
| 5248 return dartEntry.getValueInLibrary(descriptor, librarySource); | 5248 return dartEntry.getValueInLibrary(descriptor, librarySource); |
| 5249 } | 5249 } |
| 5250 | 5250 |
| 5251 /** | 5251 /** |
| 5252 * Given a source for a Dart file, return the data represented by the given de
scriptor that is | 5252 * Given a source for a Dart file, return the data represented by the given de
scriptor that is |
| 5253 * associated with that source. This method assumes that the data can be produ
ced by parsing the | 5253 * associated with that source. This method assumes that the data can be produ
ced by parsing the |
| 5254 * source if it is not already cached. | 5254 * source if it is not already cached. |
| 5255 * | 5255 * |
| 5256 * <b>Note:</b> This method cannot be used in an async environment | 5256 * <b>Note:</b> This method cannot be used in an async environment |
| 5257 * | 5257 * |
| 5258 * @param source the source representing the Dart file | 5258 * @param source the source representing the Dart file |
| 5259 * @param dartEntry the cache entry associated with the Dart file | 5259 * @param dartEntry the cache entry associated with the Dart file |
| 5260 * @param descriptor the descriptor representing the data to be returned | 5260 * @param descriptor the descriptor representing the data to be returned |
| 5261 * @return the requested data about the given source | 5261 * @return the requested data about the given source |
| 5262 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 5262 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
| 5263 */ | 5263 */ |
| 5264 Object getDartParseData(Source source, DartEntry dartEntry, DataDescriptor des
criptor) { | 5264 Object _getDartParseData(Source source, DartEntry dartEntry, DataDescriptor de
scriptor) { |
| 5265 dartEntry = cacheDartParseData(source, dartEntry, descriptor); | 5265 dartEntry = _cacheDartParseData(source, dartEntry, descriptor); |
| 5266 if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 5266 if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 5267 accessedAst(source); | 5267 _accessedAst(source); |
| 5268 return dartEntry.anyParsedCompilationUnit; | 5268 return dartEntry.anyParsedCompilationUnit; |
| 5269 } | 5269 } |
| 5270 return dartEntry.getValue(descriptor); | 5270 return dartEntry.getValue(descriptor); |
| 5271 } | 5271 } |
| 5272 | 5272 |
| 5273 /** | 5273 /** |
| 5274 * Given a source for a Dart file, return the data represented by the given de
scriptor that is | 5274 * Given a source for a Dart file, return the data represented by the given de
scriptor that is |
| 5275 * associated with that source, or the given default value if the source is no
t a Dart file. This | 5275 * associated with that source, or the given default value if the source is no
t a Dart file. This |
| 5276 * method assumes that the data can be produced by parsing the source if it is
not already cached. | 5276 * method assumes that the data can be produced by parsing the source if it is
not already cached. |
| 5277 * | 5277 * |
| 5278 * <b>Note:</b> This method cannot be used in an async environment | 5278 * <b>Note:</b> This method cannot be used in an async environment |
| 5279 * | 5279 * |
| 5280 * @param source the source representing the Dart file | 5280 * @param source the source representing the Dart file |
| 5281 * @param descriptor the descriptor representing the data to be returned | 5281 * @param descriptor the descriptor representing the data to be returned |
| 5282 * @param defaultValue the value to be returned if the source is not a Dart fi
le | 5282 * @param defaultValue the value to be returned if the source is not a Dart fi
le |
| 5283 * @return the requested data about the given source | 5283 * @return the requested data about the given source |
| 5284 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 5284 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
| 5285 */ | 5285 */ |
| 5286 Object getDartParseData2(Source source, DataDescriptor descriptor, Object defa
ultValue) { | 5286 Object _getDartParseData2(Source source, DataDescriptor descriptor, Object def
aultValue) { |
| 5287 DartEntry dartEntry = getReadableDartEntry(source); | 5287 DartEntry dartEntry = _getReadableDartEntry(source); |
| 5288 if (dartEntry == null) { | 5288 if (dartEntry == null) { |
| 5289 return defaultValue; | 5289 return defaultValue; |
| 5290 } | 5290 } |
| 5291 try { | 5291 try { |
| 5292 return getDartParseData(source, dartEntry, descriptor); | 5292 return _getDartParseData(source, dartEntry, descriptor); |
| 5293 } on ObsoleteSourceAnalysisException catch (exception) { | 5293 } on ObsoleteSourceAnalysisException catch (exception) { |
| 5294 AnalysisEngine.instance.logger.logInformation3("Could not compute ${descri
ptor.toString()}", exception); | 5294 AnalysisEngine.instance.logger.logInformation2("Could not compute ${descri
ptor.toString()}", exception); |
| 5295 return defaultValue; | 5295 return defaultValue; |
| 5296 } | 5296 } |
| 5297 } | 5297 } |
| 5298 | 5298 |
| 5299 /** | 5299 /** |
| 5300 * Given a source for a Dart file and the library that contains it, return the
data represented by | 5300 * Given a source for a Dart file and the library that contains it, return the
data represented by |
| 5301 * the given descriptor that is associated with that source. This method assum
es that the data can | 5301 * the given descriptor that is associated with that source. This method assum
es that the data can |
| 5302 * be produced by resolving the source in the context of the library if it is
not already cached. | 5302 * be produced by resolving the source in the context of the library if it is
not already cached. |
| 5303 * | 5303 * |
| 5304 * @param unitSource the source representing the Dart file | 5304 * @param unitSource the source representing the Dart file |
| 5305 * @param librarySource the source representing the library containing the Dar
t file | 5305 * @param librarySource the source representing the library containing the Dar
t file |
| 5306 * @param dartEntry the entry representing the Dart file | 5306 * @param dartEntry the entry representing the Dart file |
| 5307 * @param descriptor the descriptor representing the data to be returned | 5307 * @param descriptor the descriptor representing the data to be returned |
| 5308 * @return the requested data about the given source | 5308 * @return the requested data about the given source |
| 5309 * @throws AnalysisException if data could not be returned because the source
could not be | 5309 * @throws AnalysisException if data could not be returned because the source
could not be |
| 5310 * resolved | 5310 * resolved |
| 5311 */ | 5311 */ |
| 5312 Object getDartResolutionData(Source unitSource, Source librarySource, DartEntr
y dartEntry, DataDescriptor descriptor) { | 5312 Object _getDartResolutionData(Source unitSource, Source librarySource, DartEnt
ry dartEntry, DataDescriptor descriptor) { |
| 5313 dartEntry = cacheDartResolutionData(unitSource, librarySource, dartEntry, de
scriptor); | 5313 dartEntry = _cacheDartResolutionData(unitSource, librarySource, dartEntry, d
escriptor); |
| 5314 if (identical(descriptor, DartEntry.ELEMENT)) { | 5314 if (identical(descriptor, DartEntry.ELEMENT)) { |
| 5315 return dartEntry.getValue(descriptor); | 5315 return dartEntry.getValue(descriptor); |
| 5316 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 5316 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 5317 accessedAst(unitSource); | 5317 _accessedAst(unitSource); |
| 5318 } | 5318 } |
| 5319 return dartEntry.getValueInLibrary(descriptor, librarySource); | 5319 return dartEntry.getValueInLibrary(descriptor, librarySource); |
| 5320 } | 5320 } |
| 5321 | 5321 |
| 5322 /** | 5322 /** |
| 5323 * Given a source for a Dart file and the library that contains it, return the
data represented by | 5323 * Given a source for a Dart file and the library that contains it, return the
data represented by |
| 5324 * the given descriptor that is associated with that source, or the given defa
ult value if the | 5324 * the given descriptor that is associated with that source, or the given defa
ult value if the |
| 5325 * source is not a Dart file. This method assumes that the data can be produce
d by resolving the | 5325 * source is not a Dart file. This method assumes that the data can be produce
d by resolving the |
| 5326 * source in the context of the library if it is not already cached. | 5326 * source in the context of the library if it is not already cached. |
| 5327 * | 5327 * |
| 5328 * @param unitSource the source representing the Dart file | 5328 * @param unitSource the source representing the Dart file |
| 5329 * @param librarySource the source representing the library containing the Dar
t file | 5329 * @param librarySource the source representing the library containing the Dar
t file |
| 5330 * @param descriptor the descriptor representing the data to be returned | 5330 * @param descriptor the descriptor representing the data to be returned |
| 5331 * @param defaultValue the value to be returned if the source is not a Dart fi
le | 5331 * @param defaultValue the value to be returned if the source is not a Dart fi
le |
| 5332 * @return the requested data about the given source | 5332 * @return the requested data about the given source |
| 5333 * @throws AnalysisException if data could not be returned because the source
could not be | 5333 * @throws AnalysisException if data could not be returned because the source
could not be |
| 5334 * resolved | 5334 * resolved |
| 5335 */ | 5335 */ |
| 5336 Object getDartResolutionData2(Source unitSource, Source librarySource, DataDes
criptor descriptor, Object defaultValue) { | 5336 Object _getDartResolutionData2(Source unitSource, Source librarySource, DataDe
scriptor descriptor, Object defaultValue) { |
| 5337 DartEntry dartEntry = getReadableDartEntry(unitSource); | 5337 DartEntry dartEntry = _getReadableDartEntry(unitSource); |
| 5338 if (dartEntry == null) { | 5338 if (dartEntry == null) { |
| 5339 return defaultValue; | 5339 return defaultValue; |
| 5340 } | 5340 } |
| 5341 try { | 5341 try { |
| 5342 return getDartResolutionData(unitSource, librarySource, dartEntry, descrip
tor); | 5342 return _getDartResolutionData(unitSource, librarySource, dartEntry, descri
ptor); |
| 5343 } on ObsoleteSourceAnalysisException catch (exception) { | 5343 } on ObsoleteSourceAnalysisException catch (exception) { |
| 5344 AnalysisEngine.instance.logger.logInformation3("Could not compute ${descri
ptor.toString()}", exception); | 5344 AnalysisEngine.instance.logger.logInformation2("Could not compute ${descri
ptor.toString()}", exception); |
| 5345 return defaultValue; | 5345 return defaultValue; |
| 5346 } | 5346 } |
| 5347 } | 5347 } |
| 5348 | 5348 |
| 5349 /** | 5349 /** |
| 5350 * Given a source for a Dart file, return the data represented by the given de
scriptor that is | 5350 * Given a source for a Dart file, return the data represented by the given de
scriptor that is |
| 5351 * associated with that source. This method assumes that the data can be produ
ced by scanning the | 5351 * associated with that source. This method assumes that the data can be produ
ced by scanning the |
| 5352 * source if it is not already cached. | 5352 * source if it is not already cached. |
| 5353 * | 5353 * |
| 5354 * <b>Note:</b> This method cannot be used in an async environment | 5354 * <b>Note:</b> This method cannot be used in an async environment |
| 5355 * | 5355 * |
| 5356 * @param source the source representing the Dart file | 5356 * @param source the source representing the Dart file |
| 5357 * @param dartEntry the cache entry associated with the Dart file | 5357 * @param dartEntry the cache entry associated with the Dart file |
| 5358 * @param descriptor the descriptor representing the data to be returned | 5358 * @param descriptor the descriptor representing the data to be returned |
| 5359 * @return the requested data about the given source | 5359 * @return the requested data about the given source |
| 5360 * @throws AnalysisException if data could not be returned because the source
could not be scanned | 5360 * @throws AnalysisException if data could not be returned because the source
could not be scanned |
| 5361 */ | 5361 */ |
| 5362 Object getDartScanData(Source source, DartEntry dartEntry, DataDescriptor desc
riptor) { | 5362 Object _getDartScanData(Source source, DartEntry dartEntry, DataDescriptor des
criptor) { |
| 5363 dartEntry = cacheDartScanData(source, dartEntry, descriptor); | 5363 dartEntry = _cacheDartScanData(source, dartEntry, descriptor); |
| 5364 return dartEntry.getValue(descriptor); | 5364 return dartEntry.getValue(descriptor); |
| 5365 } | 5365 } |
| 5366 | 5366 |
| 5367 /** | 5367 /** |
| 5368 * Given a source for a Dart file, return the data represented by the given de
scriptor that is | 5368 * Given a source for a Dart file, return the data represented by the given de
scriptor that is |
| 5369 * associated with that source, or the given default value if the source is no
t a Dart file. This | 5369 * associated with that source, or the given default value if the source is no
t a Dart file. This |
| 5370 * method assumes that the data can be produced by scanning the source if it i
s not already | 5370 * method assumes that the data can be produced by scanning the source if it i
s not already |
| 5371 * cached. | 5371 * cached. |
| 5372 * | 5372 * |
| 5373 * <b>Note:</b> This method cannot be used in an async environment | 5373 * <b>Note:</b> This method cannot be used in an async environment |
| 5374 * | 5374 * |
| 5375 * @param source the source representing the Dart file | 5375 * @param source the source representing the Dart file |
| 5376 * @param descriptor the descriptor representing the data to be returned | 5376 * @param descriptor the descriptor representing the data to be returned |
| 5377 * @param defaultValue the value to be returned if the source is not a Dart fi
le | 5377 * @param defaultValue the value to be returned if the source is not a Dart fi
le |
| 5378 * @return the requested data about the given source | 5378 * @return the requested data about the given source |
| 5379 * @throws AnalysisException if data could not be returned because the source
could not be scanned | 5379 * @throws AnalysisException if data could not be returned because the source
could not be scanned |
| 5380 */ | 5380 */ |
| 5381 Object getDartScanData2(Source source, DataDescriptor descriptor, Object defau
ltValue) { | 5381 Object _getDartScanData2(Source source, DataDescriptor descriptor, Object defa
ultValue) { |
| 5382 DartEntry dartEntry = getReadableDartEntry(source); | 5382 DartEntry dartEntry = _getReadableDartEntry(source); |
| 5383 if (dartEntry == null) { | 5383 if (dartEntry == null) { |
| 5384 return defaultValue; | 5384 return defaultValue; |
| 5385 } | 5385 } |
| 5386 try { | 5386 try { |
| 5387 return getDartScanData(source, dartEntry, descriptor); | 5387 return _getDartScanData(source, dartEntry, descriptor); |
| 5388 } on ObsoleteSourceAnalysisException catch (exception) { | 5388 } on ObsoleteSourceAnalysisException catch (exception) { |
| 5389 AnalysisEngine.instance.logger.logInformation3("Could not compute ${descri
ptor.toString()}", exception); | 5389 AnalysisEngine.instance.logger.logInformation2("Could not compute ${descri
ptor.toString()}", exception); |
| 5390 return defaultValue; | 5390 return defaultValue; |
| 5391 } | 5391 } |
| 5392 } | 5392 } |
| 5393 | 5393 |
| 5394 /** | 5394 /** |
| 5395 * Given a source for a Dart file and the library that contains it, return the
data represented by | 5395 * Given a source for a Dart file and the library that contains it, return the
data represented by |
| 5396 * the given descriptor that is associated with that source. This method assum
es that the data can | 5396 * the given descriptor that is associated with that source. This method assum
es that the data can |
| 5397 * be produced by verifying the source within the given library if it is not a
lready cached. | 5397 * be produced by verifying the source within the given library if it is not a
lready cached. |
| 5398 * | 5398 * |
| 5399 * @param unitSource the source representing the Dart file | 5399 * @param unitSource the source representing the Dart file |
| 5400 * @param librarySource the source representing the library containing the Dar
t file | 5400 * @param librarySource the source representing the library containing the Dar
t file |
| 5401 * @param dartEntry the entry representing the Dart file | 5401 * @param dartEntry the entry representing the Dart file |
| 5402 * @param descriptor the descriptor representing the data to be returned | 5402 * @param descriptor the descriptor representing the data to be returned |
| 5403 * @return the requested data about the given source | 5403 * @return the requested data about the given source |
| 5404 * @throws AnalysisException if data could not be returned because the source
could not be | 5404 * @throws AnalysisException if data could not be returned because the source
could not be |
| 5405 * resolved | 5405 * resolved |
| 5406 */ | 5406 */ |
| 5407 Object getDartVerificationData(Source unitSource, Source librarySource, DartEn
try dartEntry, DataDescriptor descriptor) { | 5407 Object _getDartVerificationData(Source unitSource, Source librarySource, DartE
ntry dartEntry, DataDescriptor descriptor) { |
| 5408 dartEntry = cacheDartVerificationData(unitSource, librarySource, dartEntry,
descriptor); | 5408 dartEntry = _cacheDartVerificationData(unitSource, librarySource, dartEntry,
descriptor); |
| 5409 return dartEntry.getValueInLibrary(descriptor, librarySource); | 5409 return dartEntry.getValueInLibrary(descriptor, librarySource); |
| 5410 } | 5410 } |
| 5411 | 5411 |
| 5412 /** | 5412 /** |
| 5413 * Given a source for an HTML file, return the data represented by the given d
escriptor that is | 5413 * Given a source for an HTML file, return the data represented by the given d
escriptor that is |
| 5414 * associated with that source, or the given default value if the source is no
t an HTML file. This | 5414 * associated with that source, or the given default value if the source is no
t an HTML file. This |
| 5415 * method assumes that the data can be produced by parsing the source if it is
not already cached. | 5415 * method assumes that the data can be produced by parsing the source if it is
not already cached. |
| 5416 * | 5416 * |
| 5417 * <b>Note:</b> This method cannot be used in an async environment | 5417 * <b>Note:</b> This method cannot be used in an async environment |
| 5418 * | 5418 * |
| 5419 * @param source the source representing the Dart file | 5419 * @param source the source representing the Dart file |
| 5420 * @param descriptor the descriptor representing the data to be returned | 5420 * @param descriptor the descriptor representing the data to be returned |
| 5421 * @param defaultValue the value to be returned if the source is not an HTML f
ile | 5421 * @param defaultValue the value to be returned if the source is not an HTML f
ile |
| 5422 * @return the requested data about the given source | 5422 * @return the requested data about the given source |
| 5423 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 5423 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
| 5424 */ | 5424 */ |
| 5425 Object getHtmlParseData(Source source, DataDescriptor descriptor, Object defau
ltValue) { | 5425 Object _getHtmlParseData(Source source, DataDescriptor descriptor, Object defa
ultValue) { |
| 5426 HtmlEntry htmlEntry = getReadableHtmlEntry(source); | 5426 HtmlEntry htmlEntry = _getReadableHtmlEntry(source); |
| 5427 if (htmlEntry == null) { | 5427 if (htmlEntry == null) { |
| 5428 return defaultValue; | 5428 return defaultValue; |
| 5429 } | 5429 } |
| 5430 htmlEntry = cacheHtmlParseData(source, htmlEntry, descriptor); | 5430 htmlEntry = _cacheHtmlParseData(source, htmlEntry, descriptor); |
| 5431 if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | 5431 if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 5432 accessedAst(source); | 5432 _accessedAst(source); |
| 5433 return htmlEntry.anyParsedUnit; | 5433 return htmlEntry.anyParsedUnit; |
| 5434 } | 5434 } |
| 5435 return htmlEntry.getValue(descriptor); | 5435 return htmlEntry.getValue(descriptor); |
| 5436 } | 5436 } |
| 5437 | 5437 |
| 5438 /** | 5438 /** |
| 5439 * Given a source for an HTML file, return the data represented by the given d
escriptor that is | 5439 * Given a source for an HTML file, return the data represented by the given d
escriptor that is |
| 5440 * associated with that source, or the given default value if the source is no
t an HTML file. This | 5440 * associated with that source, or the given default value if the source is no
t an HTML file. This |
| 5441 * method assumes that the data can be produced by resolving the source if it
is not already | 5441 * method assumes that the data can be produced by resolving the source if it
is not already |
| 5442 * cached. | 5442 * cached. |
| 5443 * | 5443 * |
| 5444 * <b>Note:</b> This method cannot be used in an async environment | 5444 * <b>Note:</b> This method cannot be used in an async environment |
| 5445 * | 5445 * |
| 5446 * @param source the source representing the HTML file | 5446 * @param source the source representing the HTML file |
| 5447 * @param descriptor the descriptor representing the data to be returned | 5447 * @param descriptor the descriptor representing the data to be returned |
| 5448 * @param defaultValue the value to be returned if the source is not an HTML f
ile | 5448 * @param defaultValue the value to be returned if the source is not an HTML f
ile |
| 5449 * @return the requested data about the given source | 5449 * @return the requested data about the given source |
| 5450 * @throws AnalysisException if data could not be returned because the source
could not be | 5450 * @throws AnalysisException if data could not be returned because the source
could not be |
| 5451 * resolved | 5451 * resolved |
| 5452 */ | 5452 */ |
| 5453 Object getHtmlResolutionData(Source source, DataDescriptor descriptor, Object
defaultValue) { | 5453 Object _getHtmlResolutionData(Source source, DataDescriptor descriptor, Object
defaultValue) { |
| 5454 HtmlEntry htmlEntry = getReadableHtmlEntry(source); | 5454 HtmlEntry htmlEntry = _getReadableHtmlEntry(source); |
| 5455 if (htmlEntry == null) { | 5455 if (htmlEntry == null) { |
| 5456 return defaultValue; | 5456 return defaultValue; |
| 5457 } | 5457 } |
| 5458 try { | 5458 try { |
| 5459 return getHtmlResolutionData2(source, htmlEntry, descriptor); | 5459 return _getHtmlResolutionData2(source, htmlEntry, descriptor); |
| 5460 } on ObsoleteSourceAnalysisException catch (exception) { | 5460 } on ObsoleteSourceAnalysisException catch (exception) { |
| 5461 AnalysisEngine.instance.logger.logInformation3("Could not compute ${descri
ptor.toString()}", exception); | 5461 AnalysisEngine.instance.logger.logInformation2("Could not compute ${descri
ptor.toString()}", exception); |
| 5462 return defaultValue; | 5462 return defaultValue; |
| 5463 } | 5463 } |
| 5464 } | 5464 } |
| 5465 | 5465 |
| 5466 /** | 5466 /** |
| 5467 * Given a source for an HTML file, return the data represented by the given d
escriptor that is | 5467 * Given a source for an HTML file, return the data represented by the given d
escriptor that is |
| 5468 * associated with that source. This method assumes that the data can be produ
ced by resolving the | 5468 * associated with that source. This method assumes that the data can be produ
ced by resolving the |
| 5469 * source if it is not already cached. | 5469 * source if it is not already cached. |
| 5470 * | 5470 * |
| 5471 * <b>Note:</b> This method cannot be used in an async environment | 5471 * <b>Note:</b> This method cannot be used in an async environment |
| 5472 * | 5472 * |
| 5473 * @param source the source representing the HTML file | 5473 * @param source the source representing the HTML file |
| 5474 * @param htmlEntry the entry representing the HTML file | 5474 * @param htmlEntry the entry representing the HTML file |
| 5475 * @param descriptor the descriptor representing the data to be returned | 5475 * @param descriptor the descriptor representing the data to be returned |
| 5476 * @return the requested data about the given source | 5476 * @return the requested data about the given source |
| 5477 * @throws AnalysisException if data could not be returned because the source
could not be | 5477 * @throws AnalysisException if data could not be returned because the source
could not be |
| 5478 * resolved | 5478 * resolved |
| 5479 */ | 5479 */ |
| 5480 Object getHtmlResolutionData2(Source source, HtmlEntry htmlEntry, DataDescript
or descriptor) { | 5480 Object _getHtmlResolutionData2(Source source, HtmlEntry htmlEntry, DataDescrip
tor descriptor) { |
| 5481 htmlEntry = cacheHtmlResolutionData(source, htmlEntry, descriptor); | 5481 htmlEntry = _cacheHtmlResolutionData(source, htmlEntry, descriptor); |
| 5482 if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { | 5482 if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { |
| 5483 accessedAst(source); | 5483 _accessedAst(source); |
| 5484 } | 5484 } |
| 5485 return htmlEntry.getValue(descriptor); | 5485 return htmlEntry.getValue(descriptor); |
| 5486 } | 5486 } |
| 5487 | 5487 |
| 5488 /** | 5488 /** |
| 5489 * Look through the cache for a task that needs to be performed. Return the ta
sk that was found, | 5489 * Look through the cache for a task that needs to be performed. Return the ta
sk that was found, |
| 5490 * or `null` if there is no more work to be done. | 5490 * or `null` if there is no more work to be done. |
| 5491 * | 5491 * |
| 5492 * @return the next task that needs to be performed | 5492 * @return the next task that needs to be performed |
| 5493 */ | 5493 */ |
| 5494 AnalysisTask get nextAnalysisTask { | 5494 AnalysisTask get nextAnalysisTask { |
| 5495 bool hintsEnabled = _options.hint; | 5495 bool hintsEnabled = _options.hint; |
| 5496 bool sdkErrorsEnabled = _options.generateSdkErrors; | 5496 bool sdkErrorsEnabled = _options.generateSdkErrors; |
| 5497 bool hasBlockedTask = false; | 5497 bool hasBlockedTask = false; |
| 5498 // | 5498 // |
| 5499 // Look for incremental analysis | 5499 // Look for incremental analysis |
| 5500 // | 5500 // |
| 5501 if (_incrementalAnalysisCache != null && _incrementalAnalysisCache.hasWork)
{ | 5501 if (_incrementalAnalysisCache != null && _incrementalAnalysisCache.hasWork)
{ |
| 5502 AnalysisTask task = new IncrementalAnalysisTask(this, _incrementalAnalysis
Cache); | 5502 AnalysisTask task = new IncrementalAnalysisTask(this, _incrementalAnalysis
Cache); |
| 5503 _incrementalAnalysisCache = null; | 5503 _incrementalAnalysisCache = null; |
| 5504 return task; | 5504 return task; |
| 5505 } | 5505 } |
| 5506 // | 5506 // |
| 5507 // Look for a priority source that needs to be analyzed. | 5507 // Look for a priority source that needs to be analyzed. |
| 5508 // | 5508 // |
| 5509 for (Source source in _priorityOrder) { | 5509 for (Source source in _priorityOrder) { |
| 5510 AnalysisContextImpl_TaskData taskData = getNextNondependentAnalysisTask(so
urce, true, hintsEnabled, sdkErrorsEnabled); | 5510 AnalysisContextImpl_TaskData taskData = _getNextNondependentAnalysisTask(s
ource, true, hintsEnabled, sdkErrorsEnabled); |
| 5511 AnalysisTask task = taskData.task; | 5511 AnalysisTask task = taskData.task; |
| 5512 if (task != null) { | 5512 if (task != null) { |
| 5513 return task; | 5513 return task; |
| 5514 } else if (taskData.isBlocked) { | 5514 } else if (taskData.isBlocked) { |
| 5515 hasBlockedTask = true; | 5515 hasBlockedTask = true; |
| 5516 } | 5516 } |
| 5517 } | 5517 } |
| 5518 // | 5518 // |
| 5519 // Look for a non-priority source that needs to be analyzed. | 5519 // Look for a non-priority source that needs to be analyzed. |
| 5520 // | 5520 // |
| 5521 Source source = _workManager.nextSource; | 5521 Source source = _workManager.nextSource; |
| 5522 while (source != null) { | 5522 while (source != null) { |
| 5523 AnalysisContextImpl_TaskData taskData = getNextNondependentAnalysisTask(so
urce, false, hintsEnabled, sdkErrorsEnabled); | 5523 AnalysisContextImpl_TaskData taskData = _getNextNondependentAnalysisTask(s
ource, false, hintsEnabled, sdkErrorsEnabled); |
| 5524 AnalysisTask task = taskData.task; | 5524 AnalysisTask task = taskData.task; |
| 5525 if (task != null) { | 5525 if (task != null) { |
| 5526 return task; | 5526 return task; |
| 5527 } else if (taskData.isBlocked) { | 5527 } else if (taskData.isBlocked) { |
| 5528 hasBlockedTask = true; | 5528 hasBlockedTask = true; |
| 5529 } else { | 5529 } else { |
| 5530 _workManager.remove(source); | 5530 _workManager.remove(source); |
| 5531 } | 5531 } |
| 5532 source = _workManager.nextSource; | 5532 source = _workManager.nextSource; |
| 5533 } | 5533 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 5557 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 5557 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 5558 * | 5558 * |
| 5559 * @param source the source to be checked | 5559 * @param source the source to be checked |
| 5560 * @param sourceEntry the cache entry associated with the source | 5560 * @param sourceEntry the cache entry associated with the source |
| 5561 * @param isPriority `true` if the source is a priority source | 5561 * @param isPriority `true` if the source is a priority source |
| 5562 * @param hintsEnabled `true` if hints are currently enabled | 5562 * @param hintsEnabled `true` if hints are currently enabled |
| 5563 * @param sdkErrorsEnabled `true` if errors, warnings and hints should be gene
rated for | 5563 * @param sdkErrorsEnabled `true` if errors, warnings and hints should be gene
rated for |
| 5564 * sources in the SDK | 5564 * sources in the SDK |
| 5565 * @return the next task that needs to be performed for the given source | 5565 * @return the next task that needs to be performed for the given source |
| 5566 */ | 5566 */ |
| 5567 AnalysisContextImpl_TaskData getNextAnalysisTaskForSource(Source source, Sourc
eEntry sourceEntry, bool isPriority, bool hintsEnabled, bool sdkErrorsEnabled) { | 5567 AnalysisContextImpl_TaskData _getNextAnalysisTaskForSource(Source source, Sour
ceEntry sourceEntry, bool isPriority, bool hintsEnabled, bool sdkErrorsEnabled)
{ |
| 5568 if (sourceEntry == null) { | 5568 if (sourceEntry == null) { |
| 5569 return new AnalysisContextImpl_TaskData(null, false, null); | 5569 return new AnalysisContextImpl_TaskData(null, false, null); |
| 5570 } | 5570 } |
| 5571 CacheState contentState = sourceEntry.getState(SourceEntry.CONTENT); | 5571 CacheState contentState = sourceEntry.getState(SourceEntry.CONTENT); |
| 5572 if (identical(contentState, CacheState.INVALID)) { | 5572 if (identical(contentState, CacheState.INVALID)) { |
| 5573 return createGetContentTask(source, sourceEntry); | 5573 return _createGetContentTask(source, sourceEntry); |
| 5574 } else if (identical(contentState, CacheState.IN_PROCESS)) { | 5574 } else if (identical(contentState, CacheState.IN_PROCESS)) { |
| 5575 // We are already in the process of getting the content. There's nothing e
lse we can do with | 5575 // We are already in the process of getting the content. There's nothing e
lse we can do with |
| 5576 // this source until that's complete. | 5576 // this source until that's complete. |
| 5577 return new AnalysisContextImpl_TaskData(null, true, null); | 5577 return new AnalysisContextImpl_TaskData(null, true, null); |
| 5578 } | 5578 } |
| 5579 if (sourceEntry is DartEntry) { | 5579 if (sourceEntry is DartEntry) { |
| 5580 DartEntry dartEntry = sourceEntry; | 5580 DartEntry dartEntry = sourceEntry; |
| 5581 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS); | 5581 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS); |
| 5582 if (identical(scanErrorsState, CacheState.INVALID) || (isPriority && ident
ical(scanErrorsState, CacheState.FLUSHED))) { | 5582 if (identical(scanErrorsState, CacheState.INVALID) || (isPriority && ident
ical(scanErrorsState, CacheState.FLUSHED))) { |
| 5583 return createScanDartTask(source, dartEntry); | 5583 return _createScanDartTask(source, dartEntry); |
| 5584 } | 5584 } |
| 5585 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); | 5585 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); |
| 5586 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { | 5586 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { |
| 5587 return createParseDartTask(source, dartEntry); | 5587 return _createParseDartTask(source, dartEntry); |
| 5588 } | 5588 } |
| 5589 if (isPriority && parseErrorsState != CacheState.ERROR) { | 5589 if (isPriority && parseErrorsState != CacheState.ERROR) { |
| 5590 CompilationUnit parseUnit = dartEntry.anyParsedCompilationUnit; | 5590 CompilationUnit parseUnit = dartEntry.anyParsedCompilationUnit; |
| 5591 if (parseUnit == null) { | 5591 if (parseUnit == null) { |
| 5592 return createParseDartTask(source, dartEntry); | 5592 return _createParseDartTask(source, dartEntry); |
| 5593 } | 5593 } |
| 5594 } | 5594 } |
| 5595 CacheState exportState = dartEntry.getState(DartEntry.EXPORTED_LIBRARIES); | 5595 CacheState exportState = dartEntry.getState(DartEntry.EXPORTED_LIBRARIES); |
| 5596 if (identical(exportState, CacheState.INVALID) || (isPriority && identical
(exportState, CacheState.FLUSHED))) { | 5596 if (identical(exportState, CacheState.INVALID) || (isPriority && identical
(exportState, CacheState.FLUSHED))) { |
| 5597 return createResolveDartDependenciesTask(source, dartEntry); | 5597 return _createResolveDartDependenciesTask(source, dartEntry); |
| 5598 } | 5598 } |
| 5599 List<Source> librariesContaining = dartEntry.getValue(DartEntry.CONTAINING
_LIBRARIES); | 5599 List<Source> librariesContaining = dartEntry.getValue(DartEntry.CONTAINING
_LIBRARIES); |
| 5600 for (Source librarySource in librariesContaining) { | 5600 for (Source librarySource in librariesContaining) { |
| 5601 SourceEntry libraryEntry = _cache.get(librarySource); | 5601 SourceEntry libraryEntry = _cache.get(librarySource); |
| 5602 if (libraryEntry is DartEntry) { | 5602 if (libraryEntry is DartEntry) { |
| 5603 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); | 5603 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); |
| 5604 if (identical(elementState, CacheState.INVALID) || (isPriority && iden
tical(elementState, CacheState.FLUSHED))) { | 5604 if (identical(elementState, CacheState.INVALID) || (isPriority && iden
tical(elementState, CacheState.FLUSHED))) { |
| 5605 DartEntryImpl libraryCopy = libraryEntry.writableCopy; | 5605 DartEntryImpl libraryCopy = libraryEntry.writableCopy; |
| 5606 libraryCopy.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS); | 5606 libraryCopy.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS); |
| 5607 _cache.put(librarySource, libraryCopy); | 5607 _cache.put(librarySource, libraryCopy); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5645 } | 5645 } |
| 5646 } | 5646 } |
| 5647 } | 5647 } |
| 5648 } | 5648 } |
| 5649 } | 5649 } |
| 5650 } | 5650 } |
| 5651 } else if (sourceEntry is HtmlEntry) { | 5651 } else if (sourceEntry is HtmlEntry) { |
| 5652 HtmlEntry htmlEntry = sourceEntry; | 5652 HtmlEntry htmlEntry = sourceEntry; |
| 5653 CacheState parseErrorsState = htmlEntry.getState(HtmlEntry.PARSE_ERRORS); | 5653 CacheState parseErrorsState = htmlEntry.getState(HtmlEntry.PARSE_ERRORS); |
| 5654 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { | 5654 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { |
| 5655 return createParseHtmlTask(source, htmlEntry); | 5655 return _createParseHtmlTask(source, htmlEntry); |
| 5656 } | 5656 } |
| 5657 if (isPriority && parseErrorsState != CacheState.ERROR) { | 5657 if (isPriority && parseErrorsState != CacheState.ERROR) { |
| 5658 ht.HtmlUnit parsedUnit = htmlEntry.anyParsedUnit; | 5658 ht.HtmlUnit parsedUnit = htmlEntry.anyParsedUnit; |
| 5659 if (parsedUnit == null) { | 5659 if (parsedUnit == null) { |
| 5660 return createParseHtmlTask(source, htmlEntry); | 5660 return _createParseHtmlTask(source, htmlEntry); |
| 5661 } | 5661 } |
| 5662 } | 5662 } |
| 5663 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT)
; | 5663 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT)
; |
| 5664 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && ide
ntical(resolvedUnitState, CacheState.FLUSHED))) { | 5664 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && ide
ntical(resolvedUnitState, CacheState.FLUSHED))) { |
| 5665 return createResolveHtmlTask(source, htmlEntry); | 5665 return _createResolveHtmlTask(source, htmlEntry); |
| 5666 } | 5666 } |
| 5667 // Angular support | 5667 // Angular support |
| 5668 if (_options.analyzeAngular) { | 5668 if (_options.analyzeAngular) { |
| 5669 // try to resolve as an Angular entry point | 5669 // try to resolve as an Angular entry point |
| 5670 CacheState angularEntryState = htmlEntry.getState(HtmlEntry.ANGULAR_ENTR
Y); | 5670 CacheState angularEntryState = htmlEntry.getState(HtmlEntry.ANGULAR_ENTR
Y); |
| 5671 if (identical(angularEntryState, CacheState.INVALID)) { | 5671 if (identical(angularEntryState, CacheState.INVALID)) { |
| 5672 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) { | 5672 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) { |
| 5673 return createResolveHtmlTask(source, htmlEntry); | 5673 return _createResolveHtmlTask(source, htmlEntry); |
| 5674 } | 5674 } |
| 5675 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 5675 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 5676 htmlCopy.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.IN_PROCESS); | 5676 htmlCopy.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.IN_PROCESS); |
| 5677 _cache.put(source, htmlCopy); | 5677 _cache.put(source, htmlCopy); |
| 5678 return new AnalysisContextImpl_TaskData(new ResolveAngularEntryHtmlTas
k(this, source, htmlCopy.modificationTime, htmlCopy.getValue(HtmlEntry.RESOLVED_
UNIT)), false, null); | 5678 return new AnalysisContextImpl_TaskData(new ResolveAngularEntryHtmlTas
k(this, source, htmlCopy.modificationTime, htmlCopy.getValue(HtmlEntry.RESOLVED_
UNIT)), false, null); |
| 5679 } | 5679 } |
| 5680 // try to resolve as an Angular application part | 5680 // try to resolve as an Angular application part |
| 5681 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR
ORS); | 5681 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR
ORS); |
| 5682 if (identical(angularErrorsState, CacheState.INVALID)) { | 5682 if (identical(angularErrorsState, CacheState.INVALID)) { |
| 5683 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) { | 5683 if (htmlEntry.getState(HtmlEntry.RESOLVED_UNIT) != CacheState.VALID) { |
| 5684 return createResolveHtmlTask(source, htmlEntry); | 5684 return _createResolveHtmlTask(source, htmlEntry); |
| 5685 } | 5685 } |
| 5686 AngularApplication application = htmlEntry.getValue(HtmlEntry.ANGULAR_
APPLICATION); | 5686 AngularApplication application = htmlEntry.getValue(HtmlEntry.ANGULAR_
APPLICATION); |
| 5687 // try to resolve as an Angular template | 5687 // try to resolve as an Angular template |
| 5688 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANGUL
AR_COMPONENT); | 5688 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANGUL
AR_COMPONENT); |
| 5689 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 5689 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 5690 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.IN_PROCESS); | 5690 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.IN_PROCESS); |
| 5691 _cache.put(source, htmlCopy); | 5691 _cache.put(source, htmlCopy); |
| 5692 return new AnalysisContextImpl_TaskData(new ResolveAngularComponentTem
plateTask(this, source, htmlCopy.modificationTime, htmlCopy.getValue(HtmlEntry.R
ESOLVED_UNIT), component, application), false, null); | 5692 return new AnalysisContextImpl_TaskData(new ResolveAngularComponentTem
plateTask(this, source, htmlCopy.modificationTime, htmlCopy.getValue(HtmlEntry.R
ESOLVED_UNIT), component, application), false, null); |
| 5693 } | 5693 } |
| 5694 } | 5694 } |
| 5695 } | 5695 } |
| 5696 return new AnalysisContextImpl_TaskData(null, false, null); | 5696 return new AnalysisContextImpl_TaskData(null, false, null); |
| 5697 } | 5697 } |
| 5698 | 5698 |
| 5699 AnalysisContextImpl_TaskData getNextNondependentAnalysisTask(Source source, bo
ol isPriority, bool hintsEnabled, bool sdkErrorsEnabled) { | 5699 AnalysisContextImpl_TaskData _getNextNondependentAnalysisTask(Source source, b
ool isPriority, bool hintsEnabled, bool sdkErrorsEnabled) { |
| 5700 AnalysisContextImpl_TaskData taskData = getNextAnalysisTaskForSource(source,
_cache.get(source), isPriority, hintsEnabled, sdkErrorsEnabled); | 5700 AnalysisContextImpl_TaskData taskData = _getNextAnalysisTaskForSource(source
, _cache.get(source), isPriority, hintsEnabled, sdkErrorsEnabled); |
| 5701 if (taskData.task != null || taskData.isBlocked) { | 5701 if (taskData.task != null || taskData.isBlocked) { |
| 5702 return taskData; | 5702 return taskData; |
| 5703 } | 5703 } |
| 5704 while (taskData.dependentSource != null) { | 5704 while (taskData.dependentSource != null) { |
| 5705 taskData = getNextAnalysisTaskForSource(source, _cache.get(source), isPrio
rity, hintsEnabled, sdkErrorsEnabled); | 5705 taskData = _getNextAnalysisTaskForSource(source, _cache.get(source), isPri
ority, hintsEnabled, sdkErrorsEnabled); |
| 5706 if (taskData.task != null || taskData.isBlocked) { | 5706 if (taskData.task != null || taskData.isBlocked) { |
| 5707 return taskData; | 5707 return taskData; |
| 5708 } | 5708 } |
| 5709 } | 5709 } |
| 5710 return new AnalysisContextImpl_TaskData(null, false, null); | 5710 return new AnalysisContextImpl_TaskData(null, false, null); |
| 5711 } | 5711 } |
| 5712 | 5712 |
| 5713 /** | 5713 /** |
| 5714 * Return a change notice for the given source, creating one if one does not a
lready exist. | 5714 * Return a change notice for the given source, creating one if one does not a
lready exist. |
| 5715 * | 5715 * |
| 5716 * @param source the source for which changes are being reported | 5716 * @param source the source for which changes are being reported |
| 5717 * @return a change notice for the given source | 5717 * @return a change notice for the given source |
| 5718 */ | 5718 */ |
| 5719 ChangeNoticeImpl getNotice(Source source) { | 5719 ChangeNoticeImpl _getNotice(Source source) { |
| 5720 ChangeNoticeImpl notice = _pendingNotices[source]; | 5720 ChangeNoticeImpl notice = _pendingNotices[source]; |
| 5721 if (notice == null) { | 5721 if (notice == null) { |
| 5722 notice = new ChangeNoticeImpl(source); | 5722 notice = new ChangeNoticeImpl(source); |
| 5723 _pendingNotices[source] = notice; | 5723 _pendingNotices[source] = notice; |
| 5724 } | 5724 } |
| 5725 return notice; | 5725 return notice; |
| 5726 } | 5726 } |
| 5727 | 5727 |
| 5728 /** | 5728 /** |
| 5729 * Return the cache entry associated with the given source, or `null` if the s
ource is not a | 5729 * Return the cache entry associated with the given source, or `null` if the s
ource is not a |
| 5730 * Dart file. | 5730 * Dart file. |
| 5731 * | 5731 * |
| 5732 * @param source the source for which a cache entry is being sought | 5732 * @param source the source for which a cache entry is being sought |
| 5733 * @return the source cache entry associated with the given source | 5733 * @return the source cache entry associated with the given source |
| 5734 */ | 5734 */ |
| 5735 DartEntry getReadableDartEntry(Source source) { | 5735 DartEntry _getReadableDartEntry(Source source) { |
| 5736 SourceEntry sourceEntry = _cache.get(source); | 5736 SourceEntry sourceEntry = _cache.get(source); |
| 5737 if (sourceEntry == null) { | 5737 if (sourceEntry == null) { |
| 5738 sourceEntry = createSourceEntry(source); | 5738 sourceEntry = _createSourceEntry(source); |
| 5739 } | 5739 } |
| 5740 if (sourceEntry is DartEntry) { | 5740 if (sourceEntry is DartEntry) { |
| 5741 return sourceEntry as DartEntry; | 5741 return sourceEntry as DartEntry; |
| 5742 } | 5742 } |
| 5743 return null; | 5743 return null; |
| 5744 } | 5744 } |
| 5745 | 5745 |
| 5746 /** | 5746 /** |
| 5747 * Return the cache entry associated with the given source, or `null` if the s
ource is not | 5747 * Return the cache entry associated with the given source, or `null` if the s
ource is not |
| 5748 * an HTML file. | 5748 * an HTML file. |
| 5749 * | 5749 * |
| 5750 * @param source the source for which a cache entry is being sought | 5750 * @param source the source for which a cache entry is being sought |
| 5751 * @return the source cache entry associated with the given source | 5751 * @return the source cache entry associated with the given source |
| 5752 */ | 5752 */ |
| 5753 HtmlEntry getReadableHtmlEntry(Source source) { | 5753 HtmlEntry _getReadableHtmlEntry(Source source) { |
| 5754 SourceEntry sourceEntry = _cache.get(source); | 5754 SourceEntry sourceEntry = _cache.get(source); |
| 5755 if (sourceEntry == null) { | 5755 if (sourceEntry == null) { |
| 5756 sourceEntry = createSourceEntry(source); | 5756 sourceEntry = _createSourceEntry(source); |
| 5757 } | 5757 } |
| 5758 if (sourceEntry is HtmlEntry) { | 5758 if (sourceEntry is HtmlEntry) { |
| 5759 return sourceEntry as HtmlEntry; | 5759 return sourceEntry as HtmlEntry; |
| 5760 } | 5760 } |
| 5761 return null; | 5761 return null; |
| 5762 } | 5762 } |
| 5763 | 5763 |
| 5764 /** | 5764 /** |
| 5765 * Return the cache entry associated with the given source, or `null` if there
is no entry | 5765 * Return the cache entry associated with the given source, or `null` if there
is no entry |
| 5766 * associated with the source. | 5766 * associated with the source. |
| 5767 * | 5767 * |
| 5768 * @param source the source for which a cache entry is being sought | 5768 * @param source the source for which a cache entry is being sought |
| 5769 * @return the source cache entry associated with the given source | 5769 * @return the source cache entry associated with the given source |
| 5770 */ | 5770 */ |
| 5771 SourceEntry getReadableSourceEntry(Source source) { | 5771 SourceEntry _getReadableSourceEntry(Source source) { |
| 5772 SourceEntry sourceEntry = _cache.get(source); | 5772 SourceEntry sourceEntry = _cache.get(source); |
| 5773 if (sourceEntry == null) { | 5773 if (sourceEntry == null) { |
| 5774 sourceEntry = createSourceEntry(source); | 5774 sourceEntry = _createSourceEntry(source); |
| 5775 } | 5775 } |
| 5776 return sourceEntry; | 5776 return sourceEntry; |
| 5777 } | 5777 } |
| 5778 | 5778 |
| 5779 /** | 5779 /** |
| 5780 * Return an array containing all of the sources known to this context that ha
ve the given kind. | 5780 * Return an array containing all of the sources known to this context that ha
ve the given kind. |
| 5781 * | 5781 * |
| 5782 * @param kind the kind of sources to be returned | 5782 * @param kind the kind of sources to be returned |
| 5783 * @return all of the sources known to this context that have the given kind | 5783 * @return all of the sources known to this context that have the given kind |
| 5784 */ | 5784 */ |
| 5785 List<Source> getSources(SourceKind kind) { | 5785 List<Source> _getSources(SourceKind kind) { |
| 5786 List<Source> sources = new List<Source>(); | 5786 List<Source> sources = new List<Source>(); |
| 5787 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 5787 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 5788 if (identical(entry.getValue().kind, kind)) { | 5788 if (identical(entry.getValue().kind, kind)) { |
| 5789 sources.add(entry.getKey()); | 5789 sources.add(entry.getKey()); |
| 5790 } | 5790 } |
| 5791 } | 5791 } |
| 5792 return new List.from(sources); | 5792 return new List.from(sources); |
| 5793 } | 5793 } |
| 5794 | 5794 |
| 5795 /** | 5795 /** |
| 5796 * Look at the given source to see whether a task needs to be performed relate
d to it. If so, add | 5796 * Look at the given source to see whether a task needs to be performed relate
d to it. If so, add |
| 5797 * the source to the set of sources that need to be processed. This method dup
licates, and must | 5797 * the source to the set of sources that need to be processed. This method dup
licates, and must |
| 5798 * therefore be kept in sync with, | 5798 * therefore be kept in sync with, |
| 5799 * [getNextAnalysisTask]. This method is intended to | 5799 * [getNextAnalysisTask]. This method is intended to |
| 5800 * be used for testing purposes only. | 5800 * be used for testing purposes only. |
| 5801 * | 5801 * |
| 5802 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 5802 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 5803 * | 5803 * |
| 5804 * @param source the source to be checked | 5804 * @param source the source to be checked |
| 5805 * @param sourceEntry the cache entry associated with the source | 5805 * @param sourceEntry the cache entry associated with the source |
| 5806 * @param isPriority `true` if the source is a priority source | 5806 * @param isPriority `true` if the source is a priority source |
| 5807 * @param hintsEnabled `true` if hints are currently enabled | 5807 * @param hintsEnabled `true` if hints are currently enabled |
| 5808 * @param sources the set to which sources should be added | 5808 * @param sources the set to which sources should be added |
| 5809 */ | 5809 */ |
| 5810 void getSourcesNeedingProcessing2(Source source, SourceEntry sourceEntry, bool
isPriority, bool hintsEnabled, Set<Source> sources) { | 5810 void _getSourcesNeedingProcessing(Source source, SourceEntry sourceEntry, bool
isPriority, bool hintsEnabled, Set<Source> sources) { |
| 5811 if (sourceEntry is DartEntry) { | 5811 if (sourceEntry is DartEntry) { |
| 5812 DartEntry dartEntry = sourceEntry; | 5812 DartEntry dartEntry = sourceEntry; |
| 5813 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS); | 5813 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS); |
| 5814 if (identical(scanErrorsState, CacheState.INVALID) || (isPriority && ident
ical(scanErrorsState, CacheState.FLUSHED))) { | 5814 if (identical(scanErrorsState, CacheState.INVALID) || (isPriority && ident
ical(scanErrorsState, CacheState.FLUSHED))) { |
| 5815 sources.add(source); | 5815 sources.add(source); |
| 5816 return; | 5816 return; |
| 5817 } | 5817 } |
| 5818 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); | 5818 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); |
| 5819 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { | 5819 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { |
| 5820 sources.add(source); | 5820 sources.add(source); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5895 } | 5895 } |
| 5896 } | 5896 } |
| 5897 } | 5897 } |
| 5898 } | 5898 } |
| 5899 | 5899 |
| 5900 /** | 5900 /** |
| 5901 * Invalidate all of the resolution results computed by this context. | 5901 * Invalidate all of the resolution results computed by this context. |
| 5902 * | 5902 * |
| 5903 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 5903 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 5904 */ | 5904 */ |
| 5905 void invalidateAllResolutionInformation() { | 5905 void _invalidateAllResolutionInformation() { |
| 5906 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { | 5906 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { |
| 5907 Source source = mapEntry.getKey(); | 5907 Source source = mapEntry.getKey(); |
| 5908 SourceEntry sourceEntry = mapEntry.getValue(); | 5908 SourceEntry sourceEntry = mapEntry.getValue(); |
| 5909 if (sourceEntry is HtmlEntry) { | 5909 if (sourceEntry is HtmlEntry) { |
| 5910 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; | 5910 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; |
| 5911 htmlCopy.invalidateAllResolutionInformation(); | 5911 htmlCopy.invalidateAllResolutionInformation(); |
| 5912 mapEntry.setValue(htmlCopy); | 5912 mapEntry.setValue(htmlCopy); |
| 5913 } else if (sourceEntry is DartEntry) { | 5913 } else if (sourceEntry is DartEntry) { |
| 5914 DartEntry dartEntry = sourceEntry; | 5914 DartEntry dartEntry = sourceEntry; |
| 5915 removeFromParts(source, dartEntry); | 5915 _removeFromParts(source, dartEntry); |
| 5916 DartEntryImpl dartCopy = dartEntry.writableCopy; | 5916 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5917 dartCopy.invalidateAllResolutionInformation(); | 5917 dartCopy.invalidateAllResolutionInformation(); |
| 5918 mapEntry.setValue(dartCopy); | 5918 mapEntry.setValue(dartCopy); |
| 5919 _workManager.add(source, SourcePriority.UNKNOWN); | 5919 _workManager.add(source, SourcePriority.UNKNOWN); |
| 5920 } | 5920 } |
| 5921 } | 5921 } |
| 5922 } | 5922 } |
| 5923 | 5923 |
| 5924 /** | 5924 /** |
| 5925 * In response to a change to Angular entry point [HtmlElement], invalidate an
y results that | 5925 * In response to a change to Angular entry point [HtmlElement], invalidate an
y results that |
| 5926 * depend on it. | 5926 * depend on it. |
| 5927 * | 5927 * |
| 5928 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 5928 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 5929 * | 5929 * |
| 5930 * <b>Note:</b> Any cache entries that were accessed before this method was in
voked must be | 5930 * <b>Note:</b> Any cache entries that were accessed before this method was in
voked must be |
| 5931 * re-accessed after this method returns. | 5931 * re-accessed after this method returns. |
| 5932 * | 5932 * |
| 5933 * @param entryCopy the [HtmlEntryImpl] of the (maybe) Angular entry point bei
ng invalidated | 5933 * @param entryCopy the [HtmlEntryImpl] of the (maybe) Angular entry point bei
ng invalidated |
| 5934 */ | 5934 */ |
| 5935 void invalidateAngularResolution(HtmlEntryImpl entryCopy) { | 5935 void _invalidateAngularResolution(HtmlEntryImpl entryCopy) { |
| 5936 AngularApplication application = entryCopy.getValue(HtmlEntry.ANGULAR_ENTRY)
; | 5936 AngularApplication application = entryCopy.getValue(HtmlEntry.ANGULAR_ENTRY)
; |
| 5937 if (application == null) { | 5937 if (application == null) { |
| 5938 return; | 5938 return; |
| 5939 } | 5939 } |
| 5940 _angularApplications.remove(application); | 5940 _angularApplications.remove(application); |
| 5941 // invalidate Entry | 5941 // invalidate Entry |
| 5942 entryCopy.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.INVALID); | 5942 entryCopy.setState(HtmlEntry.ANGULAR_ENTRY, CacheState.INVALID); |
| 5943 // reset HTML sources | 5943 // reset HTML sources |
| 5944 List<AngularElement> oldAngularElements = application.elements; | 5944 List<AngularElement> oldAngularElements = application.elements; |
| 5945 for (AngularElement angularElement in oldAngularElements) { | 5945 for (AngularElement angularElement in oldAngularElements) { |
| 5946 if (angularElement is AngularHasTemplateElement) { | 5946 if (angularElement is AngularHasTemplateElement) { |
| 5947 AngularHasTemplateElement hasTemplate = angularElement; | 5947 AngularHasTemplateElement hasTemplate = angularElement; |
| 5948 Source templateSource = hasTemplate.templateSource; | 5948 Source templateSource = hasTemplate.templateSource; |
| 5949 if (templateSource != null) { | 5949 if (templateSource != null) { |
| 5950 HtmlEntry htmlEntry = getReadableHtmlEntry(templateSource); | 5950 HtmlEntry htmlEntry = _getReadableHtmlEntry(templateSource); |
| 5951 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 5951 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 5952 htmlCopy.setValue(HtmlEntry.ANGULAR_APPLICATION, null); | 5952 htmlCopy.setValue(HtmlEntry.ANGULAR_APPLICATION, null); |
| 5953 htmlCopy.setValue(HtmlEntry.ANGULAR_COMPONENT, null); | 5953 htmlCopy.setValue(HtmlEntry.ANGULAR_COMPONENT, null); |
| 5954 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID); | 5954 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID); |
| 5955 _cache.put(templateSource, htmlCopy); | 5955 _cache.put(templateSource, htmlCopy); |
| 5956 _workManager.add(templateSource, SourcePriority.HTML); | 5956 _workManager.add(templateSource, SourcePriority.HTML); |
| 5957 } | 5957 } |
| 5958 } | 5958 } |
| 5959 } | 5959 } |
| 5960 // reset Dart sources | 5960 // reset Dart sources |
| 5961 List<Source> oldElementSources = application.elementSources; | 5961 List<Source> oldElementSources = application.elementSources; |
| 5962 for (Source elementSource in oldElementSources) { | 5962 for (Source elementSource in oldElementSources) { |
| 5963 DartEntry dartEntry = getReadableDartEntry(elementSource); | 5963 DartEntry dartEntry = _getReadableDartEntry(elementSource); |
| 5964 DartEntryImpl dartCopy = dartEntry.writableCopy; | 5964 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5965 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS); | 5965 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS); |
| 5966 _cache.put(elementSource, dartCopy); | 5966 _cache.put(elementSource, dartCopy); |
| 5967 // notify about (disappeared) Angular errors | 5967 // notify about (disappeared) Angular errors |
| 5968 ChangeNoticeImpl notice = getNotice(elementSource); | 5968 ChangeNoticeImpl notice = _getNotice(elementSource); |
| 5969 notice.setErrors(dartCopy.allErrors, dartEntry.getValue(SourceEntry.LINE_I
NFO)); | 5969 notice.setErrors(dartCopy.allErrors, dartEntry.getValue(SourceEntry.LINE_I
NFO)); |
| 5970 } | 5970 } |
| 5971 } | 5971 } |
| 5972 | 5972 |
| 5973 /** | 5973 /** |
| 5974 * In response to a change to at least one of the compilation units in the giv
en library, | 5974 * In response to a change to at least one of the compilation units in the giv
en library, |
| 5975 * invalidate any results that are dependent on the result of resolving that l
ibrary. | 5975 * invalidate any results that are dependent on the result of resolving that l
ibrary. |
| 5976 * | 5976 * |
| 5977 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 5977 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 5978 * | 5978 * |
| 5979 * <b>Note:</b> Any cache entries that were accessed before this method was in
voked must be | 5979 * <b>Note:</b> Any cache entries that were accessed before this method was in
voked must be |
| 5980 * re-accessed after this method returns. | 5980 * re-accessed after this method returns. |
| 5981 * | 5981 * |
| 5982 * @param librarySource the source of the library being invalidated | 5982 * @param librarySource the source of the library being invalidated |
| 5983 * @param writer the writer to which debugging information should be written | 5983 * @param writer the writer to which debugging information should be written |
| 5984 */ | 5984 */ |
| 5985 void invalidateLibraryResolution(Source librarySource, PrintStringWriter write
r) { | 5985 void _invalidateLibraryResolution(Source librarySource, PrintStringWriter writ
er) { |
| 5986 // TODO(brianwilkerson) This could be optimized. There's no need to flush al
l of these caches if | 5986 // TODO(brianwilkerson) This could be optimized. There's no need to flush al
l of these caches if |
| 5987 // the public namespace hasn't changed, which will be a fairly common case.
The question is | 5987 // the public namespace hasn't changed, which will be a fairly common case.
The question is |
| 5988 // whether we can afford the time to compute the namespace to look for diffe
rences. | 5988 // whether we can afford the time to compute the namespace to look for diffe
rences. |
| 5989 DartEntry libraryEntry = getReadableDartEntry(librarySource); | 5989 DartEntry libraryEntry = _getReadableDartEntry(librarySource); |
| 5990 if (libraryEntry != null) { | 5990 if (libraryEntry != null) { |
| 5991 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART
S); | 5991 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART
S); |
| 5992 DartEntryImpl libraryCopy = libraryEntry.writableCopy; | 5992 DartEntryImpl libraryCopy = libraryEntry.writableCopy; |
| 5993 int oldTime = libraryCopy.modificationTime; | 5993 int oldTime = libraryCopy.modificationTime; |
| 5994 libraryCopy.invalidateAllResolutionInformation(); | 5994 libraryCopy.invalidateAllResolutionInformation(); |
| 5995 _cache.put(librarySource, libraryCopy); | 5995 _cache.put(librarySource, libraryCopy); |
| 5996 _workManager.add(librarySource, SourcePriority.LIBRARY); | 5996 _workManager.add(librarySource, SourcePriority.LIBRARY); |
| 5997 if (writer != null) { | 5997 if (writer != null) { |
| 5998 writer.println(" Invalidated library source: ${debuggingString(libraryS
ource)} (previously modified at ${oldTime})"); | 5998 writer.println(" Invalidated library source: ${_debuggingString(library
Source)} (previously modified at ${oldTime})"); |
| 5999 } | 5999 } |
| 6000 for (Source partSource in includedParts) { | 6000 for (Source partSource in includedParts) { |
| 6001 SourceEntry partEntry = _cache.get(partSource); | 6001 SourceEntry partEntry = _cache.get(partSource); |
| 6002 if (partEntry is DartEntry) { | 6002 if (partEntry is DartEntry) { |
| 6003 DartEntryImpl partCopy = partEntry.writableCopy; | 6003 DartEntryImpl partCopy = partEntry.writableCopy; |
| 6004 oldTime = partCopy.modificationTime; | 6004 oldTime = partCopy.modificationTime; |
| 6005 if (partEntry != libraryCopy) { | 6005 if (partEntry != libraryCopy) { |
| 6006 partCopy.removeContainingLibrary(librarySource); | 6006 partCopy.removeContainingLibrary(librarySource); |
| 6007 _workManager.add(librarySource, SourcePriority.NORMAL_PART); | 6007 _workManager.add(librarySource, SourcePriority.NORMAL_PART); |
| 6008 } | 6008 } |
| 6009 partCopy.invalidateAllResolutionInformation(); | 6009 partCopy.invalidateAllResolutionInformation(); |
| 6010 _cache.put(partSource, partCopy); | 6010 _cache.put(partSource, partCopy); |
| 6011 if (writer != null) { | 6011 if (writer != null) { |
| 6012 writer.println(" Invalidated part source: ${debuggingString(partSou
rce)} (previously modified at ${oldTime})"); | 6012 writer.println(" Invalidated part source: ${_debuggingString(partSo
urce)} (previously modified at ${oldTime})"); |
| 6013 } | 6013 } |
| 6014 } | 6014 } |
| 6015 } | 6015 } |
| 6016 } | 6016 } |
| 6017 // invalidate Angular applications | 6017 // invalidate Angular applications |
| 6018 List<AngularApplication> angularApplicationsCopy = []; | 6018 List<AngularApplication> angularApplicationsCopy = []; |
| 6019 for (AngularApplication application in angularApplicationsCopy) { | 6019 for (AngularApplication application in angularApplicationsCopy) { |
| 6020 if (application.dependsOn(librarySource)) { | 6020 if (application.dependsOn(librarySource)) { |
| 6021 Source entryPointSource = application.entryPoint; | 6021 Source entryPointSource = application.entryPoint; |
| 6022 HtmlEntry entry = getReadableHtmlEntry(entryPointSource); | 6022 HtmlEntry entry = _getReadableHtmlEntry(entryPointSource); |
| 6023 HtmlEntryImpl entryCopy = entry.writableCopy; | 6023 HtmlEntryImpl entryCopy = entry.writableCopy; |
| 6024 invalidateAngularResolution(entryCopy); | 6024 _invalidateAngularResolution(entryCopy); |
| 6025 _cache.put(entryPointSource, entryCopy); | 6025 _cache.put(entryPointSource, entryCopy); |
| 6026 _workManager.add(entryPointSource, SourcePriority.HTML); | 6026 _workManager.add(entryPointSource, SourcePriority.HTML); |
| 6027 } | 6027 } |
| 6028 } | 6028 } |
| 6029 } | 6029 } |
| 6030 | 6030 |
| 6031 /** | 6031 /** |
| 6032 * Return `true` if this library is, or depends on, dart:html. | 6032 * Return `true` if this library is, or depends on, dart:html. |
| 6033 * | 6033 * |
| 6034 * @param library the library being tested | 6034 * @param library the library being tested |
| 6035 * @param visitedLibraries a collection of the libraries that have been visite
d, used to prevent | 6035 * @param visitedLibraries a collection of the libraries that have been visite
d, used to prevent |
| 6036 * infinite recursion | 6036 * infinite recursion |
| 6037 * @return `true` if this library is, or depends on, dart:html | 6037 * @return `true` if this library is, or depends on, dart:html |
| 6038 */ | 6038 */ |
| 6039 bool isClient(LibraryElement library, Source htmlSource, Set<LibraryElement> v
isitedLibraries) { | 6039 bool _isClient(LibraryElement library, Source htmlSource, Set<LibraryElement>
visitedLibraries) { |
| 6040 if (visitedLibraries.contains(library)) { | 6040 if (visitedLibraries.contains(library)) { |
| 6041 return false; | 6041 return false; |
| 6042 } | 6042 } |
| 6043 if (library.source == htmlSource) { | 6043 if (library.source == htmlSource) { |
| 6044 return true; | 6044 return true; |
| 6045 } | 6045 } |
| 6046 visitedLibraries.add(library); | 6046 visitedLibraries.add(library); |
| 6047 for (LibraryElement imported in library.importedLibraries) { | 6047 for (LibraryElement imported in library.importedLibraries) { |
| 6048 if (isClient(imported, htmlSource, visitedLibraries)) { | 6048 if (_isClient(imported, htmlSource, visitedLibraries)) { |
| 6049 return true; | 6049 return true; |
| 6050 } | 6050 } |
| 6051 } | 6051 } |
| 6052 for (LibraryElement exported in library.exportedLibraries) { | 6052 for (LibraryElement exported in library.exportedLibraries) { |
| 6053 if (isClient(exported, htmlSource, visitedLibraries)) { | 6053 if (_isClient(exported, htmlSource, visitedLibraries)) { |
| 6054 return true; | 6054 return true; |
| 6055 } | 6055 } |
| 6056 } | 6056 } |
| 6057 return false; | 6057 return false; |
| 6058 } | 6058 } |
| 6059 | 6059 |
| 6060 /** | 6060 /** |
| 6061 * Log the given debugging information. | 6061 * Log the given debugging information. |
| 6062 * | 6062 * |
| 6063 * @param message the message to be added to the log | 6063 * @param message the message to be added to the log |
| 6064 */ | 6064 */ |
| 6065 void logInformation(String message) { | 6065 void _logInformation(String message) { |
| 6066 AnalysisEngine.instance.logger.logInformation(message); | 6066 AnalysisEngine.instance.logger.logInformation(message); |
| 6067 } | 6067 } |
| 6068 | 6068 |
| 6069 /** | 6069 /** |
| 6070 * Log the given debugging information. | 6070 * Log the given debugging information. |
| 6071 * | 6071 * |
| 6072 * @param message the message to be added to the log | 6072 * @param message the message to be added to the log |
| 6073 * @param exception the exception to be included in the log entry | 6073 * @param exception the exception to be included in the log entry |
| 6074 */ | 6074 */ |
| 6075 void logInformation2(String message, Exception exception) { | 6075 void _logInformation2(String message, Exception exception) { |
| 6076 if (exception == null) { | 6076 if (exception == null) { |
| 6077 AnalysisEngine.instance.logger.logInformation(message); | 6077 AnalysisEngine.instance.logger.logInformation(message); |
| 6078 } else { | 6078 } else { |
| 6079 AnalysisEngine.instance.logger.logInformation3(message, exception); | 6079 AnalysisEngine.instance.logger.logInformation2(message, exception); |
| 6080 } | 6080 } |
| 6081 } | 6081 } |
| 6082 | 6082 |
| 6083 /** | 6083 /** |
| 6084 * Updates [HtmlEntry]s that correspond to the previously known and new Angula
r application | 6084 * Updates [HtmlEntry]s that correspond to the previously known and new Angula
r application |
| 6085 * information. | 6085 * information. |
| 6086 */ | 6086 */ |
| 6087 void recordAngularEntryPoint(HtmlEntryImpl entry, ResolveAngularEntryHtmlTask
task) { | 6087 void _recordAngularEntryPoint(HtmlEntryImpl entry, ResolveAngularEntryHtmlTask
task) { |
| 6088 AngularApplication application = task.application; | 6088 AngularApplication application = task.application; |
| 6089 if (application != null) { | 6089 if (application != null) { |
| 6090 _angularApplications.add(application); | 6090 _angularApplications.add(application); |
| 6091 // if this is an entry point, then we already resolved it | 6091 // if this is an entry point, then we already resolved it |
| 6092 entry.setValue(HtmlEntry.ANGULAR_ERRORS, task.entryErrors); | 6092 entry.setValue(HtmlEntry.ANGULAR_ERRORS, task.entryErrors); |
| 6093 // schedule HTML templates analysis | 6093 // schedule HTML templates analysis |
| 6094 List<AngularElement> newAngularElements = application.elements; | 6094 List<AngularElement> newAngularElements = application.elements; |
| 6095 for (AngularElement angularElement in newAngularElements) { | 6095 for (AngularElement angularElement in newAngularElements) { |
| 6096 if (angularElement is AngularHasTemplateElement) { | 6096 if (angularElement is AngularHasTemplateElement) { |
| 6097 AngularHasTemplateElement hasTemplate = angularElement; | 6097 AngularHasTemplateElement hasTemplate = angularElement; |
| 6098 Source templateSource = hasTemplate.templateSource; | 6098 Source templateSource = hasTemplate.templateSource; |
| 6099 if (templateSource != null) { | 6099 if (templateSource != null) { |
| 6100 HtmlEntry htmlEntry = getReadableHtmlEntry(templateSource); | 6100 HtmlEntry htmlEntry = _getReadableHtmlEntry(templateSource); |
| 6101 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 6101 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 6102 htmlCopy.setValue(HtmlEntry.ANGULAR_APPLICATION, application); | 6102 htmlCopy.setValue(HtmlEntry.ANGULAR_APPLICATION, application); |
| 6103 if (hasTemplate is AngularComponentElement) { | 6103 if (hasTemplate is AngularComponentElement) { |
| 6104 AngularComponentElement component = hasTemplate; | 6104 AngularComponentElement component = hasTemplate; |
| 6105 htmlCopy.setValue(HtmlEntry.ANGULAR_COMPONENT, component); | 6105 htmlCopy.setValue(HtmlEntry.ANGULAR_COMPONENT, component); |
| 6106 } | 6106 } |
| 6107 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID); | 6107 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID); |
| 6108 _cache.put(templateSource, htmlCopy); | 6108 _cache.put(templateSource, htmlCopy); |
| 6109 _workManager.add(templateSource, SourcePriority.HTML); | 6109 _workManager.add(templateSource, SourcePriority.HTML); |
| 6110 } | 6110 } |
| 6111 } | 6111 } |
| 6112 } | 6112 } |
| 6113 // update Dart sources errors | 6113 // update Dart sources errors |
| 6114 List<Source> newElementSources = application.elementSources; | 6114 List<Source> newElementSources = application.elementSources; |
| 6115 for (Source elementSource in newElementSources) { | 6115 for (Source elementSource in newElementSources) { |
| 6116 DartEntry dartEntry = getReadableDartEntry(elementSource); | 6116 DartEntry dartEntry = _getReadableDartEntry(elementSource); |
| 6117 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6117 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6118 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, task.getErrors(elementSource
)); | 6118 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, task.getErrors(elementSource
)); |
| 6119 _cache.put(elementSource, dartCopy); | 6119 _cache.put(elementSource, dartCopy); |
| 6120 // notify about Dart errors | 6120 // notify about Dart errors |
| 6121 ChangeNoticeImpl notice = getNotice(elementSource); | 6121 ChangeNoticeImpl notice = _getNotice(elementSource); |
| 6122 notice.setErrors(dartCopy.allErrors, computeLineInfo(elementSource)); | 6122 notice.setErrors(dartCopy.allErrors, computeLineInfo(elementSource)); |
| 6123 } | 6123 } |
| 6124 } | 6124 } |
| 6125 // remember Angular entry point | 6125 // remember Angular entry point |
| 6126 entry.setValue(HtmlEntry.ANGULAR_ENTRY, application); | 6126 entry.setValue(HtmlEntry.ANGULAR_ENTRY, application); |
| 6127 } | 6127 } |
| 6128 | 6128 |
| 6129 /** | 6129 /** |
| 6130 * Given a cache entry and a library element, record the library element and o
ther information | 6130 * Given a cache entry and a library element, record the library element and o
ther information |
| 6131 * gleaned from the element in the cache entry. | 6131 * gleaned from the element in the cache entry. |
| 6132 * | 6132 * |
| 6133 * @param dartEntry the original cache entry from which the copy was made | 6133 * @param dartEntry the original cache entry from which the copy was made |
| 6134 * @param dartCopy the cache entry in which data is to be recorded | 6134 * @param dartCopy the cache entry in which data is to be recorded |
| 6135 * @param library the library element used to record information | 6135 * @param library the library element used to record information |
| 6136 * @param librarySource the source for the library used to record information | 6136 * @param librarySource the source for the library used to record information |
| 6137 * @param htmlSource the source for the HTML library | 6137 * @param htmlSource the source for the HTML library |
| 6138 */ | 6138 */ |
| 6139 void recordElementData(DartEntry dartEntry, DartEntryImpl dartCopy, LibraryEle
ment library, Source librarySource, Source htmlSource) { | 6139 void _recordElementData(DartEntry dartEntry, DartEntryImpl dartCopy, LibraryEl
ement library, Source librarySource, Source htmlSource) { |
| 6140 dartCopy.setValue(DartEntry.ELEMENT, library); | 6140 dartCopy.setValue(DartEntry.ELEMENT, library); |
| 6141 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); | 6141 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); |
| 6142 dartCopy.setValue(DartEntry.IS_CLIENT, isClient(library, htmlSource, new Set
<LibraryElement>())); | 6142 dartCopy.setValue(DartEntry.IS_CLIENT, _isClient(library, htmlSource, new Se
t<LibraryElement>())); |
| 6143 // TODO(brianwilkerson) Understand why we're doing this both here and in | 6143 // TODO(brianwilkerson) Understand why we're doing this both here and in |
| 6144 // ResolveDartDependenciesTask and whether we should also be capturing the i
mported and exported | 6144 // ResolveDartDependenciesTask and whether we should also be capturing the i
mported and exported |
| 6145 // sources here. | 6145 // sources here. |
| 6146 removeFromParts(librarySource, dartEntry); | 6146 _removeFromParts(librarySource, dartEntry); |
| 6147 List<CompilationUnitElement> parts = library.parts; | 6147 List<CompilationUnitElement> parts = library.parts; |
| 6148 int count = parts.length; | 6148 int count = parts.length; |
| 6149 List<Source> unitSources = new List<Source>(count + 1); | 6149 List<Source> unitSources = new List<Source>(count + 1); |
| 6150 unitSources[0] = library.definingCompilationUnit.source; | 6150 unitSources[0] = library.definingCompilationUnit.source; |
| 6151 for (int i = 0; i < count; i++) { | 6151 for (int i = 0; i < count; i++) { |
| 6152 Source unitSource = parts[i].source; | 6152 Source unitSource = parts[i].source; |
| 6153 unitSources[i + 1] = unitSource; | 6153 unitSources[i + 1] = unitSource; |
| 6154 DartEntry unitEntry = getReadableDartEntry(unitSource); | 6154 DartEntry unitEntry = _getReadableDartEntry(unitSource); |
| 6155 if (unitSource != null) { | 6155 if (unitSource != null) { |
| 6156 DartEntryImpl unitCopy = unitEntry.writableCopy; | 6156 DartEntryImpl unitCopy = unitEntry.writableCopy; |
| 6157 unitCopy.addContainingLibrary(librarySource); | 6157 unitCopy.addContainingLibrary(librarySource); |
| 6158 _cache.put(unitSource, unitCopy); | 6158 _cache.put(unitSource, unitCopy); |
| 6159 } | 6159 } |
| 6160 } | 6160 } |
| 6161 dartCopy.setValue(DartEntry.INCLUDED_PARTS, unitSources); | 6161 dartCopy.setValue(DartEntry.INCLUDED_PARTS, unitSources); |
| 6162 } | 6162 } |
| 6163 | 6163 |
| 6164 /** | 6164 /** |
| 6165 * Record the results produced by performing a [GenerateDartErrorsTask]. If th
e results were | 6165 * Record the results produced by performing a [GenerateDartErrorsTask]. If th
e results were |
| 6166 * computed from data that is now out-of-date, then the results will not be re
corded. | 6166 * computed from data that is now out-of-date, then the results will not be re
corded. |
| 6167 * | 6167 * |
| 6168 * @param task the task that was performed | 6168 * @param task the task that was performed |
| 6169 * @return an entry containing the computed results | 6169 * @return an entry containing the computed results |
| 6170 * @throws AnalysisException if the results could not be recorded | 6170 * @throws AnalysisException if the results could not be recorded |
| 6171 */ | 6171 */ |
| 6172 DartEntry recordGenerateDartErrorsTask(GenerateDartErrorsTask task) { | 6172 DartEntry _recordGenerateDartErrorsTask(GenerateDartErrorsTask task) { |
| 6173 Source source = task.source; | 6173 Source source = task.source; |
| 6174 Source librarySource = task.libraryElement.source; | 6174 Source librarySource = task.libraryElement.source; |
| 6175 AnalysisException thrownException = task.exception; | 6175 AnalysisException thrownException = task.exception; |
| 6176 DartEntry dartEntry = null; | 6176 DartEntry dartEntry = null; |
| 6177 SourceEntry sourceEntry = _cache.get(source); | 6177 SourceEntry sourceEntry = _cache.get(source); |
| 6178 if (sourceEntry == null) { | 6178 if (sourceEntry == null) { |
| 6179 throw new ObsoleteSourceAnalysisException(source); | 6179 throw new ObsoleteSourceAnalysisException(source); |
| 6180 } else if (sourceEntry is! DartEntry) { | 6180 } else if (sourceEntry is! DartEntry) { |
| 6181 // This shouldn't be possible because we should never have performed the t
ask if the source | 6181 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6182 // didn't represent a Dart file, but check to be safe. | 6182 // didn't represent a Dart file, but check to be safe. |
| 6183 throw new AnalysisException.con1("Internal error: attempting to verify non
-Dart file as a Dart file: ${source.fullName}"); | 6183 throw new AnalysisException.con1("Internal error: attempting to verify non
-Dart file as a Dart file: ${source.fullName}"); |
| 6184 } | 6184 } |
| 6185 dartEntry = sourceEntry as DartEntry; | 6185 dartEntry = sourceEntry as DartEntry; |
| 6186 int sourceTime = getModificationStamp(source); | 6186 int sourceTime = getModificationStamp(source); |
| 6187 int resultTime = task.modificationTime; | 6187 int resultTime = task.modificationTime; |
| 6188 if (sourceTime == resultTime) { | 6188 if (sourceTime == resultTime) { |
| 6189 if (dartEntry.modificationTime != sourceTime) { | 6189 if (dartEntry.modificationTime != sourceTime) { |
| 6190 // The source has changed without the context being notified. Simulate n
otification. | 6190 // The source has changed without the context being notified. Simulate n
otification. |
| 6191 sourceChanged(source); | 6191 _sourceChanged(source); |
| 6192 dartEntry = getReadableDartEntry(source); | 6192 dartEntry = _getReadableDartEntry(source); |
| 6193 if (dartEntry == null) { | 6193 if (dartEntry == null) { |
| 6194 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); | 6194 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); |
| 6195 } | 6195 } |
| 6196 } | 6196 } |
| 6197 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6197 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6198 if (thrownException == null) { | 6198 if (thrownException == null) { |
| 6199 dartCopy.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource,
task.errors); | 6199 dartCopy.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource,
task.errors); |
| 6200 ChangeNoticeImpl notice = getNotice(source); | 6200 ChangeNoticeImpl notice = _getNotice(source); |
| 6201 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LINE_
INFO)); | 6201 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LINE_
INFO)); |
| 6202 } else { | 6202 } else { |
| 6203 dartCopy.setStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource,
CacheState.ERROR); | 6203 dartCopy.setStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource,
CacheState.ERROR); |
| 6204 } | 6204 } |
| 6205 dartCopy.exception = thrownException; | 6205 dartCopy.exception = thrownException; |
| 6206 _cache.put(source, dartCopy); | 6206 _cache.put(source, dartCopy); |
| 6207 dartEntry = dartCopy; | 6207 dartEntry = dartCopy; |
| 6208 } else { | 6208 } else { |
| 6209 logInformation2("Generated errors discarded for ${debuggingString(source)}
; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntr
y.modificationTime}", thrownException); | 6209 _logInformation2("Generated errors discarded for ${_debuggingString(source
)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEn
try.modificationTime}", thrownException); |
| 6210 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6210 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6211 if (thrownException == null || resultTime >= 0) { | 6211 if (thrownException == null || resultTime >= 0) { |
| 6212 // | 6212 // |
| 6213 // The analysis was performed on out-of-date sources. Mark the cache so
that the source | 6213 // The analysis was performed on out-of-date sources. Mark the cache so
that the source |
| 6214 // will be re-verified using the up-to-date sources. | 6214 // will be re-verified using the up-to-date sources. |
| 6215 // | 6215 // |
| 6216 // dartCopy.setState(DartEntry.VERIFICATION_ERRORS, librarySour
ce, CacheState.INVALID); | 6216 // dartCopy.setState(DartEntry.VERIFICATION_ERRORS, librarySour
ce, CacheState.INVALID); |
| 6217 removeFromParts(source, dartEntry); | 6217 _removeFromParts(source, dartEntry); |
| 6218 dartCopy.invalidateAllInformation(); | 6218 dartCopy.invalidateAllInformation(); |
| 6219 dartCopy.modificationTime = sourceTime; | 6219 dartCopy.modificationTime = sourceTime; |
| 6220 _cache.removedAst(source); | 6220 _cache.removedAst(source); |
| 6221 _workManager.add(source, SourcePriority.UNKNOWN); | 6221 _workManager.add(source, SourcePriority.UNKNOWN); |
| 6222 } else { | 6222 } else { |
| 6223 // | 6223 // |
| 6224 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the | 6224 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the |
| 6225 // cache so that we won't attempt to re-verify the source until there's
a good chance | 6225 // cache so that we won't attempt to re-verify the source until there's
a good chance |
| 6226 // that we'll be able to do so without error. | 6226 // that we'll be able to do so without error. |
| 6227 // | 6227 // |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6238 } | 6238 } |
| 6239 | 6239 |
| 6240 /** | 6240 /** |
| 6241 * Record the results produced by performing a [GenerateDartHintsTask]. If the
results were | 6241 * Record the results produced by performing a [GenerateDartHintsTask]. If the
results were |
| 6242 * computed from data that is now out-of-date, then the results will not be re
corded. | 6242 * computed from data that is now out-of-date, then the results will not be re
corded. |
| 6243 * | 6243 * |
| 6244 * @param task the task that was performed | 6244 * @param task the task that was performed |
| 6245 * @return an entry containing the computed results | 6245 * @return an entry containing the computed results |
| 6246 * @throws AnalysisException if the results could not be recorded | 6246 * @throws AnalysisException if the results could not be recorded |
| 6247 */ | 6247 */ |
| 6248 DartEntry recordGenerateDartHintsTask(GenerateDartHintsTask task) { | 6248 DartEntry _recordGenerateDartHintsTask(GenerateDartHintsTask task) { |
| 6249 Source librarySource = task.libraryElement.source; | 6249 Source librarySource = task.libraryElement.source; |
| 6250 AnalysisException thrownException = task.exception; | 6250 AnalysisException thrownException = task.exception; |
| 6251 DartEntry libraryEntry = null; | 6251 DartEntry libraryEntry = null; |
| 6252 Map<Source, TimestampedData<List<AnalysisError>>> hintMap = task.hintMap; | 6252 Map<Source, TimestampedData<List<AnalysisError>>> hintMap = task.hintMap; |
| 6253 if (hintMap == null) { | 6253 if (hintMap == null) { |
| 6254 // We don't have any information about which sources to mark as invalid ot
her than the library | 6254 // We don't have any information about which sources to mark as invalid ot
her than the library |
| 6255 // source. | 6255 // source. |
| 6256 SourceEntry sourceEntry = _cache.get(librarySource); | 6256 SourceEntry sourceEntry = _cache.get(librarySource); |
| 6257 if (sourceEntry == null) { | 6257 if (sourceEntry == null) { |
| 6258 throw new ObsoleteSourceAnalysisException(librarySource); | 6258 throw new ObsoleteSourceAnalysisException(librarySource); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 6281 } | 6281 } |
| 6282 DartEntry dartEntry = sourceEntry as DartEntry; | 6282 DartEntry dartEntry = sourceEntry as DartEntry; |
| 6283 if (unitSource == librarySource) { | 6283 if (unitSource == librarySource) { |
| 6284 libraryEntry = dartEntry; | 6284 libraryEntry = dartEntry; |
| 6285 } | 6285 } |
| 6286 int sourceTime = getModificationStamp(unitSource); | 6286 int sourceTime = getModificationStamp(unitSource); |
| 6287 int resultTime = results.modificationTime; | 6287 int resultTime = results.modificationTime; |
| 6288 if (sourceTime == resultTime) { | 6288 if (sourceTime == resultTime) { |
| 6289 if (dartEntry.modificationTime != sourceTime) { | 6289 if (dartEntry.modificationTime != sourceTime) { |
| 6290 // The source has changed without the context being notified. Simulate
notification. | 6290 // The source has changed without the context being notified. Simulate
notification. |
| 6291 sourceChanged(unitSource); | 6291 _sourceChanged(unitSource); |
| 6292 dartEntry = getReadableDartEntry(unitSource); | 6292 dartEntry = _getReadableDartEntry(unitSource); |
| 6293 if (dartEntry == null) { | 6293 if (dartEntry == null) { |
| 6294 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${unitSource.fullName}"); | 6294 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${unitSource.fullName}"); |
| 6295 } | 6295 } |
| 6296 } | 6296 } |
| 6297 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6297 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6298 if (thrownException == null) { | 6298 if (thrownException == null) { |
| 6299 dartCopy.setValueInLibrary(DartEntry.HINTS, librarySource, results.dat
a); | 6299 dartCopy.setValueInLibrary(DartEntry.HINTS, librarySource, results.dat
a); |
| 6300 ChangeNoticeImpl notice = getNotice(unitSource); | 6300 ChangeNoticeImpl notice = _getNotice(unitSource); |
| 6301 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LIN
E_INFO)); | 6301 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LIN
E_INFO)); |
| 6302 } else { | 6302 } else { |
| 6303 dartCopy.setStateInLibrary(DartEntry.HINTS, librarySource, CacheState.
ERROR); | 6303 dartCopy.setStateInLibrary(DartEntry.HINTS, librarySource, CacheState.
ERROR); |
| 6304 } | 6304 } |
| 6305 dartCopy.exception = thrownException; | 6305 dartCopy.exception = thrownException; |
| 6306 _cache.put(unitSource, dartCopy); | 6306 _cache.put(unitSource, dartCopy); |
| 6307 dartEntry = dartCopy; | 6307 dartEntry = dartCopy; |
| 6308 } else { | 6308 } else { |
| 6309 logInformation2("Generated hints discarded for ${debuggingString(unitSou
rce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dar
tEntry.modificationTime}", thrownException); | 6309 _logInformation2("Generated hints discarded for ${_debuggingString(unitS
ource)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${d
artEntry.modificationTime}", thrownException); |
| 6310 if (identical(dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource
), CacheState.IN_PROCESS)) { | 6310 if (identical(dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource
), CacheState.IN_PROCESS)) { |
| 6311 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6311 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6312 if (thrownException == null || resultTime >= 0) { | 6312 if (thrownException == null || resultTime >= 0) { |
| 6313 // | 6313 // |
| 6314 // The analysis was performed on out-of-date sources. Mark the cache
so that the sources | 6314 // The analysis was performed on out-of-date sources. Mark the cache
so that the sources |
| 6315 // will be re-analyzed using the up-to-date sources. | 6315 // will be re-analyzed using the up-to-date sources. |
| 6316 // | 6316 // |
| 6317 // dartCopy.setState(DartEntry.HINTS, librarySource, Ca
cheState.INVALID); | 6317 // dartCopy.setState(DartEntry.HINTS, librarySource, Ca
cheState.INVALID); |
| 6318 removeFromParts(unitSource, dartEntry); | 6318 _removeFromParts(unitSource, dartEntry); |
| 6319 dartCopy.invalidateAllInformation(); | 6319 dartCopy.invalidateAllInformation(); |
| 6320 dartCopy.modificationTime = sourceTime; | 6320 dartCopy.modificationTime = sourceTime; |
| 6321 _cache.removedAst(unitSource); | 6321 _cache.removedAst(unitSource); |
| 6322 _workManager.add(unitSource, SourcePriority.UNKNOWN); | 6322 _workManager.add(unitSource, SourcePriority.UNKNOWN); |
| 6323 } else { | 6323 } else { |
| 6324 // | 6324 // |
| 6325 // We could not determine whether the sources were up-to-date or out
-of-date. Mark the | 6325 // We could not determine whether the sources were up-to-date or out
-of-date. Mark the |
| 6326 // cache so that we won't attempt to re-analyze the sources until th
ere's a good chance | 6326 // cache so that we won't attempt to re-analyze the sources until th
ere's a good chance |
| 6327 // that we'll be able to do so without error. | 6327 // that we'll be able to do so without error. |
| 6328 // | 6328 // |
| (...skipping 11 matching lines...) Expand all Loading... |
| 6340 return libraryEntry; | 6340 return libraryEntry; |
| 6341 } | 6341 } |
| 6342 | 6342 |
| 6343 /** | 6343 /** |
| 6344 * Record the results produced by performing a [GetContentTask]. | 6344 * Record the results produced by performing a [GetContentTask]. |
| 6345 * | 6345 * |
| 6346 * @param task the task that was performed | 6346 * @param task the task that was performed |
| 6347 * @return an entry containing the computed results | 6347 * @return an entry containing the computed results |
| 6348 * @throws AnalysisException if the results could not be recorded | 6348 * @throws AnalysisException if the results could not be recorded |
| 6349 */ | 6349 */ |
| 6350 SourceEntry recordGetContentsTask(GetContentTask task) { | 6350 SourceEntry _recordGetContentsTask(GetContentTask task) { |
| 6351 if (!task.isComplete) { | 6351 if (!task.isComplete) { |
| 6352 return null; | 6352 return null; |
| 6353 } | 6353 } |
| 6354 Source source = task.source; | 6354 Source source = task.source; |
| 6355 AnalysisException thrownException = task.exception; | 6355 AnalysisException thrownException = task.exception; |
| 6356 SourceEntry sourceEntry = null; | 6356 SourceEntry sourceEntry = null; |
| 6357 sourceEntry = _cache.get(source); | 6357 sourceEntry = _cache.get(source); |
| 6358 if (sourceEntry == null) { | 6358 if (sourceEntry == null) { |
| 6359 throw new ObsoleteSourceAnalysisException(source); | 6359 throw new ObsoleteSourceAnalysisException(source); |
| 6360 } | 6360 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 6375 return sourceEntry; | 6375 return sourceEntry; |
| 6376 } | 6376 } |
| 6377 | 6377 |
| 6378 /** | 6378 /** |
| 6379 * Record the results produced by performing a [IncrementalAnalysisTask]. | 6379 * Record the results produced by performing a [IncrementalAnalysisTask]. |
| 6380 * | 6380 * |
| 6381 * @param task the task that was performed | 6381 * @param task the task that was performed |
| 6382 * @return an entry containing the computed results | 6382 * @return an entry containing the computed results |
| 6383 * @throws AnalysisException if the results could not be recorded | 6383 * @throws AnalysisException if the results could not be recorded |
| 6384 */ | 6384 */ |
| 6385 DartEntry recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task) { | 6385 DartEntry _recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task)
{ |
| 6386 CompilationUnit unit = task.compilationUnit; | 6386 CompilationUnit unit = task.compilationUnit; |
| 6387 if (unit != null) { | 6387 if (unit != null) { |
| 6388 ChangeNoticeImpl notice = getNotice(task.source); | 6388 ChangeNoticeImpl notice = _getNotice(task.source); |
| 6389 notice.compilationUnit = unit; | 6389 notice.compilationUnit = unit; |
| 6390 _incrementalAnalysisCache = IncrementalAnalysisCache.cacheResult(task.cach
e, unit); | 6390 _incrementalAnalysisCache = IncrementalAnalysisCache.cacheResult(task.cach
e, unit); |
| 6391 } | 6391 } |
| 6392 return null; | 6392 return null; |
| 6393 } | 6393 } |
| 6394 | 6394 |
| 6395 /** | 6395 /** |
| 6396 * Record the results produced by performing a [ParseDartTask]. If the results
were computed | 6396 * Record the results produced by performing a [ParseDartTask]. If the results
were computed |
| 6397 * from data that is now out-of-date, then the results will not be recorded. | 6397 * from data that is now out-of-date, then the results will not be recorded. |
| 6398 * | 6398 * |
| 6399 * @param task the task that was performed | 6399 * @param task the task that was performed |
| 6400 * @return an entry containing the computed results | 6400 * @return an entry containing the computed results |
| 6401 * @throws AnalysisException if the results could not be recorded | 6401 * @throws AnalysisException if the results could not be recorded |
| 6402 */ | 6402 */ |
| 6403 DartEntry recordParseDartTaskResults(ParseDartTask task) { | 6403 DartEntry _recordParseDartTaskResults(ParseDartTask task) { |
| 6404 Source source = task.source; | 6404 Source source = task.source; |
| 6405 AnalysisException thrownException = task.exception; | 6405 AnalysisException thrownException = task.exception; |
| 6406 DartEntry dartEntry = null; | 6406 DartEntry dartEntry = null; |
| 6407 SourceEntry sourceEntry = _cache.get(source); | 6407 SourceEntry sourceEntry = _cache.get(source); |
| 6408 if (sourceEntry == null) { | 6408 if (sourceEntry == null) { |
| 6409 throw new ObsoleteSourceAnalysisException(source); | 6409 throw new ObsoleteSourceAnalysisException(source); |
| 6410 } else if (sourceEntry is! DartEntry) { | 6410 } else if (sourceEntry is! DartEntry) { |
| 6411 // This shouldn't be possible because we should never have performed the t
ask if the source | 6411 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6412 // didn't represent a Dart file, but check to be safe. | 6412 // didn't represent a Dart file, but check to be safe. |
| 6413 throw new AnalysisException.con1("Internal error: attempting to parse non-
Dart file as a Dart file: ${source.fullName}"); | 6413 throw new AnalysisException.con1("Internal error: attempting to parse non-
Dart file as a Dart file: ${source.fullName}"); |
| 6414 } | 6414 } |
| 6415 dartEntry = sourceEntry as DartEntry; | 6415 dartEntry = sourceEntry as DartEntry; |
| 6416 int sourceTime = getModificationStamp(source); | 6416 int sourceTime = getModificationStamp(source); |
| 6417 int resultTime = task.modificationTime; | 6417 int resultTime = task.modificationTime; |
| 6418 if (sourceTime == resultTime) { | 6418 if (sourceTime == resultTime) { |
| 6419 if (dartEntry.modificationTime != sourceTime) { | 6419 if (dartEntry.modificationTime != sourceTime) { |
| 6420 // The source has changed without the context being notified. Simulate n
otification. | 6420 // The source has changed without the context being notified. Simulate n
otification. |
| 6421 sourceChanged(source); | 6421 _sourceChanged(source); |
| 6422 dartEntry = getReadableDartEntry(source); | 6422 dartEntry = _getReadableDartEntry(source); |
| 6423 if (dartEntry == null) { | 6423 if (dartEntry == null) { |
| 6424 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); | 6424 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); |
| 6425 } | 6425 } |
| 6426 } | 6426 } |
| 6427 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6427 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6428 if (thrownException == null) { | 6428 if (thrownException == null) { |
| 6429 if (task.hasPartOfDirective && !task.hasLibraryDirective) { | 6429 if (task.hasPartOfDirective && !task.hasLibraryDirective) { |
| 6430 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); | 6430 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); |
| 6431 dartCopy.removeContainingLibrary(source); | 6431 dartCopy.removeContainingLibrary(source); |
| 6432 _workManager.add(source, SourcePriority.NORMAL_PART); | 6432 _workManager.add(source, SourcePriority.NORMAL_PART); |
| 6433 } else { | 6433 } else { |
| 6434 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); | 6434 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); |
| 6435 dartCopy.containingLibrary = source; | 6435 dartCopy.containingLibrary = source; |
| 6436 _workManager.add(source, SourcePriority.LIBRARY); | 6436 _workManager.add(source, SourcePriority.LIBRARY); |
| 6437 } | 6437 } |
| 6438 dartCopy.setValue(DartEntry.PARSED_UNIT, task.compilationUnit); | 6438 dartCopy.setValue(DartEntry.PARSED_UNIT, task.compilationUnit); |
| 6439 dartCopy.setValue(DartEntry.PARSE_ERRORS, task.errors); | 6439 dartCopy.setValue(DartEntry.PARSE_ERRORS, task.errors); |
| 6440 _cache.storedAst(source); | 6440 _cache.storedAst(source); |
| 6441 ChangeNoticeImpl notice = getNotice(source); | 6441 ChangeNoticeImpl notice = _getNotice(source); |
| 6442 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LINE_
INFO)); | 6442 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LINE_
INFO)); |
| 6443 // Verify that the incrementally parsed and resolved unit in the increme
ntal cache | 6443 // Verify that the incrementally parsed and resolved unit in the increme
ntal cache |
| 6444 // is structurally equivalent to the fully parsed unit | 6444 // is structurally equivalent to the fully parsed unit |
| 6445 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_in
crementalAnalysisCache, source, task.compilationUnit); | 6445 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_in
crementalAnalysisCache, source, task.compilationUnit); |
| 6446 } else { | 6446 } else { |
| 6447 removeFromParts(source, dartEntry); | 6447 _removeFromParts(source, dartEntry); |
| 6448 dartCopy.recordParseError(); | 6448 dartCopy.recordParseError(); |
| 6449 _cache.removedAst(source); | 6449 _cache.removedAst(source); |
| 6450 } | 6450 } |
| 6451 dartCopy.exception = thrownException; | 6451 dartCopy.exception = thrownException; |
| 6452 _cache.put(source, dartCopy); | 6452 _cache.put(source, dartCopy); |
| 6453 dartEntry = dartCopy; | 6453 dartEntry = dartCopy; |
| 6454 } else { | 6454 } else { |
| 6455 logInformation2("Parse results discarded for ${debuggingString(source)}; s
ourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry.m
odificationTime}", thrownException); | 6455 _logInformation2("Parse results discarded for ${_debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry
.modificationTime}", thrownException); |
| 6456 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6456 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6457 if (thrownException == null || resultTime >= 0) { | 6457 if (thrownException == null || resultTime >= 0) { |
| 6458 // | 6458 // |
| 6459 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources | 6459 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources |
| 6460 // will be re-analyzed using the up-to-date sources. | 6460 // will be re-analyzed using the up-to-date sources. |
| 6461 // | 6461 // |
| 6462 // dartCopy.recordParseNotInProcess(); | 6462 // dartCopy.recordParseNotInProcess(); |
| 6463 removeFromParts(source, dartEntry); | 6463 _removeFromParts(source, dartEntry); |
| 6464 dartCopy.invalidateAllInformation(); | 6464 dartCopy.invalidateAllInformation(); |
| 6465 dartCopy.modificationTime = sourceTime; | 6465 dartCopy.modificationTime = sourceTime; |
| 6466 _cache.removedAst(source); | 6466 _cache.removedAst(source); |
| 6467 _workManager.add(source, SourcePriority.UNKNOWN); | 6467 _workManager.add(source, SourcePriority.UNKNOWN); |
| 6468 } else { | 6468 } else { |
| 6469 // | 6469 // |
| 6470 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the | 6470 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the |
| 6471 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance | 6471 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance |
| 6472 // that we'll be able to do so without error. | 6472 // that we'll be able to do so without error. |
| 6473 // | 6473 // |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6484 } | 6484 } |
| 6485 | 6485 |
| 6486 /** | 6486 /** |
| 6487 * Record the results produced by performing a [ParseHtmlTask]. If the results
were computed | 6487 * Record the results produced by performing a [ParseHtmlTask]. If the results
were computed |
| 6488 * from data that is now out-of-date, then the results will not be recorded. | 6488 * from data that is now out-of-date, then the results will not be recorded. |
| 6489 * | 6489 * |
| 6490 * @param task the task that was performed | 6490 * @param task the task that was performed |
| 6491 * @return an entry containing the computed results | 6491 * @return an entry containing the computed results |
| 6492 * @throws AnalysisException if the results could not be recorded | 6492 * @throws AnalysisException if the results could not be recorded |
| 6493 */ | 6493 */ |
| 6494 HtmlEntry recordParseHtmlTaskResults(ParseHtmlTask task) { | 6494 HtmlEntry _recordParseHtmlTaskResults(ParseHtmlTask task) { |
| 6495 Source source = task.source; | 6495 Source source = task.source; |
| 6496 AnalysisException thrownException = task.exception; | 6496 AnalysisException thrownException = task.exception; |
| 6497 HtmlEntry htmlEntry = null; | 6497 HtmlEntry htmlEntry = null; |
| 6498 SourceEntry sourceEntry = _cache.get(source); | 6498 SourceEntry sourceEntry = _cache.get(source); |
| 6499 if (sourceEntry == null) { | 6499 if (sourceEntry == null) { |
| 6500 throw new ObsoleteSourceAnalysisException(source); | 6500 throw new ObsoleteSourceAnalysisException(source); |
| 6501 } else if (sourceEntry is! HtmlEntry) { | 6501 } else if (sourceEntry is! HtmlEntry) { |
| 6502 // This shouldn't be possible because we should never have performed the t
ask if the source | 6502 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6503 // didn't represent an HTML file, but check to be safe. | 6503 // didn't represent an HTML file, but check to be safe. |
| 6504 throw new AnalysisException.con1("Internal error: attempting to parse non-
HTML file as a HTML file: ${source.fullName}"); | 6504 throw new AnalysisException.con1("Internal error: attempting to parse non-
HTML file as a HTML file: ${source.fullName}"); |
| 6505 } | 6505 } |
| 6506 htmlEntry = sourceEntry as HtmlEntry; | 6506 htmlEntry = sourceEntry as HtmlEntry; |
| 6507 int sourceTime = getModificationStamp(source); | 6507 int sourceTime = getModificationStamp(source); |
| 6508 int resultTime = task.modificationTime; | 6508 int resultTime = task.modificationTime; |
| 6509 if (sourceTime == resultTime) { | 6509 if (sourceTime == resultTime) { |
| 6510 if (htmlEntry.modificationTime != sourceTime) { | 6510 if (htmlEntry.modificationTime != sourceTime) { |
| 6511 // The source has changed without the context being notified. Simulate n
otification. | 6511 // The source has changed without the context being notified. Simulate n
otification. |
| 6512 sourceChanged(source); | 6512 _sourceChanged(source); |
| 6513 htmlEntry = getReadableHtmlEntry(source); | 6513 htmlEntry = _getReadableHtmlEntry(source); |
| 6514 if (htmlEntry == null) { | 6514 if (htmlEntry == null) { |
| 6515 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); | 6515 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); |
| 6516 } | 6516 } |
| 6517 } | 6517 } |
| 6518 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; | 6518 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; |
| 6519 if (thrownException == null) { | 6519 if (thrownException == null) { |
| 6520 LineInfo lineInfo = task.lineInfo; | 6520 LineInfo lineInfo = task.lineInfo; |
| 6521 ht.HtmlUnit unit = task.htmlUnit; | 6521 ht.HtmlUnit unit = task.htmlUnit; |
| 6522 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | 6522 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 6523 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); | 6523 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); |
| 6524 htmlCopy.setValue(HtmlEntry.PARSE_ERRORS, task.errors); | 6524 htmlCopy.setValue(HtmlEntry.PARSE_ERRORS, task.errors); |
| 6525 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibrari
es); | 6525 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibrari
es); |
| 6526 _cache.storedAst(source); | 6526 _cache.storedAst(source); |
| 6527 ChangeNoticeImpl notice = getNotice(source); | 6527 ChangeNoticeImpl notice = _getNotice(source); |
| 6528 notice.setErrors(htmlCopy.allErrors, lineInfo); | 6528 notice.setErrors(htmlCopy.allErrors, lineInfo); |
| 6529 } else { | 6529 } else { |
| 6530 htmlCopy.recordParseError(); | 6530 htmlCopy.recordParseError(); |
| 6531 _cache.removedAst(source); | 6531 _cache.removedAst(source); |
| 6532 } | 6532 } |
| 6533 htmlCopy.exception = thrownException; | 6533 htmlCopy.exception = thrownException; |
| 6534 _cache.put(source, htmlCopy); | 6534 _cache.put(source, htmlCopy); |
| 6535 htmlEntry = htmlCopy; | 6535 htmlEntry = htmlCopy; |
| 6536 } else { | 6536 } else { |
| 6537 logInformation2("Parse results discarded for ${debuggingString(source)}; s
ourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry.m
odificationTime}", thrownException); | 6537 _logInformation2("Parse results discarded for ${_debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry
.modificationTime}", thrownException); |
| 6538 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; | 6538 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; |
| 6539 if (thrownException == null || resultTime >= 0) { | 6539 if (thrownException == null || resultTime >= 0) { |
| 6540 // | 6540 // |
| 6541 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources | 6541 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources |
| 6542 // will be re-analyzed using the up-to-date sources. | 6542 // will be re-analyzed using the up-to-date sources. |
| 6543 // | 6543 // |
| 6544 // if (htmlCopy.getState(SourceEntry.LINE_INFO) == CacheState.I
N_PROCESS) { | 6544 // if (htmlCopy.getState(SourceEntry.LINE_INFO) == CacheState.I
N_PROCESS) { |
| 6545 // htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALI
D); | 6545 // htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALI
D); |
| 6546 // } | 6546 // } |
| 6547 // if (htmlCopy.getState(HtmlEntry.PARSED_UNIT) == CacheState.I
N_PROCESS) { | 6547 // if (htmlCopy.getState(HtmlEntry.PARSED_UNIT) == CacheState.I
N_PROCESS) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 6574 return htmlEntry; | 6574 return htmlEntry; |
| 6575 } | 6575 } |
| 6576 | 6576 |
| 6577 /** | 6577 /** |
| 6578 * Record the results produced by performing a [ResolveAngularComponentTemplat
eTask]. If the | 6578 * Record the results produced by performing a [ResolveAngularComponentTemplat
eTask]. If the |
| 6579 * results were computed from data that is now out-of-date, then the results w
ill not be recorded. | 6579 * results were computed from data that is now out-of-date, then the results w
ill not be recorded. |
| 6580 * | 6580 * |
| 6581 * @param task the task that was performed | 6581 * @param task the task that was performed |
| 6582 * @throws AnalysisException if the results could not be recorded | 6582 * @throws AnalysisException if the results could not be recorded |
| 6583 */ | 6583 */ |
| 6584 HtmlEntry recordResolveAngularComponentTemplateTaskResults(ResolveAngularCompo
nentTemplateTask task) { | 6584 HtmlEntry _recordResolveAngularComponentTemplateTaskResults(ResolveAngularComp
onentTemplateTask task) { |
| 6585 Source source = task.source; | 6585 Source source = task.source; |
| 6586 AnalysisException thrownException = task.exception; | 6586 AnalysisException thrownException = task.exception; |
| 6587 HtmlEntry htmlEntry = null; | 6587 HtmlEntry htmlEntry = null; |
| 6588 SourceEntry sourceEntry = _cache.get(source); | 6588 SourceEntry sourceEntry = _cache.get(source); |
| 6589 if (sourceEntry == null) { | 6589 if (sourceEntry == null) { |
| 6590 throw new ObsoleteSourceAnalysisException(source); | 6590 throw new ObsoleteSourceAnalysisException(source); |
| 6591 } else if (sourceEntry is! HtmlEntry) { | 6591 } else if (sourceEntry is! HtmlEntry) { |
| 6592 // This shouldn't be possible because we should never have performed the t
ask if the source | 6592 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6593 // didn't represent an HTML file, but check to be safe. | 6593 // didn't represent an HTML file, but check to be safe. |
| 6594 throw new AnalysisException.con1("Internal error: attempting to resolve no
n-HTML file as an HTML file: ${source.fullName}"); | 6594 throw new AnalysisException.con1("Internal error: attempting to resolve no
n-HTML file as an HTML file: ${source.fullName}"); |
| 6595 } | 6595 } |
| 6596 htmlEntry = sourceEntry as HtmlEntry; | 6596 htmlEntry = sourceEntry as HtmlEntry; |
| 6597 int sourceTime = getModificationStamp(source); | 6597 int sourceTime = getModificationStamp(source); |
| 6598 int resultTime = task.modificationTime; | 6598 int resultTime = task.modificationTime; |
| 6599 if (sourceTime == resultTime) { | 6599 if (sourceTime == resultTime) { |
| 6600 if (htmlEntry.modificationTime != sourceTime) { | 6600 if (htmlEntry.modificationTime != sourceTime) { |
| 6601 // The source has changed without the context being notified. Simulate n
otification. | 6601 // The source has changed without the context being notified. Simulate n
otification. |
| 6602 sourceChanged(source); | 6602 _sourceChanged(source); |
| 6603 htmlEntry = getReadableHtmlEntry(source); | 6603 htmlEntry = _getReadableHtmlEntry(source); |
| 6604 if (htmlEntry == null) { | 6604 if (htmlEntry == null) { |
| 6605 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); | 6605 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); |
| 6606 } | 6606 } |
| 6607 } | 6607 } |
| 6608 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 6608 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 6609 if (thrownException == null) { | 6609 if (thrownException == null) { |
| 6610 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors); | 6610 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors); |
| 6611 // notify about errors | 6611 // notify about errors |
| 6612 ChangeNoticeImpl notice = getNotice(source); | 6612 ChangeNoticeImpl notice = _getNotice(source); |
| 6613 notice.htmlUnit = task.resolvedUnit; | 6613 notice.htmlUnit = task.resolvedUnit; |
| 6614 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_
INFO)); | 6614 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_
INFO)); |
| 6615 } else { | 6615 } else { |
| 6616 htmlCopy.recordResolutionError(); | 6616 htmlCopy.recordResolutionError(); |
| 6617 } | 6617 } |
| 6618 htmlCopy.exception = thrownException; | 6618 htmlCopy.exception = thrownException; |
| 6619 _cache.put(source, htmlCopy); | 6619 _cache.put(source, htmlCopy); |
| 6620 htmlEntry = htmlCopy; | 6620 htmlEntry = htmlCopy; |
| 6621 } else { | 6621 } else { |
| 6622 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 6622 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6655 return htmlEntry; | 6655 return htmlEntry; |
| 6656 } | 6656 } |
| 6657 | 6657 |
| 6658 /** | 6658 /** |
| 6659 * Record the results produced by performing a [ResolveAngularEntryHtmlTask].
If the results | 6659 * Record the results produced by performing a [ResolveAngularEntryHtmlTask].
If the results |
| 6660 * were computed from data that is now out-of-date, then the results will not
be recorded. | 6660 * were computed from data that is now out-of-date, then the results will not
be recorded. |
| 6661 * | 6661 * |
| 6662 * @param task the task that was performed | 6662 * @param task the task that was performed |
| 6663 * @throws AnalysisException if the results could not be recorded | 6663 * @throws AnalysisException if the results could not be recorded |
| 6664 */ | 6664 */ |
| 6665 HtmlEntry recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTask
task) { | 6665 HtmlEntry _recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTas
k task) { |
| 6666 Source source = task.source; | 6666 Source source = task.source; |
| 6667 AnalysisException thrownException = task.exception; | 6667 AnalysisException thrownException = task.exception; |
| 6668 HtmlEntry htmlEntry = null; | 6668 HtmlEntry htmlEntry = null; |
| 6669 SourceEntry sourceEntry = _cache.get(source); | 6669 SourceEntry sourceEntry = _cache.get(source); |
| 6670 if (sourceEntry == null) { | 6670 if (sourceEntry == null) { |
| 6671 throw new ObsoleteSourceAnalysisException(source); | 6671 throw new ObsoleteSourceAnalysisException(source); |
| 6672 } else if (sourceEntry is! HtmlEntry) { | 6672 } else if (sourceEntry is! HtmlEntry) { |
| 6673 // This shouldn't be possible because we should never have performed the t
ask if the source | 6673 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6674 // didn't represent an HTML file, but check to be safe. | 6674 // didn't represent an HTML file, but check to be safe. |
| 6675 throw new AnalysisException.con1("Internal error: attempting to resolve no
n-HTML file as an HTML file: ${source.fullName}"); | 6675 throw new AnalysisException.con1("Internal error: attempting to resolve no
n-HTML file as an HTML file: ${source.fullName}"); |
| 6676 } | 6676 } |
| 6677 htmlEntry = sourceEntry as HtmlEntry; | 6677 htmlEntry = sourceEntry as HtmlEntry; |
| 6678 int sourceTime = getModificationStamp(source); | 6678 int sourceTime = getModificationStamp(source); |
| 6679 int resultTime = task.modificationTime; | 6679 int resultTime = task.modificationTime; |
| 6680 if (sourceTime == resultTime) { | 6680 if (sourceTime == resultTime) { |
| 6681 if (htmlEntry.modificationTime != sourceTime) { | 6681 if (htmlEntry.modificationTime != sourceTime) { |
| 6682 // The source has changed without the context being notified. Simulate n
otification. | 6682 // The source has changed without the context being notified. Simulate n
otification. |
| 6683 sourceChanged(source); | 6683 _sourceChanged(source); |
| 6684 htmlEntry = getReadableHtmlEntry(source); | 6684 htmlEntry = _getReadableHtmlEntry(source); |
| 6685 if (htmlEntry == null) { | 6685 if (htmlEntry == null) { |
| 6686 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); | 6686 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); |
| 6687 } | 6687 } |
| 6688 } | 6688 } |
| 6689 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 6689 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 6690 if (thrownException == null) { | 6690 if (thrownException == null) { |
| 6691 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); | 6691 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); |
| 6692 recordAngularEntryPoint(htmlCopy, task); | 6692 _recordAngularEntryPoint(htmlCopy, task); |
| 6693 _cache.storedAst(source); | 6693 _cache.storedAst(source); |
| 6694 ChangeNoticeImpl notice = getNotice(source); | 6694 ChangeNoticeImpl notice = _getNotice(source); |
| 6695 notice.htmlUnit = task.resolvedUnit; | 6695 notice.htmlUnit = task.resolvedUnit; |
| 6696 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_
INFO)); | 6696 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_
INFO)); |
| 6697 } else { | 6697 } else { |
| 6698 htmlCopy.recordResolutionError(); | 6698 htmlCopy.recordResolutionError(); |
| 6699 } | 6699 } |
| 6700 htmlCopy.exception = thrownException; | 6700 htmlCopy.exception = thrownException; |
| 6701 _cache.put(source, htmlCopy); | 6701 _cache.put(source, htmlCopy); |
| 6702 htmlEntry = htmlCopy; | 6702 htmlEntry = htmlCopy; |
| 6703 } else { | 6703 } else { |
| 6704 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 6704 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6738 } | 6738 } |
| 6739 | 6739 |
| 6740 /** | 6740 /** |
| 6741 * Record the results produced by performing a [ResolveDartDependenciesTask].
If the results | 6741 * Record the results produced by performing a [ResolveDartDependenciesTask].
If the results |
| 6742 * were computed from data that is now out-of-date, then the results will not
be recorded. | 6742 * were computed from data that is now out-of-date, then the results will not
be recorded. |
| 6743 * | 6743 * |
| 6744 * @param task the task that was performed | 6744 * @param task the task that was performed |
| 6745 * @return an entry containing the computed results | 6745 * @return an entry containing the computed results |
| 6746 * @throws AnalysisException if the results could not be recorded | 6746 * @throws AnalysisException if the results could not be recorded |
| 6747 */ | 6747 */ |
| 6748 DartEntry recordResolveDartDependenciesTaskResults(ResolveDartDependenciesTask
task) { | 6748 DartEntry _recordResolveDartDependenciesTaskResults(ResolveDartDependenciesTas
k task) { |
| 6749 Source source = task.source; | 6749 Source source = task.source; |
| 6750 AnalysisException thrownException = task.exception; | 6750 AnalysisException thrownException = task.exception; |
| 6751 DartEntry dartEntry = null; | 6751 DartEntry dartEntry = null; |
| 6752 SourceEntry sourceEntry = _cache.get(source); | 6752 SourceEntry sourceEntry = _cache.get(source); |
| 6753 if (sourceEntry == null) { | 6753 if (sourceEntry == null) { |
| 6754 throw new ObsoleteSourceAnalysisException(source); | 6754 throw new ObsoleteSourceAnalysisException(source); |
| 6755 } else if (sourceEntry is! DartEntry) { | 6755 } else if (sourceEntry is! DartEntry) { |
| 6756 // This shouldn't be possible because we should never have performed the t
ask if the source | 6756 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6757 // didn't represent a Dart file, but check to be safe. | 6757 // didn't represent a Dart file, but check to be safe. |
| 6758 throw new AnalysisException.con1("Internal error: attempting to resolve Da
rt dependencies in a non-Dart file: ${source.fullName}"); | 6758 throw new AnalysisException.con1("Internal error: attempting to resolve Da
rt dependencies in a non-Dart file: ${source.fullName}"); |
| 6759 } | 6759 } |
| 6760 dartEntry = sourceEntry as DartEntry; | 6760 dartEntry = sourceEntry as DartEntry; |
| 6761 int sourceTime = getModificationStamp(source); | 6761 int sourceTime = getModificationStamp(source); |
| 6762 int resultTime = task.modificationTime; | 6762 int resultTime = task.modificationTime; |
| 6763 if (sourceTime == resultTime) { | 6763 if (sourceTime == resultTime) { |
| 6764 if (dartEntry.modificationTime != sourceTime) { | 6764 if (dartEntry.modificationTime != sourceTime) { |
| 6765 // The source has changed without the context being notified. Simulate n
otification. | 6765 // The source has changed without the context being notified. Simulate n
otification. |
| 6766 sourceChanged(source); | 6766 _sourceChanged(source); |
| 6767 dartEntry = getReadableDartEntry(source); | 6767 dartEntry = _getReadableDartEntry(source); |
| 6768 if (dartEntry == null) { | 6768 if (dartEntry == null) { |
| 6769 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); | 6769 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); |
| 6770 } | 6770 } |
| 6771 } | 6771 } |
| 6772 removeFromParts(source, dartEntry); | 6772 _removeFromParts(source, dartEntry); |
| 6773 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6773 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6774 if (thrownException == null) { | 6774 if (thrownException == null) { |
| 6775 List<Source> newParts = task.includedSources; | 6775 List<Source> newParts = task.includedSources; |
| 6776 for (int i = 0; i < newParts.length; i++) { | 6776 for (int i = 0; i < newParts.length; i++) { |
| 6777 Source partSource = newParts[i]; | 6777 Source partSource = newParts[i]; |
| 6778 DartEntry partEntry = getReadableDartEntry(partSource); | 6778 DartEntry partEntry = _getReadableDartEntry(partSource); |
| 6779 if (partEntry != null && partEntry != dartEntry) { | 6779 if (partEntry != null && partEntry != dartEntry) { |
| 6780 DartEntryImpl partCopy = partEntry.writableCopy; | 6780 DartEntryImpl partCopy = partEntry.writableCopy; |
| 6781 partCopy.addContainingLibrary(source); | 6781 partCopy.addContainingLibrary(source); |
| 6782 _cache.put(partSource, partCopy); | 6782 _cache.put(partSource, partCopy); |
| 6783 } | 6783 } |
| 6784 } | 6784 } |
| 6785 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources); | 6785 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources); |
| 6786 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources); | 6786 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources); |
| 6787 dartCopy.setValue(DartEntry.INCLUDED_PARTS, newParts); | 6787 dartCopy.setValue(DartEntry.INCLUDED_PARTS, newParts); |
| 6788 } else { | 6788 } else { |
| 6789 dartCopy.recordDependencyError(); | 6789 dartCopy.recordDependencyError(); |
| 6790 } | 6790 } |
| 6791 dartCopy.exception = thrownException; | 6791 dartCopy.exception = thrownException; |
| 6792 _cache.put(source, dartCopy); | 6792 _cache.put(source, dartCopy); |
| 6793 dartEntry = dartCopy; | 6793 dartEntry = dartCopy; |
| 6794 } else { | 6794 } else { |
| 6795 logInformation2("Dependency resolution results discarded for ${debuggingSt
ring(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime
= ${dartEntry.modificationTime}", thrownException); | 6795 _logInformation2("Dependency resolution results discarded for ${_debugging
String(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTi
me = ${dartEntry.modificationTime}", thrownException); |
| 6796 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6796 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6797 if (thrownException == null || resultTime >= 0) { | 6797 if (thrownException == null || resultTime >= 0) { |
| 6798 // | 6798 // |
| 6799 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources | 6799 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources |
| 6800 // will be re-analyzed using the up-to-date sources. | 6800 // will be re-analyzed using the up-to-date sources. |
| 6801 // | 6801 // |
| 6802 // dartCopy.recordDependencyNotInProcess(); | 6802 // dartCopy.recordDependencyNotInProcess(); |
| 6803 removeFromParts(source, dartEntry); | 6803 _removeFromParts(source, dartEntry); |
| 6804 dartCopy.invalidateAllInformation(); | 6804 dartCopy.invalidateAllInformation(); |
| 6805 dartCopy.modificationTime = sourceTime; | 6805 dartCopy.modificationTime = sourceTime; |
| 6806 _cache.removedAst(source); | 6806 _cache.removedAst(source); |
| 6807 _workManager.add(source, SourcePriority.UNKNOWN); | 6807 _workManager.add(source, SourcePriority.UNKNOWN); |
| 6808 } else { | 6808 } else { |
| 6809 // | 6809 // |
| 6810 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the | 6810 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the |
| 6811 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance | 6811 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance |
| 6812 // that we'll be able to do so without error. | 6812 // that we'll be able to do so without error. |
| 6813 // | 6813 // |
| (...skipping 12 matching lines...) Expand all Loading... |
| 6826 } | 6826 } |
| 6827 | 6827 |
| 6828 /** | 6828 /** |
| 6829 * Record the results produced by performing a [ResolveDartUnitTask]. If the r
esults were | 6829 * Record the results produced by performing a [ResolveDartUnitTask]. If the r
esults were |
| 6830 * computed from data that is now out-of-date, then the results will not be re
corded. | 6830 * computed from data that is now out-of-date, then the results will not be re
corded. |
| 6831 * | 6831 * |
| 6832 * @param task the task that was performed | 6832 * @param task the task that was performed |
| 6833 * @return an entry containing the computed results | 6833 * @return an entry containing the computed results |
| 6834 * @throws AnalysisException if the results could not be recorded | 6834 * @throws AnalysisException if the results could not be recorded |
| 6835 */ | 6835 */ |
| 6836 DartEntry recordResolveDartUnitTaskResults(ResolveDartUnitTask task) { | 6836 DartEntry _recordResolveDartUnitTaskResults(ResolveDartUnitTask task) { |
| 6837 Source unitSource = task.source; | 6837 Source unitSource = task.source; |
| 6838 Source librarySource = task.librarySource; | 6838 Source librarySource = task.librarySource; |
| 6839 AnalysisException thrownException = task.exception; | 6839 AnalysisException thrownException = task.exception; |
| 6840 DartEntry dartEntry = null; | 6840 DartEntry dartEntry = null; |
| 6841 SourceEntry sourceEntry = _cache.get(unitSource); | 6841 SourceEntry sourceEntry = _cache.get(unitSource); |
| 6842 if (sourceEntry == null) { | 6842 if (sourceEntry == null) { |
| 6843 throw new ObsoleteSourceAnalysisException(unitSource); | 6843 throw new ObsoleteSourceAnalysisException(unitSource); |
| 6844 } else if (sourceEntry is! DartEntry) { | 6844 } else if (sourceEntry is! DartEntry) { |
| 6845 // This shouldn't be possible because we should never have performed the t
ask if the source | 6845 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6846 // didn't represent a Dart file, but check to be safe. | 6846 // didn't represent a Dart file, but check to be safe. |
| 6847 throw new AnalysisException.con1("Internal error: attempting to resolve no
n-Dart file as a Dart file: ${unitSource.fullName}"); | 6847 throw new AnalysisException.con1("Internal error: attempting to resolve no
n-Dart file as a Dart file: ${unitSource.fullName}"); |
| 6848 } | 6848 } |
| 6849 dartEntry = sourceEntry as DartEntry; | 6849 dartEntry = sourceEntry as DartEntry; |
| 6850 int sourceTime = getModificationStamp(unitSource); | 6850 int sourceTime = getModificationStamp(unitSource); |
| 6851 int resultTime = task.modificationTime; | 6851 int resultTime = task.modificationTime; |
| 6852 if (sourceTime == resultTime) { | 6852 if (sourceTime == resultTime) { |
| 6853 if (dartEntry.modificationTime != sourceTime) { | 6853 if (dartEntry.modificationTime != sourceTime) { |
| 6854 // The source has changed without the context being notified. Simulate n
otification. | 6854 // The source has changed without the context being notified. Simulate n
otification. |
| 6855 sourceChanged(unitSource); | 6855 _sourceChanged(unitSource); |
| 6856 dartEntry = getReadableDartEntry(unitSource); | 6856 dartEntry = _getReadableDartEntry(unitSource); |
| 6857 if (dartEntry == null) { | 6857 if (dartEntry == null) { |
| 6858 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${unitSource.fullName}"); | 6858 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${unitSource.fullName}"); |
| 6859 } | 6859 } |
| 6860 } | 6860 } |
| 6861 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6861 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6862 if (thrownException == null) { | 6862 if (thrownException == null) { |
| 6863 dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, task.
resolvedUnit); | 6863 dartCopy.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, task.
resolvedUnit); |
| 6864 _cache.storedAst(unitSource); | 6864 _cache.storedAst(unitSource); |
| 6865 } else { | 6865 } else { |
| 6866 dartCopy.setStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource, Cache
State.ERROR); | 6866 dartCopy.setStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource, Cache
State.ERROR); |
| 6867 _cache.removedAst(unitSource); | 6867 _cache.removedAst(unitSource); |
| 6868 } | 6868 } |
| 6869 dartCopy.exception = thrownException; | 6869 dartCopy.exception = thrownException; |
| 6870 _cache.put(unitSource, dartCopy); | 6870 _cache.put(unitSource, dartCopy); |
| 6871 dartEntry = dartCopy; | 6871 dartEntry = dartCopy; |
| 6872 } else { | 6872 } else { |
| 6873 logInformation2("Resolution results discarded for ${debuggingString(unitSo
urce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${da
rtEntry.modificationTime}", thrownException); | 6873 _logInformation2("Resolution results discarded for ${_debuggingString(unit
Source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${
dartEntry.modificationTime}", thrownException); |
| 6874 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6874 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6875 if (thrownException == null || resultTime >= 0) { | 6875 if (thrownException == null || resultTime >= 0) { |
| 6876 // | 6876 // |
| 6877 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources | 6877 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources |
| 6878 // will be re-analyzed using the up-to-date sources. | 6878 // will be re-analyzed using the up-to-date sources. |
| 6879 // | 6879 // |
| 6880 // if (dartCopy.getState(DartEntry.RESOLVED_UNIT) == CacheState
.IN_PROCESS) { | 6880 // if (dartCopy.getState(DartEntry.RESOLVED_UNIT) == CacheState
.IN_PROCESS) { |
| 6881 // dartCopy.setState(DartEntry.RESOLVED_UNIT, librarySource,
CacheState.INVALID); | 6881 // dartCopy.setState(DartEntry.RESOLVED_UNIT, librarySource,
CacheState.INVALID); |
| 6882 // } | 6882 // } |
| 6883 removeFromParts(unitSource, dartEntry); | 6883 _removeFromParts(unitSource, dartEntry); |
| 6884 dartCopy.invalidateAllInformation(); | 6884 dartCopy.invalidateAllInformation(); |
| 6885 dartCopy.modificationTime = sourceTime; | 6885 dartCopy.modificationTime = sourceTime; |
| 6886 _cache.removedAst(unitSource); | 6886 _cache.removedAst(unitSource); |
| 6887 _workManager.add(unitSource, SourcePriority.UNKNOWN); | 6887 _workManager.add(unitSource, SourcePriority.UNKNOWN); |
| 6888 } else { | 6888 } else { |
| 6889 // | 6889 // |
| 6890 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the | 6890 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the |
| 6891 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance | 6891 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance |
| 6892 // that we'll be able to do so without error. | 6892 // that we'll be able to do so without error. |
| 6893 // | 6893 // |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6904 } | 6904 } |
| 6905 | 6905 |
| 6906 /** | 6906 /** |
| 6907 * Record the results produced by performing a [ResolveHtmlTask]. If the resul
ts were | 6907 * Record the results produced by performing a [ResolveHtmlTask]. If the resul
ts were |
| 6908 * computed from data that is now out-of-date, then the results will not be re
corded. | 6908 * computed from data that is now out-of-date, then the results will not be re
corded. |
| 6909 * | 6909 * |
| 6910 * @param task the task that was performed | 6910 * @param task the task that was performed |
| 6911 * @return an entry containing the computed results | 6911 * @return an entry containing the computed results |
| 6912 * @throws AnalysisException if the results could not be recorded | 6912 * @throws AnalysisException if the results could not be recorded |
| 6913 */ | 6913 */ |
| 6914 HtmlEntry recordResolveHtmlTaskResults(ResolveHtmlTask task) { | 6914 HtmlEntry _recordResolveHtmlTaskResults(ResolveHtmlTask task) { |
| 6915 Source source = task.source; | 6915 Source source = task.source; |
| 6916 AnalysisException thrownException = task.exception; | 6916 AnalysisException thrownException = task.exception; |
| 6917 HtmlEntry htmlEntry = null; | 6917 HtmlEntry htmlEntry = null; |
| 6918 SourceEntry sourceEntry = _cache.get(source); | 6918 SourceEntry sourceEntry = _cache.get(source); |
| 6919 if (sourceEntry == null) { | 6919 if (sourceEntry == null) { |
| 6920 throw new ObsoleteSourceAnalysisException(source); | 6920 throw new ObsoleteSourceAnalysisException(source); |
| 6921 } else if (sourceEntry is! HtmlEntry) { | 6921 } else if (sourceEntry is! HtmlEntry) { |
| 6922 // This shouldn't be possible because we should never have performed the t
ask if the source | 6922 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 6923 // didn't represent an HTML file, but check to be safe. | 6923 // didn't represent an HTML file, but check to be safe. |
| 6924 throw new AnalysisException.con1("Internal error: attempting to resolve no
n-HTML file as an HTML file: ${source.fullName}"); | 6924 throw new AnalysisException.con1("Internal error: attempting to resolve no
n-HTML file as an HTML file: ${source.fullName}"); |
| 6925 } | 6925 } |
| 6926 htmlEntry = sourceEntry as HtmlEntry; | 6926 htmlEntry = sourceEntry as HtmlEntry; |
| 6927 int sourceTime = getModificationStamp(source); | 6927 int sourceTime = getModificationStamp(source); |
| 6928 int resultTime = task.modificationTime; | 6928 int resultTime = task.modificationTime; |
| 6929 if (sourceTime == resultTime) { | 6929 if (sourceTime == resultTime) { |
| 6930 if (htmlEntry.modificationTime != sourceTime) { | 6930 if (htmlEntry.modificationTime != sourceTime) { |
| 6931 // The source has changed without the context being notified. Simulate n
otification. | 6931 // The source has changed without the context being notified. Simulate n
otification. |
| 6932 sourceChanged(source); | 6932 _sourceChanged(source); |
| 6933 htmlEntry = getReadableHtmlEntry(source); | 6933 htmlEntry = _getReadableHtmlEntry(source); |
| 6934 if (htmlEntry == null) { | 6934 if (htmlEntry == null) { |
| 6935 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); | 6935 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); |
| 6936 } | 6936 } |
| 6937 } | 6937 } |
| 6938 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 6938 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 6939 if (thrownException == null) { | 6939 if (thrownException == null) { |
| 6940 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); | 6940 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 6941 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); | 6941 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); |
| 6942 htmlCopy.setValue(HtmlEntry.ELEMENT, task.element); | 6942 htmlCopy.setValue(HtmlEntry.ELEMENT, task.element); |
| 6943 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors); | 6943 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors); |
| 6944 _cache.storedAst(source); | 6944 _cache.storedAst(source); |
| 6945 ChangeNoticeImpl notice = getNotice(source); | 6945 ChangeNoticeImpl notice = _getNotice(source); |
| 6946 notice.htmlUnit = task.resolvedUnit; | 6946 notice.htmlUnit = task.resolvedUnit; |
| 6947 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_
INFO)); | 6947 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_
INFO)); |
| 6948 } else { | 6948 } else { |
| 6949 htmlCopy.recordResolutionError(); | 6949 htmlCopy.recordResolutionError(); |
| 6950 _cache.removedAst(source); | 6950 _cache.removedAst(source); |
| 6951 } | 6951 } |
| 6952 htmlCopy.exception = thrownException; | 6952 htmlCopy.exception = thrownException; |
| 6953 _cache.put(source, htmlCopy); | 6953 _cache.put(source, htmlCopy); |
| 6954 htmlEntry = htmlCopy; | 6954 htmlEntry = htmlCopy; |
| 6955 } else { | 6955 } else { |
| 6956 logInformation2("Resolution results discarded for ${debuggingString(source
)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEn
try.modificationTime}", thrownException); | 6956 _logInformation2("Resolution results discarded for ${_debuggingString(sour
ce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${html
Entry.modificationTime}", thrownException); |
| 6957 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 6957 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 6958 if (thrownException == null || resultTime >= 0) { | 6958 if (thrownException == null || resultTime >= 0) { |
| 6959 // | 6959 // |
| 6960 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources | 6960 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources |
| 6961 // will be re-analyzed using the up-to-date sources. | 6961 // will be re-analyzed using the up-to-date sources. |
| 6962 // | 6962 // |
| 6963 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR
OCESS) { | 6963 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_PR
OCESS) { |
| 6964 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); | 6964 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); |
| 6965 // } | 6965 // } |
| 6966 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS
tate.IN_PROCESS) { | 6966 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == CacheS
tate.IN_PROCESS) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 6988 } | 6988 } |
| 6989 | 6989 |
| 6990 /** | 6990 /** |
| 6991 * Record the results produced by performing a [ScanDartTask]. If the results
were computed | 6991 * Record the results produced by performing a [ScanDartTask]. If the results
were computed |
| 6992 * from data that is now out-of-date, then the results will not be recorded. | 6992 * from data that is now out-of-date, then the results will not be recorded. |
| 6993 * | 6993 * |
| 6994 * @param task the task that was performed | 6994 * @param task the task that was performed |
| 6995 * @return an entry containing the computed results | 6995 * @return an entry containing the computed results |
| 6996 * @throws AnalysisException if the results could not be recorded | 6996 * @throws AnalysisException if the results could not be recorded |
| 6997 */ | 6997 */ |
| 6998 DartEntry recordScanDartTaskResults(ScanDartTask task) { | 6998 DartEntry _recordScanDartTaskResults(ScanDartTask task) { |
| 6999 Source source = task.source; | 6999 Source source = task.source; |
| 7000 AnalysisException thrownException = task.exception; | 7000 AnalysisException thrownException = task.exception; |
| 7001 DartEntry dartEntry = null; | 7001 DartEntry dartEntry = null; |
| 7002 SourceEntry sourceEntry = _cache.get(source); | 7002 SourceEntry sourceEntry = _cache.get(source); |
| 7003 if (sourceEntry == null) { | 7003 if (sourceEntry == null) { |
| 7004 throw new ObsoleteSourceAnalysisException(source); | 7004 throw new ObsoleteSourceAnalysisException(source); |
| 7005 } else if (sourceEntry is! DartEntry) { | 7005 } else if (sourceEntry is! DartEntry) { |
| 7006 // This shouldn't be possible because we should never have performed the t
ask if the source | 7006 // This shouldn't be possible because we should never have performed the t
ask if the source |
| 7007 // didn't represent a Dart file, but check to be safe. | 7007 // didn't represent a Dart file, but check to be safe. |
| 7008 throw new AnalysisException.con1("Internal error: attempting to parse non-
Dart file as a Dart file: ${source.fullName}"); | 7008 throw new AnalysisException.con1("Internal error: attempting to parse non-
Dart file as a Dart file: ${source.fullName}"); |
| 7009 } | 7009 } |
| 7010 dartEntry = sourceEntry as DartEntry; | 7010 dartEntry = sourceEntry as DartEntry; |
| 7011 int sourceTime = getModificationStamp(source); | 7011 int sourceTime = getModificationStamp(source); |
| 7012 int resultTime = task.modificationTime; | 7012 int resultTime = task.modificationTime; |
| 7013 if (sourceTime == resultTime) { | 7013 if (sourceTime == resultTime) { |
| 7014 if (dartEntry.modificationTime != sourceTime) { | 7014 if (dartEntry.modificationTime != sourceTime) { |
| 7015 // The source has changed without the context being notified. Simulate n
otification. | 7015 // The source has changed without the context being notified. Simulate n
otification. |
| 7016 sourceChanged(source); | 7016 _sourceChanged(source); |
| 7017 dartEntry = getReadableDartEntry(source); | 7017 dartEntry = _getReadableDartEntry(source); |
| 7018 if (dartEntry == null) { | 7018 if (dartEntry == null) { |
| 7019 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); | 7019 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); |
| 7020 } | 7020 } |
| 7021 } | 7021 } |
| 7022 DartEntryImpl dartCopy = dartEntry.writableCopy; | 7022 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 7023 if (thrownException == null) { | 7023 if (thrownException == null) { |
| 7024 LineInfo lineInfo = task.lineInfo; | 7024 LineInfo lineInfo = task.lineInfo; |
| 7025 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | 7025 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 7026 dartCopy.setValue(DartEntry.TOKEN_STREAM, task.tokenStream); | 7026 dartCopy.setValue(DartEntry.TOKEN_STREAM, task.tokenStream); |
| 7027 dartCopy.setValue(DartEntry.SCAN_ERRORS, task.errors); | 7027 dartCopy.setValue(DartEntry.SCAN_ERRORS, task.errors); |
| 7028 _cache.storedAst(source); | 7028 _cache.storedAst(source); |
| 7029 _workManager.add(source, SourcePriority.NORMAL_PART); | 7029 _workManager.add(source, SourcePriority.NORMAL_PART); |
| 7030 ChangeNoticeImpl notice = getNotice(source); | 7030 ChangeNoticeImpl notice = _getNotice(source); |
| 7031 notice.setErrors(dartEntry.allErrors, lineInfo); | 7031 notice.setErrors(dartEntry.allErrors, lineInfo); |
| 7032 } else { | 7032 } else { |
| 7033 removeFromParts(source, dartEntry); | 7033 _removeFromParts(source, dartEntry); |
| 7034 dartCopy.recordScanError(); | 7034 dartCopy.recordScanError(); |
| 7035 _cache.removedAst(source); | 7035 _cache.removedAst(source); |
| 7036 } | 7036 } |
| 7037 dartCopy.exception = thrownException; | 7037 dartCopy.exception = thrownException; |
| 7038 _cache.put(source, dartCopy); | 7038 _cache.put(source, dartCopy); |
| 7039 dartEntry = dartCopy; | 7039 dartEntry = dartCopy; |
| 7040 } else { | 7040 } else { |
| 7041 logInformation2("Scan results discarded for ${debuggingString(source)}; so
urceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry.mo
dificationTime}", thrownException); | 7041 _logInformation2("Scan results discarded for ${_debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry.
modificationTime}", thrownException); |
| 7042 DartEntryImpl dartCopy = dartEntry.writableCopy; | 7042 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 7043 if (thrownException == null || resultTime >= 0) { | 7043 if (thrownException == null || resultTime >= 0) { |
| 7044 // | 7044 // |
| 7045 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources | 7045 // The analysis was performed on out-of-date sources. Mark the cache so
that the sources |
| 7046 // will be re-analyzed using the up-to-date sources. | 7046 // will be re-analyzed using the up-to-date sources. |
| 7047 // | 7047 // |
| 7048 // dartCopy.recordScanNotInProcess(); | 7048 // dartCopy.recordScanNotInProcess(); |
| 7049 removeFromParts(source, dartEntry); | 7049 _removeFromParts(source, dartEntry); |
| 7050 dartCopy.invalidateAllInformation(); | 7050 dartCopy.invalidateAllInformation(); |
| 7051 dartCopy.modificationTime = sourceTime; | 7051 dartCopy.modificationTime = sourceTime; |
| 7052 _cache.removedAst(source); | 7052 _cache.removedAst(source); |
| 7053 _workManager.add(source, SourcePriority.UNKNOWN); | 7053 _workManager.add(source, SourcePriority.UNKNOWN); |
| 7054 } else { | 7054 } else { |
| 7055 // | 7055 // |
| 7056 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the | 7056 // We could not determine whether the sources were up-to-date or out-of-
date. Mark the |
| 7057 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance | 7057 // cache so that we won't attempt to re-analyze the sources until there'
s a good chance |
| 7058 // that we'll be able to do so without error. | 7058 // that we'll be able to do so without error. |
| 7059 // | 7059 // |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7071 | 7071 |
| 7072 /** | 7072 /** |
| 7073 * Remove the given library from the list of containing libraries for all of t
he parts referenced | 7073 * Remove the given library from the list of containing libraries for all of t
he parts referenced |
| 7074 * by the given entry. | 7074 * by the given entry. |
| 7075 * | 7075 * |
| 7076 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 7076 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 7077 * | 7077 * |
| 7078 * @param librarySource the library to be removed | 7078 * @param librarySource the library to be removed |
| 7079 * @param dartEntry the entry containing the list of included parts | 7079 * @param dartEntry the entry containing the list of included parts |
| 7080 */ | 7080 */ |
| 7081 void removeFromParts(Source librarySource, DartEntry dartEntry) { | 7081 void _removeFromParts(Source librarySource, DartEntry dartEntry) { |
| 7082 List<Source> oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS); | 7082 List<Source> oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS); |
| 7083 for (int i = 0; i < oldParts.length; i++) { | 7083 for (int i = 0; i < oldParts.length; i++) { |
| 7084 Source partSource = oldParts[i]; | 7084 Source partSource = oldParts[i]; |
| 7085 DartEntry partEntry = getReadableDartEntry(partSource); | 7085 DartEntry partEntry = _getReadableDartEntry(partSource); |
| 7086 if (partEntry != null && partEntry != dartEntry) { | 7086 if (partEntry != null && partEntry != dartEntry) { |
| 7087 DartEntryImpl partCopy = partEntry.writableCopy; | 7087 DartEntryImpl partCopy = partEntry.writableCopy; |
| 7088 partCopy.removeContainingLibrary(librarySource); | 7088 partCopy.removeContainingLibrary(librarySource); |
| 7089 if (partCopy.librariesContaining.length == 0 && !exists(partSource)) { | 7089 if (partCopy.librariesContaining.length == 0 && !exists(partSource)) { |
| 7090 _cache.remove(partSource); | 7090 _cache.remove(partSource); |
| 7091 } else { | 7091 } else { |
| 7092 _cache.put(partSource, partCopy); | 7092 _cache.put(partSource, partCopy); |
| 7093 } | 7093 } |
| 7094 } | 7094 } |
| 7095 } | 7095 } |
| 7096 } | 7096 } |
| 7097 | 7097 |
| 7098 /** | 7098 /** |
| 7099 * Remove the given source from the priority order if it is in the list. | 7099 * Remove the given source from the priority order if it is in the list. |
| 7100 * | 7100 * |
| 7101 * @param source the source to be removed | 7101 * @param source the source to be removed |
| 7102 */ | 7102 */ |
| 7103 void removeFromPriorityOrder(Source source) { | 7103 void _removeFromPriorityOrder(Source source) { |
| 7104 int count = _priorityOrder.length; | 7104 int count = _priorityOrder.length; |
| 7105 List<Source> newOrder = new List<Source>(); | 7105 List<Source> newOrder = new List<Source>(); |
| 7106 for (int i = 0; i < count; i++) { | 7106 for (int i = 0; i < count; i++) { |
| 7107 if (_priorityOrder[i] != source) { | 7107 if (_priorityOrder[i] != source) { |
| 7108 newOrder.add(_priorityOrder[i]); | 7108 newOrder.add(_priorityOrder[i]); |
| 7109 } | 7109 } |
| 7110 } | 7110 } |
| 7111 if (newOrder.length < count) { | 7111 if (newOrder.length < count) { |
| 7112 analysisPriorityOrder = newOrder; | 7112 analysisPriorityOrder = newOrder; |
| 7113 } | 7113 } |
| 7114 } | 7114 } |
| 7115 | 7115 |
| 7116 /** | 7116 /** |
| 7117 * Create an entry for the newly added source. Return `true` if the new source
is a Dart | 7117 * Create an entry for the newly added source. Return `true` if the new source
is a Dart |
| 7118 * file. | 7118 * file. |
| 7119 * | 7119 * |
| 7120 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 7120 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 7121 * | 7121 * |
| 7122 * @param source the source that has been added | 7122 * @param source the source that has been added |
| 7123 * @return `true` if the new source is a Dart file | 7123 * @return `true` if the new source is a Dart file |
| 7124 */ | 7124 */ |
| 7125 bool sourceAvailable(Source source) { | 7125 bool _sourceAvailable(Source source) { |
| 7126 SourceEntry sourceEntry = _cache.get(source); | 7126 SourceEntry sourceEntry = _cache.get(source); |
| 7127 if (sourceEntry == null) { | 7127 if (sourceEntry == null) { |
| 7128 sourceEntry = createSourceEntry(source); | 7128 sourceEntry = _createSourceEntry(source); |
| 7129 logInformation("Added new source: ${debuggingString(source)}"); | 7129 _logInformation("Added new source: ${_debuggingString(source)}"); |
| 7130 } else { | 7130 } else { |
| 7131 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; | 7131 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; |
| 7132 int oldTime = sourceCopy.modificationTime; | 7132 int oldTime = sourceCopy.modificationTime; |
| 7133 sourceCopy.modificationTime = getModificationStamp(source); | 7133 sourceCopy.modificationTime = getModificationStamp(source); |
| 7134 // TODO(brianwilkerson) Understand why we're not invalidating the cache. | 7134 // TODO(brianwilkerson) Understand why we're not invalidating the cache. |
| 7135 _cache.put(source, sourceCopy); | 7135 _cache.put(source, sourceCopy); |
| 7136 logInformation("Added new source: ${debuggingString(source)} (previously m
odified at ${oldTime})"); | 7136 _logInformation("Added new source: ${_debuggingString(source)} (previously
modified at ${oldTime})"); |
| 7137 } | 7137 } |
| 7138 if (sourceEntry is HtmlEntry) { | 7138 if (sourceEntry is HtmlEntry) { |
| 7139 _workManager.add(source, SourcePriority.HTML); | 7139 _workManager.add(source, SourcePriority.HTML); |
| 7140 } else { | 7140 } else { |
| 7141 _workManager.add(source, SourcePriority.UNKNOWN); | 7141 _workManager.add(source, SourcePriority.UNKNOWN); |
| 7142 } | 7142 } |
| 7143 return sourceEntry is DartEntry; | 7143 return sourceEntry is DartEntry; |
| 7144 } | 7144 } |
| 7145 | 7145 |
| 7146 /** | 7146 /** |
| 7147 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 7147 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 7148 * | 7148 * |
| 7149 * @param source the source that has been changed | 7149 * @param source the source that has been changed |
| 7150 */ | 7150 */ |
| 7151 void sourceChanged(Source source) { | 7151 void _sourceChanged(Source source) { |
| 7152 SourceEntry sourceEntry = _cache.get(source); | 7152 SourceEntry sourceEntry = _cache.get(source); |
| 7153 if (sourceEntry == null || sourceEntry.modificationTime == getModificationSt
amp(source)) { | 7153 if (sourceEntry == null || sourceEntry.modificationTime == getModificationSt
amp(source)) { |
| 7154 // Either we have removed this source, in which case we don't care that it
is changed, or we | 7154 // Either we have removed this source, in which case we don't care that it
is changed, or we |
| 7155 // have already invalidated the cache and don't need to invalidate it agai
n. | 7155 // have already invalidated the cache and don't need to invalidate it agai
n. |
| 7156 if (sourceEntry == null) { | 7156 if (sourceEntry == null) { |
| 7157 logInformation("Modified source, but there is no entry: ${debuggingStrin
g(source)}"); | 7157 _logInformation("Modified source, but there is no entry: ${_debuggingStr
ing(source)}"); |
| 7158 } else { | 7158 } else { |
| 7159 logInformation("Modified source, but modification time matches: ${debugg
ingString(source)}"); | 7159 _logInformation("Modified source, but modification time matches: ${_debu
ggingString(source)}"); |
| 7160 } | 7160 } |
| 7161 return; | 7161 return; |
| 7162 } | 7162 } |
| 7163 if (sourceEntry is HtmlEntry) { | 7163 if (sourceEntry is HtmlEntry) { |
| 7164 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; | 7164 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; |
| 7165 int oldTime = htmlCopy.modificationTime; | 7165 int oldTime = htmlCopy.modificationTime; |
| 7166 htmlCopy.modificationTime = getModificationStamp(source); | 7166 htmlCopy.modificationTime = getModificationStamp(source); |
| 7167 invalidateAngularResolution(htmlCopy); | 7167 _invalidateAngularResolution(htmlCopy); |
| 7168 htmlCopy.invalidateAllInformation(); | 7168 htmlCopy.invalidateAllInformation(); |
| 7169 _cache.put(source, htmlCopy); | 7169 _cache.put(source, htmlCopy); |
| 7170 _cache.removedAst(source); | 7170 _cache.removedAst(source); |
| 7171 _workManager.add(source, SourcePriority.HTML); | 7171 _workManager.add(source, SourcePriority.HTML); |
| 7172 logInformation("Modified HTML source: ${debuggingString(source)} (previous
ly modified at ${oldTime})"); | 7172 _logInformation("Modified HTML source: ${_debuggingString(source)} (previo
usly modified at ${oldTime})"); |
| 7173 } else if (sourceEntry is DartEntry) { | 7173 } else if (sourceEntry is DartEntry) { |
| 7174 List<Source> containingLibraries = getLibrariesContaining(source); | 7174 List<Source> containingLibraries = getLibrariesContaining(source); |
| 7175 Set<Source> librariesToInvalidate = new Set<Source>(); | 7175 Set<Source> librariesToInvalidate = new Set<Source>(); |
| 7176 for (Source containingLibrary in containingLibraries) { | 7176 for (Source containingLibrary in containingLibraries) { |
| 7177 librariesToInvalidate.add(containingLibrary); | 7177 librariesToInvalidate.add(containingLibrary); |
| 7178 for (Source dependentLibrary in getLibrariesDependingOn(containingLibrar
y)) { | 7178 for (Source dependentLibrary in getLibrariesDependingOn(containingLibrar
y)) { |
| 7179 librariesToInvalidate.add(dependentLibrary); | 7179 librariesToInvalidate.add(dependentLibrary); |
| 7180 } | 7180 } |
| 7181 } | 7181 } |
| 7182 PrintStringWriter writer = new PrintStringWriter(); | 7182 PrintStringWriter writer = new PrintStringWriter(); |
| 7183 int oldTime = sourceEntry.modificationTime; | 7183 int oldTime = sourceEntry.modificationTime; |
| 7184 writer.println("Modified Dart source: ${debuggingString(source)} (previous
ly modified at ${oldTime})"); | 7184 writer.println("Modified Dart source: ${_debuggingString(source)} (previou
sly modified at ${oldTime})"); |
| 7185 for (Source library in librariesToInvalidate) { | 7185 for (Source library in librariesToInvalidate) { |
| 7186 // for (Source library : containingLibraries) { | 7186 // for (Source library : containingLibraries) { |
| 7187 invalidateLibraryResolution(library, writer); | 7187 _invalidateLibraryResolution(library, writer); |
| 7188 } | 7188 } |
| 7189 removeFromParts(source, _cache.get(source) as DartEntry); | 7189 _removeFromParts(source, _cache.get(source) as DartEntry); |
| 7190 DartEntryImpl dartCopy = (_cache.get(source) as DartEntry).writableCopy; | 7190 DartEntryImpl dartCopy = (_cache.get(source) as DartEntry).writableCopy; |
| 7191 dartCopy.modificationTime = getModificationStamp(source); | 7191 dartCopy.modificationTime = getModificationStamp(source); |
| 7192 dartCopy.invalidateAllInformation(); | 7192 dartCopy.invalidateAllInformation(); |
| 7193 _cache.put(source, dartCopy); | 7193 _cache.put(source, dartCopy); |
| 7194 _cache.removedAst(source); | 7194 _cache.removedAst(source); |
| 7195 _workManager.add(source, SourcePriority.UNKNOWN); | 7195 _workManager.add(source, SourcePriority.UNKNOWN); |
| 7196 logInformation(writer.toString()); | 7196 _logInformation(writer.toString()); |
| 7197 } | 7197 } |
| 7198 } | 7198 } |
| 7199 | 7199 |
| 7200 /** | 7200 /** |
| 7201 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 7201 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 7202 * | 7202 * |
| 7203 * @param source the source that has been deleted | 7203 * @param source the source that has been deleted |
| 7204 */ | 7204 */ |
| 7205 void sourceRemoved(Source source) { | 7205 void _sourceRemoved(Source source) { |
| 7206 PrintStringWriter writer = new PrintStringWriter(); | 7206 PrintStringWriter writer = new PrintStringWriter(); |
| 7207 writer.println("Removed source: ${debuggingString(source)}"); | 7207 writer.println("Removed source: ${_debuggingString(source)}"); |
| 7208 SourceEntry sourceEntry = _cache.get(source); | 7208 SourceEntry sourceEntry = _cache.get(source); |
| 7209 if (sourceEntry is HtmlEntry) { | 7209 if (sourceEntry is HtmlEntry) { |
| 7210 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; | 7210 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; |
| 7211 invalidateAngularResolution(htmlCopy); | 7211 _invalidateAngularResolution(htmlCopy); |
| 7212 } else if (sourceEntry is DartEntry) { | 7212 } else if (sourceEntry is DartEntry) { |
| 7213 Set<Source> libraries = new Set<Source>(); | 7213 Set<Source> libraries = new Set<Source>(); |
| 7214 for (Source librarySource in getLibrariesContaining(source)) { | 7214 for (Source librarySource in getLibrariesContaining(source)) { |
| 7215 libraries.add(librarySource); | 7215 libraries.add(librarySource); |
| 7216 for (Source dependentLibrary in getLibrariesDependingOn(librarySource))
{ | 7216 for (Source dependentLibrary in getLibrariesDependingOn(librarySource))
{ |
| 7217 libraries.add(dependentLibrary); | 7217 libraries.add(dependentLibrary); |
| 7218 } | 7218 } |
| 7219 } | 7219 } |
| 7220 for (Source librarySource in libraries) { | 7220 for (Source librarySource in libraries) { |
| 7221 invalidateLibraryResolution(librarySource, writer); | 7221 _invalidateLibraryResolution(librarySource, writer); |
| 7222 } | 7222 } |
| 7223 } | 7223 } |
| 7224 _cache.remove(source); | 7224 _cache.remove(source); |
| 7225 _workManager.remove(source); | 7225 _workManager.remove(source); |
| 7226 removeFromPriorityOrder(source); | 7226 _removeFromPriorityOrder(source); |
| 7227 logInformation(writer.toString()); | 7227 _logInformation(writer.toString()); |
| 7228 } | 7228 } |
| 7229 | 7229 |
| 7230 /** | 7230 /** |
| 7231 * Check the cache for any invalid entries (entries whose modification time do
es not match the | 7231 * Check the cache for any invalid entries (entries whose modification time do
es not match the |
| 7232 * modification time of the source associated with the entry). Invalid entries
will be marked as | 7232 * modification time of the source associated with the entry). Invalid entries
will be marked as |
| 7233 * invalid so that the source will be re-analyzed. | 7233 * invalid so that the source will be re-analyzed. |
| 7234 * | 7234 * |
| 7235 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 7235 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 7236 * | 7236 * |
| 7237 * @return `true` if at least one entry was invalid | 7237 * @return `true` if at least one entry was invalid |
| 7238 */ | 7238 */ |
| 7239 bool validateCacheConsistency() { | 7239 bool _validateCacheConsistency() { |
| 7240 int consistencyCheckStart = JavaSystem.nanoTime(); | 7240 int consistencyCheckStart = JavaSystem.nanoTime(); |
| 7241 List<Source> missingSources = new List<Source>(); | 7241 List<Source> missingSources = new List<Source>(); |
| 7242 int inconsistentCount = 0; | 7242 int inconsistentCount = 0; |
| 7243 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 7243 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 7244 Source source = entry.getKey(); | 7244 Source source = entry.getKey(); |
| 7245 SourceEntry sourceEntry = entry.getValue(); | 7245 SourceEntry sourceEntry = entry.getValue(); |
| 7246 int sourceTime = getModificationStamp(source); | 7246 int sourceTime = getModificationStamp(source); |
| 7247 if (sourceTime != sourceEntry.modificationTime) { | 7247 if (sourceTime != sourceEntry.modificationTime) { |
| 7248 sourceChanged(source); | 7248 _sourceChanged(source); |
| 7249 inconsistentCount++; | 7249 inconsistentCount++; |
| 7250 } | 7250 } |
| 7251 if (sourceEntry.exception != null) { | 7251 if (sourceEntry.exception != null) { |
| 7252 if (!exists(source)) { | 7252 if (!exists(source)) { |
| 7253 missingSources.add(source); | 7253 missingSources.add(source); |
| 7254 } | 7254 } |
| 7255 } | 7255 } |
| 7256 } | 7256 } |
| 7257 int consistencyCheckEnd = JavaSystem.nanoTime(); | 7257 int consistencyCheckEnd = JavaSystem.nanoTime(); |
| 7258 PrintStringWriter writer = new PrintStringWriter(); | 7258 PrintStringWriter writer = new PrintStringWriter(); |
| 7259 writer.print("Consistency check took "); | 7259 writer.print("Consistency check took "); |
| 7260 writer.print((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); | 7260 writer.print((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); |
| 7261 writer.println(" ms and found"); | 7261 writer.println(" ms and found"); |
| 7262 writer.print(" "); | 7262 writer.print(" "); |
| 7263 writer.print(inconsistentCount); | 7263 writer.print(inconsistentCount); |
| 7264 writer.println(" inconsistent entries"); | 7264 writer.println(" inconsistent entries"); |
| 7265 writer.print(" "); | 7265 writer.print(" "); |
| 7266 writer.print(missingSources.length); | 7266 writer.print(missingSources.length); |
| 7267 writer.println(" missing sources"); | 7267 writer.println(" missing sources"); |
| 7268 for (Source source in missingSources) { | 7268 for (Source source in missingSources) { |
| 7269 writer.print(" "); | 7269 writer.print(" "); |
| 7270 writer.println(source.fullName); | 7270 writer.println(source.fullName); |
| 7271 } | 7271 } |
| 7272 logInformation(writer.toString()); | 7272 _logInformation(writer.toString()); |
| 7273 return inconsistentCount > 0; | 7273 return inconsistentCount > 0; |
| 7274 } | 7274 } |
| 7275 } | 7275 } |
| 7276 | 7276 |
| 7277 /** | 7277 /** |
| 7278 * Instances of the class `AnalysisTaskResultRecorder` are used by an analysis c
ontext to | 7278 * Instances of the class `AnalysisTaskResultRecorder` are used by an analysis c
ontext to |
| 7279 * record the results of a task. | 7279 * record the results of a task. |
| 7280 */ | 7280 */ |
| 7281 class AnalysisContextImpl_AnalysisTaskResultRecorder implements AnalysisTaskVisi
tor<SourceEntry> { | 7281 class AnalysisContextImpl_AnalysisTaskResultRecorder implements AnalysisTaskVisi
tor<SourceEntry> { |
| 7282 final AnalysisContextImpl AnalysisContextImpl_this; | 7282 final AnalysisContextImpl AnalysisContextImpl_this; |
| 7283 | 7283 |
| 7284 AnalysisContextImpl_AnalysisTaskResultRecorder(this.AnalysisContextImpl_this); | 7284 AnalysisContextImpl_AnalysisTaskResultRecorder(this.AnalysisContextImpl_this); |
| 7285 | 7285 |
| 7286 DartEntry visitGenerateDartErrorsTask(GenerateDartErrorsTask task) => Analysis
ContextImpl_this.recordGenerateDartErrorsTask(task); | 7286 DartEntry visitGenerateDartErrorsTask(GenerateDartErrorsTask task) => Analysis
ContextImpl_this._recordGenerateDartErrorsTask(task); |
| 7287 | 7287 |
| 7288 DartEntry visitGenerateDartHintsTask(GenerateDartHintsTask task) => AnalysisCo
ntextImpl_this.recordGenerateDartHintsTask(task); | 7288 DartEntry visitGenerateDartHintsTask(GenerateDartHintsTask task) => AnalysisCo
ntextImpl_this._recordGenerateDartHintsTask(task); |
| 7289 | 7289 |
| 7290 SourceEntry visitGetContentTask(GetContentTask task) => AnalysisContextImpl_th
is.recordGetContentsTask(task); | 7290 SourceEntry visitGetContentTask(GetContentTask task) => AnalysisContextImpl_th
is._recordGetContentsTask(task); |
| 7291 | 7291 |
| 7292 DartEntry visitIncrementalAnalysisTask(IncrementalAnalysisTask task) => Analys
isContextImpl_this.recordIncrementalAnalysisTaskResults(task); | 7292 DartEntry visitIncrementalAnalysisTask(IncrementalAnalysisTask task) => Analys
isContextImpl_this._recordIncrementalAnalysisTaskResults(task); |
| 7293 | 7293 |
| 7294 DartEntry visitParseDartTask(ParseDartTask task) => AnalysisContextImpl_this.r
ecordParseDartTaskResults(task); | 7294 DartEntry visitParseDartTask(ParseDartTask task) => AnalysisContextImpl_this._
recordParseDartTaskResults(task); |
| 7295 | 7295 |
| 7296 HtmlEntry visitParseHtmlTask(ParseHtmlTask task) => AnalysisContextImpl_this.r
ecordParseHtmlTaskResults(task); | 7296 HtmlEntry visitParseHtmlTask(ParseHtmlTask task) => AnalysisContextImpl_this._
recordParseHtmlTaskResults(task); |
| 7297 | 7297 |
| 7298 HtmlEntry visitResolveAngularComponentTemplateTask(ResolveAngularComponentTemp
lateTask task) => AnalysisContextImpl_this.recordResolveAngularComponentTemplate
TaskResults(task); | 7298 HtmlEntry visitResolveAngularComponentTemplateTask(ResolveAngularComponentTemp
lateTask task) => AnalysisContextImpl_this._recordResolveAngularComponentTemplat
eTaskResults(task); |
| 7299 | 7299 |
| 7300 HtmlEntry visitResolveAngularEntryHtmlTask(ResolveAngularEntryHtmlTask task) =
> AnalysisContextImpl_this.recordResolveAngularEntryHtmlTaskResults(task); | 7300 HtmlEntry visitResolveAngularEntryHtmlTask(ResolveAngularEntryHtmlTask task) =
> AnalysisContextImpl_this._recordResolveAngularEntryHtmlTaskResults(task); |
| 7301 | 7301 |
| 7302 DartEntry visitResolveDartDependenciesTask(ResolveDartDependenciesTask task) =
> AnalysisContextImpl_this.recordResolveDartDependenciesTaskResults(task); | 7302 DartEntry visitResolveDartDependenciesTask(ResolveDartDependenciesTask task) =
> AnalysisContextImpl_this._recordResolveDartDependenciesTaskResults(task); |
| 7303 | 7303 |
| 7304 DartEntry visitResolveDartLibraryTask(ResolveDartLibraryTask task) => Analysis
ContextImpl_this.recordResolveDartLibraryTaskResults(task); | 7304 DartEntry visitResolveDartLibraryTask(ResolveDartLibraryTask task) => Analysis
ContextImpl_this.recordResolveDartLibraryTaskResults(task); |
| 7305 | 7305 |
| 7306 DartEntry visitResolveDartUnitTask(ResolveDartUnitTask task) => AnalysisContex
tImpl_this.recordResolveDartUnitTaskResults(task); | 7306 DartEntry visitResolveDartUnitTask(ResolveDartUnitTask task) => AnalysisContex
tImpl_this._recordResolveDartUnitTaskResults(task); |
| 7307 | 7307 |
| 7308 HtmlEntry visitResolveHtmlTask(ResolveHtmlTask task) => AnalysisContextImpl_th
is.recordResolveHtmlTaskResults(task); | 7308 HtmlEntry visitResolveHtmlTask(ResolveHtmlTask task) => AnalysisContextImpl_th
is._recordResolveHtmlTaskResults(task); |
| 7309 | 7309 |
| 7310 DartEntry visitScanDartTask(ScanDartTask task) => AnalysisContextImpl_this.rec
ordScanDartTaskResults(task); | 7310 DartEntry visitScanDartTask(ScanDartTask task) => AnalysisContextImpl_this._re
cordScanDartTaskResults(task); |
| 7311 } | 7311 } |
| 7312 | 7312 |
| 7313 class AnalysisContextImpl_ContextRetentionPolicy implements CacheRetentionPolicy
{ | 7313 class AnalysisContextImpl_ContextRetentionPolicy implements CacheRetentionPolicy
{ |
| 7314 final AnalysisContextImpl AnalysisContextImpl_this; | 7314 final AnalysisContextImpl AnalysisContextImpl_this; |
| 7315 | 7315 |
| 7316 AnalysisContextImpl_ContextRetentionPolicy(this.AnalysisContextImpl_this); | 7316 AnalysisContextImpl_ContextRetentionPolicy(this.AnalysisContextImpl_this); |
| 7317 | 7317 |
| 7318 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) { | 7318 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) { |
| 7319 for (Source prioritySource in AnalysisContextImpl_this._priorityOrder) { | 7319 for (Source prioritySource in AnalysisContextImpl_this._priorityOrder) { |
| 7320 if (source == prioritySource) { | 7320 if (source == prioritySource) { |
| 7321 return RetentionPriority.HIGH; | 7321 return RetentionPriority.HIGH; |
| 7322 } | 7322 } |
| 7323 } | 7323 } |
| 7324 if (sourceEntry is DartEntry) { | 7324 if (sourceEntry is DartEntry) { |
| 7325 DartEntry dartEntry = sourceEntry; | 7325 DartEntry dartEntry = sourceEntry; |
| 7326 if (astIsNeeded(dartEntry)) { | 7326 if (_astIsNeeded(dartEntry)) { |
| 7327 return RetentionPriority.MEDIUM; | 7327 return RetentionPriority.MEDIUM; |
| 7328 } | 7328 } |
| 7329 } | 7329 } |
| 7330 return RetentionPriority.LOW; | 7330 return RetentionPriority.LOW; |
| 7331 } | 7331 } |
| 7332 | 7332 |
| 7333 bool astIsNeeded(DartEntry dartEntry) => dartEntry.hasInvalidData(DartEntry.HI
NTS) || dartEntry.hasInvalidData(DartEntry.VERIFICATION_ERRORS) || dartEntry.has
InvalidData(DartEntry.RESOLUTION_ERRORS); | 7333 bool _astIsNeeded(DartEntry dartEntry) => dartEntry.hasInvalidData(DartEntry.H
INTS) || dartEntry.hasInvalidData(DartEntry.VERIFICATION_ERRORS) || dartEntry.ha
sInvalidData(DartEntry.RESOLUTION_ERRORS); |
| 7334 } | 7334 } |
| 7335 | 7335 |
| 7336 /** | 7336 /** |
| 7337 * Instances of the class `TaskData` represent information about the next task t
o be | 7337 * Instances of the class `TaskData` represent information about the next task t
o be |
| 7338 * performed. Each data has an implicit associated source: the source that might
need to be | 7338 * performed. Each data has an implicit associated source: the source that might
need to be |
| 7339 * analyzed. There are essentially three states that can be represented: | 7339 * analyzed. There are essentially three states that can be represented: |
| 7340 * * If [getTask] returns a non-`null` value, then that is the task that should | 7340 * * If [getTask] returns a non-`null` value, then that is the task that should |
| 7341 * be executed to further analyze the associated source. | 7341 * be executed to further analyze the associated source. |
| 7342 * * Otherwise, if [isBlocked] returns `true`, then there is no work that can be | 7342 * * Otherwise, if [isBlocked] returns `true`, then there is no work that can be |
| 7343 * done, but analysis for the associated source is not complete. | 7343 * done, but analysis for the associated source is not complete. |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7545 * Set the errors that changed as a result of the analysis to the given errors
and set the line | 7545 * Set the errors that changed as a result of the analysis to the given errors
and set the line |
| 7546 * information to the given line information. | 7546 * information to the given line information. |
| 7547 * | 7547 * |
| 7548 * @param errors the errors that changed as a result of the analysis | 7548 * @param errors the errors that changed as a result of the analysis |
| 7549 * @param lineInfo the line information associated with the source | 7549 * @param lineInfo the line information associated with the source |
| 7550 */ | 7550 */ |
| 7551 void setErrors(List<AnalysisError> errors, LineInfo lineInfo) { | 7551 void setErrors(List<AnalysisError> errors, LineInfo lineInfo) { |
| 7552 this._errors = errors; | 7552 this._errors = errors; |
| 7553 this._lineInfo = lineInfo; | 7553 this._lineInfo = lineInfo; |
| 7554 if (lineInfo == null) { | 7554 if (lineInfo == null) { |
| 7555 AnalysisEngine.instance.logger.logInformation3("No line info: ${source}",
new JavaException()); | 7555 AnalysisEngine.instance.logger.logInformation2("No line info: ${source}",
new JavaException()); |
| 7556 } | 7556 } |
| 7557 } | 7557 } |
| 7558 | 7558 |
| 7559 String toString() => "Changes for ${source.fullName}"; | 7559 String toString() => "Changes for ${source.fullName}"; |
| 7560 } | 7560 } |
| 7561 | 7561 |
| 7562 /** | 7562 /** |
| 7563 * Instances of the class `DelegatingAnalysisContextImpl` extend [AnalysisContex
tImpl | 7563 * Instances of the class `DelegatingAnalysisContextImpl` extend [AnalysisContex
tImpl |
| 7564 ] to delegate sources to the appropriate analysis context. For instance, if the | 7564 ] to delegate sources to the appropriate analysis context. For instance, if the |
| 7565 * source is in a system library then the analysis context from the [DartSdk] is
used. | 7565 * source is in a system library then the analysis context from the [DartSdk] is
used. |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8025 * [AnalysisContext] by recording instrumentation data and delegating to | 8025 * [AnalysisContext] by recording instrumentation data and delegating to |
| 8026 * another analysis context to do the non-instrumentation work. | 8026 * another analysis context to do the non-instrumentation work. |
| 8027 */ | 8027 */ |
| 8028 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext { | 8028 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext { |
| 8029 /** | 8029 /** |
| 8030 * Record an exception that was thrown during analysis. | 8030 * Record an exception that was thrown during analysis. |
| 8031 * | 8031 * |
| 8032 * @param instrumentation the instrumentation builder being used to record the
exception | 8032 * @param instrumentation the instrumentation builder being used to record the
exception |
| 8033 * @param exception the exception being reported | 8033 * @param exception the exception being reported |
| 8034 */ | 8034 */ |
| 8035 static void recordAnalysisException(InstrumentationBuilder instrumentation, An
alysisException exception) { | 8035 static void _recordAnalysisException(InstrumentationBuilder instrumentation, A
nalysisException exception) { |
| 8036 instrumentation.record(exception); | 8036 instrumentation.record(exception); |
| 8037 } | 8037 } |
| 8038 | 8038 |
| 8039 /** | 8039 /** |
| 8040 * The unique identifier used to identify this analysis context in the instrum
entation data. | 8040 * The unique identifier used to identify this analysis context in the instrum
entation data. |
| 8041 */ | 8041 */ |
| 8042 String _contextId = UUID.randomUUID().toString(); | 8042 String _contextId = UUID.randomUUID().toString(); |
| 8043 | 8043 |
| 8044 /** | 8044 /** |
| 8045 * The analysis context to which all of the non-instrumentation work is delega
ted. | 8045 * The analysis context to which all of the non-instrumentation work is delega
ted. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8099 } | 8099 } |
| 8100 | 8100 |
| 8101 List<Source> computeExportedLibraries(Source source) => _basis.computeExported
Libraries(source); | 8101 List<Source> computeExportedLibraries(Source source) => _basis.computeExported
Libraries(source); |
| 8102 | 8102 |
| 8103 HtmlElement computeHtmlElement(Source source) { | 8103 HtmlElement computeHtmlElement(Source source) { |
| 8104 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeHtmlElement"); | 8104 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeHtmlElement"); |
| 8105 try { | 8105 try { |
| 8106 instrumentation.metric3("contextId", _contextId); | 8106 instrumentation.metric3("contextId", _contextId); |
| 8107 return _basis.computeHtmlElement(source); | 8107 return _basis.computeHtmlElement(source); |
| 8108 } on AnalysisException catch (e) { | 8108 } on AnalysisException catch (e) { |
| 8109 recordAnalysisException(instrumentation, e); | 8109 _recordAnalysisException(instrumentation, e); |
| 8110 throw e; | 8110 throw e; |
| 8111 } finally { | 8111 } finally { |
| 8112 instrumentation.log(); | 8112 instrumentation.log(); |
| 8113 } | 8113 } |
| 8114 } | 8114 } |
| 8115 | 8115 |
| 8116 List<Source> computeImportedLibraries(Source source) => _basis.computeImported
Libraries(source); | 8116 List<Source> computeImportedLibraries(Source source) => _basis.computeImported
Libraries(source); |
| 8117 | 8117 |
| 8118 SourceKind computeKindOf(Source source) { | 8118 SourceKind computeKindOf(Source source) { |
| 8119 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeKindOf"); | 8119 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeKindOf"); |
| 8120 try { | 8120 try { |
| 8121 instrumentation.metric3("contextId", _contextId); | 8121 instrumentation.metric3("contextId", _contextId); |
| 8122 return _basis.computeKindOf(source); | 8122 return _basis.computeKindOf(source); |
| 8123 } finally { | 8123 } finally { |
| 8124 instrumentation.log(); | 8124 instrumentation.log(); |
| 8125 } | 8125 } |
| 8126 } | 8126 } |
| 8127 | 8127 |
| 8128 LibraryElement computeLibraryElement(Source source) { | 8128 LibraryElement computeLibraryElement(Source source) { |
| 8129 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeLibraryElement"); | 8129 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeLibraryElement"); |
| 8130 try { | 8130 try { |
| 8131 instrumentation.metric3("contextId", _contextId); | 8131 instrumentation.metric3("contextId", _contextId); |
| 8132 return _basis.computeLibraryElement(source); | 8132 return _basis.computeLibraryElement(source); |
| 8133 } on AnalysisException catch (e) { | 8133 } on AnalysisException catch (e) { |
| 8134 recordAnalysisException(instrumentation, e); | 8134 _recordAnalysisException(instrumentation, e); |
| 8135 throw e; | 8135 throw e; |
| 8136 } finally { | 8136 } finally { |
| 8137 instrumentation.log(); | 8137 instrumentation.log(); |
| 8138 } | 8138 } |
| 8139 } | 8139 } |
| 8140 | 8140 |
| 8141 LineInfo computeLineInfo(Source source) { | 8141 LineInfo computeLineInfo(Source source) { |
| 8142 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeLineInfo"); | 8142 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeLineInfo"); |
| 8143 try { | 8143 try { |
| 8144 instrumentation.metric3("contextId", _contextId); | 8144 instrumentation.metric3("contextId", _contextId); |
| 8145 return _basis.computeLineInfo(source); | 8145 return _basis.computeLineInfo(source); |
| 8146 } on AnalysisException catch (e) { | 8146 } on AnalysisException catch (e) { |
| 8147 recordAnalysisException(instrumentation, e); | 8147 _recordAnalysisException(instrumentation, e); |
| 8148 throw e; | 8148 throw e; |
| 8149 } finally { | 8149 } finally { |
| 8150 instrumentation.log(); | 8150 instrumentation.log(); |
| 8151 } | 8151 } |
| 8152 } | 8152 } |
| 8153 | 8153 |
| 8154 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) => _
basis.computeResolvableCompilationUnit(source); | 8154 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) => _
basis.computeResolvableCompilationUnit(source); |
| 8155 | 8155 |
| 8156 bool exists(Source source) { | 8156 bool exists(Source source) { |
| 8157 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
exists"); | 8157 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
exists"); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8472 instrumentation.log(); | 8472 instrumentation.log(); |
| 8473 } | 8473 } |
| 8474 } | 8474 } |
| 8475 | 8475 |
| 8476 CompilationUnit parseCompilationUnit(Source source) { | 8476 CompilationUnit parseCompilationUnit(Source source) { |
| 8477 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
parseCompilationUnit"); | 8477 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
parseCompilationUnit"); |
| 8478 try { | 8478 try { |
| 8479 instrumentation.metric3("contextId", _contextId); | 8479 instrumentation.metric3("contextId", _contextId); |
| 8480 return _basis.parseCompilationUnit(source); | 8480 return _basis.parseCompilationUnit(source); |
| 8481 } on AnalysisException catch (e) { | 8481 } on AnalysisException catch (e) { |
| 8482 recordAnalysisException(instrumentation, e); | 8482 _recordAnalysisException(instrumentation, e); |
| 8483 throw e; | 8483 throw e; |
| 8484 } finally { | 8484 } finally { |
| 8485 instrumentation.log(); | 8485 instrumentation.log(); |
| 8486 } | 8486 } |
| 8487 } | 8487 } |
| 8488 | 8488 |
| 8489 ht.HtmlUnit parseHtmlUnit(Source source) { | 8489 ht.HtmlUnit parseHtmlUnit(Source source) { |
| 8490 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
parseHtmlUnit"); | 8490 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
parseHtmlUnit"); |
| 8491 try { | 8491 try { |
| 8492 instrumentation.metric3("contextId", _contextId); | 8492 instrumentation.metric3("contextId", _contextId); |
| 8493 return _basis.parseHtmlUnit(source); | 8493 return _basis.parseHtmlUnit(source); |
| 8494 } on AnalysisException catch (e) { | 8494 } on AnalysisException catch (e) { |
| 8495 recordAnalysisException(instrumentation, e); | 8495 _recordAnalysisException(instrumentation, e); |
| 8496 throw e; | 8496 throw e; |
| 8497 } finally { | 8497 } finally { |
| 8498 instrumentation.log(); | 8498 instrumentation.log(); |
| 8499 } | 8499 } |
| 8500 } | 8500 } |
| 8501 | 8501 |
| 8502 AnalysisResult performAnalysisTask() { | 8502 AnalysisResult performAnalysisTask() { |
| 8503 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
performAnalysisTask"); | 8503 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
performAnalysisTask"); |
| 8504 try { | 8504 try { |
| 8505 instrumentation.metric3("contextId", _contextId); | 8505 instrumentation.metric3("contextId", _contextId); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 8516 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { | 8516 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { |
| 8517 _basis.recordLibraryElements(elementMap); | 8517 _basis.recordLibraryElements(elementMap); |
| 8518 } | 8518 } |
| 8519 | 8519 |
| 8520 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry) { | 8520 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry) { |
| 8521 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveCompilationUnit"); | 8521 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveCompilationUnit"); |
| 8522 try { | 8522 try { |
| 8523 instrumentation.metric3("contextId", _contextId); | 8523 instrumentation.metric3("contextId", _contextId); |
| 8524 return _basis.resolveCompilationUnit(unitSource, library); | 8524 return _basis.resolveCompilationUnit(unitSource, library); |
| 8525 } on AnalysisException catch (e) { | 8525 } on AnalysisException catch (e) { |
| 8526 recordAnalysisException(instrumentation, e); | 8526 _recordAnalysisException(instrumentation, e); |
| 8527 throw e; | 8527 throw e; |
| 8528 } finally { | 8528 } finally { |
| 8529 instrumentation.log(); | 8529 instrumentation.log(); |
| 8530 } | 8530 } |
| 8531 } | 8531 } |
| 8532 | 8532 |
| 8533 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) { | 8533 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) { |
| 8534 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveCompilationUnit"); | 8534 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveCompilationUnit"); |
| 8535 try { | 8535 try { |
| 8536 instrumentation.metric3("contextId", _contextId); | 8536 instrumentation.metric3("contextId", _contextId); |
| 8537 return _basis.resolveCompilationUnit2(unitSource, librarySource); | 8537 return _basis.resolveCompilationUnit2(unitSource, librarySource); |
| 8538 } on AnalysisException catch (e) { | 8538 } on AnalysisException catch (e) { |
| 8539 recordAnalysisException(instrumentation, e); | 8539 _recordAnalysisException(instrumentation, e); |
| 8540 throw e; | 8540 throw e; |
| 8541 } finally { | 8541 } finally { |
| 8542 instrumentation.log(); | 8542 instrumentation.log(); |
| 8543 } | 8543 } |
| 8544 } | 8544 } |
| 8545 | 8545 |
| 8546 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { | 8546 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { |
| 8547 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveHtmlUnit"); | 8547 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveHtmlUnit"); |
| 8548 try { | 8548 try { |
| 8549 instrumentation.metric3("contextId", _contextId); | 8549 instrumentation.metric3("contextId", _contextId); |
| 8550 return _basis.resolveHtmlUnit(htmlSource); | 8550 return _basis.resolveHtmlUnit(htmlSource); |
| 8551 } on AnalysisException catch (e) { | 8551 } on AnalysisException catch (e) { |
| 8552 recordAnalysisException(instrumentation, e); | 8552 _recordAnalysisException(instrumentation, e); |
| 8553 throw e; | 8553 throw e; |
| 8554 } finally { | 8554 } finally { |
| 8555 instrumentation.log(); | 8555 instrumentation.log(); |
| 8556 } | 8556 } |
| 8557 } | 8557 } |
| 8558 | 8558 |
| 8559 void set analysisOptions(AnalysisOptions options) { | 8559 void set analysisOptions(AnalysisOptions options) { |
| 8560 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setAnalysisOptions"); | 8560 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setAnalysisOptions"); |
| 8561 try { | 8561 try { |
| 8562 instrumentation.metric3("contextId", _contextId); | 8562 instrumentation.metric3("contextId", _contextId); |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9236 */ | 9236 */ |
| 9237 static bool hasAngularAnnotation(ht.HtmlUnit htmlUnit) { | 9237 static bool hasAngularAnnotation(ht.HtmlUnit htmlUnit) { |
| 9238 try { | 9238 try { |
| 9239 htmlUnit.accept(new RecursiveXmlVisitor_AngularHtmlUnitResolver_hasAngular
Annotation()); | 9239 htmlUnit.accept(new RecursiveXmlVisitor_AngularHtmlUnitResolver_hasAngular
Annotation()); |
| 9240 } on AngularHtmlUnitResolver_FoundAppError catch (e) { | 9240 } on AngularHtmlUnitResolver_FoundAppError catch (e) { |
| 9241 return true; | 9241 return true; |
| 9242 } | 9242 } |
| 9243 return false; | 9243 return false; |
| 9244 } | 9244 } |
| 9245 | 9245 |
| 9246 static SimpleIdentifier createIdentifier(String name, int offset) { | 9246 static SimpleIdentifier _createIdentifier(String name, int offset) { |
| 9247 StringToken token = createStringToken(name, offset); | 9247 StringToken token = _createStringToken(name, offset); |
| 9248 return new SimpleIdentifier(token); | 9248 return new SimpleIdentifier(token); |
| 9249 } | 9249 } |
| 9250 | 9250 |
| 9251 /** | 9251 /** |
| 9252 * Adds [AngularElement] declared by the given top-level [Element]. | 9252 * Adds [AngularElement] declared by the given top-level [Element]. |
| 9253 * | 9253 * |
| 9254 * @param angularElements the list to fill with top-level [AngularElement]s | 9254 * @param angularElements the list to fill with top-level [AngularElement]s |
| 9255 * @param classElement the [ClassElement] to get [AngularElement]s from | 9255 * @param classElement the [ClassElement] to get [AngularElement]s from |
| 9256 */ | 9256 */ |
| 9257 static void addAngularElementsFromClass(Set<AngularElement> angularElements, C
lassElement classElement) { | 9257 static void _addAngularElementsFromClass(Set<AngularElement> angularElements,
ClassElement classElement) { |
| 9258 for (ToolkitObjectElement toolkitObject in classElement.toolkitObjects) { | 9258 for (ToolkitObjectElement toolkitObject in classElement.toolkitObjects) { |
| 9259 if (toolkitObject is AngularElement) { | 9259 if (toolkitObject is AngularElement) { |
| 9260 angularElements.add(toolkitObject); | 9260 angularElements.add(toolkitObject); |
| 9261 } | 9261 } |
| 9262 } | 9262 } |
| 9263 } | 9263 } |
| 9264 | 9264 |
| 9265 /** | 9265 /** |
| 9266 * Returns the array of all top-level Angular elements that could be used in t
his library. | 9266 * Returns the array of all top-level Angular elements that could be used in t
his library. |
| 9267 * | 9267 * |
| 9268 * @param libraryElement the [LibraryElement] to analyze | 9268 * @param libraryElement the [LibraryElement] to analyze |
| 9269 * @return the array of all top-level Angular elements that could be used in t
his library | 9269 * @return the array of all top-level Angular elements that could be used in t
his library |
| 9270 */ | 9270 */ |
| 9271 static void addAngularElementsFromLibrary(Set<AngularElement> angularElements,
LibraryElement library, Set<LibraryElement> visited) { | 9271 static void _addAngularElementsFromLibrary(Set<AngularElement> angularElements
, LibraryElement library, Set<LibraryElement> visited) { |
| 9272 if (library == null) { | 9272 if (library == null) { |
| 9273 return; | 9273 return; |
| 9274 } | 9274 } |
| 9275 if (!visited.add(library)) { | 9275 if (!visited.add(library)) { |
| 9276 return; | 9276 return; |
| 9277 } | 9277 } |
| 9278 // add Angular elements from current library | 9278 // add Angular elements from current library |
| 9279 for (CompilationUnitElement unit in library.units) { | 9279 for (CompilationUnitElement unit in library.units) { |
| 9280 angularElements.addAll(unit.angularViews); | 9280 angularElements.addAll(unit.angularViews); |
| 9281 for (ClassElement type in unit.types) { | 9281 for (ClassElement type in unit.types) { |
| 9282 addAngularElementsFromClass(angularElements, type); | 9282 _addAngularElementsFromClass(angularElements, type); |
| 9283 } | 9283 } |
| 9284 } | 9284 } |
| 9285 // handle imports | 9285 // handle imports |
| 9286 for (ImportElement importElement in library.imports) { | 9286 for (ImportElement importElement in library.imports) { |
| 9287 LibraryElement importedLibrary = importElement.importedLibrary; | 9287 LibraryElement importedLibrary = importElement.importedLibrary; |
| 9288 addAngularElementsFromLibrary(angularElements, importedLibrary, visited); | 9288 _addAngularElementsFromLibrary(angularElements, importedLibrary, visited); |
| 9289 } | 9289 } |
| 9290 } | 9290 } |
| 9291 | 9291 |
| 9292 static StringToken createStringToken(String name, int offset) => new StringTok
en(TokenType.IDENTIFIER, name, offset); | 9292 static StringToken _createStringToken(String name, int offset) => new StringTo
ken(TokenType.IDENTIFIER, name, offset); |
| 9293 | 9293 |
| 9294 /** | 9294 /** |
| 9295 * Returns the array of all top-level Angular elements that could be used in t
his library. | 9295 * Returns the array of all top-level Angular elements that could be used in t
his library. |
| 9296 * | 9296 * |
| 9297 * @param libraryElement the [LibraryElement] to analyze | 9297 * @param libraryElement the [LibraryElement] to analyze |
| 9298 * @return the array of all top-level Angular elements that could be used in t
his library | 9298 * @return the array of all top-level Angular elements that could be used in t
his library |
| 9299 */ | 9299 */ |
| 9300 static List<AngularElement> getAngularElements(Set<LibraryElement> libraries,
LibraryElement libraryElement) { | 9300 static List<AngularElement> _getAngularElements(Set<LibraryElement> libraries,
LibraryElement libraryElement) { |
| 9301 Set<AngularElement> angularElements = new Set(); | 9301 Set<AngularElement> angularElements = new Set(); |
| 9302 addAngularElementsFromLibrary(angularElements, libraryElement, libraries); | 9302 _addAngularElementsFromLibrary(angularElements, libraryElement, libraries); |
| 9303 return new List.from(angularElements); | 9303 return new List.from(angularElements); |
| 9304 } | 9304 } |
| 9305 | 9305 |
| 9306 /** | 9306 /** |
| 9307 * Returns the external Dart [CompilationUnit] referenced by the given [HtmlUn
it]. | 9307 * Returns the external Dart [CompilationUnit] referenced by the given [HtmlUn
it]. |
| 9308 */ | 9308 */ |
| 9309 static CompilationUnit getDartUnit(AnalysisContext context, ht.HtmlUnit unit)
{ | 9309 static CompilationUnit _getDartUnit(AnalysisContext context, ht.HtmlUnit unit)
{ |
| 9310 for (HtmlScriptElement script in unit.element.scripts) { | 9310 for (HtmlScriptElement script in unit.element.scripts) { |
| 9311 if (script is ExternalHtmlScriptElement) { | 9311 if (script is ExternalHtmlScriptElement) { |
| 9312 Source scriptSource = script.scriptSource; | 9312 Source scriptSource = script.scriptSource; |
| 9313 if (scriptSource != null) { | 9313 if (scriptSource != null) { |
| 9314 return context.resolveCompilationUnit2(scriptSource, scriptSource); | 9314 return context.resolveCompilationUnit2(scriptSource, scriptSource); |
| 9315 } | 9315 } |
| 9316 } | 9316 } |
| 9317 } | 9317 } |
| 9318 return null; | 9318 return null; |
| 9319 } | 9319 } |
| 9320 | 9320 |
| 9321 static Set<Source> getLibrarySources(Set<LibraryElement> libraries) { | 9321 static Set<Source> _getLibrarySources(Set<LibraryElement> libraries) { |
| 9322 Set<Source> sources = new Set(); | 9322 Set<Source> sources = new Set(); |
| 9323 for (LibraryElement library in libraries) { | 9323 for (LibraryElement library in libraries) { |
| 9324 sources.add(library.source); | 9324 sources.add(library.source); |
| 9325 } | 9325 } |
| 9326 return sources; | 9326 return sources; |
| 9327 } | 9327 } |
| 9328 | 9328 |
| 9329 InternalAnalysisContext _context; | 9329 InternalAnalysisContext _context; |
| 9330 | 9330 |
| 9331 TypeProvider _typeProvider; | 9331 TypeProvider _typeProvider; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9372 /** | 9372 /** |
| 9373 * The [AngularApplication] for the Web application with this entry point, may
be | 9373 * The [AngularApplication] for the Web application with this entry point, may
be |
| 9374 * `null` if not an entry point. | 9374 * `null` if not an entry point. |
| 9375 */ | 9375 */ |
| 9376 AngularApplication calculateAngularApplication() { | 9376 AngularApplication calculateAngularApplication() { |
| 9377 // check if Angular at all | 9377 // check if Angular at all |
| 9378 if (!hasAngularAnnotation(_unit)) { | 9378 if (!hasAngularAnnotation(_unit)) { |
| 9379 return null; | 9379 return null; |
| 9380 } | 9380 } |
| 9381 // prepare resolved Dart unit | 9381 // prepare resolved Dart unit |
| 9382 CompilationUnit dartUnit = getDartUnit(_context, _unit); | 9382 CompilationUnit dartUnit = _getDartUnit(_context, _unit); |
| 9383 if (dartUnit == null) { | 9383 if (dartUnit == null) { |
| 9384 return null; | 9384 return null; |
| 9385 } | 9385 } |
| 9386 // prepare accessible Angular elements | 9386 // prepare accessible Angular elements |
| 9387 LibraryElement libraryElement = dartUnit.element.library; | 9387 LibraryElement libraryElement = dartUnit.element.library; |
| 9388 Set<LibraryElement> libraries = new Set(); | 9388 Set<LibraryElement> libraries = new Set(); |
| 9389 List<AngularElement> angularElements = getAngularElements(libraries, library
Element); | 9389 List<AngularElement> angularElements = _getAngularElements(libraries, librar
yElement); |
| 9390 // resolve AngularComponentElement template URIs | 9390 // resolve AngularComponentElement template URIs |
| 9391 // TODO(scheglov) resolve to HtmlElement to allow F3 ? | 9391 // TODO(scheglov) resolve to HtmlElement to allow F3 ? |
| 9392 Set<Source> angularElementsSources = new Set(); | 9392 Set<Source> angularElementsSources = new Set(); |
| 9393 for (AngularElement angularElement in angularElements) { | 9393 for (AngularElement angularElement in angularElements) { |
| 9394 if (angularElement is AngularHasTemplateElement) { | 9394 if (angularElement is AngularHasTemplateElement) { |
| 9395 AngularHasTemplateElement hasTemplate = angularElement; | 9395 AngularHasTemplateElement hasTemplate = angularElement; |
| 9396 angularElementsSources.add(angularElement.source); | 9396 angularElementsSources.add(angularElement.source); |
| 9397 String templateUri = hasTemplate.templateUri; | 9397 String templateUri = hasTemplate.templateUri; |
| 9398 if (templateUri == null) { | 9398 if (templateUri == null) { |
| 9399 continue; | 9399 continue; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 9415 } | 9415 } |
| 9416 if (hasTemplate is AngularViewElementImpl) { | 9416 if (hasTemplate is AngularViewElementImpl) { |
| 9417 hasTemplate.templateSource = templateSource; | 9417 hasTemplate.templateSource = templateSource; |
| 9418 } | 9418 } |
| 9419 } on URISyntaxException catch (exception) { | 9419 } on URISyntaxException catch (exception) { |
| 9420 _errorListener.onError(new AnalysisError.con2(angularElement.source, h
asTemplate.templateUriOffset, templateUri.length, AngularCode.INVALID_URI, [temp
lateUri])); | 9420 _errorListener.onError(new AnalysisError.con2(angularElement.source, h
asTemplate.templateUriOffset, templateUri.length, AngularCode.INVALID_URI, [temp
lateUri])); |
| 9421 } | 9421 } |
| 9422 } | 9422 } |
| 9423 } | 9423 } |
| 9424 // create AngularApplication | 9424 // create AngularApplication |
| 9425 AngularApplication application = new AngularApplication(_source, getLibraryS
ources(libraries), angularElements, new List.from(angularElementsSources)); | 9425 AngularApplication application = new AngularApplication(_source, _getLibrary
Sources(libraries), angularElements, new List.from(angularElementsSources)); |
| 9426 // set AngularApplication for each AngularElement | 9426 // set AngularApplication for each AngularElement |
| 9427 for (AngularElement angularElement in angularElements) { | 9427 for (AngularElement angularElement in angularElements) { |
| 9428 (angularElement as AngularElementImpl).application = application; | 9428 (angularElement as AngularElementImpl).application = application; |
| 9429 } | 9429 } |
| 9430 // done | 9430 // done |
| 9431 return application; | 9431 return application; |
| 9432 } | 9432 } |
| 9433 | 9433 |
| 9434 /** | 9434 /** |
| 9435 * Resolves [source] as an [AngularComponentElement] template file. | 9435 * Resolves [source] as an [AngularComponentElement] template file. |
| 9436 * | 9436 * |
| 9437 * @param application the Angular application we are resolving for | 9437 * @param application the Angular application we are resolving for |
| 9438 * @param component the [AngularComponentElement] to resolve template for, not
`null` | 9438 * @param component the [AngularComponentElement] to resolve template for, not
`null` |
| 9439 */ | 9439 */ |
| 9440 void resolveComponentTemplate(AngularApplication application, AngularComponent
Element component) { | 9440 void resolveComponentTemplate(AngularApplication application, AngularComponent
Element component) { |
| 9441 _isAngular = true; | 9441 _isAngular = true; |
| 9442 resolveInternal(application.elements, component); | 9442 _resolveInternal(application.elements, component); |
| 9443 } | 9443 } |
| 9444 | 9444 |
| 9445 /** | 9445 /** |
| 9446 * Resolves [source] as an Angular application entry point. | 9446 * Resolves [source] as an Angular application entry point. |
| 9447 */ | 9447 */ |
| 9448 void resolveEntryPoint(AngularApplication application) { | 9448 void resolveEntryPoint(AngularApplication application) { |
| 9449 resolveInternal(application.elements, null); | 9449 _resolveInternal(application.elements, null); |
| 9450 } | 9450 } |
| 9451 | 9451 |
| 9452 Object visitXmlAttributeNode(ht.XmlAttributeNode node) { | 9452 Object visitXmlAttributeNode(ht.XmlAttributeNode node) { |
| 9453 parseEmbeddedExpressionsInAttribute(node); | 9453 _parseEmbeddedExpressionsInAttribute(node); |
| 9454 resolveExpressions(node.expressions); | 9454 _resolveExpressions(node.expressions); |
| 9455 return super.visitXmlAttributeNode(node); | 9455 return super.visitXmlAttributeNode(node); |
| 9456 } | 9456 } |
| 9457 | 9457 |
| 9458 Object visitXmlTagNode(ht.XmlTagNode node) { | 9458 Object visitXmlTagNode(ht.XmlTagNode node) { |
| 9459 bool wasAngular = _isAngular; | 9459 bool wasAngular = _isAngular; |
| 9460 try { | 9460 try { |
| 9461 // new Angular context | 9461 // new Angular context |
| 9462 if (node.getAttribute(_NG_APP) != null) { | 9462 if (node.getAttribute(_NG_APP) != null) { |
| 9463 _isAngular = true; | 9463 _isAngular = true; |
| 9464 visitModelDirectives(node); | 9464 _visitModelDirectives(node); |
| 9465 } | 9465 } |
| 9466 // not Angular | 9466 // not Angular |
| 9467 if (!_isAngular) { | 9467 if (!_isAngular) { |
| 9468 return super.visitXmlTagNode(node); | 9468 return super.visitXmlTagNode(node); |
| 9469 } | 9469 } |
| 9470 // process node in separate name scope | 9470 // process node in separate name scope |
| 9471 pushNameScope(); | 9471 _pushNameScope(); |
| 9472 try { | 9472 try { |
| 9473 parseEmbeddedExpressionsInTag(node); | 9473 _parseEmbeddedExpressionsInTag(node); |
| 9474 // apply processors | 9474 // apply processors |
| 9475 for (NgProcessor processor in _processors) { | 9475 for (NgProcessor processor in _processors) { |
| 9476 if (processor.canApply(node)) { | 9476 if (processor.canApply(node)) { |
| 9477 processor.apply(this, node); | 9477 processor.apply(this, node); |
| 9478 } | 9478 } |
| 9479 } | 9479 } |
| 9480 // resolve expressions | 9480 // resolve expressions |
| 9481 resolveExpressions(node.expressions); | 9481 _resolveExpressions(node.expressions); |
| 9482 // process children | 9482 // process children |
| 9483 return super.visitXmlTagNode(node); | 9483 return super.visitXmlTagNode(node); |
| 9484 } finally { | 9484 } finally { |
| 9485 popNameScope(); | 9485 _popNameScope(); |
| 9486 } | 9486 } |
| 9487 } finally { | 9487 } finally { |
| 9488 _isAngular = wasAngular; | 9488 _isAngular = wasAngular; |
| 9489 } | 9489 } |
| 9490 } | 9490 } |
| 9491 | 9491 |
| 9492 /** | 9492 /** |
| 9493 * Creates new [LocalVariableElementImpl] with given type and identifier. | 9493 * Creates new [LocalVariableElementImpl] with given type and identifier. |
| 9494 * | 9494 * |
| 9495 * @param type the [Type] of the variable | 9495 * @param type the [Type] of the variable |
| 9496 * @param identifier the identifier to create variable for | 9496 * @param identifier the identifier to create variable for |
| 9497 * @return the new [LocalVariableElementImpl] | 9497 * @return the new [LocalVariableElementImpl] |
| 9498 */ | 9498 */ |
| 9499 LocalVariableElementImpl createLocalVariableFromIdentifier(Type2 type, SimpleI
dentifier identifier) { | 9499 LocalVariableElementImpl _createLocalVariableFromIdentifier(Type2 type, Simple
Identifier identifier) { |
| 9500 LocalVariableElementImpl variable = new LocalVariableElementImpl(identifier)
; | 9500 LocalVariableElementImpl variable = new LocalVariableElementImpl(identifier)
; |
| 9501 _definedVariables.add(variable); | 9501 _definedVariables.add(variable); |
| 9502 variable.type = type; | 9502 variable.type = type; |
| 9503 return variable; | 9503 return variable; |
| 9504 } | 9504 } |
| 9505 | 9505 |
| 9506 /** | 9506 /** |
| 9507 * Creates new [LocalVariableElementImpl] with given name and type. | 9507 * Creates new [LocalVariableElementImpl] with given name and type. |
| 9508 * | 9508 * |
| 9509 * @param type the [Type] of the variable | 9509 * @param type the [Type] of the variable |
| 9510 * @param name the name of the variable | 9510 * @param name the name of the variable |
| 9511 * @return the new [LocalVariableElementImpl] | 9511 * @return the new [LocalVariableElementImpl] |
| 9512 */ | 9512 */ |
| 9513 LocalVariableElementImpl createLocalVariableWithName(Type2 type, String name)
{ | 9513 LocalVariableElementImpl _createLocalVariableWithName(Type2 type, String name)
{ |
| 9514 SimpleIdentifier identifier = createIdentifier(name, 0); | 9514 SimpleIdentifier identifier = _createIdentifier(name, 0); |
| 9515 return createLocalVariableFromIdentifier(type, identifier); | 9515 return _createLocalVariableFromIdentifier(type, identifier); |
| 9516 } | 9516 } |
| 9517 | 9517 |
| 9518 /** | 9518 /** |
| 9519 * Declares the given [LocalVariableElementImpl] in the [topNameScope]. | 9519 * Declares the given [LocalVariableElementImpl] in the [topNameScope]. |
| 9520 */ | 9520 */ |
| 9521 void defineTopVariable(LocalVariableElementImpl variable) { | 9521 void _defineTopVariable(LocalVariableElementImpl variable) { |
| 9522 recordDefinedVariable(variable); | 9522 _recordDefinedVariable(variable); |
| 9523 _topNameScope.define(variable); | 9523 _topNameScope.define(variable); |
| 9524 recordTypeLibraryInjected(variable); | 9524 _recordTypeLibraryInjected(variable); |
| 9525 } | 9525 } |
| 9526 | 9526 |
| 9527 /** | 9527 /** |
| 9528 * Declares the given [LocalVariableElementImpl] in the current [nameScope]. | 9528 * Declares the given [LocalVariableElementImpl] in the current [nameScope]. |
| 9529 */ | 9529 */ |
| 9530 void defineVariable(LocalVariableElementImpl variable) { | 9530 void _defineVariable(LocalVariableElementImpl variable) { |
| 9531 recordDefinedVariable(variable); | 9531 _recordDefinedVariable(variable); |
| 9532 _nameScope.define(variable); | 9532 _nameScope.define(variable); |
| 9533 recordTypeLibraryInjected(variable); | 9533 _recordTypeLibraryInjected(variable); |
| 9534 } | 9534 } |
| 9535 | 9535 |
| 9536 /** | 9536 /** |
| 9537 * @return the [AngularElement] with the given name, maybe `null`. | 9537 * @return the [AngularElement] with the given name, maybe `null`. |
| 9538 */ | 9538 */ |
| 9539 AngularElement findAngularElement(String name) { | 9539 AngularElement _findAngularElement(String name) { |
| 9540 for (AngularElement element in _angularElements) { | 9540 for (AngularElement element in _angularElements) { |
| 9541 if (name == element.name) { | 9541 if (name == element.name) { |
| 9542 return element; | 9542 return element; |
| 9543 } | 9543 } |
| 9544 } | 9544 } |
| 9545 return null; | 9545 return null; |
| 9546 } | 9546 } |
| 9547 | 9547 |
| 9548 /** | 9548 /** |
| 9549 * @return the [TypeProvider] of the [AnalysisContext]. | 9549 * @return the [TypeProvider] of the [AnalysisContext]. |
| 9550 */ | 9550 */ |
| 9551 TypeProvider get typeProvider => _typeProvider; | 9551 TypeProvider get typeProvider => _typeProvider; |
| 9552 | 9552 |
| 9553 /** | 9553 /** |
| 9554 * Parses given [String] as an [AngularExpression] at the given offset. | 9554 * Parses given [String] as an [AngularExpression] at the given offset. |
| 9555 */ | 9555 */ |
| 9556 AngularExpression parseAngularExpression(String contents, int startIndex, int
endIndex, int offset) { | 9556 AngularExpression _parseAngularExpression(String contents, int startIndex, int
endIndex, int offset) { |
| 9557 Token token = scanDart(contents, startIndex, endIndex, offset); | 9557 Token token = _scanDart(contents, startIndex, endIndex, offset); |
| 9558 return parseAngularExpressionInToken(token); | 9558 return _parseAngularExpressionInToken(token); |
| 9559 } | 9559 } |
| 9560 | 9560 |
| 9561 AngularExpression parseAngularExpressionInToken(Token token) { | 9561 AngularExpression _parseAngularExpressionInToken(Token token) { |
| 9562 List<Token> tokens = splitAtBar(token); | 9562 List<Token> tokens = _splitAtBar(token); |
| 9563 Expression mainExpression = parseDartExpressionInToken(tokens[0]); | 9563 Expression mainExpression = _parseDartExpressionInToken(tokens[0]); |
| 9564 // parse filters | 9564 // parse filters |
| 9565 List<AngularFilterNode> filters = []; | 9565 List<AngularFilterNode> filters = []; |
| 9566 for (int i = 1; i < tokens.length; i++) { | 9566 for (int i = 1; i < tokens.length; i++) { |
| 9567 Token filterToken = tokens[i]; | 9567 Token filterToken = tokens[i]; |
| 9568 Token barToken = filterToken; | 9568 Token barToken = filterToken; |
| 9569 filterToken = filterToken.next; | 9569 filterToken = filterToken.next; |
| 9570 // TODO(scheglov) report missing identifier | 9570 // TODO(scheglov) report missing identifier |
| 9571 SimpleIdentifier name = parseDartExpressionInToken(filterToken) as SimpleI
dentifier; | 9571 SimpleIdentifier name = _parseDartExpressionInToken(filterToken) as Simple
Identifier; |
| 9572 filterToken = name.endToken.next; | 9572 filterToken = name.endToken.next; |
| 9573 // parse arguments | 9573 // parse arguments |
| 9574 List<AngularFilterArgument> arguments = []; | 9574 List<AngularFilterArgument> arguments = []; |
| 9575 while (filterToken.type != TokenType.EOF) { | 9575 while (filterToken.type != TokenType.EOF) { |
| 9576 // skip ":" | 9576 // skip ":" |
| 9577 Token colonToken = filterToken; | 9577 Token colonToken = filterToken; |
| 9578 if (identical(colonToken.type, TokenType.COLON)) { | 9578 if (identical(colonToken.type, TokenType.COLON)) { |
| 9579 filterToken = filterToken.next; | 9579 filterToken = filterToken.next; |
| 9580 } else { | 9580 } else { |
| 9581 reportErrorForToken(AngularCode.MISSING_FILTER_COLON, colonToken, []); | 9581 _reportErrorForToken(AngularCode.MISSING_FILTER_COLON, colonToken, [])
; |
| 9582 } | 9582 } |
| 9583 // parse argument | 9583 // parse argument |
| 9584 Expression argument = parseDartExpressionInToken(filterToken); | 9584 Expression argument = _parseDartExpressionInToken(filterToken); |
| 9585 arguments.add(new AngularFilterArgument(colonToken, argument)); | 9585 arguments.add(new AngularFilterArgument(colonToken, argument)); |
| 9586 // next token | 9586 // next token |
| 9587 filterToken = argument.endToken.next; | 9587 filterToken = argument.endToken.next; |
| 9588 } | 9588 } |
| 9589 filters.add(new AngularFilterNode(barToken, name, arguments)); | 9589 filters.add(new AngularFilterNode(barToken, name, arguments)); |
| 9590 } | 9590 } |
| 9591 // done | 9591 // done |
| 9592 return new AngularExpression(mainExpression, filters); | 9592 return new AngularExpression(mainExpression, filters); |
| 9593 } | 9593 } |
| 9594 | 9594 |
| 9595 /** | 9595 /** |
| 9596 * Parses given [String] as an [Expression] at the given offset. | 9596 * Parses given [String] as an [Expression] at the given offset. |
| 9597 */ | 9597 */ |
| 9598 Expression parseDartExpression(String contents, int startIndex, int endIndex,
int offset) { | 9598 Expression _parseDartExpression(String contents, int startIndex, int endIndex,
int offset) { |
| 9599 Token token = scanDart(contents, startIndex, endIndex, offset); | 9599 Token token = _scanDart(contents, startIndex, endIndex, offset); |
| 9600 return parseDartExpressionInToken(token); | 9600 return _parseDartExpressionInToken(token); |
| 9601 } | 9601 } |
| 9602 | 9602 |
| 9603 Expression parseDartExpressionInToken(Token token) { | 9603 Expression _parseDartExpressionInToken(Token token) { |
| 9604 Parser parser = new Parser(_source, _errorListener); | 9604 Parser parser = new Parser(_source, _errorListener); |
| 9605 return parser.parseExpression(token); | 9605 return parser.parseExpression(token); |
| 9606 } | 9606 } |
| 9607 | 9607 |
| 9608 void popNameScope() { | 9608 void _popNameScope() { |
| 9609 _nameScope = _resolver.popNameScope(); | 9609 _nameScope = _resolver.popNameScope(); |
| 9610 } | 9610 } |
| 9611 | 9611 |
| 9612 void pushNameScope() { | 9612 void _pushNameScope() { |
| 9613 _nameScope = _resolver.pushNameScope(); | 9613 _nameScope = _resolver.pushNameScope(); |
| 9614 } | 9614 } |
| 9615 | 9615 |
| 9616 /** | 9616 /** |
| 9617 * Reports given [ErrorCode] at the given [AstNode]. | 9617 * Reports given [ErrorCode] at the given [AstNode]. |
| 9618 */ | 9618 */ |
| 9619 void reportErrorForNode(ErrorCode errorCode, AstNode node, List<Object> argume
nts) { | 9619 void _reportErrorForNode(ErrorCode errorCode, AstNode node, List<Object> argum
ents) { |
| 9620 reportErrorForOffset(errorCode, node.offset, node.length, arguments); | 9620 _reportErrorForOffset(errorCode, node.offset, node.length, arguments); |
| 9621 } | 9621 } |
| 9622 | 9622 |
| 9623 /** | 9623 /** |
| 9624 * Reports given [ErrorCode] at the given position. | 9624 * Reports given [ErrorCode] at the given position. |
| 9625 */ | 9625 */ |
| 9626 void reportErrorForOffset(ErrorCode errorCode, int offset, int length, List<Ob
ject> arguments) { | 9626 void _reportErrorForOffset(ErrorCode errorCode, int offset, int length, List<O
bject> arguments) { |
| 9627 _errorListener.onError(new AnalysisError.con2(_source, offset, length, error
Code, arguments)); | 9627 _errorListener.onError(new AnalysisError.con2(_source, offset, length, error
Code, arguments)); |
| 9628 } | 9628 } |
| 9629 | 9629 |
| 9630 /** | 9630 /** |
| 9631 * Reports given [ErrorCode] at the given [Token]. | 9631 * Reports given [ErrorCode] at the given [Token]. |
| 9632 */ | 9632 */ |
| 9633 void reportErrorForToken(ErrorCode errorCode, Token token, List<Object> argume
nts) { | 9633 void _reportErrorForToken(ErrorCode errorCode, Token token, List<Object> argum
ents) { |
| 9634 reportErrorForOffset(errorCode, token.offset, token.length, arguments); | 9634 _reportErrorForOffset(errorCode, token.offset, token.length, arguments); |
| 9635 } | 9635 } |
| 9636 | 9636 |
| 9637 void resolveExpression(AngularExpression angularExpression) { | 9637 void _resolveExpression(AngularExpression angularExpression) { |
| 9638 List<Expression> dartExpressions = angularExpression.expressions; | 9638 List<Expression> dartExpressions = angularExpression.expressions; |
| 9639 for (Expression dartExpression in dartExpressions) { | 9639 for (Expression dartExpression in dartExpressions) { |
| 9640 resolveNode(dartExpression); | 9640 _resolveNode(dartExpression); |
| 9641 } | 9641 } |
| 9642 } | 9642 } |
| 9643 | 9643 |
| 9644 /** | 9644 /** |
| 9645 * Resolves given [AstNode] using [resolver]. | 9645 * Resolves given [AstNode] using [resolver]. |
| 9646 */ | 9646 */ |
| 9647 void resolveNode(AstNode node) { | 9647 void _resolveNode(AstNode node) { |
| 9648 node.accept(_resolver); | 9648 node.accept(_resolver); |
| 9649 } | 9649 } |
| 9650 | 9650 |
| 9651 Token scanDart(String contents, int startIndex, int endIndex, int offset) => h
t.HtmlParser.scanDartSource(_source, _lineInfo, contents.substring(startIndex, e
ndIndex), offset + startIndex, _errorListener); | 9651 Token _scanDart(String contents, int startIndex, int endIndex, int offset) =>
ht.HtmlParser.scanDartSource(_source, _lineInfo, contents.substring(startIndex,
endIndex), offset + startIndex, _errorListener); |
| 9652 | 9652 |
| 9653 /** | 9653 /** |
| 9654 * Puts into [libraryElement] an artificial [LibraryElementImpl] for this HTML | 9654 * Puts into [libraryElement] an artificial [LibraryElementImpl] for this HTML |
| 9655 * [Source]. | 9655 * [Source]. |
| 9656 */ | 9656 */ |
| 9657 void createLibraryElement() { | 9657 void _createLibraryElement() { |
| 9658 // create CompilationUnitElementImpl | 9658 // create CompilationUnitElementImpl |
| 9659 String unitName = _source.shortName; | 9659 String unitName = _source.shortName; |
| 9660 _unitElement = new CompilationUnitElementImpl(unitName); | 9660 _unitElement = new CompilationUnitElementImpl(unitName); |
| 9661 _unitElement.source = _source; | 9661 _unitElement.source = _source; |
| 9662 // create LibraryElementImpl | 9662 // create LibraryElementImpl |
| 9663 _libraryElement = new LibraryElementImpl(_context, null); | 9663 _libraryElement = new LibraryElementImpl(_context, null); |
| 9664 _libraryElement.definingCompilationUnit = _unitElement; | 9664 _libraryElement.definingCompilationUnit = _unitElement; |
| 9665 _libraryElement.angularHtml = true; | 9665 _libraryElement.angularHtml = true; |
| 9666 _injectedLibraries.add(_libraryElement); | 9666 _injectedLibraries.add(_libraryElement); |
| 9667 // create FunctionElementImpl | 9667 // create FunctionElementImpl |
| 9668 _functionElement = new FunctionElementImpl.con2(0); | 9668 _functionElement = new FunctionElementImpl.con2(0); |
| 9669 _unitElement.functions = <FunctionElement> [_functionElement]; | 9669 _unitElement.functions = <FunctionElement> [_functionElement]; |
| 9670 } | 9670 } |
| 9671 | 9671 |
| 9672 /** | 9672 /** |
| 9673 * Creates new [NgProcessor] for the given [AngularElement], maybe `null` if n
ot | 9673 * Creates new [NgProcessor] for the given [AngularElement], maybe `null` if n
ot |
| 9674 * supported. | 9674 * supported. |
| 9675 */ | 9675 */ |
| 9676 NgProcessor createProcessor(AngularElement element) { | 9676 NgProcessor _createProcessor(AngularElement element) { |
| 9677 if (element is AngularComponentElement) { | 9677 if (element is AngularComponentElement) { |
| 9678 AngularComponentElement component = element; | 9678 AngularComponentElement component = element; |
| 9679 return new NgComponentElementProcessor(component); | 9679 return new NgComponentElementProcessor(component); |
| 9680 } | 9680 } |
| 9681 if (element is AngularControllerElement) { | 9681 if (element is AngularControllerElement) { |
| 9682 AngularControllerElement controller = element; | 9682 AngularControllerElement controller = element; |
| 9683 return new NgControllerElementProcessor(controller); | 9683 return new NgControllerElementProcessor(controller); |
| 9684 } | 9684 } |
| 9685 if (element is AngularDirectiveElement) { | 9685 if (element is AngularDirectiveElement) { |
| 9686 AngularDirectiveElement directive = element; | 9686 AngularDirectiveElement directive = element; |
| 9687 return new NgDirectiveElementProcessor(directive); | 9687 return new NgDirectiveElementProcessor(directive); |
| 9688 } | 9688 } |
| 9689 return null; | 9689 return null; |
| 9690 } | 9690 } |
| 9691 | 9691 |
| 9692 /** | 9692 /** |
| 9693 * Puts into [resolver] an [ResolverVisitor] to resolve [Expression]s in | 9693 * Puts into [resolver] an [ResolverVisitor] to resolve [Expression]s in |
| 9694 * [source]. | 9694 * [source]. |
| 9695 */ | 9695 */ |
| 9696 void createResolver() { | 9696 void _createResolver() { |
| 9697 InheritanceManager inheritanceManager = new InheritanceManager(_libraryEleme
nt); | 9697 InheritanceManager inheritanceManager = new InheritanceManager(_libraryEleme
nt); |
| 9698 _resolver = new ResolverVisitor.con2(_libraryElement, _source, _typeProvider
, inheritanceManager, _errorListener); | 9698 _resolver = new ResolverVisitor.con2(_libraryElement, _source, _typeProvider
, inheritanceManager, _errorListener); |
| 9699 _topNameScope = _resolver.pushNameScope(); | 9699 _topNameScope = _resolver.pushNameScope(); |
| 9700 // add Scope variables - no type, no location, just to avoid warnings | 9700 // add Scope variables - no type, no location, just to avoid warnings |
| 9701 { | 9701 { |
| 9702 Type2 type = _typeProvider.dynamicType; | 9702 Type2 type = _typeProvider.dynamicType; |
| 9703 _topNameScope.define(createLocalVariableWithName(type, "\$id")); | 9703 _topNameScope.define(_createLocalVariableWithName(type, "\$id")); |
| 9704 _topNameScope.define(createLocalVariableWithName(type, "\$parent")); | 9704 _topNameScope.define(_createLocalVariableWithName(type, "\$parent")); |
| 9705 _topNameScope.define(createLocalVariableWithName(type, "\$root")); | 9705 _topNameScope.define(_createLocalVariableWithName(type, "\$root")); |
| 9706 } | 9706 } |
| 9707 } | 9707 } |
| 9708 | 9708 |
| 9709 /** | 9709 /** |
| 9710 * Defines variable for the given [AngularElement] with type of the enclosing | 9710 * Defines variable for the given [AngularElement] with type of the enclosing |
| 9711 * [ClassElement]. | 9711 * [ClassElement]. |
| 9712 */ | 9712 */ |
| 9713 void defineTopVariable_forClassElement(AngularElement element) { | 9713 void _defineTopVariable_forClassElement(AngularElement element) { |
| 9714 ClassElement classElement = element.enclosingElement as ClassElement; | 9714 ClassElement classElement = element.enclosingElement as ClassElement; |
| 9715 InterfaceType type = classElement.type; | 9715 InterfaceType type = classElement.type; |
| 9716 LocalVariableElementImpl variable = createLocalVariableWithName(type, elemen
t.name); | 9716 LocalVariableElementImpl variable = _createLocalVariableWithName(type, eleme
nt.name); |
| 9717 defineTopVariable(variable); | 9717 _defineTopVariable(variable); |
| 9718 variable.toolkitObjects = <AngularElement> [element]; | 9718 variable.toolkitObjects = <AngularElement> [element]; |
| 9719 } | 9719 } |
| 9720 | 9720 |
| 9721 /** | 9721 /** |
| 9722 * Defines variable for the given [AngularScopePropertyElement]. | 9722 * Defines variable for the given [AngularScopePropertyElement]. |
| 9723 */ | 9723 */ |
| 9724 void defineTopVariable_forScopeProperty(AngularScopePropertyElement element) { | 9724 void _defineTopVariable_forScopeProperty(AngularScopePropertyElement element)
{ |
| 9725 Type2 type = element.type; | 9725 Type2 type = element.type; |
| 9726 LocalVariableElementImpl variable = createLocalVariableWithName(type, elemen
t.name); | 9726 LocalVariableElementImpl variable = _createLocalVariableWithName(type, eleme
nt.name); |
| 9727 defineTopVariable(variable); | 9727 _defineTopVariable(variable); |
| 9728 variable.toolkitObjects = <AngularElement> [element]; | 9728 variable.toolkitObjects = <AngularElement> [element]; |
| 9729 } | 9729 } |
| 9730 | 9730 |
| 9731 /** | 9731 /** |
| 9732 * Parse the value of the given token for embedded expressions, and add any em
bedded expressions | 9732 * Parse the value of the given token for embedded expressions, and add any em
bedded expressions |
| 9733 * that are found to the given list of expressions. | 9733 * that are found to the given list of expressions. |
| 9734 * | 9734 * |
| 9735 * @param expressions the list to which embedded expressions are to be added | 9735 * @param expressions the list to which embedded expressions are to be added |
| 9736 * @param token the token whose value is to be parsed | 9736 * @param token the token whose value is to be parsed |
| 9737 */ | 9737 */ |
| 9738 void parseEmbeddedExpressions(List<AngularMoustacheXmlExpression> expressions,
ht.Token token) { | 9738 void _parseEmbeddedExpressions(List<AngularMoustacheXmlExpression> expressions
, ht.Token token) { |
| 9739 // prepare Token information | 9739 // prepare Token information |
| 9740 String lexeme = token.lexeme; | 9740 String lexeme = token.lexeme; |
| 9741 int offset = token.offset; | 9741 int offset = token.offset; |
| 9742 // find expressions between {{ and }} | 9742 // find expressions between {{ and }} |
| 9743 int startIndex = StringUtilities.indexOf2(lexeme, 0, AngularMoustacheXmlExpr
ession.OPENING_DELIMITER_CHAR, AngularMoustacheXmlExpression.OPENING_DELIMITER_C
HAR); | 9743 int startIndex = StringUtilities.indexOf2(lexeme, 0, AngularMoustacheXmlExpr
ession.OPENING_DELIMITER_CHAR, AngularMoustacheXmlExpression.OPENING_DELIMITER_C
HAR); |
| 9744 while (startIndex >= 0) { | 9744 while (startIndex >= 0) { |
| 9745 int endIndex = StringUtilities.indexOf2(lexeme, startIndex + AngularMousta
cheXmlExpression.OPENING_DELIMITER_LENGTH, AngularMoustacheXmlExpression.CLOSING
_DELIMITER_CHAR, AngularMoustacheXmlExpression.CLOSING_DELIMITER_CHAR); | 9745 int endIndex = StringUtilities.indexOf2(lexeme, startIndex + AngularMousta
cheXmlExpression.OPENING_DELIMITER_LENGTH, AngularMoustacheXmlExpression.CLOSING
_DELIMITER_CHAR, AngularMoustacheXmlExpression.CLOSING_DELIMITER_CHAR); |
| 9746 if (endIndex < 0) { | 9746 if (endIndex < 0) { |
| 9747 // TODO(brianwilkerson) Should we report this error or will it be report
ed by something else? | 9747 // TODO(brianwilkerson) Should we report this error or will it be report
ed by something else? |
| 9748 return; | 9748 return; |
| 9749 } else if (startIndex + AngularMoustacheXmlExpression.OPENING_DELIMITER_LE
NGTH < endIndex) { | 9749 } else if (startIndex + AngularMoustacheXmlExpression.OPENING_DELIMITER_LE
NGTH < endIndex) { |
| 9750 startIndex += AngularMoustacheXmlExpression.OPENING_DELIMITER_LENGTH; | 9750 startIndex += AngularMoustacheXmlExpression.OPENING_DELIMITER_LENGTH; |
| 9751 AngularExpression expression = parseAngularExpression(lexeme, startIndex
, endIndex, offset); | 9751 AngularExpression expression = _parseAngularExpression(lexeme, startInde
x, endIndex, offset); |
| 9752 expressions.add(new AngularMoustacheXmlExpression(startIndex, endIndex,
expression)); | 9752 expressions.add(new AngularMoustacheXmlExpression(startIndex, endIndex,
expression)); |
| 9753 } | 9753 } |
| 9754 startIndex = StringUtilities.indexOf2(lexeme, endIndex + AngularMoustacheX
mlExpression.CLOSING_DELIMITER_LENGTH, AngularMoustacheXmlExpression.OPENING_DEL
IMITER_CHAR, AngularMoustacheXmlExpression.OPENING_DELIMITER_CHAR); | 9754 startIndex = StringUtilities.indexOf2(lexeme, endIndex + AngularMoustacheX
mlExpression.CLOSING_DELIMITER_LENGTH, AngularMoustacheXmlExpression.OPENING_DEL
IMITER_CHAR, AngularMoustacheXmlExpression.OPENING_DELIMITER_CHAR); |
| 9755 } | 9755 } |
| 9756 } | 9756 } |
| 9757 | 9757 |
| 9758 void parseEmbeddedExpressionsInAttribute(ht.XmlAttributeNode node) { | 9758 void _parseEmbeddedExpressionsInAttribute(ht.XmlAttributeNode node) { |
| 9759 List<AngularMoustacheXmlExpression> expressions = []; | 9759 List<AngularMoustacheXmlExpression> expressions = []; |
| 9760 parseEmbeddedExpressions(expressions, node.valueToken); | 9760 _parseEmbeddedExpressions(expressions, node.valueToken); |
| 9761 if (!expressions.isEmpty) { | 9761 if (!expressions.isEmpty) { |
| 9762 node.expressions = new List.from(expressions); | 9762 node.expressions = new List.from(expressions); |
| 9763 } | 9763 } |
| 9764 } | 9764 } |
| 9765 | 9765 |
| 9766 void parseEmbeddedExpressionsInTag(ht.XmlTagNode node) { | 9766 void _parseEmbeddedExpressionsInTag(ht.XmlTagNode node) { |
| 9767 List<AngularMoustacheXmlExpression> expressions = []; | 9767 List<AngularMoustacheXmlExpression> expressions = []; |
| 9768 ht.Token token = node.attributeEnd; | 9768 ht.Token token = node.attributeEnd; |
| 9769 ht.Token endToken = node.endToken; | 9769 ht.Token endToken = node.endToken; |
| 9770 bool inChild = false; | 9770 bool inChild = false; |
| 9771 while (token != endToken) { | 9771 while (token != endToken) { |
| 9772 for (ht.XmlTagNode child in node.tagNodes) { | 9772 for (ht.XmlTagNode child in node.tagNodes) { |
| 9773 if (identical(token, child.beginToken)) { | 9773 if (identical(token, child.beginToken)) { |
| 9774 inChild = true; | 9774 inChild = true; |
| 9775 break; | 9775 break; |
| 9776 } | 9776 } |
| 9777 if (identical(token, child.endToken)) { | 9777 if (identical(token, child.endToken)) { |
| 9778 inChild = false; | 9778 inChild = false; |
| 9779 break; | 9779 break; |
| 9780 } | 9780 } |
| 9781 } | 9781 } |
| 9782 if (!inChild && identical(token.type, ht.TokenType.TEXT)) { | 9782 if (!inChild && identical(token.type, ht.TokenType.TEXT)) { |
| 9783 parseEmbeddedExpressions(expressions, token); | 9783 _parseEmbeddedExpressions(expressions, token); |
| 9784 } | 9784 } |
| 9785 token = token.next; | 9785 token = token.next; |
| 9786 } | 9786 } |
| 9787 node.expressions = new List.from(expressions); | 9787 node.expressions = new List.from(expressions); |
| 9788 } | 9788 } |
| 9789 | 9789 |
| 9790 void recordDefinedVariable(LocalVariableElementImpl variable) { | 9790 void _recordDefinedVariable(LocalVariableElementImpl variable) { |
| 9791 _definedVariables.add(variable); | 9791 _definedVariables.add(variable); |
| 9792 _functionElement.localVariables = new List.from(_definedVariables); | 9792 _functionElement.localVariables = new List.from(_definedVariables); |
| 9793 } | 9793 } |
| 9794 | 9794 |
| 9795 /** | 9795 /** |
| 9796 * When we inject variable, we give access to the library of its type. | 9796 * When we inject variable, we give access to the library of its type. |
| 9797 */ | 9797 */ |
| 9798 void recordTypeLibraryInjected(LocalVariableElementImpl variable) { | 9798 void _recordTypeLibraryInjected(LocalVariableElementImpl variable) { |
| 9799 LibraryElement typeLibrary = variable.type.element.library; | 9799 LibraryElement typeLibrary = variable.type.element.library; |
| 9800 _injectedLibraries.add(typeLibrary); | 9800 _injectedLibraries.add(typeLibrary); |
| 9801 } | 9801 } |
| 9802 | 9802 |
| 9803 void resolveExpressions(List<ht.XmlExpression> expressions) { | 9803 void _resolveExpressions(List<ht.XmlExpression> expressions) { |
| 9804 for (ht.XmlExpression xmlExpression in expressions) { | 9804 for (ht.XmlExpression xmlExpression in expressions) { |
| 9805 if (xmlExpression is AngularXmlExpression) { | 9805 if (xmlExpression is AngularXmlExpression) { |
| 9806 AngularXmlExpression angularXmlExpression = xmlExpression; | 9806 AngularXmlExpression angularXmlExpression = xmlExpression; |
| 9807 resolveXmlExpression(angularXmlExpression); | 9807 _resolveXmlExpression(angularXmlExpression); |
| 9808 } | 9808 } |
| 9809 } | 9809 } |
| 9810 } | 9810 } |
| 9811 | 9811 |
| 9812 /** | 9812 /** |
| 9813 * Resolves Angular specific expressions and elements in the [source]. | 9813 * Resolves Angular specific expressions and elements in the [source]. |
| 9814 * | 9814 * |
| 9815 * @param angularElements the [AngularElement]s accessible in the component's
library, not | 9815 * @param angularElements the [AngularElement]s accessible in the component's
library, not |
| 9816 * `null` | 9816 * `null` |
| 9817 * @param component the [AngularComponentElement] to resolve template for, may
be | 9817 * @param component the [AngularComponentElement] to resolve template for, may
be |
| 9818 * `null` if not a component template | 9818 * `null` if not a component template |
| 9819 */ | 9819 */ |
| 9820 void resolveInternal(List<AngularElement> angularElements, AngularComponentEle
ment component) { | 9820 void _resolveInternal(List<AngularElement> angularElements, AngularComponentEl
ement component) { |
| 9821 this._angularElements = angularElements; | 9821 this._angularElements = angularElements; |
| 9822 // add built-in processors | 9822 // add built-in processors |
| 9823 _processors.add(NgModelProcessor.INSTANCE); | 9823 _processors.add(NgModelProcessor.INSTANCE); |
| 9824 // _processors.add(NgRepeatProcessor.INSTANCE); | 9824 // _processors.add(NgRepeatProcessor.INSTANCE); |
| 9825 // add element's libraries | 9825 // add element's libraries |
| 9826 for (AngularElement angularElement in angularElements) { | 9826 for (AngularElement angularElement in angularElements) { |
| 9827 _injectedLibraries.add(angularElement.library); | 9827 _injectedLibraries.add(angularElement.library); |
| 9828 } | 9828 } |
| 9829 // prepare Dart library | 9829 // prepare Dart library |
| 9830 createLibraryElement(); | 9830 _createLibraryElement(); |
| 9831 (_unit.element as HtmlElementImpl).angularCompilationUnit = _unitElement; | 9831 (_unit.element as HtmlElementImpl).angularCompilationUnit = _unitElement; |
| 9832 // prepare Dart resolver | 9832 // prepare Dart resolver |
| 9833 createResolver(); | 9833 _createResolver(); |
| 9834 // maybe resolving component template | 9834 // maybe resolving component template |
| 9835 if (component != null) { | 9835 if (component != null) { |
| 9836 defineTopVariable_forClassElement(component); | 9836 _defineTopVariable_forClassElement(component); |
| 9837 for (AngularScopePropertyElement scopeProperty in component.scopePropertie
s) { | 9837 for (AngularScopePropertyElement scopeProperty in component.scopePropertie
s) { |
| 9838 defineTopVariable_forScopeProperty(scopeProperty); | 9838 _defineTopVariable_forScopeProperty(scopeProperty); |
| 9839 } | 9839 } |
| 9840 } | 9840 } |
| 9841 // add processors | 9841 // add processors |
| 9842 for (AngularElement angularElement in angularElements) { | 9842 for (AngularElement angularElement in angularElements) { |
| 9843 NgProcessor processor = createProcessor(angularElement); | 9843 NgProcessor processor = _createProcessor(angularElement); |
| 9844 if (processor != null) { | 9844 if (processor != null) { |
| 9845 _processors.add(processor); | 9845 _processors.add(processor); |
| 9846 } | 9846 } |
| 9847 } | 9847 } |
| 9848 // define filters | 9848 // define filters |
| 9849 for (AngularElement angularElement in angularElements) { | 9849 for (AngularElement angularElement in angularElements) { |
| 9850 if (angularElement is AngularFilterElement) { | 9850 if (angularElement is AngularFilterElement) { |
| 9851 defineTopVariable_forClassElement(angularElement); | 9851 _defineTopVariable_forClassElement(angularElement); |
| 9852 } | 9852 } |
| 9853 } | 9853 } |
| 9854 // run this HTML visitor | 9854 // run this HTML visitor |
| 9855 _unit.accept(this); | 9855 _unit.accept(this); |
| 9856 // simulate imports for injects | 9856 // simulate imports for injects |
| 9857 { | 9857 { |
| 9858 List<ImportElement> imports = []; | 9858 List<ImportElement> imports = []; |
| 9859 for (LibraryElement injectedLibrary in _injectedLibraries) { | 9859 for (LibraryElement injectedLibrary in _injectedLibraries) { |
| 9860 ImportElementImpl importElement = new ImportElementImpl(-1); | 9860 ImportElementImpl importElement = new ImportElementImpl(-1); |
| 9861 importElement.importedLibrary = injectedLibrary; | 9861 importElement.importedLibrary = injectedLibrary; |
| 9862 imports.add(importElement); | 9862 imports.add(importElement); |
| 9863 } | 9863 } |
| 9864 _libraryElement.imports = new List.from(imports); | 9864 _libraryElement.imports = new List.from(imports); |
| 9865 } | 9865 } |
| 9866 // push conditional errors | 9866 // push conditional errors |
| 9867 for (ProxyConditionalAnalysisError conditionalCode in _resolver.proxyConditi
onalAnalysisErrors) { | 9867 for (ProxyConditionalAnalysisError conditionalCode in _resolver.proxyConditi
onalAnalysisErrors) { |
| 9868 _resolver.reportError(conditionalCode.analysisError); | 9868 _resolver.reportError(conditionalCode.analysisError); |
| 9869 } | 9869 } |
| 9870 } | 9870 } |
| 9871 | 9871 |
| 9872 void resolveXmlExpression(AngularXmlExpression angularXmlExpression) { | 9872 void _resolveXmlExpression(AngularXmlExpression angularXmlExpression) { |
| 9873 AngularExpression angularExpression = angularXmlExpression.expression; | 9873 AngularExpression angularExpression = angularXmlExpression.expression; |
| 9874 resolveExpression(angularExpression); | 9874 _resolveExpression(angularExpression); |
| 9875 } | 9875 } |
| 9876 | 9876 |
| 9877 List<Token> splitAtBar(Token token) { | 9877 List<Token> _splitAtBar(Token token) { |
| 9878 List<Token> tokens = []; | 9878 List<Token> tokens = []; |
| 9879 tokens.add(token); | 9879 tokens.add(token); |
| 9880 while (token.type != TokenType.EOF) { | 9880 while (token.type != TokenType.EOF) { |
| 9881 if (identical(token.type, TokenType.BAR)) { | 9881 if (identical(token.type, TokenType.BAR)) { |
| 9882 tokens.add(token); | 9882 tokens.add(token); |
| 9883 Token eofToken = new Token(TokenType.EOF, 0); | 9883 Token eofToken = new Token(TokenType.EOF, 0); |
| 9884 token.previous.setNext(eofToken); | 9884 token.previous.setNext(eofToken); |
| 9885 } | 9885 } |
| 9886 token = token.next; | 9886 token = token.next; |
| 9887 } | 9887 } |
| 9888 return tokens; | 9888 return tokens; |
| 9889 } | 9889 } |
| 9890 | 9890 |
| 9891 /** | 9891 /** |
| 9892 * The "ng-model" directive is special, it contributes to the top-level name s
cope. These models | 9892 * The "ng-model" directive is special, it contributes to the top-level name s
cope. These models |
| 9893 * can be used before actual "ng-model" attribute in HTML. So, we need to defi
ne them once we | 9893 * can be used before actual "ng-model" attribute in HTML. So, we need to defi
ne them once we |
| 9894 * found [NG_APP] context. | 9894 * found [NG_APP] context. |
| 9895 */ | 9895 */ |
| 9896 void visitModelDirectives(ht.XmlTagNode appNode) { | 9896 void _visitModelDirectives(ht.XmlTagNode appNode) { |
| 9897 appNode.accept(new RecursiveXmlVisitor_AngularHtmlUnitResolver_visitModelDir
ectives(this)); | 9897 appNode.accept(new RecursiveXmlVisitor_AngularHtmlUnitResolver_visitModelDir
ectives(this)); |
| 9898 } | 9898 } |
| 9899 } | 9899 } |
| 9900 | 9900 |
| 9901 class AngularHtmlUnitResolver_FilteringAnalysisErrorListener implements Analysis
ErrorListener { | 9901 class AngularHtmlUnitResolver_FilteringAnalysisErrorListener implements Analysis
ErrorListener { |
| 9902 AnalysisErrorListener _listener; | 9902 AnalysisErrorListener _listener; |
| 9903 | 9903 |
| 9904 AngularHtmlUnitResolver_FilteringAnalysisErrorListener(AnalysisErrorListener l
istener) { | 9904 AngularHtmlUnitResolver_FilteringAnalysisErrorListener(AnalysisErrorListener l
istener) { |
| 9905 this._listener = listener; | 9905 this._listener = listener; |
| 9906 } | 9906 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 9927 } | 9927 } |
| 9928 | 9928 |
| 9929 class RecursiveXmlVisitor_AngularHtmlUnitResolver_visitModelDirectives extends h
t.RecursiveXmlVisitor<Object> { | 9929 class RecursiveXmlVisitor_AngularHtmlUnitResolver_visitModelDirectives extends h
t.RecursiveXmlVisitor<Object> { |
| 9930 final AngularHtmlUnitResolver AngularHtmlUnitResolver_this; | 9930 final AngularHtmlUnitResolver AngularHtmlUnitResolver_this; |
| 9931 | 9931 |
| 9932 RecursiveXmlVisitor_AngularHtmlUnitResolver_visitModelDirectives(this.AngularH
tmlUnitResolver_this) : super(); | 9932 RecursiveXmlVisitor_AngularHtmlUnitResolver_visitModelDirectives(this.AngularH
tmlUnitResolver_this) : super(); |
| 9933 | 9933 |
| 9934 Object visitXmlTagNode(ht.XmlTagNode node) { | 9934 Object visitXmlTagNode(ht.XmlTagNode node) { |
| 9935 NgModelProcessor directive = NgModelProcessor.INSTANCE; | 9935 NgModelProcessor directive = NgModelProcessor.INSTANCE; |
| 9936 if (directive.canApply(node)) { | 9936 if (directive.canApply(node)) { |
| 9937 directive.applyTopDeclarations(AngularHtmlUnitResolver_this, node); | 9937 directive._applyTopDeclarations(AngularHtmlUnitResolver_this, node); |
| 9938 } | 9938 } |
| 9939 return super.visitXmlTagNode(node); | 9939 return super.visitXmlTagNode(node); |
| 9940 } | 9940 } |
| 9941 } | 9941 } |
| 9942 | 9942 |
| 9943 /** | 9943 /** |
| 9944 * Implementation of [AngularXmlExpression] for an [AngularExpression] enclosed
between | 9944 * Implementation of [AngularXmlExpression] for an [AngularExpression] enclosed
between |
| 9945 * <code>{{</code> and <code>}}</code>. | 9945 * <code>{{</code> and <code>}}</code>. |
| 9946 */ | 9946 */ |
| 9947 class AngularMoustacheXmlExpression extends AngularXmlExpression { | 9947 class AngularMoustacheXmlExpression extends AngularXmlExpression { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9999 abstract class AngularXmlExpression extends ht.XmlExpression { | 9999 abstract class AngularXmlExpression extends ht.XmlExpression { |
| 10000 /** | 10000 /** |
| 10001 * The expression that is enclosed between the delimiters. | 10001 * The expression that is enclosed between the delimiters. |
| 10002 */ | 10002 */ |
| 10003 final AngularExpression expression; | 10003 final AngularExpression expression; |
| 10004 | 10004 |
| 10005 AngularXmlExpression(this.expression); | 10005 AngularXmlExpression(this.expression); |
| 10006 | 10006 |
| 10007 ht.XmlExpression_Reference getReference(int offset) { | 10007 ht.XmlExpression_Reference getReference(int offset) { |
| 10008 // main expression | 10008 // main expression |
| 10009 ht.XmlExpression_Reference reference = getReferenceAtNode(expression.express
ion, offset); | 10009 ht.XmlExpression_Reference reference = _getReferenceAtNode(expression.expres
sion, offset); |
| 10010 if (reference != null) { | 10010 if (reference != null) { |
| 10011 return reference; | 10011 return reference; |
| 10012 } | 10012 } |
| 10013 // filters | 10013 // filters |
| 10014 for (AngularFilterNode filter in expression.filters) { | 10014 for (AngularFilterNode filter in expression.filters) { |
| 10015 // filter name | 10015 // filter name |
| 10016 reference = getReferenceAtNode(filter.name, offset); | 10016 reference = _getReferenceAtNode(filter.name, offset); |
| 10017 if (reference != null) { | 10017 if (reference != null) { |
| 10018 return reference; | 10018 return reference; |
| 10019 } | 10019 } |
| 10020 // filter arguments | 10020 // filter arguments |
| 10021 for (AngularFilterArgument filterArgument in filter.arguments) { | 10021 for (AngularFilterArgument filterArgument in filter.arguments) { |
| 10022 reference = getReferenceAtNode(filterArgument.expression, offset); | 10022 reference = _getReferenceAtNode(filterArgument.expression, offset); |
| 10023 if (reference != null) { | 10023 if (reference != null) { |
| 10024 return reference; | 10024 return reference; |
| 10025 } | 10025 } |
| 10026 } | 10026 } |
| 10027 } | 10027 } |
| 10028 return null; | 10028 return null; |
| 10029 } | 10029 } |
| 10030 | 10030 |
| 10031 /** | 10031 /** |
| 10032 * If the given [AstNode] has an [Element] at the given offset, then returns | 10032 * If the given [AstNode] has an [Element] at the given offset, then returns |
| 10033 * [Reference] with this [Element]. | 10033 * [Reference] with this [Element]. |
| 10034 */ | 10034 */ |
| 10035 ht.XmlExpression_Reference getReferenceAtNode(AstNode root, int offset) { | 10035 ht.XmlExpression_Reference _getReferenceAtNode(AstNode root, int offset) { |
| 10036 AstNode node = new NodeLocator.con1(offset).searchWithin(root); | 10036 AstNode node = new NodeLocator.con1(offset).searchWithin(root); |
| 10037 if (node != null) { | 10037 if (node != null) { |
| 10038 Element element = ElementLocator.locate(node); | 10038 Element element = ElementLocator.locate(node); |
| 10039 return new ht.XmlExpression_Reference(element, node.offset, node.length); | 10039 return new ht.XmlExpression_Reference(element, node.offset, node.length); |
| 10040 } | 10040 } |
| 10041 return null; | 10041 return null; |
| 10042 } | 10042 } |
| 10043 } | 10043 } |
| 10044 | 10044 |
| 10045 /** | 10045 /** |
| 10046 * Recursively visits [HtmlUnit] and every embedded [Expression]. | 10046 * Recursively visits [HtmlUnit] and every embedded [Expression]. |
| 10047 */ | 10047 */ |
| 10048 abstract class ExpressionVisitor extends ht.RecursiveXmlVisitor<Object> { | 10048 abstract class ExpressionVisitor extends ht.RecursiveXmlVisitor<Object> { |
| 10049 /** | 10049 /** |
| 10050 * Visits the given [Expression]s embedded into tag or attribute. | 10050 * Visits the given [Expression]s embedded into tag or attribute. |
| 10051 * | 10051 * |
| 10052 * @param expression the [Expression] to visit, not `null` | 10052 * @param expression the [Expression] to visit, not `null` |
| 10053 */ | 10053 */ |
| 10054 void visitExpression(Expression expression); | 10054 void visitExpression(Expression expression); |
| 10055 | 10055 |
| 10056 Object visitXmlAttributeNode(ht.XmlAttributeNode node) { | 10056 Object visitXmlAttributeNode(ht.XmlAttributeNode node) { |
| 10057 visitExpressions(node.expressions); | 10057 _visitExpressions(node.expressions); |
| 10058 return super.visitXmlAttributeNode(node); | 10058 return super.visitXmlAttributeNode(node); |
| 10059 } | 10059 } |
| 10060 | 10060 |
| 10061 Object visitXmlTagNode(ht.XmlTagNode node) { | 10061 Object visitXmlTagNode(ht.XmlTagNode node) { |
| 10062 visitExpressions(node.expressions); | 10062 _visitExpressions(node.expressions); |
| 10063 return super.visitXmlTagNode(node); | 10063 return super.visitXmlTagNode(node); |
| 10064 } | 10064 } |
| 10065 | 10065 |
| 10066 /** | 10066 /** |
| 10067 * Visits [Expression]s of the given [XmlExpression]s. | 10067 * Visits [Expression]s of the given [XmlExpression]s. |
| 10068 */ | 10068 */ |
| 10069 void visitExpressions(List<ht.XmlExpression> expressions) { | 10069 void _visitExpressions(List<ht.XmlExpression> expressions) { |
| 10070 for (ht.XmlExpression xmlExpression in expressions) { | 10070 for (ht.XmlExpression xmlExpression in expressions) { |
| 10071 if (xmlExpression is AngularXmlExpression) { | 10071 if (xmlExpression is AngularXmlExpression) { |
| 10072 AngularXmlExpression angularXmlExpression = xmlExpression; | 10072 AngularXmlExpression angularXmlExpression = xmlExpression; |
| 10073 List<Expression> dartExpressions = angularXmlExpression.expression.expre
ssions; | 10073 List<Expression> dartExpressions = angularXmlExpression.expression.expre
ssions; |
| 10074 for (Expression dartExpression in dartExpressions) { | 10074 for (Expression dartExpression in dartExpressions) { |
| 10075 visitExpression(dartExpression); | 10075 visitExpression(dartExpression); |
| 10076 } | 10076 } |
| 10077 } | 10077 } |
| 10078 if (xmlExpression is ht.RawXmlExpression) { | 10078 if (xmlExpression is ht.RawXmlExpression) { |
| 10079 ht.RawXmlExpression rawXmlExpression = xmlExpression; | 10079 ht.RawXmlExpression rawXmlExpression = xmlExpression; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 10097 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { | 10097 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { |
| 10098 node.element = _element.selector; | 10098 node.element = _element.selector; |
| 10099 for (AngularPropertyElement property in _element.properties) { | 10099 for (AngularPropertyElement property in _element.properties) { |
| 10100 String name = property.name; | 10100 String name = property.name; |
| 10101 ht.XmlAttributeNode attribute = node.getAttribute(name); | 10101 ht.XmlAttributeNode attribute = node.getAttribute(name); |
| 10102 if (attribute != null) { | 10102 if (attribute != null) { |
| 10103 attribute.element = property; | 10103 attribute.element = property; |
| 10104 // resolve if binding | 10104 // resolve if binding |
| 10105 if (property.propertyKind != AngularPropertyKind.ATTR) { | 10105 if (property.propertyKind != AngularPropertyKind.ATTR) { |
| 10106 AngularExpression expression = parseAngularExpression(resolver, attrib
ute); | 10106 AngularExpression expression = parseAngularExpression(resolver, attrib
ute); |
| 10107 resolver.resolveExpression(expression); | 10107 resolver._resolveExpression(expression); |
| 10108 setAngularExpression(attribute, expression); | 10108 setAngularExpression(attribute, expression); |
| 10109 } | 10109 } |
| 10110 } | 10110 } |
| 10111 } | 10111 } |
| 10112 } | 10112 } |
| 10113 | 10113 |
| 10114 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); | 10114 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); |
| 10115 } | 10115 } |
| 10116 | 10116 |
| 10117 /** | 10117 /** |
| 10118 * [NgControllerElementProcessor] applies [AngularControllerElement]. | 10118 * [NgControllerElementProcessor] applies [AngularControllerElement]. |
| 10119 */ | 10119 */ |
| 10120 class NgControllerElementProcessor extends NgProcessor { | 10120 class NgControllerElementProcessor extends NgProcessor { |
| 10121 AngularControllerElement _element; | 10121 AngularControllerElement _element; |
| 10122 | 10122 |
| 10123 NgControllerElementProcessor(AngularControllerElement element) { | 10123 NgControllerElementProcessor(AngularControllerElement element) { |
| 10124 this._element = element; | 10124 this._element = element; |
| 10125 } | 10125 } |
| 10126 | 10126 |
| 10127 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { | 10127 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { |
| 10128 InterfaceType type = (_element.enclosingElement as ClassElement).type; | 10128 InterfaceType type = (_element.enclosingElement as ClassElement).type; |
| 10129 String name = _element.name; | 10129 String name = _element.name; |
| 10130 LocalVariableElementImpl variable = resolver.createLocalVariableWithName(typ
e, name); | 10130 LocalVariableElementImpl variable = resolver._createLocalVariableWithName(ty
pe, name); |
| 10131 resolver.defineVariable(variable); | 10131 resolver._defineVariable(variable); |
| 10132 variable.toolkitObjects = <AngularElement> [_element]; | 10132 variable.toolkitObjects = <AngularElement> [_element]; |
| 10133 } | 10133 } |
| 10134 | 10134 |
| 10135 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); | 10135 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); |
| 10136 } | 10136 } |
| 10137 | 10137 |
| 10138 /** | 10138 /** |
| 10139 * [NgDirectiveElementProcessor] applies [AngularDirectiveElement] by parsing ma
pped | 10139 * [NgDirectiveElementProcessor] applies [AngularDirectiveElement] by parsing ma
pped |
| 10140 * attributes as expressions. | 10140 * attributes as expressions. |
| 10141 */ | 10141 */ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 10168 } | 10168 } |
| 10169 // resolve attribute expression | 10169 // resolve attribute expression |
| 10170 ht.XmlAttributeNode attribute = node.getAttribute(name); | 10170 ht.XmlAttributeNode attribute = node.getAttribute(name); |
| 10171 if (attribute != null) { | 10171 if (attribute != null) { |
| 10172 // if not resolved as the selector, resolve as a property | 10172 // if not resolved as the selector, resolve as a property |
| 10173 if (name != selectorAttributeName) { | 10173 if (name != selectorAttributeName) { |
| 10174 attribute.element = property; | 10174 attribute.element = property; |
| 10175 } | 10175 } |
| 10176 // resolve if binding | 10176 // resolve if binding |
| 10177 if (property.propertyKind != AngularPropertyKind.ATTR) { | 10177 if (property.propertyKind != AngularPropertyKind.ATTR) { |
| 10178 resolver.pushNameScope(); | 10178 resolver._pushNameScope(); |
| 10179 try { | 10179 try { |
| 10180 onNgEventDirective(resolver); | 10180 _onNgEventDirective(resolver); |
| 10181 AngularExpression expression = parseAngularExpression(resolver, attr
ibute); | 10181 AngularExpression expression = parseAngularExpression(resolver, attr
ibute); |
| 10182 resolver.resolveExpression(expression); | 10182 resolver._resolveExpression(expression); |
| 10183 setAngularExpression(attribute, expression); | 10183 setAngularExpression(attribute, expression); |
| 10184 } finally { | 10184 } finally { |
| 10185 resolver.popNameScope(); | 10185 resolver._popNameScope(); |
| 10186 } | 10186 } |
| 10187 } | 10187 } |
| 10188 } | 10188 } |
| 10189 } | 10189 } |
| 10190 } | 10190 } |
| 10191 | 10191 |
| 10192 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); | 10192 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); |
| 10193 | 10193 |
| 10194 /** | 10194 /** |
| 10195 * Support for <code>$event</code> variable in <code>NgEventDirective</code>. | 10195 * Support for <code>$event</code> variable in <code>NgEventDirective</code>. |
| 10196 */ | 10196 */ |
| 10197 void onNgEventDirective(AngularHtmlUnitResolver resolver) { | 10197 void _onNgEventDirective(AngularHtmlUnitResolver resolver) { |
| 10198 if (_element.isClass("NgEventDirective")) { | 10198 if (_element.isClass("NgEventDirective")) { |
| 10199 Type2 dynamicType = resolver.typeProvider.dynamicType; | 10199 Type2 dynamicType = resolver.typeProvider.dynamicType; |
| 10200 resolver.defineVariable(resolver.createLocalVariableWithName(dynamicType,
"\$event")); | 10200 resolver._defineVariable(resolver._createLocalVariableWithName(dynamicType
, "\$event")); |
| 10201 } | 10201 } |
| 10202 } | 10202 } |
| 10203 } | 10203 } |
| 10204 | 10204 |
| 10205 /** | 10205 /** |
| 10206 * [NgDirectiveProcessor] describes any <code>NgDirective</code> annotation inst
ance. | 10206 * [NgDirectiveProcessor] describes any <code>NgDirective</code> annotation inst
ance. |
| 10207 */ | 10207 */ |
| 10208 abstract class NgDirectiveProcessor extends NgProcessor { | 10208 abstract class NgDirectiveProcessor extends NgProcessor { |
| 10209 static AngularRawXmlExpression newAngularRawXmlExpression(AngularExpression e)
=> new AngularRawXmlExpression(e); | 10209 static AngularRawXmlExpression newAngularRawXmlExpression(AngularExpression e)
=> new AngularRawXmlExpression(e); |
| 10210 | 10210 |
| 10211 static ht.RawXmlExpression newRawXmlExpression(Expression e) => new ht.RawXmlE
xpression(e); | 10211 static ht.RawXmlExpression newRawXmlExpression(Expression e) => new ht.RawXmlE
xpression(e); |
| 10212 | 10212 |
| 10213 AngularExpression parseAngularExpression(AngularHtmlUnitResolver resolver, ht.
XmlAttributeNode attribute) { | 10213 AngularExpression parseAngularExpression(AngularHtmlUnitResolver resolver, ht.
XmlAttributeNode attribute) { |
| 10214 Token token = scanAttribute(resolver, attribute); | 10214 Token token = _scanAttribute(resolver, attribute); |
| 10215 return resolver.parseAngularExpressionInToken(token); | 10215 return resolver._parseAngularExpressionInToken(token); |
| 10216 } | 10216 } |
| 10217 | 10217 |
| 10218 Expression parseDartExpression(AngularHtmlUnitResolver resolver, ht.XmlAttribu
teNode attribute) { | 10218 Expression parseDartExpression(AngularHtmlUnitResolver resolver, ht.XmlAttribu
teNode attribute) { |
| 10219 Token token = scanAttribute(resolver, attribute); | 10219 Token token = _scanAttribute(resolver, attribute); |
| 10220 return resolver.parseDartExpressionInToken(token); | 10220 return resolver._parseDartExpressionInToken(token); |
| 10221 } | 10221 } |
| 10222 | 10222 |
| 10223 /** | 10223 /** |
| 10224 * Sets single [AngularExpression] for [XmlAttributeNode]. | 10224 * Sets single [AngularExpression] for [XmlAttributeNode]. |
| 10225 */ | 10225 */ |
| 10226 void setAngularExpression(ht.XmlAttributeNode attribute, AngularExpression exp
ression) { | 10226 void setAngularExpression(ht.XmlAttributeNode attribute, AngularExpression exp
ression) { |
| 10227 setExpression2(attribute, newAngularRawXmlExpression(expression)); | 10227 _setExpression(attribute, newAngularRawXmlExpression(expression)); |
| 10228 } | 10228 } |
| 10229 | 10229 |
| 10230 /** | 10230 /** |
| 10231 * Sets single [Expression] for [XmlAttributeNode]. | 10231 * Sets single [Expression] for [XmlAttributeNode]. |
| 10232 */ | 10232 */ |
| 10233 void setExpression(ht.XmlAttributeNode attribute, Expression expression) { | 10233 void setExpression(ht.XmlAttributeNode attribute, Expression expression) { |
| 10234 setExpression2(attribute, newRawXmlExpression(expression)); | 10234 _setExpression(attribute, newRawXmlExpression(expression)); |
| 10235 } | 10235 } |
| 10236 | 10236 |
| 10237 void setExpressions(ht.XmlAttributeNode attribute, List<ht.XmlExpression> xmlE
xpressions) { | 10237 void setExpressions(ht.XmlAttributeNode attribute, List<ht.XmlExpression> xmlE
xpressions) { |
| 10238 attribute.expressions = new List.from(xmlExpressions); | 10238 attribute.expressions = new List.from(xmlExpressions); |
| 10239 } | 10239 } |
| 10240 | 10240 |
| 10241 Token scanAttribute(AngularHtmlUnitResolver resolver, ht.XmlAttributeNode attr
ibute) { | 10241 Token _scanAttribute(AngularHtmlUnitResolver resolver, ht.XmlAttributeNode att
ribute) { |
| 10242 int offset = attribute.valueToken.offset + 1; | 10242 int offset = attribute.valueToken.offset + 1; |
| 10243 String value = attribute.text; | 10243 String value = attribute.text; |
| 10244 return resolver.scanDart(value, 0, value.length, offset); | 10244 return resolver._scanDart(value, 0, value.length, offset); |
| 10245 } | 10245 } |
| 10246 | 10246 |
| 10247 void setExpression2(ht.XmlAttributeNode attribute, ht.XmlExpression xmlExpress
ion) { | 10247 void _setExpression(ht.XmlAttributeNode attribute, ht.XmlExpression xmlExpress
ion) { |
| 10248 attribute.expressions = <ht.XmlExpression> [xmlExpression]; | 10248 attribute.expressions = <ht.XmlExpression> [xmlExpression]; |
| 10249 } | 10249 } |
| 10250 } | 10250 } |
| 10251 | 10251 |
| 10252 /** | 10252 /** |
| 10253 * [NgModelProcessor] describes built-in <code>NgModel</code> directive. | 10253 * [NgModelProcessor] describes built-in <code>NgModel</code> directive. |
| 10254 */ | 10254 */ |
| 10255 class NgModelProcessor extends NgDirectiveProcessor { | 10255 class NgModelProcessor extends NgDirectiveProcessor { |
| 10256 static String _NG_MODEL = "ng-model"; | 10256 static String _NG_MODEL = "ng-model"; |
| 10257 | 10257 |
| 10258 static NgModelProcessor INSTANCE = new NgModelProcessor(); | 10258 static NgModelProcessor INSTANCE = new NgModelProcessor(); |
| 10259 | 10259 |
| 10260 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { | 10260 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { |
| 10261 ht.XmlAttributeNode attribute = node.getAttribute(_NG_MODEL); | 10261 ht.XmlAttributeNode attribute = node.getAttribute(_NG_MODEL); |
| 10262 Expression expression = parseDartExpression(resolver, attribute); | 10262 Expression expression = parseDartExpression(resolver, attribute); |
| 10263 // identifiers have been already handled by "apply top" | 10263 // identifiers have been already handled by "apply top" |
| 10264 if (expression is SimpleIdentifier) { | 10264 if (expression is SimpleIdentifier) { |
| 10265 return; | 10265 return; |
| 10266 } | 10266 } |
| 10267 // resolve | 10267 // resolve |
| 10268 resolver.resolveNode(expression); | 10268 resolver._resolveNode(expression); |
| 10269 // remember expression | 10269 // remember expression |
| 10270 setExpression(attribute, expression); | 10270 setExpression(attribute, expression); |
| 10271 } | 10271 } |
| 10272 | 10272 |
| 10273 bool canApply(ht.XmlTagNode node) => node.getAttribute(_NG_MODEL) != null; | 10273 bool canApply(ht.XmlTagNode node) => node.getAttribute(_NG_MODEL) != null; |
| 10274 | 10274 |
| 10275 /** | 10275 /** |
| 10276 * This method is used to define top-level [VariableElement]s for each "ng-mod
el" with | 10276 * This method is used to define top-level [VariableElement]s for each "ng-mod
el" with |
| 10277 * simple identifier model. | 10277 * simple identifier model. |
| 10278 */ | 10278 */ |
| 10279 void applyTopDeclarations(AngularHtmlUnitResolver resolver, ht.XmlTagNode node
) { | 10279 void _applyTopDeclarations(AngularHtmlUnitResolver resolver, ht.XmlTagNode nod
e) { |
| 10280 ht.XmlAttributeNode attribute = node.getAttribute(_NG_MODEL); | 10280 ht.XmlAttributeNode attribute = node.getAttribute(_NG_MODEL); |
| 10281 Expression expression = parseDartExpression(resolver, attribute); | 10281 Expression expression = parseDartExpression(resolver, attribute); |
| 10282 // if not identifier, then not a top-level model, delay until "apply" | 10282 // if not identifier, then not a top-level model, delay until "apply" |
| 10283 if (expression is! SimpleIdentifier) { | 10283 if (expression is! SimpleIdentifier) { |
| 10284 return; | 10284 return; |
| 10285 } | 10285 } |
| 10286 SimpleIdentifier identifier = expression as SimpleIdentifier; | 10286 SimpleIdentifier identifier = expression as SimpleIdentifier; |
| 10287 // define variable Element | 10287 // define variable Element |
| 10288 InterfaceType type = resolver.typeProvider.stringType; | 10288 InterfaceType type = resolver.typeProvider.stringType; |
| 10289 LocalVariableElementImpl element = resolver.createLocalVariableFromIdentifie
r(type, identifier); | 10289 LocalVariableElementImpl element = resolver._createLocalVariableFromIdentifi
er(type, identifier); |
| 10290 resolver.defineTopVariable(element); | 10290 resolver._defineTopVariable(element); |
| 10291 // remember expression | 10291 // remember expression |
| 10292 identifier.staticElement = element; | 10292 identifier.staticElement = element; |
| 10293 identifier.staticType = type; | 10293 identifier.staticType = type; |
| 10294 setExpression(attribute, identifier); | 10294 setExpression(attribute, identifier); |
| 10295 } | 10295 } |
| 10296 } | 10296 } |
| 10297 | 10297 |
| 10298 /** | 10298 /** |
| 10299 * [NgProcessor] is used to apply an Angular feature. | 10299 * [NgProcessor] is used to apply an Angular feature. |
| 10300 */ | 10300 */ |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10358 | 10358 |
| 10359 /** | 10359 /** |
| 10360 * Perform this analysis task and use the given visitor to visit this task aft
er it has completed. | 10360 * Perform this analysis task and use the given visitor to visit this task aft
er it has completed. |
| 10361 * | 10361 * |
| 10362 * @param visitor the visitor used to visit this task after it has completed | 10362 * @param visitor the visitor used to visit this task after it has completed |
| 10363 * @return the value returned by the visitor | 10363 * @return the value returned by the visitor |
| 10364 * @throws AnalysisException if the visitor throws the exception | 10364 * @throws AnalysisException if the visitor throws the exception |
| 10365 */ | 10365 */ |
| 10366 Object perform(AnalysisTaskVisitor visitor) { | 10366 Object perform(AnalysisTaskVisitor visitor) { |
| 10367 try { | 10367 try { |
| 10368 safelyPerform(); | 10368 _safelyPerform(); |
| 10369 } on AnalysisException catch (exception) { | 10369 } on AnalysisException catch (exception) { |
| 10370 _thrownException = exception; | 10370 _thrownException = exception; |
| 10371 AnalysisEngine.instance.logger.logInformation3("Task failed: ${taskDescrip
tion}", exception); | 10371 AnalysisEngine.instance.logger.logInformation2("Task failed: ${taskDescrip
tion}", exception); |
| 10372 } | 10372 } |
| 10373 return accept(visitor); | 10373 return accept(visitor); |
| 10374 } | 10374 } |
| 10375 | 10375 |
| 10376 String toString() => taskDescription; | 10376 String toString() => taskDescription; |
| 10377 | 10377 |
| 10378 /** | 10378 /** |
| 10379 * Return a textual description of this task. | 10379 * Return a textual description of this task. |
| 10380 * | 10380 * |
| 10381 * @return a textual description of this task | 10381 * @return a textual description of this task |
| 10382 */ | 10382 */ |
| 10383 String get taskDescription; | 10383 String get taskDescription; |
| 10384 | 10384 |
| 10385 /** | 10385 /** |
| 10386 * Perform this analysis task, protected by an exception handler. | 10386 * Perform this analysis task, protected by an exception handler. |
| 10387 * | 10387 * |
| 10388 * @throws AnalysisException if an exception occurs while performing the task | 10388 * @throws AnalysisException if an exception occurs while performing the task |
| 10389 */ | 10389 */ |
| 10390 void internalPerform(); | 10390 void internalPerform(); |
| 10391 | 10391 |
| 10392 /** | 10392 /** |
| 10393 * Perform this analysis task, ensuring that all exceptions are wrapped in an | 10393 * Perform this analysis task, ensuring that all exceptions are wrapped in an |
| 10394 * [AnalysisException]. | 10394 * [AnalysisException]. |
| 10395 * | 10395 * |
| 10396 * @throws AnalysisException if any exception occurs while performing the task | 10396 * @throws AnalysisException if any exception occurs while performing the task |
| 10397 */ | 10397 */ |
| 10398 void safelyPerform() { | 10398 void _safelyPerform() { |
| 10399 try { | 10399 try { |
| 10400 internalPerform(); | 10400 internalPerform(); |
| 10401 } on AnalysisException catch (exception) { | 10401 } on AnalysisException catch (exception) { |
| 10402 throw exception; | 10402 throw exception; |
| 10403 } on JavaException catch (exception) { | 10403 } on JavaException catch (exception) { |
| 10404 throw new AnalysisException.con3(exception); | 10404 throw new AnalysisException.con3(exception); |
| 10405 } | 10405 } |
| 10406 } | 10406 } |
| 10407 } | 10407 } |
| 10408 | 10408 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10657 void internalPerform() { | 10657 void internalPerform() { |
| 10658 RecordingErrorListener errorListener = new RecordingErrorListener(); | 10658 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 10659 List<CompilationUnitElement> parts = libraryElement.parts; | 10659 List<CompilationUnitElement> parts = libraryElement.parts; |
| 10660 int partCount = parts.length; | 10660 int partCount = parts.length; |
| 10661 List<CompilationUnit> compilationUnits = new List<CompilationUnit>(partCount
+ 1); | 10661 List<CompilationUnit> compilationUnits = new List<CompilationUnit>(partCount
+ 1); |
| 10662 Map<Source, TimestampedData<CompilationUnit>> timestampMap = new Map<Source,
TimestampedData<CompilationUnit>>(); | 10662 Map<Source, TimestampedData<CompilationUnit>> timestampMap = new Map<Source,
TimestampedData<CompilationUnit>>(); |
| 10663 // | 10663 // |
| 10664 // Get all of the (fully resolved) compilation units that will be analyzed. | 10664 // Get all of the (fully resolved) compilation units that will be analyzed. |
| 10665 // | 10665 // |
| 10666 Source unitSource = libraryElement.definingCompilationUnit.source; | 10666 Source unitSource = libraryElement.definingCompilationUnit.source; |
| 10667 TimestampedData<CompilationUnit> resolvedUnit = getCompilationUnit(unitSourc
e); | 10667 TimestampedData<CompilationUnit> resolvedUnit = _getCompilationUnit(unitSour
ce); |
| 10668 timestampMap[unitSource] = resolvedUnit; | 10668 timestampMap[unitSource] = resolvedUnit; |
| 10669 CompilationUnit unit = resolvedUnit.data; | 10669 CompilationUnit unit = resolvedUnit.data; |
| 10670 if (unit == null) { | 10670 if (unit == null) { |
| 10671 throw new AnalysisException.con1("Internal error: GenerateDartHintsTask fa
iled to access resolved compilation unit for ${unitSource.fullName}"); | 10671 throw new AnalysisException.con1("Internal error: GenerateDartHintsTask fa
iled to access resolved compilation unit for ${unitSource.fullName}"); |
| 10672 } | 10672 } |
| 10673 compilationUnits[0] = unit; | 10673 compilationUnits[0] = unit; |
| 10674 for (int i = 0; i < partCount; i++) { | 10674 for (int i = 0; i < partCount; i++) { |
| 10675 unitSource = parts[i].source; | 10675 unitSource = parts[i].source; |
| 10676 resolvedUnit = getCompilationUnit(unitSource); | 10676 resolvedUnit = _getCompilationUnit(unitSource); |
| 10677 timestampMap[unitSource] = resolvedUnit; | 10677 timestampMap[unitSource] = resolvedUnit; |
| 10678 unit = resolvedUnit.data; | 10678 unit = resolvedUnit.data; |
| 10679 if (unit == null) { | 10679 if (unit == null) { |
| 10680 throw new AnalysisException.con1("Internal error: GenerateDartHintsTask
failed to access resolved compilation unit for ${unitSource.fullName}"); | 10680 throw new AnalysisException.con1("Internal error: GenerateDartHintsTask
failed to access resolved compilation unit for ${unitSource.fullName}"); |
| 10681 } | 10681 } |
| 10682 compilationUnits[i + 1] = unit; | 10682 compilationUnits[i + 1] = unit; |
| 10683 } | 10683 } |
| 10684 // | 10684 // |
| 10685 // Analyze all of the units. | 10685 // Analyze all of the units. |
| 10686 // | 10686 // |
| (...skipping 11 matching lines...) Expand all Loading... |
| 10698 } | 10698 } |
| 10699 } | 10699 } |
| 10700 | 10700 |
| 10701 /** | 10701 /** |
| 10702 * Return the resolved compilation unit associated with the given source. | 10702 * Return the resolved compilation unit associated with the given source. |
| 10703 * | 10703 * |
| 10704 * @param unitSource the source for the compilation unit whose resolved AST is
to be returned | 10704 * @param unitSource the source for the compilation unit whose resolved AST is
to be returned |
| 10705 * @return the resolved compilation unit associated with the given source | 10705 * @return the resolved compilation unit associated with the given source |
| 10706 * @throws AnalysisException if the resolved compilation unit could not be com
puted | 10706 * @throws AnalysisException if the resolved compilation unit could not be com
puted |
| 10707 */ | 10707 */ |
| 10708 TimestampedData<CompilationUnit> getCompilationUnit(Source unitSource) => cont
ext.internalResolveCompilationUnit(unitSource, libraryElement); | 10708 TimestampedData<CompilationUnit> _getCompilationUnit(Source unitSource) => con
text.internalResolveCompilationUnit(unitSource, libraryElement); |
| 10709 } | 10709 } |
| 10710 | 10710 |
| 10711 /** | 10711 /** |
| 10712 * Instances of the class `GetContentTask` get the contents of a source. | 10712 * Instances of the class `GetContentTask` get the contents of a source. |
| 10713 */ | 10713 */ |
| 10714 class GetContentTask extends AnalysisTask { | 10714 class GetContentTask extends AnalysisTask { |
| 10715 /** | 10715 /** |
| 10716 * The source to be read. | 10716 * The source to be read. |
| 10717 */ | 10717 */ |
| 10718 final Source source; | 10718 final Source source; |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11400 } | 11400 } |
| 11401 | 11401 |
| 11402 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartDependenciesTas
k(this); | 11402 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartDependenciesTas
k(this); |
| 11403 | 11403 |
| 11404 /** | 11404 /** |
| 11405 * Return an array containing the sources referenced by 'export' directives, o
r an empty array if | 11405 * Return an array containing the sources referenced by 'export' directives, o
r an empty array if |
| 11406 * the task has not yet been performed or if an exception occurred. | 11406 * the task has not yet been performed or if an exception occurred. |
| 11407 * | 11407 * |
| 11408 * @return an array containing the sources referenced by 'export' directives | 11408 * @return an array containing the sources referenced by 'export' directives |
| 11409 */ | 11409 */ |
| 11410 List<Source> get exportedSources => toArray(_exportedSources); | 11410 List<Source> get exportedSources => _toArray(_exportedSources); |
| 11411 | 11411 |
| 11412 /** | 11412 /** |
| 11413 * Return an array containing the sources referenced by 'import' directives, o
r an empty array if | 11413 * Return an array containing the sources referenced by 'import' directives, o
r an empty array if |
| 11414 * the task has not yet been performed or if an exception occurred. | 11414 * the task has not yet been performed or if an exception occurred. |
| 11415 * | 11415 * |
| 11416 * @return an array containing the sources referenced by 'import' directives | 11416 * @return an array containing the sources referenced by 'import' directives |
| 11417 */ | 11417 */ |
| 11418 List<Source> get importedSources => toArray(_importedSources); | 11418 List<Source> get importedSources => _toArray(_importedSources); |
| 11419 | 11419 |
| 11420 /** | 11420 /** |
| 11421 * Return an array containing the sources referenced by 'part' directives, or
an empty array if | 11421 * Return an array containing the sources referenced by 'part' directives, or
an empty array if |
| 11422 * the task has not yet been performed or if an exception occurred. | 11422 * the task has not yet been performed or if an exception occurred. |
| 11423 * | 11423 * |
| 11424 * @return an array containing the sources referenced by 'part' directives | 11424 * @return an array containing the sources referenced by 'part' directives |
| 11425 */ | 11425 */ |
| 11426 List<Source> get includedSources => toArray(_includedSources); | 11426 List<Source> get includedSources => _toArray(_includedSources); |
| 11427 | 11427 |
| 11428 String get taskDescription { | 11428 String get taskDescription { |
| 11429 if (source == null) { | 11429 if (source == null) { |
| 11430 return "resolve dart dependencies null source"; | 11430 return "resolve dart dependencies null source"; |
| 11431 } | 11431 } |
| 11432 return "resolve dart dependencies ${source.fullName}"; | 11432 return "resolve dart dependencies ${source.fullName}"; |
| 11433 } | 11433 } |
| 11434 | 11434 |
| 11435 void internalPerform() { | 11435 void internalPerform() { |
| 11436 TimeCounter_TimeCounterHandle timeCounterParse = PerformanceStatistics.parse
.start(); | 11436 TimeCounter_TimeCounterHandle timeCounterParse = PerformanceStatistics.parse
.start(); |
| 11437 try { | 11437 try { |
| 11438 for (Directive directive in _unit.directives) { | 11438 for (Directive directive in _unit.directives) { |
| 11439 if (directive is ExportDirective) { | 11439 if (directive is ExportDirective) { |
| 11440 Source exportSource = resolveSource(source, directive); | 11440 Source exportSource = _resolveSource(source, directive); |
| 11441 if (exportSource != null) { | 11441 if (exportSource != null) { |
| 11442 _exportedSources.add(exportSource); | 11442 _exportedSources.add(exportSource); |
| 11443 } | 11443 } |
| 11444 } else if (directive is ImportDirective) { | 11444 } else if (directive is ImportDirective) { |
| 11445 Source importSource = resolveSource(source, directive); | 11445 Source importSource = _resolveSource(source, directive); |
| 11446 if (importSource != null) { | 11446 if (importSource != null) { |
| 11447 _importedSources.add(importSource); | 11447 _importedSources.add(importSource); |
| 11448 } | 11448 } |
| 11449 } else if (directive is PartDirective) { | 11449 } else if (directive is PartDirective) { |
| 11450 Source partSource = resolveSource(source, directive); | 11450 Source partSource = _resolveSource(source, directive); |
| 11451 if (partSource != null) { | 11451 if (partSource != null) { |
| 11452 _includedSources.add(partSource); | 11452 _includedSources.add(partSource); |
| 11453 } | 11453 } |
| 11454 } | 11454 } |
| 11455 } | 11455 } |
| 11456 } finally { | 11456 } finally { |
| 11457 timeCounterParse.stop(); | 11457 timeCounterParse.stop(); |
| 11458 } | 11458 } |
| 11459 } | 11459 } |
| 11460 | 11460 |
| 11461 /** | 11461 /** |
| 11462 * Return the result of resolving the URI of the given URI-based directive aga
inst the URI of the | 11462 * Return the result of resolving the URI of the given URI-based directive aga
inst the URI of the |
| 11463 * given library, or `null` if the URI is not valid. | 11463 * given library, or `null` if the URI is not valid. |
| 11464 * | 11464 * |
| 11465 * @param librarySource the source representing the library containing the dir
ective | 11465 * @param librarySource the source representing the library containing the dir
ective |
| 11466 * @param directive the directive which URI should be resolved | 11466 * @param directive the directive which URI should be resolved |
| 11467 * @return the result of resolving the URI against the URI of the library | 11467 * @return the result of resolving the URI against the URI of the library |
| 11468 */ | 11468 */ |
| 11469 Source resolveSource(Source librarySource, UriBasedDirective directive) { | 11469 Source _resolveSource(Source librarySource, UriBasedDirective directive) { |
| 11470 StringLiteral uriLiteral = directive.uri; | 11470 StringLiteral uriLiteral = directive.uri; |
| 11471 if (uriLiteral is StringInterpolation) { | 11471 if (uriLiteral is StringInterpolation) { |
| 11472 return null; | 11472 return null; |
| 11473 } | 11473 } |
| 11474 String uriContent = uriLiteral.stringValue.trim(); | 11474 String uriContent = uriLiteral.stringValue.trim(); |
| 11475 if (uriContent == null) { | 11475 if (uriContent == null) { |
| 11476 return null; | 11476 return null; |
| 11477 } | 11477 } |
| 11478 uriContent = Uri.encodeFull(uriContent); | 11478 uriContent = Uri.encodeFull(uriContent); |
| 11479 try { | 11479 try { |
| 11480 parseUriWithException(uriContent); | 11480 parseUriWithException(uriContent); |
| 11481 return context.sourceFactory.resolveUri(librarySource, uriContent); | 11481 return context.sourceFactory.resolveUri(librarySource, uriContent); |
| 11482 } on URISyntaxException catch (exception) { | 11482 } on URISyntaxException catch (exception) { |
| 11483 return null; | 11483 return null; |
| 11484 } | 11484 } |
| 11485 } | 11485 } |
| 11486 | 11486 |
| 11487 /** | 11487 /** |
| 11488 * Efficiently convert the given set of sources to an array. | 11488 * Efficiently convert the given set of sources to an array. |
| 11489 * | 11489 * |
| 11490 * @param sources the set to be converted | 11490 * @param sources the set to be converted |
| 11491 * @return an array containing all of the sources in the given set | 11491 * @return an array containing all of the sources in the given set |
| 11492 */ | 11492 */ |
| 11493 List<Source> toArray(Set<Source> sources) { | 11493 List<Source> _toArray(Set<Source> sources) { |
| 11494 int size = sources.length; | 11494 int size = sources.length; |
| 11495 if (size == 0) { | 11495 if (size == 0) { |
| 11496 return Source.EMPTY_ARRAY; | 11496 return Source.EMPTY_ARRAY; |
| 11497 } | 11497 } |
| 11498 return new List.from(sources); | 11498 return new List.from(sources); |
| 11499 } | 11499 } |
| 11500 } | 11500 } |
| 11501 | 11501 |
| 11502 /** | 11502 /** |
| 11503 * Instances of the class `ResolveDartLibraryTask` parse a specific Dart library
. | 11503 * Instances of the class `ResolveDartLibraryTask` parse a specific Dart library
. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11621 TypeProvider typeProvider = (_libraryElement.context as InternalAnalysisCont
ext).typeProvider; | 11621 TypeProvider typeProvider = (_libraryElement.context as InternalAnalysisCont
ext).typeProvider; |
| 11622 ResolvableCompilationUnit resolvableUnit = context.computeResolvableCompilat
ionUnit(source); | 11622 ResolvableCompilationUnit resolvableUnit = context.computeResolvableCompilat
ionUnit(source); |
| 11623 _modificationTime = resolvableUnit.modificationTime; | 11623 _modificationTime = resolvableUnit.modificationTime; |
| 11624 CompilationUnit unit = resolvableUnit.compilationUnit; | 11624 CompilationUnit unit = resolvableUnit.compilationUnit; |
| 11625 if (unit == null) { | 11625 if (unit == null) { |
| 11626 throw new AnalysisException.con1("Internal error: computeResolvableCompila
tionUnit returned a value without a parsed Dart unit"); | 11626 throw new AnalysisException.con1("Internal error: computeResolvableCompila
tionUnit returned a value without a parsed Dart unit"); |
| 11627 } | 11627 } |
| 11628 // | 11628 // |
| 11629 // Resolve names in declarations. | 11629 // Resolve names in declarations. |
| 11630 // | 11630 // |
| 11631 new DeclarationResolver().resolve(unit, find(_libraryElement, source)); | 11631 new DeclarationResolver().resolve(unit, _find(_libraryElement, source)); |
| 11632 // | 11632 // |
| 11633 // Resolve the type names. | 11633 // Resolve the type names. |
| 11634 // | 11634 // |
| 11635 RecordingErrorListener errorListener = new RecordingErrorListener(); | 11635 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 11636 TypeResolverVisitor typeResolverVisitor = new TypeResolverVisitor.con2(_libr
aryElement, source, typeProvider, errorListener); | 11636 TypeResolverVisitor typeResolverVisitor = new TypeResolverVisitor.con2(_libr
aryElement, source, typeProvider, errorListener); |
| 11637 unit.accept(typeResolverVisitor); | 11637 unit.accept(typeResolverVisitor); |
| 11638 // | 11638 // |
| 11639 // Resolve the rest of the structure | 11639 // Resolve the rest of the structure |
| 11640 // | 11640 // |
| 11641 InheritanceManager inheritanceManager = new InheritanceManager(_libraryEleme
nt); | 11641 InheritanceManager inheritanceManager = new InheritanceManager(_libraryEleme
nt); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 11668 | 11668 |
| 11669 /** | 11669 /** |
| 11670 * Search the compilation units that are part of the given library and return
the element | 11670 * Search the compilation units that are part of the given library and return
the element |
| 11671 * representing the compilation unit with the given source. Return `null` if t
here is no | 11671 * representing the compilation unit with the given source. Return `null` if t
here is no |
| 11672 * such compilation unit. | 11672 * such compilation unit. |
| 11673 * | 11673 * |
| 11674 * @param libraryElement the element representing the library being searched t
hrough | 11674 * @param libraryElement the element representing the library being searched t
hrough |
| 11675 * @param unitSource the source for the compilation unit whose element is to b
e returned | 11675 * @param unitSource the source for the compilation unit whose element is to b
e returned |
| 11676 * @return the element representing the compilation unit | 11676 * @return the element representing the compilation unit |
| 11677 */ | 11677 */ |
| 11678 CompilationUnitElement find(LibraryElement libraryElement, Source unitSource)
{ | 11678 CompilationUnitElement _find(LibraryElement libraryElement, Source unitSource)
{ |
| 11679 CompilationUnitElement element = libraryElement.definingCompilationUnit; | 11679 CompilationUnitElement element = libraryElement.definingCompilationUnit; |
| 11680 if (element.source == unitSource) { | 11680 if (element.source == unitSource) { |
| 11681 return element; | 11681 return element; |
| 11682 } | 11682 } |
| 11683 for (CompilationUnitElement partElement in libraryElement.parts) { | 11683 for (CompilationUnitElement partElement in libraryElement.parts) { |
| 11684 if (partElement.source == unitSource) { | 11684 if (partElement.source == unitSource) { |
| 11685 return partElement; | 11685 return partElement; |
| 11686 } | 11686 } |
| 11687 } | 11687 } |
| 11688 return null; | 11688 return null; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11931 * @param exception the exception being logged | 11931 * @param exception the exception being logged |
| 11932 */ | 11932 */ |
| 11933 void logInformation(String message); | 11933 void logInformation(String message); |
| 11934 | 11934 |
| 11935 /** | 11935 /** |
| 11936 * Log the given exception as one representing an informational message. | 11936 * Log the given exception as one representing an informational message. |
| 11937 * | 11937 * |
| 11938 * @param message an explanation of why the error occurred or what it means | 11938 * @param message an explanation of why the error occurred or what it means |
| 11939 * @param exception the exception being logged | 11939 * @param exception the exception being logged |
| 11940 */ | 11940 */ |
| 11941 void logInformation3(String message, Exception exception); | 11941 void logInformation2(String message, Exception exception); |
| 11942 } | 11942 } |
| 11943 | 11943 |
| 11944 /** | 11944 /** |
| 11945 * Implementation of [Logger] that does nothing. | 11945 * Implementation of [Logger] that does nothing. |
| 11946 */ | 11946 */ |
| 11947 class Logger_NullLogger implements Logger { | 11947 class Logger_NullLogger implements Logger { |
| 11948 void logError(String message) { | 11948 void logError(String message) { |
| 11949 } | 11949 } |
| 11950 | 11950 |
| 11951 void logError2(String message, Exception exception) { | 11951 void logError2(String message, Exception exception) { |
| 11952 } | 11952 } |
| 11953 | 11953 |
| 11954 void logInformation(String message) { | 11954 void logInformation(String message) { |
| 11955 } | 11955 } |
| 11956 | 11956 |
| 11957 void logInformation3(String message, Exception exception) { | 11957 void logInformation2(String message, Exception exception) { |
| 11958 } | 11958 } |
| 11959 } | 11959 } |
| OLD | NEW |