Index: pkg/analysis_server/lib/src/operation/operation_analysis.dart |
diff --git a/pkg/analysis_server/lib/src/operation/operation_analysis.dart b/pkg/analysis_server/lib/src/operation/operation_analysis.dart |
index b99cec3c962d6f50e1e93839a4db7e6a9c494e40..f35a63091c7ed879437ca4fdef78b7e73478526d 100644 |
--- a/pkg/analysis_server/lib/src/operation/operation_analysis.dart |
+++ b/pkg/analysis_server/lib/src/operation/operation_analysis.dart |
@@ -9,6 +9,7 @@ import 'package:analysis_server/src/computer/computer_highlights.dart'; |
import 'package:analysis_server/src/computer/computer_highlights2.dart'; |
import 'package:analysis_server/src/computer/computer_outline.dart'; |
import 'package:analysis_server/src/computer/computer_overrides.dart'; |
+import 'package:analysis_server/src/context_manager.dart'; |
import 'package:analysis_server/src/domains/analysis/implemented_dart.dart'; |
import 'package:analysis_server/src/domains/analysis/navigation.dart'; |
import 'package:analysis_server/src/domains/analysis/occurrences.dart'; |
@@ -21,6 +22,7 @@ import 'package:analyzer/dart/element/element.dart'; |
import 'package:analyzer/src/generated/engine.dart'; |
import 'package:analyzer/src/generated/error.dart'; |
import 'package:analyzer/src/generated/source.dart'; |
+import 'package:analyzer/src/task/dart.dart'; |
/** |
* Runs the given function [f] with the working cache size in [context]. |
@@ -376,6 +378,7 @@ class PerformAnalysisOperation extends ServerOperation { |
setCacheSize(context, IDLE_CACHE_SIZE); |
server.sendContextAnalysisDoneNotifications( |
context, AnalysisDoneReason.COMPLETE); |
+ _flushCache(server); |
return; |
} |
// process results |
@@ -388,6 +391,28 @@ class PerformAnalysisOperation extends ServerOperation { |
} |
/** |
+ * Flush some of the [context] cache results, which we probably not |
+ * going to use anymore. |
+ */ |
+ void _flushCache(AnalysisServer server) { |
+ if (context is InternalAnalysisContext) { |
+ InternalAnalysisContext context = this.context; |
+ // Flush AST results for source outside of the analysis roots. |
+ ContextManager contextManager = server.contextManager; |
+ context.analysisCache.flush((target, result) { |
Brian Wilkerson
2016/08/23 19:56:32
This won't work well when we start sharing more an
|
+ Source targetSource = target.source; |
+ if (RESOLVED_UNIT_RESULTS.contains(result) && |
+ targetSource != null && |
+ !context.prioritySources.contains(targetSource) && |
+ !contextManager.isInAnalysisRoot(targetSource.fullName)) { |
+ return true; |
+ } |
+ return false; |
+ }); |
+ } |
+ } |
+ |
+ /** |
* Send the information in the given list of notices back to the client. |
*/ |
void _sendNotices(AnalysisServer server, List<ChangeNotice> notices) { |