| 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/instrumentation/instrumentation.dart'; | 10 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 source, contents, offset, oldLength, newLength)); | 1155 source, contents, offset, oldLength, newLength)); |
| 1156 } | 1156 } |
| 1157 } | 1157 } |
| 1158 | 1158 |
| 1159 @override | 1159 @override |
| 1160 void setContents(Source source, String contents) { | 1160 void setContents(Source source, String contents) { |
| 1161 _contentsChanged(source, contents, true); | 1161 _contentsChanged(source, contents, true); |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 @override | 1164 @override |
| 1165 bool shouldErrorsBeAnalyzed(Source source, Object entry) { |
| 1166 CacheEntry entry = analysisCache.get(source); |
| 1167 if (source.isInSystemLibrary) { |
| 1168 return _options.generateSdkErrors; |
| 1169 } else if (!entry.explicitlyAdded) { |
| 1170 return _options.generateImplicitErrors; |
| 1171 } else { |
| 1172 return true; |
| 1173 } |
| 1174 } |
| 1175 |
| 1176 @override |
| 1165 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, | 1177 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, |
| 1166 DataDescriptor rowDesc, CacheState state)) { | 1178 DataDescriptor rowDesc, CacheState state)) { |
| 1167 // TODO(brianwilkerson) Figure out where this is used and adjust the call | 1179 // TODO(brianwilkerson) Figure out where this is used and adjust the call |
| 1168 // sites to use CacheEntry's. | 1180 // sites to use CacheEntry's. |
| 1169 // bool hintsEnabled = _options.hint; | 1181 // bool hintsEnabled = _options.hint; |
| 1170 // bool lintsEnabled = _options.lint; | 1182 // bool lintsEnabled = _options.lint; |
| 1171 // MapIterator<AnalysisTarget, cache.CacheEntry> iterator = _cache.iterator()
; | 1183 // MapIterator<AnalysisTarget, cache.CacheEntry> iterator = _cache.iterator()
; |
| 1172 // while (iterator.moveNext()) { | 1184 // while (iterator.moveNext()) { |
| 1173 // Source source = iterator.key; | 1185 // Source source = iterator.key; |
| 1174 // cache.CacheEntry entry = iterator.value; | 1186 // cache.CacheEntry entry = iterator.value; |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 CacheEntry unitEntry = | 1489 CacheEntry unitEntry = |
| 1478 _cache.get(new LibrarySpecificUnit(librarySource, source)); | 1490 _cache.get(new LibrarySpecificUnit(librarySource, source)); |
| 1479 state = unitEntry.getState(RESOLVED_UNIT); | 1491 state = unitEntry.getState(RESOLVED_UNIT); |
| 1480 if (state == CacheState.INVALID || | 1492 if (state == CacheState.INVALID || |
| 1481 (isPriority && state == CacheState.FLUSHED)) { | 1493 (isPriority && state == CacheState.FLUSHED)) { |
| 1482 sources.add(source); | 1494 sources.add(source); |
| 1483 return; | 1495 return; |
| 1484 } else if (state == CacheState.ERROR) { | 1496 } else if (state == CacheState.ERROR) { |
| 1485 return; | 1497 return; |
| 1486 } | 1498 } |
| 1487 if (_shouldErrorsBeAnalyzed(source, unitEntry)) { | 1499 if (shouldErrorsBeAnalyzed(source, unitEntry)) { |
| 1488 state = unitEntry.getState(VERIFY_ERRORS); | 1500 state = unitEntry.getState(VERIFY_ERRORS); |
| 1489 if (state == CacheState.INVALID || | 1501 if (state == CacheState.INVALID || |
| 1490 (isPriority && state == CacheState.FLUSHED)) { | 1502 (isPriority && state == CacheState.FLUSHED)) { |
| 1491 sources.add(source); | 1503 sources.add(source); |
| 1492 return; | 1504 return; |
| 1493 } else if (state == CacheState.ERROR) { | 1505 } else if (state == CacheState.ERROR) { |
| 1494 return; | 1506 return; |
| 1495 } | 1507 } |
| 1496 if (hintsEnabled) { | 1508 if (hintsEnabled) { |
| 1497 state = unitEntry.getState(HINTS); | 1509 state = unitEntry.getState(HINTS); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 if (_priorityOrder[i] != source) { | 1626 if (_priorityOrder[i] != source) { |
| 1615 newOrder.add(_priorityOrder[i]); | 1627 newOrder.add(_priorityOrder[i]); |
| 1616 } | 1628 } |
| 1617 } | 1629 } |
| 1618 if (newOrder.length < count) { | 1630 if (newOrder.length < count) { |
| 1619 analysisPriorityOrder = newOrder; | 1631 analysisPriorityOrder = newOrder; |
| 1620 } | 1632 } |
| 1621 } | 1633 } |
| 1622 | 1634 |
| 1623 /** | 1635 /** |
| 1624 * Return `true` if errors should be produced for the given [source]. The | |
| 1625 * [entry] associated with the source is passed in for efficiency. | |
| 1626 */ | |
| 1627 bool _shouldErrorsBeAnalyzed(Source source, CacheEntry entry) { | |
| 1628 if (source.isInSystemLibrary) { | |
| 1629 return _options.generateSdkErrors; | |
| 1630 } else if (!entry.explicitlyAdded) { | |
| 1631 return _options.generateImplicitErrors; | |
| 1632 } else { | |
| 1633 return true; | |
| 1634 } | |
| 1635 } | |
| 1636 | |
| 1637 /** | |
| 1638 * Create an entry for the newly added [source] and invalidate any sources | 1636 * Create an entry for the newly added [source] and invalidate any sources |
| 1639 * that referenced the source before it existed. | 1637 * that referenced the source before it existed. |
| 1640 */ | 1638 */ |
| 1641 void _sourceAvailable(Source source) { | 1639 void _sourceAvailable(Source source) { |
| 1642 CacheEntry entry = _cache.get(source); | 1640 CacheEntry entry = _cache.get(source); |
| 1643 if (entry == null) { | 1641 if (entry == null) { |
| 1644 _createCacheEntry(source, true); | 1642 _createCacheEntry(source, true); |
| 1645 } else { | 1643 } else { |
| 1646 entry.modificationTime = getModificationStamp(source); | 1644 entry.modificationTime = getModificationStamp(source); |
| 1647 entry.setState(CONTENT, CacheState.INVALID); | 1645 entry.setState(CONTENT, CacheState.INVALID); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2024 PendingFuture pendingFuture = | 2022 PendingFuture pendingFuture = |
| 2025 new PendingFuture<T>(_context, target, computeValue); | 2023 new PendingFuture<T>(_context, target, computeValue); |
| 2026 if (!pendingFuture.evaluate(entry)) { | 2024 if (!pendingFuture.evaluate(entry)) { |
| 2027 _context._pendingFutureTargets | 2025 _context._pendingFutureTargets |
| 2028 .putIfAbsent(target, () => <PendingFuture>[]) | 2026 .putIfAbsent(target, () => <PendingFuture>[]) |
| 2029 .add(pendingFuture); | 2027 .add(pendingFuture); |
| 2030 } | 2028 } |
| 2031 return pendingFuture.future; | 2029 return pendingFuture.future; |
| 2032 } | 2030 } |
| 2033 } | 2031 } |
| OLD | NEW |