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

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

Issue 1081903002: Use working cache size when request resolved units in requests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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/analysis_server/lib/src/analysis_server.dart ('k') | 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 243384fd5ba68f8df5801f0893b978ece215ce81..7f0fe1a84bb10549a03c371c25408e752fd58eb6 100644
--- a/pkg/analysis_server/lib/src/operation/operation_analysis.dart
+++ b/pkg/analysis_server/lib/src/operation/operation_analysis.dart
@@ -20,6 +20,24 @@ import 'package:analyzer/src/generated/html.dart';
import 'package:analyzer/src/generated/source.dart';
/**
+ * Runs the given function [f] with the working cache size in [context].
+ * Returns the result of [f] invocation.
+ */
+runWithWorkingCacheSize(AnalysisContext context, f()) {
+ int currentCacheSize = context.analysisOptions.cacheSize;
+ if (currentCacheSize < PerformAnalysisOperation.WORKING_CACHE_SIZE) {
+ setCacheSize(context, PerformAnalysisOperation.WORKING_CACHE_SIZE);
+ try {
+ return f();
+ } finally {
+ setCacheSize(context, currentCacheSize);
+ }
+ } else {
+ return f();
+ }
+}
+
+/**
* Schedules indexing of the given [file] using the resolved [dartUnit].
*/
void scheduleIndexOperation(AnalysisServer server, String file,
@@ -152,6 +170,16 @@ void sendAnalysisNotificationOverrides(
}
/**
+ * Sets the cache size in the given [context] to the given value.
+ */
+void setCacheSize(AnalysisContext context, int cacheSize) {
+ AnalysisOptionsImpl options =
+ new AnalysisOptionsImpl.con1(context.analysisOptions);
+ options.cacheSize = cacheSize;
+ context.analysisOptions = options;
+}
+
+/**
* Runs the given notification producing function [f], catching exceptions.
*/
void _sendNotification(AnalysisServer server, f()) {
@@ -207,13 +235,13 @@ class PerformAnalysisOperation extends ServerOperation {
// sendStatusNotification(context.toString(), taskDescription);
// });
if (!isContinue) {
- _setCacheSize(WORKING_CACHE_SIZE);
+ setCacheSize(context, WORKING_CACHE_SIZE);
}
// prepare results
AnalysisResult result = context.performAnalysisTask();
List<ChangeNotice> notices = result.changeNotices;
if (notices == null) {
- _setCacheSize(IDLE_CACHE_SIZE);
+ setCacheSize(context, IDLE_CACHE_SIZE);
server.sendContextAnalysisDoneNotifications(
context, AnalysisDoneReason.COMPLETE);
return;
@@ -245,13 +273,6 @@ class PerformAnalysisOperation extends ServerOperation {
}
}
- void _setCacheSize(int cacheSize) {
- AnalysisOptionsImpl options =
- new AnalysisOptionsImpl.con1(context.analysisOptions);
- options.cacheSize = cacheSize;
- context.analysisOptions = options;
- }
-
void _updateIndex(AnalysisServer server, List<ChangeNotice> notices) {
if (server.index == null) {
return;
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698