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

Unified Diff: pkg/analyzer/lib/src/context/context.dart

Issue 2008133002: Fix cross-partition dependency handling (issue 26466) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/context/cache.dart ('k') | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/context/context.dart
diff --git a/pkg/analyzer/lib/src/context/context.dart b/pkg/analyzer/lib/src/context/context.dart
index db5dd0273db129eccb1d894dcf3fadf8fb733894..b43b7173aa291b1f9d61ae74156396dfcc3ca0f0 100644
--- a/pkg/analyzer/lib/src/context/context.dart
+++ b/pkg/analyzer/lib/src/context/context.dart
@@ -116,6 +116,12 @@ class AnalysisContextImpl implements InternalAnalysisContext {
*/
AnalysisCache _cache;
+ @override
+ final ReentrantSynchronousStream<InvalidatedResult> onResultInvalidated =
+ new ReentrantSynchronousStream<InvalidatedResult>();
+
+ ReentrantSynchronousStreamSubscription onResultInvalidatedSubscription = null;
+
/**
* Configuration data associated with this context.
*/
@@ -421,6 +427,7 @@ class AnalysisContextImpl implements InternalAnalysisContext {
}
factory.context = this;
_sourceFactory = factory;
+ _cache?.dispose();
_cache = createCacheFromSourceFactory(factory);
for (WorkManager workManager in workManagers) {
workManager.onSourceFactoryChanged();
@@ -678,18 +685,26 @@ class AnalysisContextImpl implements InternalAnalysisContext {
* Create an analysis cache based on the given source [factory].
*/
AnalysisCache createCacheFromSourceFactory(SourceFactory factory) {
- if (factory == null) {
- return new AnalysisCache(<CachePartition>[_privatePartition]);
+ AnalysisCache createCache() {
+ if (factory == null) {
+ return new AnalysisCache(<CachePartition>[_privatePartition]);
+ }
+ DartSdk sdk = factory.dartSdk;
+ if (sdk == null) {
+ return new AnalysisCache(<CachePartition>[_privatePartition]);
+ }
+ return new AnalysisCache(<CachePartition>[
+ AnalysisEngine.instance.partitionManager.forSdk(sdk),
+ _privatePartition
+ ]);
}
- DartSdk sdk = factory.dartSdk;
- if (sdk == null) {
- return new AnalysisCache(<CachePartition>[_privatePartition]);
+
+ AnalysisCache cache = createCache();
+ if (onResultInvalidatedSubscription != null) {
+ onResultInvalidatedSubscription.cancel();
scheglov 2016/05/25 01:44:44 We could use here: onResultInvalidatedSubscription
Brian Wilkerson 2016/05/25 14:42:33 Done
}
- AnalysisCache cache = new AnalysisCache(<CachePartition>[
- AnalysisEngine.instance.partitionManager.forSdk(sdk),
- _privatePartition
- ]);
- cache.onResultInvalidated.listen((InvalidatedResult event) {
+ onResultInvalidatedSubscription = cache.onResultInvalidated.listen((InvalidatedResult event) {
+ onResultInvalidated.add(event);
StreamController<ResultChangedEvent> controller =
_resultChangedControllers[event.descriptor];
if (controller != null) {
@@ -1079,6 +1094,7 @@ class AnalysisContextImpl implements InternalAnalysisContext {
* to do.
*/
void invalidateCachedResults() {
+ _cache?.dispose();
_cache = createCacheFromSourceFactory(_sourceFactory);
for (WorkManager workManager in workManagers) {
workManager.onAnalysisOptionsChanged();
« no previous file with comments | « pkg/analyzer/lib/src/context/cache.dart ('k') | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698