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

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

Issue 904093002: Discard pending notifications on the same source change. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
Index: pkg/analysis_server/lib/src/operation/operation_queue.dart
diff --git a/pkg/analysis_server/lib/src/operation/operation_queue.dart b/pkg/analysis_server/lib/src/operation/operation_queue.dart
index 67ca99310f580a6cefc19896986c27567f13c7f0..deaa51226affadac2c6dfea16e0c3d6352773fff 100644
--- a/pkg/analysis_server/lib/src/operation/operation_queue.dart
+++ b/pkg/analysis_server/lib/src/operation/operation_queue.dart
@@ -8,6 +8,7 @@ import 'dart:collection';
import 'package:analysis_server/src/analysis_server.dart';
import 'package:analysis_server/src/operation/operation.dart';
+import 'package:analyzer/src/generated/source.dart';
/**
@@ -51,8 +52,8 @@ class ServerOperationQueue {
}
/**
- * Return the next operation to perform, or `null` if the queue is empty. This
- * method does not change the queue.
+ * Return the next operation to perform, or `null` if the queue is empty.
+ * This method does not change the queue.
*/
ServerOperation peek() {
for (Queue<ServerOperation> queue in _queues) {
@@ -78,6 +79,20 @@ class ServerOperationQueue {
}
/**
+ * The given [source] if about to changed.
+ */
+ void sourceAboutToChange(Source source) {
+ for (Queue<ServerOperation> queue in _queues) {
+ queue.removeWhere((operation) {
+ if (operation is SourceSensitiveOperation) {
+ return operation.shouldBeDiscardedOnSourceChange(source);
+ }
+ return false;
+ });
+ }
+ }
+
+ /**
* Returns the next operation to perform or `null` if empty.
*/
ServerOperation take() {
@@ -88,4 +103,19 @@ class ServerOperationQueue {
}
return null;
}
+
+ /**
+ * Returns an operation that satisfies the given [test] or `null`.
+ */
+ ServerOperation takeIf(bool test(ServerOperation operation)) {
+ for (Queue<ServerOperation> queue in _queues) {
+ for (var operation in queue) {
+ if (test(operation)) {
+ queue.remove(operation);
+ return operation;
+ }
+ }
+ }
+ return null;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698