| 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 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 return _cache.getValue(target, result); | 1004 return _cache.getValue(target, result); |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 @override | 1007 @override |
| 1008 List<Source> getSourcesWithFullName(String path) { | 1008 List<Source> getSourcesWithFullName(String path) { |
| 1009 return analysisCache.getSourcesWithFullName(path); | 1009 return analysisCache.getSourcesWithFullName(path); |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 @override | 1012 @override |
| 1013 bool handleContentsChanged( | 1013 bool handleContentsChanged( |
| 1014 Source source, String originalContents, String newContents, bool notify) { | 1014 Source source, String originalContents, String newContents, bool notify, |
| 1015 {bool explicit: false}) { |
| 1016 explicit = explicit && (newContents != null); |
| 1015 CacheEntry entry = _cache.get(source); | 1017 CacheEntry entry = _cache.get(source); |
| 1016 if (entry == null) { | 1018 if (entry == null) { |
| 1017 return false; | 1019 if (explicit) { |
| 1020 // Create it now. |
| 1021 entry = _createCacheEntry(source, true); |
| 1022 } else { |
| 1023 return false; |
| 1024 } |
| 1025 } |
| 1026 if (explicit) { |
| 1027 // Mark as explicit whether there was any other change or not. |
| 1028 entry.explicitlyAdded = true; |
| 1018 } | 1029 } |
| 1019 bool changed = newContents != originalContents; | 1030 bool changed = newContents != originalContents; |
| 1020 if (newContents != null) { | 1031 if (newContents != null) { |
| 1021 if (changed) { | 1032 if (changed) { |
| 1022 if (!analysisOptions.incremental || | 1033 if (!analysisOptions.incremental || |
| 1023 !_tryPoorMansIncrementalResolution(source, newContents)) { | 1034 !_tryPoorMansIncrementalResolution(source, newContents)) { |
| 1024 // Don't compare with old contents because the cache has already been | 1035 // Don't compare with old contents because the cache has already been |
| 1025 // updated, and we know at this point that it changed. | 1036 // updated, and we know at this point that it changed. |
| 1026 _sourceChanged(source, compareWithOld: false); | 1037 _sourceChanged(source, compareWithOld: false); |
| 1027 } | 1038 } |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1737 } | 1748 } |
| 1738 } | 1749 } |
| 1739 | 1750 |
| 1740 /** | 1751 /** |
| 1741 * Create an entry for the newly added [source] and invalidate any sources | 1752 * Create an entry for the newly added [source] and invalidate any sources |
| 1742 * that referenced the source before it existed. | 1753 * that referenced the source before it existed. |
| 1743 */ | 1754 */ |
| 1744 void _sourceAvailable(Source source) { | 1755 void _sourceAvailable(Source source) { |
| 1745 driver.reset(); | 1756 driver.reset(); |
| 1746 // TODO(brianwilkerson) This method needs to check whether the source was | 1757 // TODO(brianwilkerson) This method needs to check whether the source was |
| 1747 // previously being implicitly analyzed. If so, the cache entry needs to be | 1758 // previously being implicitly analyzed. If so, an event needs to be |
| 1748 // update to reflect the new status and an event needs to be generated to | 1759 // generated to inform clients that it is no longer being implicitly |
| 1749 // inform clients that it is no longer being implicitly analyzed. | 1760 // analyzed. |
| 1750 CacheEntry entry = _cache.get(source); | 1761 CacheEntry entry = _cache.get(source); |
| 1751 if (entry == null) { | 1762 if (entry == null) { |
| 1752 _createCacheEntry(source, true); | 1763 _createCacheEntry(source, true); |
| 1753 } else { | 1764 } else { |
| 1754 entry.explicitlyAdded = true; | 1765 entry.explicitlyAdded = true; |
| 1755 entry.modificationTime = getModificationStamp(source); | 1766 entry.modificationTime = getModificationStamp(source); |
| 1756 entry.setState(CONTENT, CacheState.INVALID); | 1767 entry.setState(CONTENT, CacheState.INVALID); |
| 1757 } | 1768 } |
| 1758 } | 1769 } |
| 1759 | 1770 |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2143 } | 2154 } |
| 2144 DartSdk sdk = factory.dartSdk; | 2155 DartSdk sdk = factory.dartSdk; |
| 2145 if (sdk == null) { | 2156 if (sdk == null) { |
| 2146 throw new IllegalArgumentException( | 2157 throw new IllegalArgumentException( |
| 2147 "The source factory for an SDK analysis context must have a DartUriRes
olver"); | 2158 "The source factory for an SDK analysis context must have a DartUriRes
olver"); |
| 2148 } | 2159 } |
| 2149 return new AnalysisCache( | 2160 return new AnalysisCache( |
| 2150 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); | 2161 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); |
| 2151 } | 2162 } |
| 2152 } | 2163 } |
| OLD | NEW |