Index: pkg/analyzer/lib/src/generated/engine.dart |
diff --git a/pkg/analyzer/lib/src/generated/engine.dart b/pkg/analyzer/lib/src/generated/engine.dart |
index 83769e6d77e53c152d3dfb6cd9677aa65ca2ba35..858bf7d9c5539dc14143e0030daff0c46de8ade1 100644 |
--- a/pkg/analyzer/lib/src/generated/engine.dart |
+++ b/pkg/analyzer/lib/src/generated/engine.dart |
@@ -208,9 +208,10 @@ class AnalysisCache { |
} |
/** |
- * Remove all information related to the given [source] from this cache. |
+ * Remove all information related to the given [source] from this cache and |
+ * return the entry associated with the source. |
Paul Berry
2015/07/15 19:50:01
Document when we would return `null` here too.
Brian Wilkerson
2015/07/15 21:23:37
Done
|
*/ |
- void remove(Source source) { |
+ SourceEntry remove(Source source) { |
int count = _partitions.length; |
for (int i = 0; i < count; i++) { |
if (_partitions[i].contains(source)) { |
@@ -223,10 +224,10 @@ class AnalysisCache { |
JavaSystem.currentTimeMillis(); |
} |
} |
- _partitions[i].remove(source); |
- return; |
+ return _partitions[i].remove(source); |
} |
} |
+ return null; |
} |
/** |
@@ -342,6 +343,12 @@ abstract class AnalysisContext { |
void set analysisPriorityOrder(List<Source> sources); |
/** |
+ * The stream that is notified when a source either starts or stops being |
+ * analyzed implicitly. |
+ */ |
+ Stream<AnalyzedSourcesEvent> get analyzedSources; |
Paul Berry
2015/07/15 19:50:01
Similarly, consider renaming this to "implicitlyAn
Brian Wilkerson
2015/07/15 21:23:37
I struggled a bit with the name. I suppose what yo
|
+ |
+ /** |
* Return the set of declared variables used when computing constant values. |
*/ |
DeclaredVariables get declaredVariables; |
@@ -1034,6 +1041,12 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
StreamController<SourcesChangedEvent> _onSourcesChangedController; |
/** |
+ * A subscription for a stream of events indicating when files are (and are |
+ * not) being implicitly analyzed. |
+ */ |
+ StreamController<AnalyzedSourcesEvent> _analyzedSourcesController; |
+ |
+ /** |
* The listeners that are to be notified when various analysis results are |
* produced in this context. |
*/ |
@@ -1084,6 +1097,8 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
_cache = createCacheFromSourceFactory(null); |
_onSourcesChangedController = |
new StreamController<SourcesChangedEvent>.broadcast(); |
+ _analyzedSourcesController = |
+ new StreamController<AnalyzedSourcesEvent>.broadcast(); |
} |
@override |
@@ -1175,6 +1190,10 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
} |
@override |
+ Stream<AnalyzedSourcesEvent> get analyzedSources => |
+ _analyzedSourcesController.stream; |
+ |
+ @override |
set contentCache(ContentCache value) { |
_contentCache = value; |
} |
@@ -2410,7 +2429,7 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
} else { |
unitEntry.recordResolutionError(thrownException); |
} |
- _cache.remove(unitSource); |
+ _removeFromCache(unitSource); |
if (thrownException != null) { |
throw new AnalysisException('<rethrow>', thrownException); |
} |
@@ -2483,7 +2502,7 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
} else { |
unitEntry.recordResolutionError(thrownException); |
} |
- _cache.remove(unitSource); |
+ _removeFromCache(unitSource); |
if (thrownException != null) { |
throw new AnalysisException('<rethrow>', thrownException); |
} |
@@ -2513,7 +2532,7 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
} else { |
dartEntry.recordResolutionErrorInLibrary( |
librarySource, thrownException); |
- _cache.remove(source); |
+ _removeFromCache(source); |
} |
if (source != librarySource) { |
_workManager.add(source, SourcePriority.PRIORITY_PART); |
@@ -2615,7 +2634,7 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
for (Source source in missingSources) { |
if (getLibrariesContaining(source).isEmpty && |
getLibrariesDependingOn(source).isEmpty) { |
- _cache.remove(source); |
+ _removeFromCache(source); |
removalCount++; |
} |
} |
@@ -3385,12 +3404,18 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
htmlEntry.modificationTime = getModificationStamp(source); |
htmlEntry.explicitlyAdded = explicitlyAdded; |
_cache.put(source, htmlEntry); |
+ if (!explicitlyAdded) { |
+ _analyzedSourcesController.add(new AnalyzedSourcesEvent(source, true)); |
+ } |
return htmlEntry; |
} else { |
DartEntry dartEntry = new DartEntry(); |
dartEntry.modificationTime = getModificationStamp(source); |
dartEntry.explicitlyAdded = explicitlyAdded; |
_cache.put(source, dartEntry); |
+ if (!explicitlyAdded) { |
+ _analyzedSourcesController.add(new AnalyzedSourcesEvent(source, true)); |
+ } |
return dartEntry; |
} |
} |
@@ -4108,6 +4133,16 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
AnalysisEngine.instance.logger.logInformation(message); |
} |
+ /** |
+ * Notify all of the analysis listeners that a task is about to be performed. |
+ */ |
+ void _notifyAboutToPerformTask(String taskDescription) { |
+ int count = _listeners.length; |
+ for (int i = 0; i < count; i++) { |
+ _listeners[i].aboutToPerformTask(this, taskDescription); |
+ } |
+ } |
+ |
// /** |
// * Notify all of the analysis listeners that the given source is no longer included in the set of |
// * sources that are being analyzed. |
@@ -4187,16 +4222,6 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
// } |
/** |
- * Notify all of the analysis listeners that a task is about to be performed. |
- */ |
- void _notifyAboutToPerformTask(String taskDescription) { |
- int count = _listeners.length; |
- for (int i = 0; i < count; i++) { |
- _listeners[i].aboutToPerformTask(this, taskDescription); |
- } |
- } |
- |
- /** |
* Notify all of the analysis listeners that the errors associated with the |
* given [source] has been updated to the given [errors]. |
*/ |
@@ -4569,6 +4594,13 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
return dartEntry; |
} |
+ void _removeFromCache(Source source) { |
+ SourceEntry entry = _cache.remove(source); |
+ if (entry != null && entry.explicitlyAdded) { |
+ _analyzedSourcesController.add(new AnalyzedSourcesEvent(source, false)); |
+ } |
+ } |
+ |
/** |
* Remove the given [librarySource] from the list of containing libraries for |
* all of the parts referenced by the given [dartEntry]. |
@@ -4581,7 +4613,7 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
if (partEntry != null && !identical(partEntry, dartEntry)) { |
partEntry.removeContainingLibrary(librarySource); |
if (partEntry.containingLibraries.length == 0 && !exists(partSource)) { |
- _cache.remove(partSource); |
+ _removeFromCache(partSource); |
} |
} |
} |
@@ -4601,7 +4633,7 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
partEntry.removeContainingLibrary(librarySource); |
if (partEntry.containingLibraries.length == 0 && |
!exists(partSource)) { |
- _cache.remove(partSource); |
+ _removeFromCache(partSource); |
} |
} |
} |
@@ -4718,7 +4750,7 @@ class AnalysisContextImpl implements InternalAnalysisContext { |
_invalidateLibraryResolution(librarySource); |
} |
} |
- _cache.remove(source); |
+ _removeFromCache(source); |
_workManager.remove(source); |
_removeFromPriorityOrder(source); |
} |
@@ -6594,6 +6626,32 @@ abstract class AnalysisTaskVisitor<E> { |
} |
/** |
+ * An event indicating when a source either starts or stops being implicitly |
+ * analyzed. |
+ */ |
+class AnalyzedSourcesEvent { |
+ /** |
+ * The source whose status has changed. |
+ */ |
+ final Source source; |
+ |
+ /** |
+ * A flag indicating whether the source is now being analyzed. |
+ */ |
+ final bool isAnalyzed; |
+ |
+ /** |
+ * Initialize a newly created event to indicate that the given [source] has |
+ * changed it status to match the [isAnalyzed] flag. |
+ */ |
+ AnalyzedSourcesEvent(this.source, this.isAnalyzed); |
+ |
+ @override |
+ String toString() => |
+ '${isAnalyzed ? '' : 'not '}analyzing ${source.fullName}'; |
+} |
+ |
+/** |
* A `CachedResult` is a single analysis result that is stored in a |
* [SourceEntry]. |
*/ |
@@ -6752,11 +6810,12 @@ abstract class CachePartition { |
} |
/** |
- * Remove all information related to the given [source] from this cache. |
+ * Remove all information related to the given [source] from this partition |
+ * and return the entry associated with the source. |
Paul Berry
2015/07/15 19:50:01
Document when we might return `null`.
Brian Wilkerson
2015/07/15 21:23:37
Done
|
*/ |
- void remove(Source source) { |
+ SourceEntry remove(Source source) { |
_recentlyUsed.remove(source); |
- _sourceMap.remove(source); |
+ return _sourceMap.remove(source); |
} |
/** |