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 ced4a8c9e54f74c59d2c92e382f5b5fc6558d6b0..1687a4bc3209fdde14a7f59a7d712b52d8ac24e4 100644 |
--- a/pkg/analysis_server/lib/src/operation/operation_queue.dart |
+++ b/pkg/analysis_server/lib/src/operation/operation_queue.dart |
@@ -39,6 +39,14 @@ class ServerOperationQueue { |
void add(ServerOperation operation) { |
int queueIndex = operation.priority.ordinal; |
Queue<ServerOperation> queue = _queues[queueIndex]; |
+ // try to merge into an existing operation |
+ for (ServerOperation existingOperation in queue) { |
+ if (existingOperation is MergeableOperation && |
+ existingOperation.merge(operation)) { |
+ return; |
+ } |
+ } |
+ // add it |
queue.addLast(operation); |
} |
@@ -119,7 +127,7 @@ class ServerOperationQueue { |
*/ |
ServerOperation takeIf(bool test(ServerOperation operation)) { |
for (Queue<ServerOperation> queue in _queues) { |
- for (var operation in queue) { |
+ for (ServerOperation operation in queue) { |
if (test(operation)) { |
queue.remove(operation); |
return operation; |