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

Side by Side Diff: pkg/analyzer/lib/src/context/context.dart

Issue 1129033003: When a target is removed, invalidate all dependent results. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/context/cache.dart ('k') | pkg/analyzer/test/src/context/cache_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 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/src/cancelable_future.dart'; 10 import 'package:analyzer/src/cancelable_future.dart';
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 // oldPartMap[target] = dartEntry.getValue(DartEntry.INCLUDED_PARTS); 1625 // oldPartMap[target] = dartEntry.getValue(DartEntry.INCLUDED_PARTS);
1626 // dartEntry.invalidateAllResolutionInformation(invalidateUris); 1626 // dartEntry.invalidateAllResolutionInformation(invalidateUris);
1627 // iterator.value = dartEntry; 1627 // iterator.value = dartEntry;
1628 // _workManager.add(target, _computePriority(dartEntry)); 1628 // _workManager.add(target, _computePriority(dartEntry));
1629 // } 1629 // }
1630 // } 1630 // }
1631 _removeFromPartsUsingMap(oldPartMap); 1631 _removeFromPartsUsingMap(oldPartMap);
1632 } 1632 }
1633 1633
1634 /** 1634 /**
1635 * In response to a change to at least one of the compilation units in the
1636 * library defined by the given [librarySource], invalidate any results that
1637 * are dependent on the result of resolving that library.
1638 *
1639 * <b>Note:</b> Any cache entries that were accessed before this method was
1640 * invoked must be re-accessed after this method returns.
1641 */
1642 void _invalidateLibraryResolution(Source librarySource) {
1643 // TODO(brianwilkerson) Figure out whether we still need this.
1644 // TODO(brianwilkerson) This could be optimized. There's no need to flush
1645 // all of these entries if the public namespace hasn't changed, which will
1646 // be a fairly common case. The question is whether we can afford the time
1647 // to compute the namespace to look for differences.
1648 // DartEntry libraryEntry = _getReadableDartEntry(librarySource);
1649 // if (libraryEntry != null) {
1650 // List<Source> includedParts =
1651 // libraryEntry.getValue(DartEntry.INCLUDED_PARTS);
1652 // libraryEntry.invalidateAllResolutionInformation(false);
1653 // _workManager.add(librarySource, SourcePriority.LIBRARY);
1654 // for (Source partSource in includedParts) {
1655 // SourceEntry partEntry = _cache.get(partSource);
1656 // if (partEntry is DartEntry) {
1657 // partEntry.invalidateAllResolutionInformation(false);
1658 // }
1659 // }
1660 // }
1661 }
1662
1663 /**
1664 * Log the given debugging [message]. 1635 * Log the given debugging [message].
1665 */ 1636 */
1666 void _logInformation(String message) { 1637 void _logInformation(String message) {
1667 AnalysisEngine.instance.logger.logInformation(message); 1638 AnalysisEngine.instance.logger.logInformation(message);
1668 } 1639 }
1669 1640
1670 /** 1641 /**
1671 * Notify all of the analysis listeners that the errors associated with the 1642 * Notify all of the analysis listeners that the errors associated with the
1672 * given [source] has been updated to the given [errors]. 1643 * given [source] has been updated to the given [errors].
1673 */ 1644 */
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 // new AnalysisException("This source was marked as being deleted"), 1776 // new AnalysisException("This source was marked as being deleted"),
1806 // null)); 1777 // null));
1807 // } 1778 // }
1808 _removeFromPriorityOrder(source); 1779 _removeFromPriorityOrder(source);
1809 } 1780 }
1810 1781
1811 /** 1782 /**
1812 * Record that the given [source] has been removed. 1783 * Record that the given [source] has been removed.
1813 */ 1784 */
1814 void _sourceRemoved(Source source) { 1785 void _sourceRemoved(Source source) {
1815 List<Source> containingLibraries = getLibrariesContaining(source);
1816 if (containingLibraries != null && containingLibraries.isNotEmpty) {
1817 HashSet<Source> libraries = new HashSet<Source>();
1818 for (Source librarySource in containingLibraries) {
1819 libraries.add(librarySource);
1820 for (Source dependentLibrary
1821 in getLibrariesDependingOn(librarySource)) {
1822 libraries.add(dependentLibrary);
1823 }
1824 }
1825 for (Source librarySource in libraries) {
1826 _invalidateLibraryResolution(librarySource);
1827 }
1828 }
1829 _cache.remove(source); 1786 _cache.remove(source);
1830 _removeFromPriorityOrder(source); 1787 _removeFromPriorityOrder(source);
1831 } 1788 }
1832 1789
1833 /** 1790 /**
1834 * TODO(scheglov) A hackish, limited incremental resolution implementation. 1791 * TODO(scheglov) A hackish, limited incremental resolution implementation.
1835 */ 1792 */
1836 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) { 1793 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) {
1837 // TODO(brianwilkerson) Implement this. 1794 // TODO(brianwilkerson) Implement this.
1838 return false; 1795 return false;
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 PendingFuture pendingFuture = 2071 PendingFuture pendingFuture =
2115 new PendingFuture<T>(_context, target, computeValue); 2072 new PendingFuture<T>(_context, target, computeValue);
2116 if (!pendingFuture.evaluate(entry)) { 2073 if (!pendingFuture.evaluate(entry)) {
2117 _context._pendingFutureTargets 2074 _context._pendingFutureTargets
2118 .putIfAbsent(target, () => <PendingFuture>[]) 2075 .putIfAbsent(target, () => <PendingFuture>[])
2119 .add(pendingFuture); 2076 .add(pendingFuture);
2120 } 2077 }
2121 return pendingFuture.future; 2078 return pendingFuture.future;
2122 } 2079 }
2123 } 2080 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/context/cache.dart ('k') | pkg/analyzer/test/src/context/cache_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698