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

Unified Diff: pkg/analysis_server/lib/src/operation/operation_analysis.dart

Issue 2271803002: Flush AST results for source outside of the analysis roots. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698