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

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

Issue 2481323002: Send notifications in the scheduled futures. (Closed)
Patch Set: Document delaying sending notifications. Created 4 years, 1 month 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 | pkg/analysis_server/lib/src/computer/new_notifications.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 99a0f7d72a862f6f1c9c18bbcfce92b568d69420..99f3724d6d46884b8ad1bb1a3c76a5fe56cbaaa6 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -16,8 +16,6 @@ import 'package:analysis_server/src/analysis_logger.dart';
import 'package:analysis_server/src/channel/channel.dart';
import 'package:analysis_server/src/computer/new_notifications.dart';
import 'package:analysis_server/src/context_manager.dart';
-import 'package:analysis_server/src/domains/analysis/navigation.dart';
-import 'package:analysis_server/src/domains/analysis/navigation_dart.dart';
import 'package:analysis_server/src/operation/operation.dart';
import 'package:analysis_server/src/operation/operation_analysis.dart';
import 'package:analysis_server/src/operation/operation_queue.dart';
@@ -1764,21 +1762,23 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks {
if (analysisServer.priorityFiles.contains(result.path)) {
analysisServer.priorityFileResults[result.path] = result;
}
- new_sendErrorNotification(analysisServer, result);
+ _runDelayed(() {
+ new_sendErrorNotification(analysisServer, result);
+ });
CompilationUnit unit = result.unit;
if (unit != null) {
if (analysisServer._hasAnalysisServiceSubscription(
AnalysisService.HIGHLIGHTS, result.path)) {
- sendAnalysisNotificationHighlights(analysisServer, result.path, unit);
+ _runDelayed(() {
+ sendAnalysisNotificationHighlights(
+ analysisServer, result.path, unit);
+ });
}
if (analysisServer._hasAnalysisServiceSubscription(
AnalysisService.NAVIGATION, result.path)) {
- NavigationCollectorImpl collector = new NavigationCollectorImpl();
- computeSimpleDartNavigation(collector, unit);
- collector.createRegions();
- var params = new AnalysisNavigationParams(result.path,
- collector.regions, collector.targets, collector.files);
- analysisServer.sendNotification(params.toNotification());
+ _runDelayed(() {
+ new_sendDartNotificationNavigation(analysisServer, result);
+ });
}
}
// TODO(scheglov) Implement more notifications.
@@ -1896,6 +1896,25 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks {
.add(new ContextsChangedEvent(changed: [context]));
analysisServer.schedulePerformAnalysisOperation(context);
}
+
+ /**
+ * Run [f] in a new [Future].
+ *
+ * This method is used to delay sending notifications. If there is a more
+ * important consumer of an analysis results, specifically a code completion
+ * computer, we want it to run before spending time of sending notifications.
+ *
+ * TODO(scheglov) Consider replacing this with full priority based scheduler.
+ *
+ * TODO(scheglov) Alternatively, if code completion work in a way that does
+ * not produce (at first) fully resolved unit, but only part of it - a single
+ * method, or a top-level declaration, we would not have this problem - the
+ * completion computer would be the only consumer of the partial analysis
+ * result.
+ */
+ void _runDelayed(f()) {
+ new Future(f);
+ }
}
/**
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/computer/new_notifications.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698