| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library analyzer.src.context.context; | 5 library analyzer.src.context.context; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 setValue(IS_LAUNCHABLE, false); | 1198 setValue(IS_LAUNCHABLE, false); |
| 1199 setValue(LIBRARY_ELEMENT, library); | 1199 setValue(LIBRARY_ELEMENT, library); |
| 1200 setValue(LIBRARY_ELEMENT1, library); | 1200 setValue(LIBRARY_ELEMENT1, library); |
| 1201 setValue(LIBRARY_ELEMENT2, library); | 1201 setValue(LIBRARY_ELEMENT2, library); |
| 1202 setValue(LIBRARY_ELEMENT3, library); | 1202 setValue(LIBRARY_ELEMENT3, library); |
| 1203 setValue(LIBRARY_ELEMENT4, library); | 1203 setValue(LIBRARY_ELEMENT4, library); |
| 1204 setValue(LIBRARY_ELEMENT5, library); | 1204 setValue(LIBRARY_ELEMENT5, library); |
| 1205 setValue(LIBRARY_ELEMENT6, library); | 1205 setValue(LIBRARY_ELEMENT6, library); |
| 1206 setValue(LIBRARY_ELEMENT7, library); | 1206 setValue(LIBRARY_ELEMENT7, library); |
| 1207 setValue(LIBRARY_ELEMENT8, library); | 1207 setValue(LIBRARY_ELEMENT8, library); |
| 1208 setValue(LIBRARY_ELEMENT9, library); |
| 1208 setValue(LINE_INFO, new LineInfo(<int>[0])); | 1209 setValue(LINE_INFO, new LineInfo(<int>[0])); |
| 1209 setValue(PARSE_ERRORS, AnalysisError.NO_ERRORS); | 1210 setValue(PARSE_ERRORS, AnalysisError.NO_ERRORS); |
| 1210 entry.setState(PARSED_UNIT, CacheState.FLUSHED); | 1211 entry.setState(PARSED_UNIT, CacheState.FLUSHED); |
| 1211 entry.setState(RESOLVE_TYPE_NAMES_ERRORS, CacheState.FLUSHED); | 1212 entry.setState(RESOLVE_TYPE_NAMES_ERRORS, CacheState.FLUSHED); |
| 1213 entry.setState(RESOLVE_TYPE_BOUNDS_ERRORS, CacheState.FLUSHED); |
| 1212 setValue(SCAN_ERRORS, AnalysisError.NO_ERRORS); | 1214 setValue(SCAN_ERRORS, AnalysisError.NO_ERRORS); |
| 1213 setValue(SOURCE_KIND, SourceKind.LIBRARY); | 1215 setValue(SOURCE_KIND, SourceKind.LIBRARY); |
| 1214 entry.setState(TOKEN_STREAM, CacheState.FLUSHED); | 1216 entry.setState(TOKEN_STREAM, CacheState.FLUSHED); |
| 1215 setValue(UNITS, <Source>[librarySource]); | 1217 setValue(UNITS, <Source>[librarySource]); |
| 1216 | 1218 |
| 1217 LibrarySpecificUnit unit = | 1219 LibrarySpecificUnit unit = |
| 1218 new LibrarySpecificUnit(librarySource, librarySource); | 1220 new LibrarySpecificUnit(librarySource, librarySource); |
| 1219 entry = getCacheEntry(unit); | 1221 entry = getCacheEntry(unit); |
| 1220 setValue(HINTS, AnalysisError.NO_ERRORS); | 1222 setValue(HINTS, AnalysisError.NO_ERRORS); |
| 1221 setValue(LINTS, AnalysisError.NO_ERRORS); | 1223 setValue(LINTS, AnalysisError.NO_ERRORS); |
| 1222 setValue(LIBRARY_UNIT_ERRORS, AnalysisError.NO_ERRORS); | 1224 setValue(LIBRARY_UNIT_ERRORS, AnalysisError.NO_ERRORS); |
| 1223 setValue(RESOLVE_TYPE_NAMES_ERRORS, AnalysisError.NO_ERRORS); | 1225 setValue(RESOLVE_TYPE_NAMES_ERRORS, AnalysisError.NO_ERRORS); |
| 1224 setValue(RESOLVE_UNIT_ERRORS, AnalysisError.NO_ERRORS); | 1226 setValue(RESOLVE_UNIT_ERRORS, AnalysisError.NO_ERRORS); |
| 1225 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); | 1227 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); |
| 1226 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED); | 1228 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED); |
| 1227 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED); | 1229 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED); |
| 1228 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); | 1230 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); |
| 1229 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); | 1231 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); |
| 1230 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); | 1232 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); |
| 1231 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED); | 1233 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED); |
| 1232 entry.setState(RESOLVED_UNIT7, CacheState.FLUSHED); | 1234 entry.setState(RESOLVED_UNIT7, CacheState.FLUSHED); |
| 1233 entry.setState(RESOLVED_UNIT8, CacheState.FLUSHED); | 1235 entry.setState(RESOLVED_UNIT8, CacheState.FLUSHED); |
| 1234 entry.setState(RESOLVED_UNIT9, CacheState.FLUSHED); | 1236 entry.setState(RESOLVED_UNIT9, CacheState.FLUSHED); |
| 1235 entry.setState(RESOLVED_UNIT10, CacheState.FLUSHED); | 1237 entry.setState(RESOLVED_UNIT10, CacheState.FLUSHED); |
| 1236 entry.setState(RESOLVED_UNIT11, CacheState.FLUSHED); | 1238 entry.setState(RESOLVED_UNIT11, CacheState.FLUSHED); |
| 1237 entry.setState(RESOLVED_UNIT12, CacheState.FLUSHED); | 1239 entry.setState(RESOLVED_UNIT12, CacheState.FLUSHED); |
| 1240 entry.setState(RESOLVED_UNIT13, CacheState.FLUSHED); |
| 1238 // USED_IMPORTED_ELEMENTS | 1241 // USED_IMPORTED_ELEMENTS |
| 1239 // USED_LOCAL_ELEMENTS | 1242 // USED_LOCAL_ELEMENTS |
| 1240 setValue(STRONG_MODE_ERRORS, AnalysisError.NO_ERRORS); | 1243 setValue(STRONG_MODE_ERRORS, AnalysisError.NO_ERRORS); |
| 1241 setValue(VARIABLE_REFERENCE_ERRORS, AnalysisError.NO_ERRORS); | 1244 setValue(VARIABLE_REFERENCE_ERRORS, AnalysisError.NO_ERRORS); |
| 1242 setValue(VERIFY_ERRORS, AnalysisError.NO_ERRORS); | 1245 setValue(VERIFY_ERRORS, AnalysisError.NO_ERRORS); |
| 1243 }); | 1246 }); |
| 1244 | 1247 |
| 1245 CacheEntry entry = getCacheEntry(AnalysisContextTarget.request); | 1248 CacheEntry entry = getCacheEntry(AnalysisContextTarget.request); |
| 1246 entry.setValue(TYPE_PROVIDER, typeProvider, TargetedResult.EMPTY_LIST); | 1249 entry.setValue(TYPE_PROVIDER, typeProvider, TargetedResult.EMPTY_LIST); |
| 1247 } | 1250 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1307 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); | 1310 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); |
| 1308 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); | 1311 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); |
| 1309 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); | 1312 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); |
| 1310 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED); | 1313 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED); |
| 1311 entry.setState(RESOLVED_UNIT7, CacheState.FLUSHED); | 1314 entry.setState(RESOLVED_UNIT7, CacheState.FLUSHED); |
| 1312 entry.setState(RESOLVED_UNIT8, CacheState.FLUSHED); | 1315 entry.setState(RESOLVED_UNIT8, CacheState.FLUSHED); |
| 1313 entry.setState(RESOLVED_UNIT9, CacheState.FLUSHED); | 1316 entry.setState(RESOLVED_UNIT9, CacheState.FLUSHED); |
| 1314 entry.setState(RESOLVED_UNIT10, CacheState.FLUSHED); | 1317 entry.setState(RESOLVED_UNIT10, CacheState.FLUSHED); |
| 1315 entry.setState(RESOLVED_UNIT11, CacheState.FLUSHED); | 1318 entry.setState(RESOLVED_UNIT11, CacheState.FLUSHED); |
| 1316 entry.setState(RESOLVED_UNIT12, CacheState.FLUSHED); | 1319 entry.setState(RESOLVED_UNIT12, CacheState.FLUSHED); |
| 1320 entry.setState(RESOLVED_UNIT13, CacheState.FLUSHED); |
| 1317 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); | 1321 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); |
| 1318 } | 1322 } |
| 1319 | 1323 |
| 1320 @override | 1324 @override |
| 1321 bool validateCacheConsistency() { | 1325 bool validateCacheConsistency() { |
| 1322 int consistencyCheckStart = JavaSystem.nanoTime(); | 1326 int consistencyCheckStart = JavaSystem.nanoTime(); |
| 1323 HashSet<Source> changedSources = new HashSet<Source>(); | 1327 HashSet<Source> changedSources = new HashSet<Source>(); |
| 1324 HashSet<Source> missingSources = new HashSet<Source>(); | 1328 HashSet<Source> missingSources = new HashSet<Source>(); |
| 1325 for (Source source in _cache.sources) { | 1329 for (Source source in _cache.sources) { |
| 1326 CacheEntry entry = _cache.get(source); | 1330 CacheEntry entry = _cache.get(source); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1542 /** | 1546 /** |
| 1543 * Return a [CompilationUnit] for the given library and unit sources, which | 1547 * Return a [CompilationUnit] for the given library and unit sources, which |
| 1544 * can be incrementally resolved. | 1548 * can be incrementally resolved. |
| 1545 */ | 1549 */ |
| 1546 CompilationUnit _getIncrementallyResolvableUnit( | 1550 CompilationUnit _getIncrementallyResolvableUnit( |
| 1547 Source librarySource, Source unitSource) { | 1551 Source librarySource, Source unitSource) { |
| 1548 LibrarySpecificUnit target = | 1552 LibrarySpecificUnit target = |
| 1549 new LibrarySpecificUnit(librarySource, unitSource); | 1553 new LibrarySpecificUnit(librarySource, unitSource); |
| 1550 for (ResultDescriptor result in [ | 1554 for (ResultDescriptor result in [ |
| 1551 RESOLVED_UNIT, | 1555 RESOLVED_UNIT, |
| 1556 RESOLVED_UNIT13, |
| 1552 RESOLVED_UNIT12, | 1557 RESOLVED_UNIT12, |
| 1553 RESOLVED_UNIT11, | 1558 RESOLVED_UNIT11, |
| 1554 RESOLVED_UNIT10, | 1559 RESOLVED_UNIT10, |
| 1555 RESOLVED_UNIT9, | 1560 RESOLVED_UNIT9, |
| 1556 RESOLVED_UNIT8, | 1561 RESOLVED_UNIT8 |
| 1557 RESOLVED_UNIT7 | |
| 1558 ]) { | 1562 ]) { |
| 1559 CompilationUnit unit = getResult(target, result); | 1563 CompilationUnit unit = getResult(target, result); |
| 1560 if (unit != null) { | 1564 if (unit != null) { |
| 1561 return unit; | 1565 return unit; |
| 1562 } | 1566 } |
| 1563 } | 1567 } |
| 1564 return null; | 1568 return null; |
| 1565 } | 1569 } |
| 1566 | 1570 |
| 1567 /** | 1571 /** |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1783 // previously being implicitly analyzed. If so, the cache entry needs to be | 1787 // previously being implicitly analyzed. If so, the cache entry needs to be |
| 1784 // update to reflect the new status and an event needs to be generated to | 1788 // update to reflect the new status and an event needs to be generated to |
| 1785 // inform clients that it is no longer being implicitly analyzed. | 1789 // inform clients that it is no longer being implicitly analyzed. |
| 1786 CacheEntry entry = _cache.get(source); | 1790 CacheEntry entry = _cache.get(source); |
| 1787 if (entry == null) { | 1791 if (entry == null) { |
| 1788 _createCacheEntry(source, true); | 1792 _createCacheEntry(source, true); |
| 1789 } else { | 1793 } else { |
| 1790 entry.explicitlyAdded = true; | 1794 entry.explicitlyAdded = true; |
| 1791 entry.modificationTime = getModificationStamp(source); | 1795 entry.modificationTime = getModificationStamp(source); |
| 1792 entry.setState(CONTENT, CacheState.INVALID); | 1796 entry.setState(CONTENT, CacheState.INVALID); |
| 1797 entry.setState(MODIFICATION_TIME, CacheState.INVALID); |
| 1793 } | 1798 } |
| 1794 } | 1799 } |
| 1795 | 1800 |
| 1796 /** | 1801 /** |
| 1797 * Invalidate the [source] that was changed and any sources that referenced | 1802 * Invalidate the [source] that was changed and any sources that referenced |
| 1798 * the source before it existed. | 1803 * the source before it existed. |
| 1799 * | 1804 * |
| 1800 * Note: source may be considered "changed" if it was previously missing, | 1805 * Note: source may be considered "changed" if it was previously missing, |
| 1801 * but pointed to by an import or export directive. | 1806 * but pointed to by an import or export directive. |
| 1802 */ | 1807 */ |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2195 } | 2200 } |
| 2196 DartSdk sdk = factory.dartSdk; | 2201 DartSdk sdk = factory.dartSdk; |
| 2197 if (sdk == null) { | 2202 if (sdk == null) { |
| 2198 throw new IllegalArgumentException( | 2203 throw new IllegalArgumentException( |
| 2199 "The source factory for an SDK analysis context must have a DartUriRes
olver"); | 2204 "The source factory for an SDK analysis context must have a DartUriRes
olver"); |
| 2200 } | 2205 } |
| 2201 return new AnalysisCache( | 2206 return new AnalysisCache( |
| 2202 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); | 2207 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); |
| 2203 } | 2208 } |
| 2204 } | 2209 } |
| OLD | NEW |